WebRTC: RTCPeerConnection: Sort out responsibilities of close() and stop()
authoradam.bergkvist@ericsson.com <adam.bergkvist@ericsson.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Feb 2016 08:14:58 +0000 (08:14 +0000)
committeradam.bergkvist@ericsson.com <adam.bergkvist@ericsson.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Feb 2016 08:14:58 +0000 (08:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=154581

Reviewed by Eric Carlson.

Source/WebCore:

Let RTCPeerConnection::close() contain all teardown logic be called by stop().
close() is also responisble for stopping the PeerConnectionBackend and stopping
all RTCRtpSender objects.

Test coverage:
fast/mediastream/RTCRtpSender-replaceTrack.html (updated)
fast/mediastream/RTCPeerConnection-closed-state.html

* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::close):
(WebCore::RTCPeerConnection::stop):
(WebCore::RTCPeerConnection::RTCPeerConnection): Deleted.
* Modules/mediastream/RTCPeerConnection.h:

LayoutTests:

Updated test with replaceTrack() call after the RTCPeerConnection object, that
created the RTCRtpSender, is closed.

* fast/mediastream/RTCRtpSender-replaceTrack-expected.txt:
* fast/mediastream/RTCRtpSender-replaceTrack.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197020 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/mediastream/RTCRtpSender-replaceTrack-expected.txt
LayoutTests/fast/mediastream/RTCRtpSender-replaceTrack.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.h

index 16ae147..2374a09 100644 (file)
@@ -1,3 +1,16 @@
+2016-02-24  Adam Bergkvist  <adam.bergkvist@ericsson.com>
+
+        WebRTC: RTCPeerConnection: Sort out responsibilities of close() and stop()
+        https://bugs.webkit.org/show_bug.cgi?id=154581
+
+        Reviewed by Eric Carlson.
+
+        Updated test with replaceTrack() call after the RTCPeerConnection object, that
+        created the RTCRtpSender, is closed.
+
+        * fast/mediastream/RTCRtpSender-replaceTrack-expected.txt:
+        * fast/mediastream/RTCRtpSender-replaceTrack.html:
+
 2016-02-23  Chris Dumez  <cdumez@apple.com>
 
         Align our implementation of Range.createContextualFragment with the specification
index 2766952..1cea2f7 100644 (file)
@@ -16,6 +16,10 @@ This is a valid call but will be rejected until the PeerConnectionBackend implem
 PASS promise sender.replaceTrack(audioTrack2) rejected with [object DOMError]
 Stop sender, and try replacing the track
 PASS promise sender.replaceTrack(audioTrack2) rejected with [object DOMError]
+Create a new sender
+PASS sender = pc.addTrack(audioTrack2, stream) did not throw exception.
+Close pc and try replacing the track
+PASS promise sender.replaceTrack(audioTrack3) rejected with [object DOMError]
 End of promise chain
 PASS successfullyParsed is true
 
index c013ccb..b0b24db 100644 (file)
@@ -29,6 +29,7 @@
                 videoTrack = stream.getVideoTracks()[0];
 
                 audioTrack2 = audioTrack.clone();
+                audioTrack3 = audioTrack.clone();
 
                 shouldBe("pc.getSenders().length", "0");
 
                     return promiseShouldReject("sender.replaceTrack(audioTrack2)");
                 })
                 .catch(function () {
+                    debug("Create a new sender");
+                    shouldNotThrow("sender = pc.addTrack(audioTrack2, stream)");
+                    debug("Close pc and try replacing the track");
+                    pc.close();
+                    return promiseShouldReject("sender.replaceTrack(audioTrack3)");
+                })
+                .catch(function () {
                     debug("End of promise chain");
                     finishJSTest();
                 });
index 2b16674..3e8955b 100644 (file)
@@ -1,5 +1,26 @@
 2016-02-24  Adam Bergkvist  <adam.bergkvist@ericsson.com>
 
+        WebRTC: RTCPeerConnection: Sort out responsibilities of close() and stop()
+        https://bugs.webkit.org/show_bug.cgi?id=154581
+
+        Reviewed by Eric Carlson.
+
+        Let RTCPeerConnection::close() contain all teardown logic be called by stop().
+        close() is also responisble for stopping the PeerConnectionBackend and stopping
+        all RTCRtpSender objects.
+
+        Test coverage:
+        fast/mediastream/RTCRtpSender-replaceTrack.html (updated)
+        fast/mediastream/RTCPeerConnection-closed-state.html
+
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::close):
+        (WebCore::RTCPeerConnection::stop):
+        (WebCore::RTCPeerConnection::RTCPeerConnection): Deleted.
+        * Modules/mediastream/RTCPeerConnection.h:
+
+2016-02-24  Adam Bergkvist  <adam.bergkvist@ericsson.com>
+
         WebRTC: Add addReceiver() function to PeerConnectionBackendClient interface
         https://bugs.webkit.org/show_bug.cgi?id=154583
 
index 4178440..7b7e46c 100644 (file)
@@ -79,7 +79,6 @@ RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context, RefPtr<RTC
     , m_iceGatheringState(IceGatheringState::New)
     , m_iceConnectionState(IceConnectionState::New)
     , m_configuration(WTFMove(configuration))
-    , m_stopped(false)
 {
     Document& document = downcast<Document>(context);
 
@@ -367,17 +366,18 @@ void RTCPeerConnection::close()
     if (m_signalingState == SignalingState::Closed)
         return;
 
+    m_backend->stop();
+
+    m_iceConnectionState = IceConnectionState::Closed;
     m_signalingState = SignalingState::Closed;
+
+    for (auto& sender : m_senderSet)
+        sender->stop();
 }
 
 void RTCPeerConnection::stop()
 {
-    if (m_stopped)
-        return;
-
-    m_stopped = true;
-    m_iceConnectionState = IceConnectionState::Closed;
-    m_signalingState = SignalingState::Closed;
+    close();
 }
 
 const char* RTCPeerConnection::activeDOMObjectName() const
index a7d91cd..c27b9c4 100644 (file)
@@ -147,8 +147,6 @@ private:
     std::unique_ptr<PeerConnectionBackend> m_backend;
 
     RefPtr<RTCConfiguration> m_configuration;
-
-    bool m_stopped;
 };
 
 } // namespace WebCore