Title: [212338] trunk
Revision
212338
Author
[email protected]
Date
2017-02-14 17:23:39 -0800 (Tue, 14 Feb 2017)

Log Message

[WebRTC] Add support for libwebrtc negotiation needed event
https://bugs.webkit.org/show_bug.cgi?id=168267

Patch by Youenn Fablet <[email protected]> on 2017-02-14
Reviewed by Eric Carlson.

Source/WebCore:

Test: webrtc/negotiatedneeded-event-addStream.html

Moving generic code (markAsNeedingNegotiation) from MediaEndpointPeerConnection to PeerConnectionBackend.
This code handles the control of sending or not the negotiationneeded event.

Updating mock to use markAsNeedingNegotiation when streams are changed.
Updating libwebrtc backend to call markAsNeedingNegotiation when required by libwebrtc implementation.

* Modules/mediastream/MediaEndpointPeerConnection.cpp:
(WebCore::MediaEndpointPeerConnection::setLocalDescriptionTask):
* Modules/mediastream/MediaEndpointPeerConnection.h:
* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::PeerConnectionBackend::markAsNeedingNegotiation):
* Modules/mediastream/PeerConnectionBackend.h:
(WebCore::PeerConnectionBackend::isNegotiationNeeded):
(WebCore::PeerConnectionBackend::clearNegotiationNeededState):
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::OnRenegotiationNeeded):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
* testing/MockLibWebRTCPeerConnection.cpp:
(WebCore::MockLibWebRTCPeerConnection::AddStream):
(WebCore::MockLibWebRTCPeerConnection::RemoveStream):

LayoutTests:

* fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt:
* platform/gtk/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt: Copied from LayoutTests/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt.
* webrtc/negotiatedneeded-event-addStream-expected.txt: Added.
* webrtc/negotiatedneeded-event-addStream.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (212337 => 212338)


--- trunk/LayoutTests/ChangeLog	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/LayoutTests/ChangeLog	2017-02-15 01:23:39 UTC (rev 212338)
@@ -1,3 +1,15 @@
+2017-02-14  Youenn Fablet  <[email protected]>
+
+        [WebRTC] Add support for libwebrtc negotiation needed event
+        https://bugs.webkit.org/show_bug.cgi?id=168267
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt:
+        * platform/gtk/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt: Copied from LayoutTests/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt.
+        * webrtc/negotiatedneeded-event-addStream-expected.txt: Added.
+        * webrtc/negotiatedneeded-event-addStream.html: Added.
+
 2017-02-14  Ryan Haddad  <[email protected]>
 
         Mark media/modern-media-controls/placard-support/placard-support-airplay.html as flaky.

Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt (212337 => 212338)


--- trunk/LayoutTests/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/LayoutTests/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt	2017-02-15 01:23:39 UTC (rev 212338)
@@ -18,7 +18,6 @@
 PASS pc.getTransceivers().length is 2
 Create an answer for the audio only offer
 Set answer as local description
-PASS negotiationneededevent fired: There is local media not negotiated that needs to be negotiated in a follow-up offer
 PASS Answer set
 PASS successfullyParsed is true
 

Copied: trunk/LayoutTests/platform/gtk/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt (from rev 212337, trunk/LayoutTests/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt) (0 => 212338)


--- trunk/LayoutTests/platform/gtk/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/gtk/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt	2017-02-15 01:23:39 UTC (rev 212338)
@@ -0,0 +1,26 @@
+Test that a negotiationneeded event is fired when not all local media can be included in an answer
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS pc.signalingState is 'stable'
+Add local audio and video tracks to pc
+pc.addTrack(stream.getAudioTracks()[0], stream)
+pc.addTrack(stream.getVideoTracks()[0], stream)
+PASS pc.getTransceivers().length is 2
+PASS negotiationneededevent fired: There is local media added with addTrack
+
+Register a new handler for the negotiationneededevent
+PASS remotePc.getTransceivers().length is 1
+Create a remote offer with audio only
+Set remote offer as remote description
+PASS Remote offer set
+PASS pc.getTransceivers().length is 2
+Create an answer for the audio only offer
+Set answer as local description
+PASS negotiationneededevent fired: There is local media not negotiated that needs to be negotiated in a follow-up offer
+PASS Answer set
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream-expected.txt (0 => 212338)


--- trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream-expected.txt	2017-02-15 01:23:39 UTC (rev 212338)
@@ -0,0 +1,4 @@
+
+
+PASS on negotiation needed in case of adding a stream 
+

Added: trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream.html (0 => 212338)


--- trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream.html	2017-02-15 01:23:39 UTC (rev 212338)
@@ -0,0 +1,31 @@
+<!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>
+
+promise_test((test) => {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
+        return new Promise((resolve, reject) => {
+            if (window.internals)
+                internals.useMockRTCPeerConnectionFactory("OneRealPeerConnection");
+            var pc = new RTCPeerConnection();
+            pc._onnegotiationneeded_ = () => { resolve(); };
+            pc.addStream(stream);
+        });
+    });
+}, "on negotiation needed in case of adding a stream");
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (212337 => 212338)


--- trunk/Source/WebCore/ChangeLog	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/Source/WebCore/ChangeLog	2017-02-15 01:23:39 UTC (rev 212338)
@@ -1,3 +1,34 @@
+2017-02-14  Youenn Fablet  <[email protected]>
+
+        [WebRTC] Add support for libwebrtc negotiation needed event
+        https://bugs.webkit.org/show_bug.cgi?id=168267
+
+        Reviewed by Eric Carlson.
+
+        Test: webrtc/negotiatedneeded-event-addStream.html
+
+        Moving generic code (markAsNeedingNegotiation) from MediaEndpointPeerConnection to PeerConnectionBackend.
+        This code handles the control of sending or not the negotiationneeded event.
+
+        Updating mock to use markAsNeedingNegotiation when streams are changed.
+        Updating libwebrtc backend to call markAsNeedingNegotiation when required by libwebrtc implementation.
+
+        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+        (WebCore::MediaEndpointPeerConnection::setLocalDescriptionTask):
+        * Modules/mediastream/MediaEndpointPeerConnection.h:
+        * Modules/mediastream/PeerConnectionBackend.cpp:
+        (WebCore::PeerConnectionBackend::markAsNeedingNegotiation):
+        * Modules/mediastream/PeerConnectionBackend.h:
+        (WebCore::PeerConnectionBackend::isNegotiationNeeded):
+        (WebCore::PeerConnectionBackend::clearNegotiationNeededState):
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::OnRenegotiationNeeded):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+        * testing/MockLibWebRTCPeerConnection.cpp:
+        (WebCore::MockLibWebRTCPeerConnection::AddStream):
+        (WebCore::MockLibWebRTCPeerConnection::RemoveStream):
+
 2017-02-14  Brady Eidson  <[email protected]>
 
         Unreviewed followup to r212330 to fix Debug builds

Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp (212337 => 212338)


--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2017-02-15 01:23:39 UTC (rev 212338)
@@ -420,9 +420,7 @@
     if (m_peerConnection.internalIceGatheringState() == IceGatheringState::New && mediaDescriptions.size())
         m_peerConnection.updateIceGatheringState(IceGatheringState::Gathering);
 
-    if (m_peerConnection.internalSignalingState() == SignalingState::Stable && m_negotiationNeeded)
-        m_peerConnection.scheduleNegotiationNeededEvent();
-
+    markAsNeedingNegotiation();
     setLocalDescriptionSucceeded();
 }
 
@@ -731,17 +729,6 @@
     m_mediaEndpoint->stop();
 }
 
-void MediaEndpointPeerConnection::markAsNeedingNegotiation()
-{
-    if (m_negotiationNeeded)
-        return;
-
-    m_negotiationNeeded = true;
-
-    if (m_peerConnection.internalSignalingState() == SignalingState::Stable)
-        m_peerConnection.scheduleNegotiationNeededEvent();
-}
-
 void MediaEndpointPeerConnection::emulatePlatformEvent(const String& action)
 {
     m_mediaEndpoint->emulatePlatformEvent(action);

Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h (212337 => 212338)


--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h	2017-02-15 01:23:39 UTC (rev 212338)
@@ -64,10 +64,6 @@
     Ref<RTCRtpReceiver> createReceiver(const String& transceiverMid, const String& trackKind, const String& trackId) final;
     void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) final;
 
-    bool isNegotiationNeeded() const final { return m_negotiationNeeded; };
-    void markAsNeedingNegotiation() final;
-    void clearNegotiationNeededState() final { m_negotiationNeeded = false; };
-
     void emulatePlatformEvent(const String& action) final;
 
     void runTask(Function<void ()>&&);
