getReceivers() should return transceivers that have only an active receiver
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jun 2017 17:41:13 +0000 (17:41 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jun 2017 17:41:13 +0000 (17:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173313

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-13
Reviewed by Alex Christensen.

Source/WebCore:

Test: webrtc/video-receivers.html

Creating transceivers for receivers created from an offer.
Setting these as recvonly.

* Modules/mediastream/RTCRtpTransceiver.h:
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::LibWebRTCPeerConnectionBackend::videoReceiver):
(WebCore::LibWebRTCPeerConnectionBackend::audioReceiver):

LayoutTests:

* fast/mediastream/RTCPeerConnection-addTrack-reuse-sender-expected.txt:
* webrtc/video-receivers-expected.txt: Added.
* webrtc/video-receivers.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/mediastream/RTCPeerConnection-addTrack-reuse-sender-expected.txt
LayoutTests/webrtc/video-receivers-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/video-receivers.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCRtpTransceiver.h
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp

index a72dca7..e948faf 100644 (file)
@@ -1,5 +1,16 @@
 2017-06-13  Youenn Fablet  <youenn@apple.com>
 
+        getReceivers() should return transceivers that have only an active receiver
+        https://bugs.webkit.org/show_bug.cgi?id=173313
+
+        Reviewed by Alex Christensen.
+
+        * fast/mediastream/RTCPeerConnection-addTrack-reuse-sender-expected.txt:
+        * webrtc/video-receivers-expected.txt: Added.
+        * webrtc/video-receivers.html: Added.
+
+2017-06-13  Youenn Fablet  <youenn@apple.com>
+
         Refresh WPT tests up to cb7017e654fb4daddb9dee8d654c78b26e61fa9f
         https://bugs.webkit.org/show_bug.cgi?id=173260
 
index 54be173..de12818 100644 (file)
@@ -4,28 +4,28 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 *** Remote description with audio offer set
-FAIL pc.getSenders().length should be 1. Was 0.
-FAIL pc.getReceivers().length should be 1. Was 0.
-FAIL pc.getReceivers()[0].track.kind should be audio. Threw exception TypeError: undefined is not an object (evaluating 'pc.getReceivers()[0].track')
-FAIL pc.getTransceivers().length should be 1. Was 0.
+PASS pc.getSenders().length is 1
+PASS pc.getReceivers().length is 1
+PASS pc.getReceivers()[0].track.kind is 'audio'
+PASS pc.getTransceivers().length is 1
 
 *** Check unused sender
 audioSender = pc.getSenders()[0]
-FAIL audioSender.track should be null. Threw exception TypeError: undefined is not an object (evaluating 'audioSender.track')
+PASS audioSender.track is null
 
 *** Adding a video track should not reuse audioSender (wrong kind)
 senderFromAddTrack = pc.addTrack(videoTrack, stream)
 PASS senderFromAddTrack is not audioSender
 
 *** An extra sender should have been added
-FAIL pc.getSenders().length should be 2. Was 1.
-FAIL pc.getSenders().includes(audioSender) should be true. Was false.
+PASS pc.getSenders().length is 2
+PASS pc.getSenders().includes(audioSender) is true
 PASS pc.getSenders().includes(senderFromAddTrack) is true
 
 *** Adding an audio track should reuse audioSender
 senderFromAddTrack = pc.addTrack(audioTrack, stream)
-FAIL senderFromAddTrack should be undefined (of type undefined). Was [object RTCRtpSender] (of type object).
-FAIL audioSender.track should be [object MediaStreamTrack]. Threw exception TypeError: undefined is not an object (evaluating 'audioSender.track')
+PASS senderFromAddTrack is audioSender
+PASS audioSender.track is audioTrack
 
 *** The number of senders should not have changed
 PASS pc.getSenders().length is 2
diff --git a/LayoutTests/webrtc/video-receivers-expected.txt b/LayoutTests/webrtc/video-receivers-expected.txt
new file mode 100644 (file)
index 0000000..6882089
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Basic video exchange checking getReceivers 
+
diff --git a/LayoutTests/webrtc/video-receivers.html b/LayoutTests/webrtc/video-receivers.html
new file mode 100644 (file)
index 0000000..2f00af4
--- /dev/null
@@ -0,0 +1,37 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing basic video exchange from offerer to receiver</title>
+        <script src="../resources/testharness.js"></script>
+        <script src="../resources/testharnessreport.js"></script>
+    </head>
+    <body>
+        <script src ="routines.js"></script>
+        <script>
+var firstConnection, secondConnection;
+promise_test((test) => {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
+        return new Promise((resolve, reject) => {
+            createConnections((connection) => {
+                firstConnection = connection;
+                var track = stream.getVideoTracks()[0];
+                firstConnection.addTrack(stream.getVideoTracks()[0], stream);
+                assert_equals(firstConnection.getSenders()[0].track, track, "first connection track");
+            }, (connection) => {
+                secondConnection = connection;
+                secondConnection.ontrack = (trackEvent) => {
+                    assert_equals(secondConnection.getReceivers()[0].track, trackEvent.track, "second connection track");
+                    resolve(trackEvent.streams[0]);
+                };
+            });
+            setTimeout(() => reject("Test timed out"), 5000);
+        });
+    });
+}, "Basic video exchange checking getReceivers");
+        </script>
+    </body>
+</html>
index a59e582..c19f891 100644 (file)
@@ -1,3 +1,20 @@
+2017-06-13  Youenn Fablet  <youenn@apple.com>
+
+        getReceivers() should return transceivers that have only an active receiver
+        https://bugs.webkit.org/show_bug.cgi?id=173313
+
+        Reviewed by Alex Christensen.
+
+        Test: webrtc/video-receivers.html
+
+        Creating transceivers for receivers created from an offer.
+        Setting these as recvonly.
+
+        * Modules/mediastream/RTCRtpTransceiver.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::LibWebRTCPeerConnectionBackend::videoReceiver):
+        (WebCore::LibWebRTCPeerConnectionBackend::audioReceiver):
+
 2017-06-13  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Unable to paste text that was copied from a page into the universal search field
