A sender created through addTransceiver and populated using addTrack should have...
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 19:54:40 +0000 (19:54 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 19:54:40 +0000 (19:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192136

Reviewed by Eric Carlson.

Source/WebCore:

In case libwebrtc backend is already created, we need to make sure to
set the track source to the libwebrtc sender backend that is actually
tied to the sender.

Covered by updated test.

* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::LibWebRTCPeerConnectionBackend::addTrack):
* Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h:

LayoutTests:

* webrtc/video-replace-track-expected.txt:
* webrtc/video-replace-track.html:

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

LayoutTests/ChangeLog
LayoutTests/webrtc/video-replace-track-expected.txt
LayoutTests/webrtc/video-replace-track.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h

index fb8c198..2d87950 100644 (file)
@@ -1,3 +1,13 @@
+2018-11-29  Youenn Fablet  <youenn@apple.com>
+
+        A sender created through addTransceiver and populated using addTrack should have its source set
+        https://bugs.webkit.org/show_bug.cgi?id=192136
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/video-replace-track-expected.txt:
+        * webrtc/video-replace-track.html:
+
 2018-11-29  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed test gardening, skip three datalist tests that are marked as flaky crashes.
index 6758221..3487723 100644 (file)
@@ -2,4 +2,5 @@
 PASS Switching from front to back camera 
 PASS Switching from front to back camera, with lower resolution 
 PASS Switching from front to back camera, with higher resolution 
+PASS Replace a track for a sender created by addTransceiver and used by addTrack 
 
index e52c719..a62aed7 100644 (file)
@@ -181,6 +181,14 @@ promise_test((test) => {
     });
 
 }, "Switching from front to back camera, with higher resolution");
+
+promise_test(async (test) => {
+    const stream = await navigator.mediaDevices.getUserMedia({ video: true });
+    const pc = new RTCPeerConnection();
+    pc.addTransceiver("video", {direction: "sendonly"});
+    const sender = pc.addTrack(stream.getVideoTracks()[0], stream);
+    await sender.replaceTrack(stream.getVideoTracks()[0].clone());
+}, "Replace a track for a sender created by addTransceiver and used by addTrack");
         </script>
     </body>
 </html>
index 1bc6d21..667f578 100644 (file)
@@ -1,3 +1,20 @@
+2018-11-29  Youenn Fablet  <youenn@apple.com>
+
+        A sender created through addTransceiver and populated using addTrack should have its source set
+        https://bugs.webkit.org/show_bug.cgi?id=192136
+
+        Reviewed by Eric Carlson.
+
+        In case libwebrtc backend is already created, we need to make sure to
+        set the track source to the libwebrtc sender backend that is actually
+        tied to the sender.
+
+        Covered by updated test.
+
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::LibWebRTCPeerConnectionBackend::addTrack):
+        * Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h:
+
 2018-11-29  Megan Gardner  <megan_gardner@apple.com>
 
         Move Lookup Code for better cross platform usage
index 1a93264..0b408d1 100644 (file)
@@ -403,6 +403,7 @@ ExceptionOr<Ref<RTCRtpSender>> LibWebRTCPeerConnectionBackend::addTrack(MediaStr
             return Exception { TypeError, "Unable to add track"_s };
 
         if (auto sender = findExistingSender(m_peerConnection.currentSenders(), *senderBackend)) {
+            backendFromRTPSender(*sender).takeSource(*senderBackend);
             sender->setTrack(makeRef(track));
             sender->setMediaStreamIds(WTFMove(mediaStreamIds));
             return sender.releaseNonNull();
index 8c9ea61..82b1712 100644 (file)
@@ -94,6 +94,12 @@ public:
         ASSERT(hasSource());
     }
 
+    void takeSource(LibWebRTCRtpSenderBackend& backend)
+    {
+        ASSERT(backend.hasSource());
+        setSource(WTFMove(backend.m_source));
+    }
+
 private:
     void replaceTrack(ScriptExecutionContext&, RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&) final;
     RTCRtpSendParameters getParameters() const final;