@@ -129,8 +125,6 @@
     RefPtr<MediaEndpointSessionDescription> m_pendingRemoteDescription;
 
     HashMap<String, RefPtr<MediaStream>> m_remoteStreamMap;
-
-    bool m_negotiationNeeded { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (212337 => 212338)


--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp	2017-02-15 01:23:39 UTC (rev 212338)
@@ -296,6 +296,17 @@
     doStop();
 }
 
+void PeerConnectionBackend::markAsNeedingNegotiation()
+{
+    if (m_negotiationNeeded)
+        return;
+    
+    m_negotiationNeeded = true;
+    
+    if (m_peerConnection.internalSignalingState() == PeerConnectionStates::SignalingState::Stable)
+        m_peerConnection.scheduleNegotiationNeededEvent();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_RTC)

Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h (212337 => 212338)


--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2017-02-15 01:23:39 UTC (rev 212338)
@@ -95,9 +95,9 @@
     virtual Ref<RTCRtpReceiver> createReceiver(const String& transceiverMid, const String& trackKind, const String& trackId) = 0;
     virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) = 0;
 
-    virtual bool isNegotiationNeeded() const = 0;
-    virtual void markAsNeedingNegotiation() = 0;
-    virtual void clearNegotiationNeededState() = 0;
+    void markAsNeedingNegotiation();
+    bool isNegotiationNeeded() const { return m_negotiationNeeded; };
+    void clearNegotiationNeededState() { m_negotiationNeeded = false; };
 
     virtual void emulatePlatformEvent(const String& action) = 0;
 
@@ -137,6 +137,8 @@
     std::optional<PeerConnection::SessionDescriptionPromise> m_offerAnswerPromise;
     std::optional<DOMPromise<void>> m_setDescriptionPromise;
     std::optional<DOMPromise<void>> m_addIceCandidatePromise;
+    
+    bool m_negotiationNeeded { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (212337 => 212338)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-02-15 01:23:39 UTC (rev 212338)
@@ -380,7 +380,11 @@
 
 void LibWebRTCMediaEndpoint::OnRenegotiationNeeded()
 {
-    notImplemented();
+    callOnMainThread([protectedThis = makeRef(*this)] {
+        if (protectedThis->isStopped())
+            return;
+        protectedThis->m_peerConnectionBackend.markAsNeedingNegotiation();
+    });
 }
 
 static inline PeerConnectionStates::IceConnectionState iceConnectionState(webrtc::PeerConnectionInterface::IceConnectionState state)

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (212337 => 212338)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2017-02-15 01:23:39 UTC (rev 212338)
@@ -201,11 +201,6 @@
     m_videoSources.append(WTFMove(source));
 }
 
-void LibWebRTCPeerConnectionBackend::markAsNeedingNegotiation()
-{
-    // FIXME: Implement this
-}
-
 Ref<RTCRtpReceiver> LibWebRTCPeerConnectionBackend::createReceiver(const String&, const String& trackKind, const String& trackId)
 {
     // FIXME: We need to create a source that will get fueled once we will receive OnAddStream.

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h (212337 => 212338)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2017-02-15 01:23:39 UTC (rev 212338)
@@ -70,9 +70,6 @@
     // FIXME: API to implement for real
     Vector<RefPtr<MediaStream>> getRemoteStreams() const final { return { }; }
     void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) final { }
-    bool isNegotiationNeeded() const final { return false; }
-    void markAsNeedingNegotiation() final;
-    void clearNegotiationNeededState() final { }
 
     void emulatePlatformEvent(const String&) final { }
 

Modified: trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp (212337 => 212338)


--- trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp	2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp	2017-02-15 01:23:39 UTC (rev 212338)
@@ -226,11 +226,17 @@
 bool MockLibWebRTCPeerConnection::AddStream(webrtc::MediaStreamInterface* stream)
 {
     m_stream = stream;
+    LibWebRTCProvider::callOnWebRTCSignalingThread([observer = &m_observer] {
+        observer->OnRenegotiationNeeded();
+    });
     return true;
 }
 
 void MockLibWebRTCPeerConnection::RemoveStream(webrtc::MediaStreamInterface*)
 {
+    LibWebRTCProvider::callOnWebRTCSignalingThread([observer = &m_observer] {
+        observer->OnRenegotiationNeeded();
+    });
     m_stream = nullptr;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to