WebRTC: Incorrect sdpMLineIndex for video breaks Firefox interop
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jul 2017 14:27:31 +0000 (14:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Jul 2017 14:27:31 +0000 (14:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173530

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

Source/WebCore:

Test: webrtc/ice-candidate-sdpMLineIndex.html

Reading missing parameter from libwebrtc backend and setting it when firing the RTCIceCandidate event.

* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::PeerConnectionBackend::disableICECandidateFiltering):
(WebCore::PeerConnectionBackend::newICECandidate):
* Modules/mediastream/PeerConnectionBackend.h:
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::OnIceCandidate):

LayoutTests:

* webrtc/ice-candidate-sdpMLineIndex-expected.txt: Added.
* webrtc/ice-candidate-sdpMLineIndex.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/webrtc/ice-candidate-sdpMLineIndex-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/ice-candidate-sdpMLineIndex.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp

index 8e37512..13212e9 100644 (file)
@@ -1,3 +1,13 @@
+2017-07-12  Youenn Fablet  <youenn@apple.com>
+
+        WebRTC: Incorrect sdpMLineIndex for video breaks Firefox interop
+        https://bugs.webkit.org/show_bug.cgi?id=173530
+
+        Reviewed by Alex Christensen.
+
+        * webrtc/ice-candidate-sdpMLineIndex-expected.txt: Added.
+        * webrtc/ice-candidate-sdpMLineIndex.html: Added.
+
 2017-07-12  Zan Dobersek  <zdobersek@igalia.com>
 
         [GCrypt] Implement CryptoKeyEC PKCS#8 exports
diff --git a/LayoutTests/webrtc/ice-candidate-sdpMLineIndex-expected.txt b/LayoutTests/webrtc/ice-candidate-sdpMLineIndex-expected.txt
new file mode 100644 (file)
index 0000000..c7cb20a
--- /dev/null
@@ -0,0 +1,3 @@
+
+PASS Basic audio/video ICE candidate gathering 
+
diff --git a/LayoutTests/webrtc/ice-candidate-sdpMLineIndex.html b/LayoutTests/webrtc/ice-candidate-sdpMLineIndex.html
new file mode 100644 (file)
index 0000000..c8b9bf7
--- /dev/null
@@ -0,0 +1,46 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing ICE candidates with audio and video tracks</title>
+        <script src="../resources/testharness.js"></script>
+        <script src="../resources/testharnessreport.js"></script>
+    </head>
+    <body>
+        <script>
+promise_test((test) => {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    return navigator.mediaDevices.getUserMedia({audio: true, video: true}).then((stream) => {
+        return new Promise((resolve, reject) => {
+            var pc = new RTCPeerConnection();
+            pc.addTrack(stream.getAudioTracks()[0], stream);
+           pc.addTrack(stream.getVideoTracks()[0], stream); 
+            var candidates = [];
+            pc.onicecandidate = (event) => {
+                if (event.candidate === null) {
+                    resolve(candidates);
+                    return;
+                }
+                candidates.push(event.candidate.candidate);
+            };
+            pc.createOffer().then((offer) => {
+                pc.setLocalDescription(offer);
+            });
+         });
+     }).then((candidates) => {
+         var index0Count, index1Count;
+         for (var candidate of candidates) {
+             if (candidate.sdpMLineIndex === 0)
+                 index0Count++;
+             if (candidate.sdpMLineIndex === 1)
+                 index1Count++;
+         }
+         assert_true(!!candidates.length, "candidates should be found");
+         assert_equals(index0Count, index1Count, "same number of candidates should be found for audio and video");
+     });
+}, "Basic audio/video ICE candidate gathering");
+        </script>
+    </body>
+</html>
index 1b2ec67..59a6fd2 100644 (file)
@@ -1,3 +1,21 @@
+2017-07-12  Youenn Fablet  <youenn@apple.com>
+
+        WebRTC: Incorrect sdpMLineIndex for video breaks Firefox interop
+        https://bugs.webkit.org/show_bug.cgi?id=173530
+
+        Reviewed by Alex Christensen.
+
+        Test: webrtc/ice-candidate-sdpMLineIndex.html
+
+        Reading missing parameter from libwebrtc backend and setting it when firing the RTCIceCandidate event.
+
+        * Modules/mediastream/PeerConnectionBackend.cpp:
+        (WebCore::PeerConnectionBackend::disableICECandidateFiltering):
+        (WebCore::PeerConnectionBackend::newICECandidate):
+        * Modules/mediastream/PeerConnectionBackend.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::OnIceCandidate):
+
 2017-07-12  Zan Dobersek  <zdobersek@igalia.com>
 
         [GCrypt] Implement CryptoKeyEC PKCS#8 exports
