Modified: trunk/Source/WebCore/ChangeLog (274708 => 274709)
--- trunk/Source/WebCore/ChangeLog 2021-03-19 09:14:52 UTC (rev 274708)
+++ trunk/Source/WebCore/ChangeLog 2021-03-19 09:17:14 UTC (rev 274709)
@@ -1,3 +1,21 @@
+2021-03-19 Youenn Fablet <[email protected]>
+
+ Disable SFrame compatibility mode for audio senders and receivers
+ https://bugs.webkit.org/show_bug.cgi?id=223391
+ <rdar://problem/75538500>
+
+ Reviewed by Eric Carlson.
+
+ Add RTCRtpSFrameTransformer::setMediaType to allow setting the authentication size.
+ In case mode is H264/VP8 and media type is audio, set back mode to none.
+ Covered by API test.
+
+ * Modules/mediastream/RTCRtpSFrameTransform.cpp:
+ (WebCore::RTCRtpSFrameTransform::initializeTransformer):
+ * Modules/mediastream/RTCRtpSFrameTransformer.h:
+ (WebCore::RTCRtpSFrameTransformer::setMediaType):
+ * WebCore.xcodeproj/project.pbxproj:
+
2021-03-17 Sergio Villar Senin <[email protected]>
[css-flex] Make {main|cross}SizeForPercentageResolution() return booleans instead of actual sizes
Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp (274708 => 274709)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp 2021-03-19 09:14:52 UTC (rev 274708)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransform.cpp 2021-03-19 09:17:14 UTC (rev 274709)
@@ -101,7 +101,7 @@
m_writable->lock();
m_transformer->setIsEncrypting(side == Side::Sender);
- m_transformer->setAuthenticationSize(backend.mediaType() == RTCRtpTransformBackend::MediaType::Audio ? 4 : 10);
+ m_transformer->setMediaType(backend.mediaType());
backend.setTransformableFrameCallback([transformer = m_transformer, backend = makeRef(backend)](auto&& frame) {
auto chunk = frame->data();
Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h (274708 => 274709)
--- trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h 2021-03-19 09:14:52 UTC (rev 274708)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformer.h 2021-03-19 09:17:14 UTC (rev 274709)
@@ -28,6 +28,7 @@
#if ENABLE(WEB_RTC)
#include "ExceptionOr.h"
+#include "RTCRtpTransformBackend.h"
#include <wtf/HashMap.h>
#include <wtf/Lock.h>
#include <wtf/ThreadSafeRefCounted.h>
@@ -45,6 +46,7 @@
void setIsEncrypting(bool);
void setAuthenticationSize(uint64_t);
+ void setMediaType(RTCRtpTransformBackend::MediaType);
WEBCORE_EXPORT ExceptionOr<void> setEncryptionKey(const Vector<uint8_t>& rawKey, Optional<uint64_t>);
WEBCORE_EXPORT ExceptionOr<Vector<uint8_t>> transform(const uint8_t*, size_t);
@@ -104,6 +106,16 @@
m_authenticationSize = size;
}
+inline void RTCRtpSFrameTransformer::setMediaType(RTCRtpTransformBackend::MediaType mediaType)
+{
+ if (mediaType == RTCRtpTransformBackend::MediaType::Video) {
+ m_authenticationSize = 10;
+ return;
+ }
+ m_authenticationSize = 4;
+ m_compatibilityMode = CompatibilityMode::None;
+}
+
} // namespace WebCore
#endif // ENABLE(WEB_RTC)
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (274708 => 274709)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-03-19 09:14:52 UTC (rev 274708)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-03-19 09:17:14 UTC (rev 274709)
@@ -1115,7 +1115,7 @@
417F7AEF2139BF6F00FBA7EC /* MediaSessionManagerCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 417F7AED2139BF6500FBA7EC /* MediaSessionManagerCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
41815C1E138319830057AAA4 /* WebCoreTestSupport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41815C1C138319830057AAA4 /* WebCoreTestSupport.cpp */; };
41815C1F138319830057AAA4 /* WebCoreTestSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 41815C1D138319830057AAA4 /* WebCoreTestSupport.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 4181C5C9255573DF00AEB0FF /* RTCRtpTransformBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C5C8255573DF00AEB0FF /* RTCRtpTransformBackend.h */; };
+ 4181C5C9255573DF00AEB0FF /* RTCRtpTransformBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C5C8255573DF00AEB0FF /* RTCRtpTransformBackend.h */; settings = {ATTRIBUTES = (Private, ); }; };
4181C5CB255582E400AEB0FF /* RTCRtpTransformableFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C5CA255582E300AEB0FF /* RTCRtpTransformableFrame.h */; };
4181C5CD2555836900AEB0FF /* LibWebRTCRtpTransformableFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C5CC2555836800AEB0FF /* LibWebRTCRtpTransformableFrame.h */; };
4181C5D12555895600AEB0FF /* LibWebRTCRtpTransformBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 4181C5CF2555895600AEB0FF /* LibWebRTCRtpTransformBackend.h */; };
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp (274708 => 274709)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp 2021-03-19 09:14:52 UTC (rev 274708)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp 2021-03-19 09:17:14 UTC (rev 274709)
@@ -75,7 +75,7 @@
{
auto transformer = WebCore::RTCRtpSFrameTransformer::create();
transformer->setIsEncrypting(isEncrypting);
- transformer->setAuthenticationSize(10);
+ transformer->setMediaType(WebCore::RTCRtpTransformBackend::MediaType::Video);
auto keyId = Vector<uint8_t>::from(198, 31, 251, 197, 48, 139, 91, 51);
uint64_t keyIdValue = 0;
@@ -88,6 +88,23 @@
return transformer;
}
+static Ref<WebCore::RTCRtpSFrameTransformer> createAudioTransformer(bool isEncrypting, WebCore::RTCRtpSFrameTransformer::CompatibilityMode mode)
+{
+ auto transformer = WebCore::RTCRtpSFrameTransformer::create(mode);
+ transformer->setIsEncrypting(isEncrypting);
+ transformer->setMediaType(WebCore::RTCRtpTransformBackend::MediaType::Audio);
+
+ auto keyId = Vector<uint8_t>::from(31, 251, 197, 48, 139, 91, 51);
+ uint64_t keyIdValue = 0;
+ for (auto value : keyId)
+ keyIdValue = value + (keyIdValue << 8);
+
+ auto keyResult = transformer->setEncryptionKey(getRawKey(), keyIdValue);
+ EXPECT_FALSE(keyResult.hasException());
+
+ return transformer;
+}
+
static void checkVectorsAreEqual(const Vector<uint8_t>& computed, const Vector<uint8_t>& expected)
{
EXPECT_EQ(computed.size(), expected.size());
@@ -216,6 +233,28 @@
checkVectorsAreEqual(decryptedResult.returnValue(), frame);
}
+TEST(RTCRtpSFrameTransformer, EncryptDecryptAudio)
+{
+ // We ignore compatiblity mode for audio.
+ uint64_t keyId = 1255995222;
+ auto encryptor = createAudioTransformer(true, WebCore::RTCRtpSFrameTransformer::CompatibilityMode::H264);
+ encryptor->setEncryptionKey(getRawKey(), keyId);
+
+ auto decryptor = createAudioTransformer(false, WebCore::RTCRtpSFrameTransformer::CompatibilityMode::None);
+ decryptor->setEncryptionKey(getRawKey(), keyId);
+
+ auto frame = Vector<uint8_t>::from(135, 89, 51, 166, 248, 129, 157, 111, 190, 134, 220, 56);
+
+ auto encryptedResult = encryptor->transform(frame.data(), frame.size());
+ EXPECT_FALSE(encryptedResult.hasException());
+
+ auto encrypted = encryptedResult.releaseReturnValue();
+ auto decryptedResult = decryptor->transform(encrypted.data(), encrypted.size());
+ EXPECT_FALSE(decryptedResult.hasException());
+
+ checkVectorsAreEqual(decryptedResult.returnValue(), frame);
+}
+
TEST(RTCRtpSFrameTransformer, TransformCounter0)
{
auto transformer = createVideoTransformer();