Title: [219127] trunk
Revision
219127
Author
commit-qu...@webkit.org
Date
2017-07-05 08:53:17 -0700 (Wed, 05 Jul 2017)

Log Message

Receiving tracks should be ended when peer connection is being closed
https://bugs.webkit.org/show_bug.cgi?id=174109

Patch by Youenn Fablet <you...@apple.com> on 2017-07-05
Reviewed by Eric Carlson.

Source/WebCore:

Test: webrtc/peer-connection-track-end.html

As per https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close, tracks should be ended when peer connection is closed.
Also updating transceiver stopped state.

* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::doClose):
* Modules/mediastream/RTCRtpReceiver.cpp:
(WebCore::RTCRtpReceiver::stop):
* Modules/mediastream/RTCRtpReceiver.h:

LayoutTests:

* webrtc/peer-connection-track-end-expected.txt: Added.
* webrtc/peer-connection-track-end.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219126 => 219127)


--- trunk/LayoutTests/ChangeLog	2017-07-05 14:05:47 UTC (rev 219126)
+++ trunk/LayoutTests/ChangeLog	2017-07-05 15:53:17 UTC (rev 219127)
@@ -1,3 +1,13 @@
+2017-07-05  Youenn Fablet  <you...@apple.com>
+
+        Receiving tracks should be ended when peer connection is being closed
+        https://bugs.webkit.org/show_bug.cgi?id=174109
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/peer-connection-track-end-expected.txt: Added.
+        * webrtc/peer-connection-track-end.html: Added.
+
 2017-07-04  Antti Koivisto  <an...@apple.com>
 
         FrameView should not set RenderView::logicalWidth directly for printing

Added: trunk/LayoutTests/webrtc/peer-connection-track-end-expected.txt (0 => 219127)


--- trunk/LayoutTests/webrtc/peer-connection-track-end-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/peer-connection-track-end-expected.txt	2017-07-05 15:53:17 UTC (rev 219127)
@@ -0,0 +1,4 @@
+
+
+PASS Ensuring onended events are thrown when peer connection is closed 
+

Added: trunk/LayoutTests/webrtc/peer-connection-track-end.html (0 => 219127)


--- trunk/LayoutTests/webrtc/peer-connection-track-end.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/peer-connection-track-end.html	2017-07-05 15:53:17 UTC (rev 219127)
@@ -0,0 +1,53 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing basic video exchange from offerer to receiver</title>
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <video id="video" autoplay></video>
+        <script src =""
+        <script>
+promise_test((test) => {
+    var remoteStream, newOffer, secondConnection;
+    var testPromise;
+    return navigator.mediaDevices.getUserMedia({audio: true, video: true}).then((stream) => {
+        return new Promise((resolve, reject) => {
+            createConnections((firstConnection) => {
+                firstConnection.addTrack(stream.getAudioTracks()[0], stream);
+                firstConnection.addTrack(stream.getVideoTracks()[0], stream);
+            }, (connection) => {
+                secondConnection = connection;
+                secondConnection._ontrack_ = (trackEvent) => {
+                    resolve(trackEvent.streams[0]);
+                };
+            });
+            setTimeout(() => reject("Test timed out"), 5000);
+        });
+    }).then((stream) => {
+        remoteStream = stream;
+        video.srcObject = stream;
+        return video.play();
+    }).then(() => {
+        testPromise = new Promise((resolve, reject) => {
+            var count = 0;
+            var callback = () => {
+                if (++count === 2)
+                    resolve();
+            }
+            setTimeout(() => { reject("onended callbacks took too long"); }, 5000);
+            remoteStream.getAudioTracks()[0]._onended_ = callback;
+            remoteStream.getVideoTracks()[0]._onended_ = callback;
+        });
+        secondConnection.close();
+        return testPromise;
+    }).then(() => {
+        assert_true(secondConnection.getTransceivers()[0].stopped, "transceiver 1 should be stopped");
+        assert_true(secondConnection.getTransceivers()[1].stopped, "transceiver 2 should be stopped");
+    });
+}, "Ensuring onended events are thrown when peer connection is closed");
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (219126 => 219127)


--- trunk/Source/WebCore/ChangeLog	2017-07-05 14:05:47 UTC (rev 219126)
+++ trunk/Source/WebCore/ChangeLog	2017-07-05 15:53:17 UTC (rev 219127)
@@ -1,3 +1,21 @@
+2017-07-05  Youenn Fablet  <you...@apple.com>
+
+        Receiving tracks should be ended when peer connection is being closed
+        https://bugs.webkit.org/show_bug.cgi?id=174109
+
+        Reviewed by Eric Carlson.
+
+        Test: webrtc/peer-connection-track-end.html
+
+        As per https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close, tracks should be ended when peer connection is closed.
+        Also updating transceiver stopped state.
+
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::doClose):
+        * Modules/mediastream/RTCRtpReceiver.cpp:
+        (WebCore::RTCRtpReceiver::stop):
+        * Modules/mediastream/RTCRtpReceiver.h:
+
 2017-07-04  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         Unreviewed, review follow-up after r218961

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (219126 => 219127)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-07-05 14:05:47 UTC (rev 219126)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-07-05 15:53:17 UTC (rev 219127)
@@ -387,12 +387,12 @@
     m_connectionState = RTCPeerConnectionState::Closed;
     m_iceConnectionState = RTCIceConnectionState::Closed;
 
-    for (RTCRtpReceiver& receiver : m_transceiverSet->receivers())
-        receiver.stop();
+    for (auto& transceiver : m_transceiverSet->list()) {
+        transceiver->stop();
+        transceiver->sender().stop();
+        transceiver->receiver().stop();
+    }
 
-    for (RTCRtpSender& sender : m_transceiverSet->senders())
-        sender.stop();
-
     return true;
 }
 

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.cpp (219126 => 219127)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.cpp	2017-07-05 14:05:47 UTC (rev 219126)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.cpp	2017-07-05 15:53:17 UTC (rev 219127)
@@ -43,6 +43,14 @@
 {
 }
 
+void RTCRtpReceiver::stop()
+{
+    m_backend = nullptr;
+
+    if (m_track)
+        m_track->stopTrack(MediaStreamTrack::StopMode::PostEvent);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_RTC)

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.h (219126 => 219127)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.h	2017-07-05 14:05:47 UTC (rev 219126)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.h	2017-07-05 15:53:17 UTC (rev 219127)
@@ -51,7 +51,8 @@
         return adoptRef(*new RTCRtpReceiver(WTFMove(track), backend));
     }
 
-    void stop() { m_backend = nullptr; }
+    void stop();
+
     // FIXME: We should pass a UniqueRef here.
     void setBackend(std::unique_ptr<Backend>&& backend) { m_backend = WTFMove(backend); }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to