index 0b5fa6d..3737e47 100644 (file)
@@ -55,6 +55,7 @@ public:
 
     const String& directionString() const;
     RTCRtpTransceiverDirection direction() const { return m_direction; }
+    // FIXME: setDirection should trigger negotiation needed.
     void setDirection(RTCRtpTransceiverDirection direction) { m_direction = direction; }
 
     const String& provisionalMid() const { return m_provisionalMid; }
index aecd967..816ff05 100644 (file)
@@ -251,6 +251,11 @@ LibWebRTCPeerConnectionBackend::VideoReceiver LibWebRTCPeerConnectionBackend::vi
     }
     auto source = RealtimeIncomingVideoSource::create(nullptr, WTFMove(trackId));
     auto receiver = createReceiverForSource(*m_peerConnection.scriptExecutionContext(), source.copyRef());
+
+    auto transceiver = RTCRtpTransceiver::create(RTCRtpSender::create("video", { }, m_peerConnection), receiver.copyRef());
+    transceiver->disableSendingDirection();
+    m_peerConnection.addTransceiver(WTFMove(transceiver));
+
     return { WTFMove(receiver), WTFMove(source) };
 }
 
@@ -268,6 +273,11 @@ LibWebRTCPeerConnectionBackend::AudioReceiver LibWebRTCPeerConnectionBackend::au
     }
     auto source = RealtimeIncomingAudioSource::create(nullptr, WTFMove(trackId));
     auto receiver = createReceiverForSource(*m_peerConnection.scriptExecutionContext(), source.copyRef());
+
+    auto transceiver = RTCRtpTransceiver::create(RTCRtpSender::create("audio", { }, m_peerConnection), receiver.copyRef());
+    transceiver->disableSendingDirection();
+    m_peerConnection.addTransceiver(WTFMove(transceiver));
+
     return { WTFMove(receiver), WTFMove(source) };
 }