index 773e7e8..22def2b 100644 (file)
@@ -297,7 +297,7 @@ void PeerConnectionBackend::disableICECandidateFiltering()
 {
     m_shouldFilterICECandidates = false;
     for (auto& pendingICECandidate : m_pendingICECandidates)
-        fireICECandidateEvent(RTCIceCandidate::create(WTFMove(pendingICECandidate.sdp), WTFMove(pendingICECandidate.mid), 0));
+        fireICECandidateEvent(RTCIceCandidate::create(WTFMove(pendingICECandidate.sdp), WTFMove(pendingICECandidate.mid), pendingICECandidate.sdpMLineIndex));
     m_pendingICECandidates.clear();
 }
 
@@ -347,19 +347,19 @@ String PeerConnectionBackend::filterSDP(String&& sdp) const
     return filteredSDP.toString();
 }
 
-void PeerConnectionBackend::newICECandidate(String&& sdp, String&& mid)
+void PeerConnectionBackend::newICECandidate(String&& sdp, String&& mid, unsigned short sdpMLineIndex)
 {
     RELEASE_LOG(WebRTC, "Gathered ice candidate:\n%{public}s\n", sdp.utf8().data());
 
     if (!m_shouldFilterICECandidates) {
-        fireICECandidateEvent(RTCIceCandidate::create(WTFMove(sdp), WTFMove(mid), 0));
+        fireICECandidateEvent(RTCIceCandidate::create(WTFMove(sdp), WTFMove(mid), sdpMLineIndex));
         return;
     }
     if (sdp.find(" host ", 0) != notFound) {
-        m_pendingICECandidates.append(PendingICECandidate { WTFMove(sdp), WTFMove(mid)});
+        m_pendingICECandidates.append(PendingICECandidate { WTFMove(sdp), WTFMove(mid), sdpMLineIndex});
         return;
     }
-    fireICECandidateEvent(RTCIceCandidate::create(filterICECandidate(WTFMove(sdp)), WTFMove(mid), 0));
+    fireICECandidateEvent(RTCIceCandidate::create(filterICECandidate(WTFMove(sdp)), WTFMove(mid), sdpMLineIndex));
 }
 
 void PeerConnectionBackend::doneGatheringCandidates()
index 5abad98..dc6b245 100644 (file)
@@ -107,7 +107,7 @@ public:
 
     virtual void emulatePlatformEvent(const String& action) = 0;
 
-    void newICECandidate(String&& sdp, String&& mid);
+    void newICECandidate(String&& sdp, String&& mid, unsigned short sdpMLineIndex);
     void disableICECandidateFiltering();
     void enableICECandidateFiltering();
 
@@ -158,6 +158,7 @@ private:
         // Fields described in https://www.w3.org/TR/webrtc/#idl-def-rtcicecandidateinit.
         String sdp;
         String mid;
+        unsigned short sdpMLineIndex;
     };
     Vector<PendingICECandidate> m_pendingICECandidates;
 
index 7fb5d50..1ceebfc 100644 (file)
@@ -852,10 +852,12 @@ void LibWebRTCMediaEndpoint::OnIceCandidate(const webrtc::IceCandidateInterface
     auto mid = rtcCandidate->sdp_mid();
     String candidateMid(mid.data(), mid.size());
 
-    callOnMainThread([protectedThis = makeRef(*this), mid = WTFMove(candidateMid), sdp = WTFMove(candidateSDP)] {
+    auto sdpMLineIndex = safeCast<unsigned short>(rtcCandidate->sdp_mline_index());
+
+    callOnMainThread([protectedThis = makeRef(*this), mid = WTFMove(candidateMid), sdp = WTFMove(candidateSDP), sdpMLineIndex] {
         if (protectedThis->isStopped())
             return;
-        protectedThis->m_peerConnectionBackend.newICECandidate(String(sdp), String(mid));
+        protectedThis->m_peerConnectionBackend.newICECandidate(String(sdp), String(mid), sdpMLineIndex);
     });
 }