<!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>[212399] 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/212399">212399</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2017-02-15 14:44:25 -0800 (Wed, 15 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Disabled Media Sources should render black/silence
https://bugs.webkit.org/show_bug.cgi?id=168281
Source/WebCore:

Reviewed by Eric Carlson.

Test: webrtc/video-disabled-black.html

Pass the enabled flag setting down from the MediaStreamTrackPrivate to its underlying
source, including RealtimeMediaSource and RealtimeOutgoingAudio/VideoSource. When either
enabled is cleared or muted is set, generate empty (black or silent) media, as opposed to
pausing media or (worse) continuing to send generated media.

* platform/mediastream/MediaStreamTrackPrivate.cpp:
(WebCore::MediaStreamTrackPrivate::setEnabled):
(WebCore::MediaStreamTrackPrivate::sourceEnabledChanged):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::setEnabled):
* platform/mediastream/RealtimeMediaSource.h:
(WebCore::RealtimeMediaSource::enabled):
* platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
(WebCore::MockRealtimeAudioSourceMac::render):
* platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::sourceMutedChanged):
(WebCore::RealtimeOutgoingAudioSource::sourceEnabledChanged):
(WebCore::RealtimeOutgoingAudioSource::pullAudioData):
* platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
* platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::sourceMutedChanged):
(WebCore::RealtimeOutgoingVideoSource::sourceEnabledChanged):
(WebCore::RealtimeOutgoingVideoSource::videoSampleAvailable):
* platform/mediastream/mac/RealtimeOutgoingVideoSource.h:
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::generateFrame):

LayoutTests:

&lt;rdar://problem/30508003&gt;

Reviewed by Eric Carlson.

