<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[212338] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/212338">212338</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-02-14 17:23:39 -0800 (Tue, 14 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebRTC] Add support for libwebrtc negotiation needed event
https://bugs.webkit.org/show_bug.cgi?id=168267

Patch by Youenn Fablet &lt;youennf@gmail.com&gt; 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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastmediastreamRTCPeerConnectionmoremediatonegotiateexpectedtxt">trunk/LayoutTests/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaEndpointPeerConnectioncpp">trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamMediaEndpointPeerConnectionh">trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamPeerConnectionBackendcpp">trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamPeerConnectionBackendh">trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCMediaEndpointcpp">trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCPeerConnectionBackendcpp">trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCPeerConnectionBackendh">trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h</a></li>
<li><a href="#trunkSourceWebCoretestingMockLibWebRTCPeerConnectioncpp">trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/platform/gtk/fast/mediastream/</li>
<li><a href="#trunkLayoutTestsplatformgtkfastmediastreamRTCPeerConnectionmoremediatonegotiateexpectedtxt">trunk/LayoutTests/platform/gtk/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcnegotiatedneededeventaddStreamexpectedtxt">trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcnegotiatedneededeventaddStreamhtml">trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-15 00:35:56 UTC (rev 212337)
+++ trunk/LayoutTests/ChangeLog        2017-02-15 01:23:39 UTC (rev 212338)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2017-02-14  Youenn Fablet  &lt;youennf@gmail.com&gt;
+
+        [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.
+
</ins><span class="cx"> 2017-02-14  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Mark media/modern-media-controls/placard-support/placard-support-airplay.html as flaky.
</span></span></pre></div>
<a id="trunkLayoutTestsfastmediastreamRTCPeerConnectionmoremediatonegotiateexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/mediastream/RTCPeerConnection-more-media-to-negotiate-expected.txt (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -18,7 +18,6 @@
</span><span class="cx"> PASS pc.getTransceivers().length is 2
</span><span class="cx"> Create an answer for the audio only offer
</span><span class="cx"> Set answer as local description
</span><del>-PASS negotiationneededevent fired: There is local media not negotiated that needs to be negotiated in a follow-up offer
</del><span class="cx"> PASS Answer set
</span><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkfastmediastreamRTCPeerConnectionmoremediatonegotiateexpectedtxtfromrev212337trunkLayoutTestsfastmediastreamRTCPeerConnectionmoremediatonegotiateexpectedtxt"></a>
<div class="copfile"><h4>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)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcnegotiatedneededeventaddStreamexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream-expected.txt (0 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+
+PASS on negotiation needed in case of adding a stream 
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcnegotiatedneededeventaddStreamhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/negotiatedneeded-event-addStream.html (0 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;meta charset=&quot;utf-8&quot;&gt;
+        &lt;title&gt;Testing basic video exchange from offerer to receiver&lt;/title&gt;
+        &lt;script src=&quot;../resources/testharness.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+    &lt;/head&gt;
+    &lt;body&gt;
+        &lt;video id=&quot;video&quot; autoplay=&quot;&quot;&gt;&lt;/video&gt;
+        &lt;canvas id=&quot;canvas&quot; width=&quot;640&quot; height=&quot;480&quot;&gt;&lt;/canvas&gt;
+        &lt;script src =&quot;routines.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+
+promise_test((test) =&gt; {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) =&gt; {
+        return new Promise((resolve, reject) =&gt; {
+            if (window.internals)
+                internals.useMockRTCPeerConnectionFactory(&quot;OneRealPeerConnection&quot;);
+            var pc = new RTCPeerConnection();
+            pc.onnegotiationneeded = () =&gt; { resolve(); };
+            pc.addStream(stream);
+        });
+    });
+}, &quot;on negotiation needed in case of adding a stream&quot;);
+        &lt;/script&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2017-02-14  Youenn Fablet  &lt;youennf@gmail.com&gt;
+
+        [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):
+
</ins><span class="cx"> 2017-02-14  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed followup to r212330 to fix Debug builds
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaEndpointPeerConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -420,9 +420,7 @@
</span><span class="cx">     if (m_peerConnection.internalIceGatheringState() == IceGatheringState::New &amp;&amp; mediaDescriptions.size())
</span><span class="cx">         m_peerConnection.updateIceGatheringState(IceGatheringState::Gathering);
</span><span class="cx"> 
</span><del>-    if (m_peerConnection.internalSignalingState() == SignalingState::Stable &amp;&amp; m_negotiationNeeded)
-        m_peerConnection.scheduleNegotiationNeededEvent();
-
</del><ins>+    markAsNeedingNegotiation();
</ins><span class="cx">     setLocalDescriptionSucceeded();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -731,17 +729,6 @@
</span><span class="cx">     m_mediaEndpoint-&gt;stop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MediaEndpointPeerConnection::markAsNeedingNegotiation()
-{
-    if (m_negotiationNeeded)
-        return;
-
-    m_negotiationNeeded = true;
-
-    if (m_peerConnection.internalSignalingState() == SignalingState::Stable)
-        m_peerConnection.scheduleNegotiationNeededEvent();
-}
-
</del><span class="cx"> void MediaEndpointPeerConnection::emulatePlatformEvent(const String&amp; action)
</span><span class="cx"> {
</span><span class="cx">     m_mediaEndpoint-&gt;emulatePlatformEvent(action);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamMediaEndpointPeerConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -64,10 +64,6 @@
</span><span class="cx">     Ref&lt;RTCRtpReceiver&gt; createReceiver(const String&amp; transceiverMid, const String&amp; trackKind, const String&amp; trackId) final;
</span><span class="cx">     void replaceTrack(RTCRtpSender&amp;, RefPtr&lt;MediaStreamTrack&gt;&amp;&amp;, DOMPromise&lt;void&gt;&amp;&amp;) final;
</span><span class="cx"> 
</span><del>-    bool isNegotiationNeeded() const final { return m_negotiationNeeded; };
-    void markAsNeedingNegotiation() final;
-    void clearNegotiationNeededState() final { m_negotiationNeeded = false; };
-
</del><span class="cx">     void emulatePlatformEvent(const String&amp; action) final;
</span><span class="cx"> 
</span><span class="cx">     void runTask(Function&lt;void ()&gt;&amp;&amp;);
</span><span class="lines">@@ -129,8 +125,6 @@
</span><span class="cx">     RefPtr&lt;MediaEndpointSessionDescription&gt; m_pendingRemoteDescription;
</span><span class="cx"> 
</span><span class="cx">     HashMap&lt;String, RefPtr&lt;MediaStream&gt;&gt; m_remoteStreamMap;
</span><del>-
-    bool m_negotiationNeeded { false };
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamPeerConnectionBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -296,6 +296,17 @@
</span><span class="cx">     doStop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PeerConnectionBackend::markAsNeedingNegotiation()
+{
+    if (m_negotiationNeeded)
+        return;
+    
+    m_negotiationNeeded = true;
+    
+    if (m_peerConnection.internalSignalingState() == PeerConnectionStates::SignalingState::Stable)
+        m_peerConnection.scheduleNegotiationNeededEvent();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEB_RTC)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamPeerConnectionBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -95,9 +95,9 @@
</span><span class="cx">     virtual Ref&lt;RTCRtpReceiver&gt; createReceiver(const String&amp; transceiverMid, const String&amp; trackKind, const String&amp; trackId) = 0;
</span><span class="cx">     virtual void replaceTrack(RTCRtpSender&amp;, RefPtr&lt;MediaStreamTrack&gt;&amp;&amp;, DOMPromise&lt;void&gt;&amp;&amp;) = 0;
</span><span class="cx"> 
</span><del>-    virtual bool isNegotiationNeeded() const = 0;
-    virtual void markAsNeedingNegotiation() = 0;
-    virtual void clearNegotiationNeededState() = 0;
</del><ins>+    void markAsNeedingNegotiation();
+    bool isNegotiationNeeded() const { return m_negotiationNeeded; };
+    void clearNegotiationNeededState() { m_negotiationNeeded = false; };
</ins><span class="cx"> 
</span><span class="cx">     virtual void emulatePlatformEvent(const String&amp; action) = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -137,6 +137,8 @@
</span><span class="cx">     std::optional&lt;PeerConnection::SessionDescriptionPromise&gt; m_offerAnswerPromise;
</span><span class="cx">     std::optional&lt;DOMPromise&lt;void&gt;&gt; m_setDescriptionPromise;
</span><span class="cx">     std::optional&lt;DOMPromise&lt;void&gt;&gt; m_addIceCandidatePromise;
</span><ins>+    
+    bool m_negotiationNeeded { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCMediaEndpointcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -380,7 +380,11 @@
</span><span class="cx"> 
</span><span class="cx"> void LibWebRTCMediaEndpoint::OnRenegotiationNeeded()
</span><span class="cx"> {
</span><del>-    notImplemented();
</del><ins>+    callOnMainThread([protectedThis = makeRef(*this)] {
+        if (protectedThis-&gt;isStopped())
+            return;
+        protectedThis-&gt;m_peerConnectionBackend.markAsNeedingNegotiation();
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline PeerConnectionStates::IceConnectionState iceConnectionState(webrtc::PeerConnectionInterface::IceConnectionState state)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCPeerConnectionBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -201,11 +201,6 @@
</span><span class="cx">     m_videoSources.append(WTFMove(source));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void LibWebRTCPeerConnectionBackend::markAsNeedingNegotiation()
-{
-    // FIXME: Implement this
-}
-
</del><span class="cx"> Ref&lt;RTCRtpReceiver&gt; LibWebRTCPeerConnectionBackend::createReceiver(const String&amp;, const String&amp; trackKind, const String&amp; trackId)
</span><span class="cx"> {
</span><span class="cx">     // FIXME: We need to create a source that will get fueled once we will receive OnAddStream.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCPeerConnectionBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -70,9 +70,6 @@
</span><span class="cx">     // FIXME: API to implement for real
</span><span class="cx">     Vector&lt;RefPtr&lt;MediaStream&gt;&gt; getRemoteStreams() const final { return { }; }
</span><span class="cx">     void replaceTrack(RTCRtpSender&amp;, RefPtr&lt;MediaStreamTrack&gt;&amp;&amp;, DOMPromise&lt;void&gt;&amp;&amp;) final { }
</span><del>-    bool isNegotiationNeeded() const final { return false; }
-    void markAsNeedingNegotiation() final;
-    void clearNegotiationNeededState() final { }
</del><span class="cx"> 
</span><span class="cx">     void emulatePlatformEvent(const String&amp;) final { }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockLibWebRTCPeerConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp (212337 => 212338)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -226,11 +226,17 @@
</span><span class="cx"> bool MockLibWebRTCPeerConnection::AddStream(webrtc::MediaStreamInterface* stream)
</span><span class="cx"> {
</span><span class="cx">     m_stream = stream;
</span><ins>+    LibWebRTCProvider::callOnWebRTCSignalingThread([observer = &amp;m_observer] {
+        observer-&gt;OnRenegotiationNeeded();
+    });
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MockLibWebRTCPeerConnection::RemoveStream(webrtc::MediaStreamInterface*)
</span><span class="cx"> {
</span><ins>+    LibWebRTCProvider::callOnWebRTCSignalingThread([observer = &amp;m_observer] {
+        observer-&gt;OnRenegotiationNeeded();
+    });
</ins><span class="cx">     m_stream = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>