Title: [215412] trunk
Revision
215412
Author
commit-qu...@webkit.org
Date
2017-04-17 08:27:40 -0700 (Mon, 17 Apr 2017)

Log Message

RTCPeerConnection addTrack does not require a stream parameter
https://bugs.webkit.org/show_bug.cgi?id=170894

Patch by Youenn Fablet <you...@apple.com> on 2017-04-17
Reviewed by Alex Christensen.

Source/WebCore:

Test: webrtc/video-addTrack.html

* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::addTrack): Removing obsolete error throwing.

LayoutTests:

* webrtc/video-addTrack-expected.txt: Added.
* webrtc/video-addTrack.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (215411 => 215412)


--- trunk/LayoutTests/ChangeLog	2017-04-17 15:01:32 UTC (rev 215411)
+++ trunk/LayoutTests/ChangeLog	2017-04-17 15:27:40 UTC (rev 215412)
@@ -1,3 +1,13 @@
+2017-04-17  Youenn Fablet  <you...@apple.com>
+
+        RTCPeerConnection addTrack does not require a stream parameter
+        https://bugs.webkit.org/show_bug.cgi?id=170894
+
+        Reviewed by Alex Christensen.
+
+        * webrtc/video-addTrack-expected.txt: Added.
+        * webrtc/video-addTrack.html: Added.
+
 2017-04-16  Joseph Pecoraro  <pecor...@apple.com>
 
         test262: test262/test/built-ins/Object/prototype/toLocaleString/primitive_this_value.js

Added: trunk/LayoutTests/webrtc/video-addTrack-expected.txt (0 => 215412)


--- trunk/LayoutTests/webrtc/video-addTrack-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/video-addTrack-expected.txt	2017-04-17 15:27:40 UTC (rev 215412)
@@ -0,0 +1,11 @@
+ 
+
+PASS Basic video exchange with addTrack - waiting for second track before playing 
+PASS Basic video exchange with addTrack - not waiting for second track to play 
+PASS  track 0, wait = true 
+PASS  track 1, wait = true 
+PASS Testing image result, wait = true 
+PASS  track 0, wait = false 
+PASS  track 1, wait = false 
+FAIL Testing image result, wait = false The index is not in the allowed range.
+

Added: trunk/LayoutTests/webrtc/video-addTrack.html (0 => 215412)


--- trunk/LayoutTests/webrtc/video-addTrack.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/video-addTrack.html	2017-04-17 15:27:40 UTC (rev 215412)
@@ -0,0 +1,82 @@
+<!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>
+        <canvas id="canvas" width="640" height="480"></canvas>
+        <script src =""
+        <script>
+video = document.getElementById("video");
+canvas = document.getElementById("canvas");
+
+function testImage(wait)
+{
+  test(() => {
+    canvas.width = video.videoWidth;
+    canvas.height = video.videoHeight;
+    canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
+
+    imageData = canvas.getContext('2d').getImageData(10, 325, 250, 1);
+    data = ""
+
+    var index = 20;
+    assert_true(data[index] < 100);
+    assert_true(data[index + 1] < 100);
+    assert_true(data[index + 2] < 100);
+
+    index = 80;
+    assert_true(data[index] > 200);
+    assert_true(data[index + 1] > 200);
+    assert_true(data[index + 2] > 200);
+
+    index += 80;
+    assert_true(data[index] > 200);
+    assert_true(data[index + 1] > 200);
+    assert_true(data[index + 2] < 100);
+  }, "Testing image result, wait = " + wait);
+}
+
+function testBasicVideoExchangeWithAddTrack(waitForSecondTrack)
+{
+  promise_test((test) => {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    return navigator.mediaDevices.getUserMedia({audio: true, video: true}).then((stream) => {
+        return new Promise((resolve, reject) => {
+            createConnections((firstConnection) => {
+                assert_equals(stream.getTracks().length, 2);
+                stream.getTracks().forEach(track => firstConnection.addTrack(track));
+            }, (secondConnection) => {
+                var count = 0;
+                secondConnection._ontrack_ = (trackEvent) => {
+                    window.test(function() {
+                        if (trackEvent.track.kind === "video")
+                            assert_equals(trackEvent.track.id, stream.getVideoTracks()[0].id);
+                        else
+                            assert_equals(trackEvent.track.id, stream.getAudioTracks()[0].id);
+                    }, " track " + count + ", wait = " + waitForSecondTrack);
+                    if (count++ === (waitForSecondTrack ? 1 : 0))
+                        resolve(trackEvent.streams[0]);
+                };
+            });
+            setTimeout(() => reject("Test timed out"), 5000);
+        });
+    }).then((stream) => {
+        video.srcObject = stream;
+        return video.play();
+    }).then(() => {
+        testImage(waitForSecondTrack);
+    });
+  }, "Basic video exchange with addTrack - " + (waitForSecondTrack ? "waiting for second track before playing" : "not waiting for second track to play"));
+}
+testBasicVideoExchangeWithAddTrack(true);
+testBasicVideoExchangeWithAddTrack(false);
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (215411 => 215412)


--- trunk/Source/WebCore/ChangeLog	2017-04-17 15:01:32 UTC (rev 215411)
+++ trunk/Source/WebCore/ChangeLog	2017-04-17 15:27:40 UTC (rev 215412)
@@ -1,5 +1,17 @@
 2017-04-17  Youenn Fablet  <you...@apple.com>
 
+        RTCPeerConnection addTrack does not require a stream parameter
+        https://bugs.webkit.org/show_bug.cgi?id=170894
+
+        Reviewed by Alex Christensen.
+
+        Test: webrtc/video-addTrack.html
+
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::addTrack): Removing obsolete error throwing.
+
+2017-04-17  Youenn Fablet  <you...@apple.com>
+
         Add an external libwebrtc encoder factory in WebCore
         https://bugs.webkit.org/show_bug.cgi?id=170883
 

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (215411 => 215412)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-04-17 15:01:32 UTC (rev 215411)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-04-17 15:27:40 UTC (rev 215412)
@@ -101,10 +101,6 @@
     if (isClosed())
         return Exception { INVALID_STATE_ERR };
 
-    // Require at least one stream until https://github.com/w3c/webrtc-pc/issues/288 is resolved
-    if (!streams.size())
-        return Exception { NOT_SUPPORTED_ERR };
-
     for (RTCRtpSender& sender : m_transceiverSet->senders()) {
         if (sender.trackId() == track->id())
             return Exception { INVALID_ACCESS_ERR };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to