* webrtc/video-disabled-black-expected.txt: Added.
* webrtc/video-disabled-black.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamMediaStreamTrackPrivatecpp">trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamMediaStreamTrackPrivateh">trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeMediaSourcecpp">trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceh">trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAudioTrackPrivateMediaStreamCocoah">trunk/Source/WebCore/platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMacmm">trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourcecpp">trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourceh">trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingVideoSourcecpp">trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingVideoSourceh">trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeVideoSourcecpp">trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswebrtcvideodisabledblackexpectedtxt">trunk/LayoutTests/webrtc/video-disabled-black-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcvideodisabledblackhtml">trunk/LayoutTests/webrtc/video-disabled-black.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/LayoutTests/ChangeLog        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-02-15  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Disabled Media Sources should render black/silence
+        https://bugs.webkit.org/show_bug.cgi?id=168281
+        &lt;rdar://problem/30508003&gt;
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/video-disabled-black-expected.txt: Added.
+        * webrtc/video-disabled-black.html: Added.
+
</ins><span class="cx"> 2017-02-15  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove ElCapitan flag from flaky test media/modern-media-controls/airplay-support/airplay-support.html.
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcvideodisabledblackexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/video-disabled-black-expected.txt (0 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-disabled-black-expected.txt                                (rev 0)
+++ trunk/LayoutTests/webrtc/video-disabled-black-expected.txt        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+
+
+PASS Disabled source exchange
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcvideodisabledblackhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/video-disabled-black.html (0 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-disabled-black.html                                (rev 0)
+++ trunk/LayoutTests/webrtc/video-disabled-black.html        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -0,0 +1,70 @@
</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;
+if (window.internals)
+    internals.useMockRTCPeerConnectionFactory(&quot;TwoRealPeerConnections&quot;);
+
+if (window.testRunner)
+    testRunner.setUserMediaPermission(true);
+
+video = document.getElementById(&quot;video&quot;);
+canvas = document.getElementById(&quot;canvas&quot;);
+// FIXME: We should use tracks
+
+function testImage()
+{
+    try {
+        canvas.width = video.videoWidth;
+        canvas.height = video.videoHeight;
+        canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
+
+        imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);
+        assert_true(imageData.data.every( (pixel, index) =&gt; {
+            if (index % 4 === 3)
+                return pixel === 255;
+            return pixel === 0;
+        }));
+
+        finishTest();
+    } catch(e) {
+        errorTest(e);
+    }
+}
+
+function testStream(stream)
+{
+    video.srcObject = stream;
+    stream.getTracks()[0].enabled = false;
+    // Video may play with black frames
+    video.onplay = setTimeout(() =&gt; {
+        testImage();
+    }, 1000);
+}
+
+var finishTest, errorTest;
+promise_test((test) =&gt; {
+    return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) =&gt; {
+        return new Promise((resolve, reject) =&gt; {
+            finishTest = resolve;
+            errorTest = reject;
+            createConnections((firstConnection) =&gt; {
+                firstConnection.addStream(stream);
+            }, (secondConnection) =&gt; {
+                secondConnection.onaddstream = (streamEvent) =&gt; { testStream(streamEvent.stream); };
+            });
+        });
+    });
+}, &quot;Disabled source exchange&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 (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/ChangeLog        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2017-02-15  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Disabled Media Sources should render black/silence
+        https://bugs.webkit.org/show_bug.cgi?id=168281
+
+        Reviewed by Eric Carlson.
+
+        Test: webrtc/video-disabled-black.html
+
+        Pass the enabled flag setting down from the MediaStreamTrackPrivate to its underlying
+        source, including RealtimeMediaSource and RealtimeOutgoingAudio/VideoSource. When either
+        enabled is cleared or muted is set, generate empty (black or silent) media, as opposed to
+        pausing media or (worse) continuing to send generated media.
+
+        * platform/mediastream/MediaStreamTrackPrivate.cpp:
+        (WebCore::MediaStreamTrackPrivate::setEnabled):
+        (WebCore::MediaStreamTrackPrivate::sourceEnabledChanged):
+        * platform/mediastream/MediaStreamTrackPrivate.h:
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (WebCore::RealtimeMediaSource::setEnabled):
+        * platform/mediastream/RealtimeMediaSource.h:
+        (WebCore::RealtimeMediaSource::enabled):
+        * platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h:
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
+        (WebCore::MockRealtimeAudioSourceMac::render):
+        * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
+        (WebCore::RealtimeOutgoingAudioSource::sourceMutedChanged):
+        (WebCore::RealtimeOutgoingAudioSource::sourceEnabledChanged):
+        (WebCore::RealtimeOutgoingAudioSource::pullAudioData):
+        * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
+        * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp:
+        (WebCore::RealtimeOutgoingVideoSource::sourceMutedChanged):
+        (WebCore::RealtimeOutgoingVideoSource::sourceEnabledChanged):
+        (WebCore::RealtimeOutgoingVideoSource::videoSampleAvailable):
+        * platform/mediastream/mac/RealtimeOutgoingVideoSource.h:
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::generateFrame):
+
</ins><span class="cx"> 2017-02-15  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Editing history scripts should not add the contenteditable attribute or override key events
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamMediaStreamTrackPrivatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -100,6 +100,8 @@
</span><span class="cx">     // Always update the enabled state regardless of the track being ended.
</span><span class="cx">     m_isEnabled = enabled;
</span><span class="cx"> 
</span><ins>+    m_source-&gt;setEnabled(enabled);
+
</ins><span class="cx">     for (auto&amp; observer : m_observers)
</span><span class="cx">         observer-&gt;trackEnabledChanged(*this);
</span><span class="cx"> }
</span><span class="lines">@@ -186,6 +188,12 @@
</span><span class="cx">         observer-&gt;trackMutedChanged(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaStreamTrackPrivate::sourceEnabledChanged()
+{
+    for (auto&amp; observer : m_observers)
+        observer-&gt;trackEnabledChanged(*this);
+}
+
</ins><span class="cx"> void MediaStreamTrackPrivate::sourceSettingsChanged()
</span><span class="cx"> {
</span><span class="cx">     for (auto&amp; observer : m_observers)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamMediaStreamTrackPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx">     // RealtimeMediaSourceObserver
</span><span class="cx">     void sourceStopped() final;
</span><span class="cx">     void sourceMutedChanged() final;
</span><ins>+    void sourceEnabledChanged() final;
</ins><span class="cx">     void sourceSettingsChanged() final;
</span><span class="cx">     bool preventSourceFromStopping() final;
</span><span class="cx">     void videoSampleAvailable(MediaSample&amp;) final;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeMediaSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -96,6 +96,20 @@
</span><span class="cx">         observer-&gt;sourceMutedChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RealtimeMediaSource::setEnabled(bool enabled)
+{
+    if (m_stopped || m_enabled == enabled)
+        return;
+
+    m_enabled = enabled;
+
+    if (m_stopped)
+        return;
+
+    for (auto&amp; observer : m_observers)
+        observer-&gt;sourceEnabledChanged();
+}
+
</ins><span class="cx"> void RealtimeMediaSource::settingsDidChange()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -69,6 +69,7 @@
</span><span class="cx">         // Source state changes.
</span><span class="cx">         virtual void sourceStopped() = 0;
</span><span class="cx">         virtual void sourceMutedChanged() = 0;
</span><ins>+        virtual void sourceEnabledChanged() = 0;
</ins><span class="cx">         virtual void sourceSettingsChanged() = 0;
</span><span class="cx"> 
</span><span class="cx">         // Observer state queries.
</span><span class="lines">@@ -117,6 +118,9 @@
</span><span class="cx">     virtual bool muted() const { return m_muted; }
</span><span class="cx">     virtual void setMuted(bool);
</span><span class="cx"> 
</span><ins>+    virtual bool enabled() const { return m_enabled; }
+    virtual void setEnabled(bool);
+
</ins><span class="cx">     virtual bool readonly() const;
</span><span class="cx">     virtual void setReadonly(bool readonly) { m_readonly = readonly; }
</span><span class="cx"> 
</span><span class="lines">@@ -190,6 +194,7 @@
</span><span class="cx">     virtual void applySizeAndFrameRate(std::optional&lt;int&gt; width, std::optional&lt;int&gt; height, std::optional&lt;double&gt;);
</span><span class="cx"> 
</span><span class="cx">     bool m_muted { false };
</span><ins>+    bool m_enabled { true };
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WeakPtr&lt;RealtimeMediaSource&gt; createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAudioTrackPrivateMediaStreamCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.h        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -64,6 +64,7 @@
</span><span class="cx">     // RealtimeMediaSource::Observer
</span><span class="cx">     void sourceStopped() final;
</span><span class="cx">     void sourceMutedChanged()  final { }
</span><ins>+    void sourceEnabledChanged() final { }
</ins><span class="cx">     void sourceSettingsChanged() final { }
</span><span class="cx">     bool preventSourceFromStopping() final { return false; }
</span><span class="cx">     void audioSamplesAvailable(const MediaTime&amp;, const PlatformAudioData&amp;, const AudioStreamDescription&amp;, size_t) final;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -149,6 +149,9 @@
</span><span class="cx"> 
</span><span class="cx"> void MockRealtimeAudioSourceMac::render(double delta)
</span><span class="cx"> {
</span><ins>+    if (m_muted || !m_enabled)
+        return;
+
</ins><span class="cx">     static double theta;
</span><span class="cx">     static const double frequencies[] = { 1500., 500. };
</span><span class="cx">     static const double tau = 2 * M_PI;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -53,9 +53,16 @@
</span><span class="cx"> 
</span><span class="cx"> void RealtimeOutgoingAudioSource::sourceMutedChanged()
</span><span class="cx"> {
</span><del>-    m_isMuted = m_audioSource-&gt;muted();
</del><ins>+    m_muted = m_audioSource-&gt;muted();
+    m_sampleConverter-&gt;setMuted(m_muted || !m_enabled);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RealtimeOutgoingAudioSource::sourceEnabledChanged()
+{
+    m_enabled = m_audioSource-&gt;enabled();
+    m_sampleConverter-&gt;setMuted(m_muted || !m_enabled);
+}
+
</ins><span class="cx"> void RealtimeOutgoingAudioSource::audioSamplesAvailable(const MediaTime&amp; time, const PlatformAudioData&amp; audioData, const AudioStreamDescription&amp; streamDescription, size_t sampleCount)
</span><span class="cx"> {
</span><span class="cx">     if (m_inputStreamDescription != streamDescription) {
</span><span class="lines">@@ -86,8 +93,6 @@
</span><span class="cx"> 
</span><span class="cx">     m_sampleConverter-&gt;pullAvalaibleSamplesAsChunks(bufferList, LibWebRTCAudioFormat::chunkSampleCount, m_startFrame, [this] {
</span><span class="cx">         m_startFrame += LibWebRTCAudioFormat::chunkSampleCount;
</span><del>-        if (m_isMuted)
-            return;
</del><span class="cx">         for (auto sink : m_sinks)
</span><span class="cx">             sink-&gt;OnData(m_audioBuffer.data(), LibWebRTCAudioFormat::sampleSize, LibWebRTCAudioFormat::sampleRate, m_inputStreamDescription.numberOfChannels(), LibWebRTCAudioFormat::chunkSampleCount);
</span><span class="cx">     });
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -65,6 +65,7 @@
</span><span class="cx">     // RealtimeMediaSource::Observer API
</span><span class="cx">     void sourceStopped() final { }
</span><span class="cx">     void sourceMutedChanged() final;
</span><ins>+    void sourceEnabledChanged() final;
</ins><span class="cx">     void sourceSettingsChanged() final { }
</span><span class="cx">     bool preventSourceFromStopping() final { return false; }
</span><span class="cx">     void audioSamplesAvailable(const MediaTime&amp;, const PlatformAudioData&amp;, const AudioStreamDescription&amp;, size_t) final;
</span><span class="lines">@@ -79,7 +80,8 @@
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;uint16_t&gt; m_audioBuffer;
</span><span class="cx">     uint64_t m_startFrame { 0 };
</span><del>-    bool m_isMuted { false };
</del><ins>+    bool m_muted { false };
+    bool m_enabled { true };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingVideoSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -44,6 +44,16 @@
</span><span class="cx">     m_videoSource-&gt;addObserver(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RealtimeOutgoingVideoSource::sourceMutedChanged()
+{
+    m_muted = m_videoSource-&gt;muted();
+}
+
+void RealtimeOutgoingVideoSource::sourceEnabledChanged()
+{
+    m_enabled = m_videoSource-&gt;enabled();
+}
+
</ins><span class="cx"> bool RealtimeOutgoingVideoSource::GetStats(Stats*)
</span><span class="cx"> {
</span><span class="cx">     return false;
</span><span class="lines">@@ -66,13 +76,7 @@
</span><span class="cx">     if (!m_sinks.size())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    ASSERT(sample.platformSample().type == PlatformSample::CMSampleBufferType);
-    auto pixelBuffer = static_cast&lt;CVPixelBufferRef&gt;(CMSampleBufferGetImageBuffer(sample.platformSample().sample.cmSampleBuffer));
-    auto pixelFormatType = CVPixelBufferGetPixelFormatType(pixelBuffer);
</del><span class="cx"> 
</span><del>-    CVPixelBufferLockBaseAddress(pixelBuffer, 0);
-    uint8_t* src = reinterpret_cast&lt;uint8_t*&gt;(CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0));
-
</del><span class="cx">     // FIXME: Shouldn't we use RealtimeMediaSource::size()
</span><span class="cx">     const auto&amp; settings = m_videoSource-&gt;settings();
</span><span class="cx"> 
</span><span class="lines">@@ -79,19 +83,30 @@
</span><span class="cx">     // FIXME: We should not need to allocate one buffer per frame.
</span><span class="cx">     auto dest = webrtc::I420Buffer::Create(settings.width(), settings.height());
</span><span class="cx"> 
</span><del>-    if (pixelFormatType == kCVPixelFormatType_420YpCbCr8Planar) {
-        // We probably can memcpy the data directly
-        webrtc::ConvertToI420(webrtc::kI420, src, 0, 0, settings.width(), settings.height(), 0, webrtc::kVideoRotation_0, dest);
-    } else if (pixelFormatType == kCVPixelFormatType_32BGRA)
-        webrtc::ConvertToI420(webrtc::kARGB, src, 0, 0, settings.width(), settings.height(), 0, webrtc::kVideoRotation_0, dest);
-    else {
-        // FIXME: Mock source conversion works with kBGRA while regular camera works with kARGB
-        ASSERT(pixelFormatType == kCVPixelFormatType_32ARGB);
-        webrtc::ConvertToI420(webrtc::kBGRA, src, 0, 0, settings.width(), settings.height(), 0, webrtc::kVideoRotation_0, dest);
</del><ins>+    if (!m_muted &amp;&amp; m_enabled) {
+        ASSERT(sample.platformSample().type == PlatformSample::CMSampleBufferType);
+        auto pixelBuffer = static_cast&lt;CVPixelBufferRef&gt;(CMSampleBufferGetImageBuffer(sample.platformSample().sample.cmSampleBuffer));
+        auto pixelFormatType = CVPixelBufferGetPixelFormatType(pixelBuffer);
+
+        CVPixelBufferLockBaseAddress(pixelBuffer, 0);
+        uint8_t* src = reinterpret_cast&lt;uint8_t*&gt;(CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0));
+
+        if (pixelFormatType == kCVPixelFormatType_420YpCbCr8Planar) {
+            // We probably can memcpy the data directly
+            webrtc::ConvertToI420(webrtc::kI420, src, 0, 0, settings.width(), settings.height(), 0, webrtc::kVideoRotation_0, dest);
+        } else if (pixelFormatType == kCVPixelFormatType_32BGRA)
+            webrtc::ConvertToI420(webrtc::kARGB, src, 0, 0, settings.width(), settings.height(), 0, webrtc::kVideoRotation_0, dest);
+        else {
+            // FIXME: Mock source conversion works with kBGRA while regular camera works with kARGB
+            ASSERT(pixelFormatType == kCVPixelFormatType_32ARGB);
+            webrtc::ConvertToI420(webrtc::kBGRA, src, 0, 0, settings.width(), settings.height(), 0, webrtc::kVideoRotation_0, dest);
+        }
+
+        CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
+    } else {
+        dest-&gt;SetToBlack();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
-
</del><span class="cx">     webrtc::VideoFrame frame(dest, 0, 0,  webrtc::kVideoRotation_0);
</span><span class="cx">     for (auto* sink : m_sinks)
</span><span class="cx">         sink-&gt;OnFrame(frame);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingVideoSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -68,12 +68,15 @@
</span><span class="cx">     // RealtimeMediaSource::Observer API
</span><span class="cx">     bool preventSourceFromStopping() final { return false; }
</span><span class="cx">     void sourceStopped() final { }
</span><del>-    void sourceMutedChanged() final { }
</del><ins>+    void sourceMutedChanged() final;
+    void sourceEnabledChanged() final;
</ins><span class="cx">     void sourceSettingsChanged() final { }
</span><span class="cx">     void videoSampleAvailable(MediaSample&amp;) final;
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;rtc::VideoSinkInterface&lt;webrtc::VideoFrame&gt;*&gt; m_sinks;
</span><span class="cx">     Ref&lt;RealtimeMediaSource&gt; m_videoSource;
</span><ins>+    bool m_enabled { true };
+    bool m_muted { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeVideoSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (212398 => 212399)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp        2017-02-15 22:43:59 UTC (rev 212398)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp        2017-02-15 22:44:25 UTC (rev 212399)
</span><span class="lines">@@ -333,9 +333,11 @@
</span><span class="cx">     FloatRect frameRect(FloatPoint(), size);
</span><span class="cx">     context.fillRect(FloatRect(FloatPoint(), size), Color::black);
</span><span class="cx"> 
</span><del>-    drawText(context);
-    drawAnimation(context);
-    drawBoxes(context);
</del><ins>+    if (!m_muted &amp;&amp; m_enabled) {
+        drawText(context);
+        drawAnimation(context);
+        drawBoxes(context);
+    }
</ins><span class="cx"> 
</span><span class="cx">     updateSampleBuffer();
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>