haikuwebkit/LayoutTests/webrtc/video-sframe.html

77 lines
3.2 KiB
HTML
Raw Permalink Normal View History

Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<video id="local" autoplay playsInline></video>
<video id="remote" autoplay playsInline></video>
<script src ="routines.js"></script>
<script>
async function doSFrameTest(codec, shouldClose)
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
{
let pc1, pc2;
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
let sender, receiver;
const localStream = await navigator.mediaDevices.getUserMedia({video: true});
const key = await crypto.subtle.importKey("raw", new Uint8Array([143, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]);
const stream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
pc1 = firstConnection;
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
sender = firstConnection.addTrack(localStream.getTracks()[0], localStream);
firstConnection.getTransceivers()[0].setCodecPreferences([codec]);
let transform = new SFrameTransform({compatibilityMode: "H264"});
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
transform.setEncryptionKey(key);
sender.transform = transform;
}, (secondConnection) => {
pc2 = secondConnection;
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
secondConnection.ontrack = (trackEvent) => {
let transform = new SFrameTransform({compatibilityMode: "H264"});
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
transform.setEncryptionKey(key);
receiver = trackEvent.receiver;
receiver.transform = transform;
resolve(trackEvent.streams[0]);
};
});
setTimeout(() => reject("Test timed out"), 5000);
});
local.srcObject = localStream;
remote.srcObject = stream;
await remote.play();
if (window.internals) {
const senderCounter = internals.sframeCounter(sender.transform);
const receiverCounter = internals.sframeCounter(receiver.transform);
let counter = 0;
while (receiverCounter === internals.sframeCounter(receiver.transform) && ++counter < 100)
await new Promise(resolve => setTimeout(resolve, 50));
assert_not_equals(internals.sframeCounter(receiver.transform), receiverCounter, "receiver");
counter = 0;
while (senderCounter === internals.sframeCounter(sender.transform) && ++counter < 100)
await new Promise(resolve => setTimeout(resolve, 50));
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
assert_not_equals(internals.sframeCounter(sender.transform), senderCounter, "sender");
}
if (shouldClose) {
pc1.close();
pc2.close();
}
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
}
promise_test((test) => {
return doSFrameTest({clockRate: 90000, mimeType: "video/H264", sdpFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f"}, "H264", true);
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
}, "Video exchange with SFrame - H264 baseline");
promise_test((test) => {
return doSFrameTest({clockRate: 90000, mimeType: "video/H264", sdpFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640c1f"}, "H264", true);
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
}, "Video exchange with SFrame - H264 high");
promise_test((test) => {
return doSFrameTest({mimeType: "video/VP8", clockRate: 90000}, "VP8", false);
}, "Video exchange with SFrame - VP8");
Add a SFrame H264 experimental compatibility mode https://bugs.webkit.org/show_bug.cgi?id=219532 Reviewed by Eric Carlson. Source/WebCore: Add an SFrame compatibility mode for H.264. To do so, the encryptor generates an SFrame and prefixes it with either a delta frame prefix or a key frame prefix. The SFrame content is escaped so that it is considered as one big IDR or Slice nalu. The decoder on the other hand, unescapes the content, removes the prefix and decrypts the SFrame content. Test: webrtc/video-sframe.html * Modules/mediastream/H264Utils.cpp: Added. (WebCore::isSliceNALU): (WebCore::isSPSNALU): (WebCore::isPPSNALU): (WebCore::isIDRNALU): (WebCore::findNalus): (WebCore::computePrefixOffset): (WebCore::needsRbspUnescaping): (WebCore::fromRbsp): (WebCore::computePrefixBuffer): (WebCore::findEscapeRbspPatterns): (WebCore::toRbsp): * Modules/mediastream/H264Utils.h: Added. * Modules/mediastream/MediaStreamTrack.cpp: * Modules/mediastream/RTCRtpSFrameTransform.cpp: (WebCore::RTCRtpSFrameTransform::RTCRtpSFrameTransform): * Modules/mediastream/RTCRtpSFrameTransform.h: * Modules/mediastream/RTCRtpSFrameTransform.idl: * Modules/mediastream/RTCRtpSFrameTransformer.cpp: (WebCore::RTCRtpSFrameTransformer::create): (WebCore::RTCRtpSFrameTransformer::RTCRtpSFrameTransformer): (WebCore::RTCRtpSFrameTransformer::decryptFrame): (WebCore::RTCRtpSFrameTransformer::encryptFrame): * Modules/mediastream/RTCRtpSFrameTransformer.h: * Modules/mediastream/RTCRtpScriptTransformer.cpp: * Modules/mediastream/RTCRtpScriptTransformer.h: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Tools: * TestWebKitAPI/Tests/WebCore/RTCRtpSFrameTransformerTests.cpp: (TestWebKitAPI::TEST): LayoutTests: * webrtc/video-sframe-expected.txt: Added. * webrtc/video-sframe.html: Added. Canonical link: https://commits.webkit.org/232183@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@270506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-12-07 16:59:56 +00:00
</script>
</body>
</html>