Title: [275408] trunk
- Revision
- 275408
- Author
- you...@apple.com
- Date
- 2021-04-02 01:11:44 -0700 (Fri, 02 Apr 2021)
Log Message
Bail out early if encoded frame is written twice
https://bugs.webkit.org/show_bug.cgi?id=224041
Reviewed by Eric Carlson.
Source/WebCore:
Test: http/wpt/webrtc/write-twice-transform.html
* Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.cpp:
(WebCore::LibWebRTCRtpTransformBackend::processTransformedFrame):
In case the frame is written twice, the second write is considered as a no-op.
LayoutTests:
* http/wpt/webrtc/write-twice-transform-expected.txt: Added.
* http/wpt/webrtc/write-twice-transform.html: Added.
* http/wpt/webrtc/write-twice-transform.js: Added.
(onrtctransform.process):
(onrtctransform):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (275407 => 275408)
--- trunk/LayoutTests/ChangeLog 2021-04-02 08:07:28 UTC (rev 275407)
+++ trunk/LayoutTests/ChangeLog 2021-04-02 08:11:44 UTC (rev 275408)
@@ -1,3 +1,16 @@
+2021-04-02 Youenn Fablet <you...@apple.com>
+
+ Bail out early if encoded frame is written twice
+ https://bugs.webkit.org/show_bug.cgi?id=224041
+
+ Reviewed by Eric Carlson.
+
+ * http/wpt/webrtc/write-twice-transform-expected.txt: Added.
+ * http/wpt/webrtc/write-twice-transform.html: Added.
+ * http/wpt/webrtc/write-twice-transform.js: Added.
+ (onrtctransform.process):
+ (onrtctransform):
+
2021-04-01 Chris Gambrell <cgambr...@apple.com>
[LayoutTests] Convert http/tests/cache convert PHP to Python
Added: trunk/LayoutTests/http/wpt/webrtc/write-twice-transform-expected.txt (0 => 275408)
--- trunk/LayoutTests/http/wpt/webrtc/write-twice-transform-expected.txt (rev 0)
+++ trunk/LayoutTests/http/wpt/webrtc/write-twice-transform-expected.txt 2021-04-02 08:11:44 UTC (rev 275408)
@@ -0,0 +1,4 @@
+
+
+PASS video exchange with write twice transform
+
Added: trunk/LayoutTests/http/wpt/webrtc/write-twice-transform.html (0 => 275408)
--- trunk/LayoutTests/http/wpt/webrtc/write-twice-transform.html (rev 0)
+++ trunk/LayoutTests/http/wpt/webrtc/write-twice-transform.html 2021-04-02 08:11:44 UTC (rev 275408)
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <video id="video1" autoplay></video>
+ <video id="video2" autoplay></video>
+ <script src =""
+ <script>
+async function waitForMessage(worker, data)
+{
+ while (true) {
+ const received = await new Promise(resolve => worker._onmessage_ = (event) => resolve(event.data));
+ if (data ="" received)
+ return;
+ }
+}
+
+promise_test(async (test) => {
+ worker = new Worker('write-twice-transform.js');
+ const data = "" new Promise(resolve => worker._onmessage_ = (event) => resolve(event.data));
+ assert_equals(data, "registered");
+
+ const localStream = await navigator.mediaDevices.getUserMedia({video: true});
+
+ let sender, receiver;
+ const senderTransform = new RTCRtpScriptTransform(worker, {name:'MockRTCRtpTransform', side:'sender', role:'encrypt'});
+ const receiverTransform = new RTCRtpScriptTransform(worker, {name:'MockRTCRtpTransform', side:'receiver', role:'decrypt'});
+
+ const startedPromise = new Promise(resolve => worker._onmessage_ = (event) => resolve(event.data));
+
+ const stream = await new Promise((resolve, reject) => {
+ createConnections((firstConnection) => {
+ pc1 = firstConnection;
+ sender = firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
+ sender.transform = senderTransform;
+ }, (secondConnection) => {
+ pc2 = secondConnection;
+ secondConnection._ontrack_ = (trackEvent) => {
+ receiver = trackEvent.receiver;
+ receiver.transform = receiverTransform;
+ resolve(trackEvent.streams[0]);
+ };
+ });
+ setTimeout(() => reject("Test timed out"), 5000);
+ });
+
+ assert_equals(await startedPromise, "started");
+
+ video1.srcObject = stream;
+ await video1.play();
+}, "video exchange with write twice transform");
+ </script>
+ </body>
+</html>
Added: trunk/LayoutTests/http/wpt/webrtc/write-twice-transform.js (0 => 275408)
--- trunk/LayoutTests/http/wpt/webrtc/write-twice-transform.js (rev 0)
+++ trunk/LayoutTests/http/wpt/webrtc/write-twice-transform.js 2021-04-02 08:11:44 UTC (rev 275408)
@@ -0,0 +1,23 @@
+_onrtctransform_ = (event) => {
+ const transformer = event.transformer;
+ transformer.port._onmessage_ = (event) => transformer.port.postMessage(event.data);
+
+ self.postMessage("started");
+
+ transformer.reader = transformer.readable.getReader();
+ transformer.writer = transformer.writable.getWriter();
+ function process(transformer)
+ {
+ transformer.reader.read().then(chunk => {
+ if (chunk.done)
+ return;
+
+ transformer.writer.write(chunk.value);
+ transformer.writer.write(chunk.value);
+ process(transformer);
+ });
+ }
+
+ process(transformer);
+};
+self.postMessage("registered");
Modified: trunk/Source/WebCore/ChangeLog (275407 => 275408)
--- trunk/Source/WebCore/ChangeLog 2021-04-02 08:07:28 UTC (rev 275407)
+++ trunk/Source/WebCore/ChangeLog 2021-04-02 08:11:44 UTC (rev 275408)
@@ -1,3 +1,16 @@
+2021-04-02 Youenn Fablet <you...@apple.com>
+
+ Bail out early if encoded frame is written twice
+ https://bugs.webkit.org/show_bug.cgi?id=224041
+
+ Reviewed by Eric Carlson.
+
+ Test: http/wpt/webrtc/write-twice-transform.html
+
+ * Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.cpp:
+ (WebCore::LibWebRTCRtpTransformBackend::processTransformedFrame):
+ In case the frame is written twice, the second write is considered as a no-op.
+
2021-04-01 Cameron McCormack <hey...@apple.com>
Remove redundant #if in RuntimeApplicationChecks.h.
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.cpp (275407 => 275408)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.cpp 2021-04-02 08:07:28 UTC (rev 275407)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpTransformBackend.cpp 2021-04-02 08:11:44 UTC (rev 275408)
@@ -50,9 +50,12 @@
void LibWebRTCRtpTransformBackend::processTransformedFrame(RTCRtpTransformableFrame& frame)
{
+ auto rtcFrame = static_cast<LibWebRTCRtpTransformableFrame&>(frame).takeRTCFrame();
+ if (!rtcFrame)
+ return;
auto locker = holdLock(m_outputCallbackLock);
if (m_outputCallback)
- m_outputCallback->OnTransformedFrame(static_cast<LibWebRTCRtpTransformableFrame&>(frame).takeRTCFrame());
+ m_outputCallback->OnTransformedFrame(WTFMove(rtcFrame));
}
void LibWebRTCRtpTransformBackend::Transform(std::unique_ptr<webrtc::TransformableFrameInterface> rtcFrame)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes