<!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>[218497] 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/218497">218497</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-06-19 10:12:57 -0700 (Mon, 19 Jun 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>A cloned MediaStreamTrack should mute independently other tracks using the same source
https://bugs.webkit.org/show_bug.cgi?id=172831
<rdar://problem/32518527>

Patch by Youenn Fablet <youenn@apple.com> on 2017-06-19
Reviewed by Eric Carlson.

Source/WebCore:

Test: webrtc/clone-audio-track.html

Move enabled handling in MediaStreamTrackPrivate instead of RealtimeMediaSource.
Move WebRTC and WebAudio customers of RealtimeMediaSource to MediaStreamTrackPrivate.
Move creation of WebAudio provider to MediaStreamTrackPrivate.

This allows changing some parameters of tracks having the same source independently.
Using this for enabled track attribute.

We no longer stop generating frames in case track is disabled.
This should be added back as an optimization in a follow-up.

* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::addTrack):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::LibWebRTCPeerConnectionBackend::replaceTrack):
* Modules/webaudio/MediaStreamAudioSource.cpp:
* Modules/webaudio/MediaStreamAudioSource.h:
* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/MediaStreamTrackPrivate.cpp:
(WebCore::MediaStreamTrackPrivate::create):
(WebCore::MediaStreamTrackPrivate::~MediaStreamTrackPrivate):
(WebCore::MediaStreamTrackPrivate::setEnabled):
(WebCore::MediaStreamTrackPrivate::audioSourceProvider):
(WebCore::MediaStreamTrackPrivate::videoSampleAvailable):
(WebCore::MediaStreamTrackPrivate::audioSamplesAvailable):
* platform/mediastream/MediaStreamTrackPrivate.h:
(WebCore::MediaStreamTrackPrivate::Observer::audioSamplesAvailable):
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::removeObserver):
* platform/mediastream/RealtimeMediaSource.h:
* platform/mediastream/mac/AVMediaCaptureSource.h:
* platform/mediastream/mac/AVMediaCaptureSource.mm:
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::CoreAudioCaptureSource::startProducingData):
(WebCore::CoreAudioCaptureSource::stopProducingData):
* platform/mediastream/mac/CoreAudioCaptureSource.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
(WebCore::MockRealtimeAudioSourceMac::render):
* platform/mediastream/mac/RealtimeIncomingAudioSource.cpp:
(WebCore::RealtimeIncomingAudioSource::~RealtimeIncomingAudioSource):
(WebCore::RealtimeIncomingAudioSource::OnData):
* platform/mediastream/mac/RealtimeIncomingAudioSource.h:
* platform/mediastream/mac/RealtimeIncomingVideoSource.cpp:
(WebCore::RealtimeIncomingVideoSource::pixelBufferFromVideoFrame):
* platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::RealtimeOutgoingAudioSource):
(WebCore::RealtimeOutgoingAudioSource::setSource):
* platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
* platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource):
(WebCore::RealtimeOutgoingVideoSource::setSource):
(WebCore::RealtimeOutgoingVideoSource::initializeFromSource):
* platform/mediastream/mac/RealtimeOutgoingVideoSource.h:
* platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h:
* platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm:
(WebCore::WebAudioSourceProviderAVFObjC::create):
(WebCore::WebAudioSourceProviderAVFObjC::WebAudioSourceProviderAVFObjC):
(WebCore::WebAudioSourceProviderAVFObjC::setClient):
(WebCore::WebAudioSourceProviderAVFObjC::audioSamplesAvailable):
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::generateFrame):
* platform/spi/cocoa/PassKitSPI.h:

Source/WebKit2:

* WebProcess/cocoa/UserMediaCaptureManager.cpp:
(WebKit::UserMediaCaptureManager::Source::setStorage):

LayoutTests:

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestswebrtcvideodisabledblackhtml">trunk/LayoutTests/webrtc/video-disabled-black.html</a></li>
<li><a href="#trunkLayoutTestswebrtcvideounmuteexpectedtxt">trunk/LayoutTests/webrtc/video-unmute-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcvideounmutehtml">trunk/LayoutTests/webrtc/video-unmute.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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="#trunkSourceWebCoreModuleswebaudioMediaStreamAudioSourcecpp">trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioMediaStreamAudioSourceh">trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</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="#trunkSourceWebCoreplatformmediastreammacAVMediaCaptureSourceh">trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAVMediaCaptureSourcemm">trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacCoreAudioCaptureSourcecpp">trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacCoreAudioCaptureSourceh">trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMach">trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMacmm">trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeIncomingAudioSourcecpp">trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeIncomingAudioSourceh">trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeIncomingVideoSourcecpp">trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.cpp</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="#trunkSourceWebCoreplatformmediastreammacWebAudioSourceProviderAVFObjCh">trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacWebAudioSourceProviderAVFObjCmm">trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeVideoSourcecpp">trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUserMediaCaptureManagerProxycpp">trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUserMediaCaptureManagerProxyh">trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUserMediaCaptureManagerProxymessagesin">trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaUserMediaCaptureManagercpp">trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaUserMediaCaptureManagerh">trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcesscocoaUserMediaCaptureManagermessagesin">trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.messages.in</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswebrtccloneaudiotrackexpectedtxt">trunk/LayoutTests/webrtc/clone-audio-track-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtccloneaudiotrackhtml">trunk/LayoutTests/webrtc/clone-audio-track.html</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamWebAudioSourceProviderh">trunk/Source/WebCore/platform/mediastream/WebAudioSourceProvider.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/LayoutTests/ChangeLog 2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2017-06-19  Youenn Fablet  <youenn@apple.com>
+
+        A cloned MediaStreamTrack should mute independently other tracks using the same source
+        https://bugs.webkit.org/show_bug.cgi?id=172831
+        <rdar://problem/32518527>
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/clone-audio-track.html: Added.
+        * webrtc/video-disabled-black.html:
+        * webrtc/video-unmute-expected.txt:
+        * webrtc/video-unmute.html:
+
</ins><span class="cx"> 2017-06-19  Sam Weinig  <sam@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         [WebIDL] Properly model buffer source / typed arrays as their own IDL types
</span></span></pre></div>
<a id="trunkLayoutTestswebrtccloneaudiotrackexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/clone-audio-track-expected.txt (0 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/clone-audio-track-expected.txt                          (rev 0)
+++ trunk/LayoutTests/webrtc/clone-audio-track-expected.txt     2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+PASS Muting an outgoing audio track but not its clone 
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtccloneaudiotrackhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/clone-audio-track.html (0 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/clone-audio-track.html                          (rev 0)
+++ trunk/LayoutTests/webrtc/clone-audio-track.html     2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>Testing local audio capture playback causes "playing" event to fire</title>
+    <script src="../resources/testharness.js"></script>
+    <script src="../resources/testharnessreport.js"></script>
+</head>
+<body>
+    <script src ="routines.js"></script>
+    <script>
+    var context = new webkitAudioContext();
+    promise_test((test) => {
+        if (window.testRunner)
+            testRunner.setUserMediaPermission(true);
+
+        return navigator.mediaDevices.getUserMedia({audio: true}).then((localStream) => {
+            var clonedTrack;
+            var remoteTrack;
+            var remoteStream;
+            return new Promise((resolve, reject) => {
+                createConnections((firstConnection) => {
+                    var track = localStream.getAudioTracks()[0];
+                    clonedTrack = track.clone();
+                    track.enabled = false;
+                    firstConnection.addTrack(localStream.getAudioTracks()[0], localStream);
+                }, (secondConnection) => {
+                    secondConnection.ontrack = (trackEvent) => {
+                        remoteStream = trackEvent.streams[0];
+                        remoteTrack = remoteStream.getAudioTracks()[0];
+                        resolve();
+                    };
+                });
+            }).then(() => {
+                return analyseAudio(remoteStream, 200, context).then((results) => {
+                    assert_false(results.heardHum, "Did not heard hum from remote enabled track");
+                });
+            }).then(() => {
+                return analyseAudio(new MediaStream([clonedTrack]), 200, context).then((results) => {
+                    assert_true(results.heardHum, "Heard hum from cloned track");
+                });
+            }).then(() => {
+                return context.close();
+            });
+        });
+    }, "Muting an outgoing audio track but not its clone");
+    </script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcvideodisabledblackhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/video-disabled-black.html (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-disabled-black.html       2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/LayoutTests/webrtc/video-disabled-black.html  2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -27,7 +27,7 @@
</span><span class="cx"> 
</span><span class="cx">         imageData = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height);
</span><span class="cx">         assert_true(imageData.data.every( (pixel, index) => {
</span><del>-            return pixel === 0;
</del><ins>+            return pixel === 0 || (index % 4) === 3;
</ins><span class="cx">         }));
</span><span class="cx"> 
</span><span class="cx">         finishTest();
</span><span class="lines">@@ -39,11 +39,12 @@
</span><span class="cx"> function testStream(stream)
</span><span class="cx"> {
</span><span class="cx">     video.srcObject = stream;
</span><del>-    stream.getTracks()[0].enabled = false;
-    // Video may play with black frames
</del><span class="cx">     video.onplay = setTimeout(() => {
</span><del>-        testImage();
-    }, 1000);
</del><ins>+        stream.getTracks()[0].enabled = false;
+        setTimeout(() => {
+            testImage();
+        }, 0);
+    }, 500);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> var finishTest, errorTest;
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcvideounmuteexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/video-unmute-expected.txt (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-unmute-expected.txt       2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/LayoutTests/webrtc/video-unmute-expected.txt  2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx">    
</span><span class="cx"> 
</span><span class="cx"> PASS Setting video exchange 
</span><del>-PASS Track is enabled, video should be black 
</del><ins>+PASS Track is disabled, video should be black 
</ins><span class="cx"> PASS Track is enabled, video should not be black 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcvideounmutehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webrtc/video-unmute.html (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-unmute.html       2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/LayoutTests/webrtc/video-unmute.html  2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx"> 
</span><span class="cx"> promise_test((test) => {
</span><span class="cx">     return checkVideoBlack(true, "canvas1");
</span><del>-}, "Track is enabled, video should be black");
</del><ins>+}, "Track is disabled, video should be black");
</ins><span class="cx"> 
</span><span class="cx"> promise_test((test) => {
</span><span class="cx">     track.enabled = true;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/ChangeLog      2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -1,3 +1,76 @@
</span><ins>+2017-06-19  Youenn Fablet  <youenn@apple.com>
+
+        A cloned MediaStreamTrack should mute independently other tracks using the same source
+        https://bugs.webkit.org/show_bug.cgi?id=172831
+        <rdar://problem/32518527>
+
+        Reviewed by Eric Carlson.
+
+        Test: webrtc/clone-audio-track.html
+
+        Move enabled handling in MediaStreamTrackPrivate instead of RealtimeMediaSource.
+        Move WebRTC and WebAudio customers of RealtimeMediaSource to MediaStreamTrackPrivate.
+        Move creation of WebAudio provider to MediaStreamTrackPrivate.
+
+        This allows changing some parameters of tracks having the same source independently.
+        Using this for enabled track attribute.
+
+        We no longer stop generating frames in case track is disabled.
+        This should be added back as an optimization in a follow-up.
+
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::addTrack):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack):
+        * Modules/webaudio/MediaStreamAudioSource.cpp:
+        * Modules/webaudio/MediaStreamAudioSource.h:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/mediastream/MediaStreamTrackPrivate.cpp:
+        (WebCore::MediaStreamTrackPrivate::create):
+        (WebCore::MediaStreamTrackPrivate::~MediaStreamTrackPrivate):
+        (WebCore::MediaStreamTrackPrivate::setEnabled):
+        (WebCore::MediaStreamTrackPrivate::audioSourceProvider):
+        (WebCore::MediaStreamTrackPrivate::videoSampleAvailable):
+        (WebCore::MediaStreamTrackPrivate::audioSamplesAvailable):
+        * platform/mediastream/MediaStreamTrackPrivate.h:
+        (WebCore::MediaStreamTrackPrivate::Observer::audioSamplesAvailable):
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (WebCore::RealtimeMediaSource::removeObserver):
+        * platform/mediastream/RealtimeMediaSource.h:
+        * platform/mediastream/mac/AVMediaCaptureSource.h:
+        * platform/mediastream/mac/AVMediaCaptureSource.mm:
+        * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+        (WebCore::CoreAudioCaptureSource::startProducingData):
+        (WebCore::CoreAudioCaptureSource::stopProducingData):
+        * platform/mediastream/mac/CoreAudioCaptureSource.h:
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
+        (WebCore::MockRealtimeAudioSourceMac::render):
+        * platform/mediastream/mac/RealtimeIncomingAudioSource.cpp:
+        (WebCore::RealtimeIncomingAudioSource::~RealtimeIncomingAudioSource):
+        (WebCore::RealtimeIncomingAudioSource::OnData):
+        * platform/mediastream/mac/RealtimeIncomingAudioSource.h:
+        * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp:
+        (WebCore::RealtimeIncomingVideoSource::pixelBufferFromVideoFrame):
+        * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp:
+        (WebCore::RealtimeOutgoingAudioSource::RealtimeOutgoingAudioSource):
+        (WebCore::RealtimeOutgoingAudioSource::setSource):
+        * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
+        * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp:
+        (WebCore::RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource):
+        (WebCore::RealtimeOutgoingVideoSource::setSource):
+        (WebCore::RealtimeOutgoingVideoSource::initializeFromSource):
+        * platform/mediastream/mac/RealtimeOutgoingVideoSource.h:
+        * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h:
+        * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm:
+        (WebCore::WebAudioSourceProviderAVFObjC::create):
+        (WebCore::WebAudioSourceProviderAVFObjC::WebAudioSourceProviderAVFObjC):
+        (WebCore::WebAudioSourceProviderAVFObjC::setClient):
+        (WebCore::WebAudioSourceProviderAVFObjC::audioSamplesAvailable):
+        * platform/mock/MockRealtimeVideoSource.cpp:
+        (WebCore::MockRealtimeVideoSource::generateFrame):
+        * platform/spi/cocoa/PassKitSPI.h:
+
</ins><span class="cx"> 2017-06-19  Sam Weinig  <sam@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         [WebIDL] Properly model buffer source / typed arrays as their own IDL types
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCMediaEndpointcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -176,10 +176,9 @@
</span><span class="cx">         mediaStreams.push_back(mediaStream.get());
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    auto& source = track.source();
-    switch (source.type()) {
</del><ins>+    switch (track.privateTrack().type()) {
</ins><span class="cx">     case RealtimeMediaSource::Type::Audio: {
</span><del>-        auto trackSource = RealtimeOutgoingAudioSource::create(source);
</del><ins>+        auto trackSource = RealtimeOutgoingAudioSource::create(track.privateTrack());
</ins><span class="cx">         auto audioTrack = m_peerConnectionFactory.CreateAudioTrack(track.id().utf8().data(), trackSource.ptr());
</span><span class="cx">         m_peerConnectionBackend.addAudioSource(WTFMove(trackSource));
</span><span class="cx">         m_senders.add(&sender, m_backend->AddTrack(audioTrack.get(), WTFMove(mediaStreams)));
</span><span class="lines">@@ -186,7 +185,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     case RealtimeMediaSource::Type::Video: {
</span><del>-        auto videoSource = RealtimeOutgoingVideoSource::create(source);
</del><ins>+        auto videoSource = RealtimeOutgoingVideoSource::create(track.privateTrack());
</ins><span class="cx">         auto videoTrack = m_peerConnectionFactory.CreateVideoTrack(track.id().utf8().data(), videoSource.ptr());
</span><span class="cx">         m_peerConnectionBackend.addVideoSource(WTFMove(videoSource));
</span><span class="cx">         m_senders.add(&sender, m_backend->AddTrack(videoTrack.get(), WTFMove(mediaStreams)));
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCPeerConnectionBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -361,8 +361,8 @@
</span><span class="cx">         break;
</span><span class="cx">     case RealtimeMediaSource::Type::Audio: {
</span><span class="cx">         for (auto& audioSource : m_audioSources) {
</span><del>-            if (&audioSource->source() == &currentTrack->source()) {
-                if (!audioSource->setSource(track->source())) {
</del><ins>+            if (&audioSource->source() == &currentTrack->privateTrack()) {
+                if (!audioSource->setSource(track->privateTrack())) {
</ins><span class="cx">                     promise.reject(INVALID_MODIFICATION_ERR);
</span><span class="cx">                     return;
</span><span class="cx">                 }
</span><span class="lines">@@ -375,8 +375,8 @@
</span><span class="cx">     }
</span><span class="cx">     case RealtimeMediaSource::Type::Video: {
</span><span class="cx">         for (auto& videoSource : m_videoSources) {
</span><del>-            if (&videoSource->source() == &currentTrack->source()) {
-                if (!videoSource->setSource(track->source())) {
</del><ins>+            if (&videoSource->source() == &currentTrack->privateTrack()) {
+                if (!videoSource->setSource(track->privateTrack())) {
</ins><span class="cx">                     promise.reject(INVALID_MODIFICATION_ERR);
</span><span class="cx">                     return;
</span><span class="cx">                 }
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioMediaStreamAudioSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp 2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.cpp    2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -60,13 +60,6 @@
</span><span class="cx">     return m_currentSettings;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AudioSourceProvider* MediaStreamAudioSource::audioSourceProvider()
-{
-    // FIXME: implement this.
-    notImplemented();
-    return nullptr;
-}
-
</del><span class="cx"> void MediaStreamAudioSource::addAudioConsumer(AudioDestinationConsumer* consumer)
</span><span class="cx"> {
</span><span class="cx">     LockHolder locker(m_audioConsumersLock);
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioMediaStreamAudioSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h   2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSource.h      2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -62,7 +62,6 @@
</span><span class="cx"> private:
</span><span class="cx">     MediaStreamAudioSource();
</span><span class="cx"> 
</span><del>-    AudioSourceProvider* audioSourceProvider() override;
</del><span class="cx">     bool isCaptureSource() const final { return true; }
</span><span class="cx"> 
</span><span class="cx">     String m_deviceId;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -302,7 +302,7 @@
</span><span class="cx">          07FE99DC18807A7D00256648 /* MediaElementSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FE99DA18807A7D00256648 /* MediaElementSession.cpp */; };
</span><span class="cx">          07FE99DD18807A7D00256648 /* MediaElementSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FE99DB18807A7D00256648 /* MediaElementSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          07FFDE68181AED420072D409 /* MediaStreamTrackPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FFDE66181AED420072D409 /* MediaStreamTrackPrivate.cpp */; };
</span><del>-               07FFDE69181AED420072D409 /* MediaStreamTrackPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FFDE67181AED420072D409 /* MediaStreamTrackPrivate.h */; };
</del><ins>+                07FFDE69181AED420072D409 /* MediaStreamTrackPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 07FFDE67181AED420072D409 /* MediaStreamTrackPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           0806E57A12893045007CED32 /* SVGMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = 0806E57912893045007CED32 /* SVGMatrix.h */; };
</span><span class="cx">          080E49261255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.h in Headers */ = {isa = PBXBuildFile; fileRef = 080E49221255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.h */; };
</span><span class="cx">          080E49281255F3BD00EFCA27 /* SVGTextLayoutEngineSpacing.h in Headers */ = {isa = PBXBuildFile; fileRef = 080E49241255F3BD00EFCA27 /* SVGTextLayoutEngineSpacing.h */; };
</span><span class="lines">@@ -1785,6 +1785,7 @@
</span><span class="cx">          41ABE67B1D0580DB006D862D /* CrossOriginPreflightChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */; };
</span><span class="cx">          41ABE67C1D0580E0006D862D /* CrossOriginPreflightChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41ABE6791D0580D5006D862D /* CrossOriginPreflightChecker.cpp */; };
</span><span class="cx">          41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 41AD75391CEF6BCE00A31486 /* FetchOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+               41B2A6261EF1BF6D002B9D7A /* WebAudioSourceProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 41B2A6251EF1BF60002B9D7A /* WebAudioSourceProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           41BF700C0FE86F49005E8DEC /* MessagePortChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          41BF700F0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41BF700D0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp */; };
</span><span class="cx">          41BF70100FE86F61005E8DEC /* PlatformMessagePortChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 41BF700E0FE86F61005E8DEC /* PlatformMessagePortChannel.h */; };
</span><span class="lines">@@ -2877,8 +2878,6 @@
</span><span class="cx">          65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
</span><span class="cx">          69A6CBAC1C6BE42C00B836E9 /* AccessibilitySVGElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */; };
</span><span class="cx">          69A6CBAD1C6BE42C00B836E9 /* AccessibilitySVGElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */; };
</span><del>-               6A32D7CE1A16D8C000412F0B /* InspectorCanvasAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */; };
-               6A4B6D6519D22519006F11D3 /* InspectorCanvasAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */; };
</del><span class="cx">           6B3480940EEF50D400AC1B41 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */; };
</span><span class="lines">@@ -9479,6 +9478,7 @@
</span><span class="cx">          41ABE6791D0580D5006D862D /* CrossOriginPreflightChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossOriginPreflightChecker.cpp; sourceTree = "<group>"; };
</span><span class="cx">          41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossOriginPreflightChecker.h; sourceTree = "<group>"; };
</span><span class="cx">          41AD75391CEF6BCE00A31486 /* FetchOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchOptions.h; sourceTree = "<group>"; };
</span><ins>+               41B2A6251EF1BF60002B9D7A /* WebAudioSourceProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebAudioSourceProvider.h; sourceTree = "<group>"; };
</ins><span class="cx">           41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessagePortChannel.h; sourceTree = "<group>"; };
</span><span class="cx">          41BF700D0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlatformMessagePortChannel.cpp; path = default/PlatformMessagePortChannel.cpp; sourceTree = "<group>"; };
</span><span class="cx">          41BF700E0FE86F61005E8DEC /* PlatformMessagePortChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformMessagePortChannel.h; path = default/PlatformMessagePortChannel.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -10732,8 +10732,6 @@
</span><span class="cx">          65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
</span><span class="cx">          697101071C6BE1550018C7F1 /* AccessibilitySVGElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilitySVGElement.cpp; sourceTree = "<group>"; };
</span><span class="cx">          697101081C6BE1550018C7F1 /* AccessibilitySVGElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySVGElement.h; sourceTree = "<group>"; };
</span><del>-               6A4B6D6419D22519006F11D3 /* InspectorCanvasAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCanvasAgent.h; sourceTree = "<group>"; };
-               6A4B6D6619D225D8006F11D3 /* InspectorCanvasAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCanvasAgent.cpp; sourceTree = "<group>"; };
</del><span class="cx">           6B3480920EEF50D400AC1B41 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; };
</span><span class="cx">          6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadObserver.h; sourceTree = "<group>"; };
</span><span class="cx">          6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadObserver.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -16302,6 +16300,7 @@
</span><span class="cx">                          5EA3D6E51C85A9C300300BBB /* SDPProcessorScriptResource.cpp */,
</span><span class="cx">                          5EA3D6E61C85A9C300300BBB /* SDPProcessorScriptResource.h */,
</span><span class="cx">                          070E81D01BF27656001FDA48 /* VideoTrackPrivateMediaStream.h */,
</span><ins>+                               41B2A6251EF1BF60002B9D7A /* WebAudioSourceProvider.h */,
</ins><span class="cx">                   );
</span><span class="cx">                  path = mediastream;
</span><span class="cx">                  sourceTree = "<group>";
</span><span class="lines">@@ -27935,6 +27934,7 @@
</span><span class="cx">                          BE61039E18A9D65A00DD50D7 /* JSDataCue.h in Headers */,
</span><span class="cx">                          BCA83E500D7CE1E9003421A8 /* JSDataTransfer.h in Headers */,
</span><span class="cx">                          4162A4581011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h in Headers */,
</span><ins>+                               41B2A6261EF1BF6D002B9D7A /* WebAudioSourceProvider.h in Headers */,
</ins><span class="cx">                           FDA15ED212B03F94003A583A /* JSDelayNode.h in Headers */,
</span><span class="cx">                          947949311E0459FA00018D85 /* JSDeprecatedCSSOMCounter.h in Headers */,
</span><span class="cx">                          947949321E0459FA00018D85 /* JSDeprecatedCSSOMPrimitiveValue.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamMediaStreamTrackPrivatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -29,16 +29,21 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx"> 
</span><del>-#include "AudioSourceProvider.h"
</del><span class="cx"> #include "GraphicsContext.h"
</span><span class="cx"> #include "IntRect.h"
</span><span class="cx"> #include <wtf/UUID.h>
</span><span class="cx"> 
</span><ins>+#if PLATFORM(COCOA)
+#include "WebAudioSourceProviderAVFObjC.h"
+#else
+#include "WebAudioSourceProvider.h"
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> Ref<MediaStreamTrackPrivate> MediaStreamTrackPrivate::create(Ref<RealtimeMediaSource>&& source)
</span><span class="cx"> {
</span><del>-    return adoptRef(*new MediaStreamTrackPrivate(WTFMove(source), createCanonicalUUIDString()));
</del><ins>+    return create(WTFMove(source), createCanonicalUUIDString());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref<MediaStreamTrackPrivate> MediaStreamTrackPrivate::create(Ref<RealtimeMediaSource>&& source, String&& id)
</span><span class="lines">@@ -93,8 +98,6 @@
</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><del>-    m_source->setEnabled(enabled);
-
</del><span class="cx">     for (auto& observer : m_observers)
</span><span class="cx">         observer->trackEnabledChanged(*this);
</span><span class="cx"> }
</span><span class="lines">@@ -148,7 +151,11 @@
</span><span class="cx"> 
</span><span class="cx"> AudioSourceProvider* MediaStreamTrackPrivate::audioSourceProvider()
</span><span class="cx"> {
</span><del>-    return m_source->audioSourceProvider();
</del><ins>+#if PLATFORM(COCOA)
+    if (!m_audioSourceProvider)
+        m_audioSourceProvider = WebAudioSourceProviderAVFObjC::create(*this);
+#endif
+    return m_audioSourceProvider.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaStreamTrackPrivate::sourceStarted()
</span><span class="lines">@@ -175,12 +182,6 @@
</span><span class="cx">         observer->trackMutedChanged(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MediaStreamTrackPrivate::sourceEnabledChanged()
-{
-    for (auto& observer : m_observers)
-        observer->trackEnabledChanged(*this);
-}
-
</del><span class="cx"> void MediaStreamTrackPrivate::sourceSettingsChanged()
</span><span class="cx"> {
</span><span class="cx">     for (auto& observer : m_observers)
</span><span class="lines">@@ -200,12 +201,15 @@
</span><span class="cx">         updateReadyState();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (!enabled())
+        return;
+
</ins><span class="cx">     mediaSample.setTrackID(id());
</span><span class="cx">     for (auto& observer : m_observers)
</span><span class="cx">         observer->sampleBufferUpdated(*this, mediaSample);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MediaStreamTrackPrivate::audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t)
</del><ins>+void MediaStreamTrackPrivate::audioSamplesAvailable(const MediaTime& mediaTime, const PlatformAudioData& data, const AudioStreamDescription& description, size_t sampleCount)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_haveProducedData) {
</span><span class="cx">         m_haveProducedData = true;
</span><span class="lines">@@ -212,8 +216,11 @@
</span><span class="cx">         updateReadyState();
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (!enabled())
+        return;
+
</ins><span class="cx">     for (auto& observer : m_observers)
</span><del>-        observer->audioSamplesAvailable(*this);
</del><ins>+        observer->audioSamplesAvailable(*this, mediaTime, data, description, sampleCount);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamMediaStreamTrackPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h      2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h 2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> class GraphicsContext;
</span><span class="cx"> class MediaSample;
</span><span class="cx"> class RealtimeMediaSourceCapabilities;
</span><ins>+class WebAudioSourceProvider;
</ins><span class="cx"> 
</span><span class="cx"> class MediaStreamTrackPrivate : public RefCounted<MediaStreamTrackPrivate>, public RealtimeMediaSource::Observer {
</span><span class="cx"> public:
</span><span class="lines">@@ -49,7 +50,7 @@
</span><span class="cx">         virtual void trackSettingsChanged(MediaStreamTrackPrivate&) = 0;
</span><span class="cx">         virtual void trackEnabledChanged(MediaStreamTrackPrivate&) = 0;
</span><span class="cx">         virtual void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample&) { };
</span><del>-        virtual void audioSamplesAvailable(MediaStreamTrackPrivate&) { };
</del><ins>+        virtual void audioSamplesAvailable(MediaStreamTrackPrivate&, const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) { };
</ins><span class="cx">         virtual void readyStateChanged(MediaStreamTrackPrivate&) { };
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="lines">@@ -106,7 +107,6 @@
</span><span class="cx">     void sourceStarted() final;
</span><span class="cx">     void sourceStopped() final;
</span><span class="cx">     void sourceMutedChanged() final;
</span><del>-    void sourceEnabledChanged() final;
</del><span class="cx">     void sourceSettingsChanged() final;
</span><span class="cx">     bool preventSourceFromStopping() final;
</span><span class="cx">     void videoSampleAvailable(MediaSample&) final;
</span><span class="lines">@@ -122,6 +122,7 @@
</span><span class="cx">     bool m_isEnabled { true };
</span><span class="cx">     bool m_isEnded { false };
</span><span class="cx">     bool m_haveProducedData { false };
</span><ins>+    RefPtr<WebAudioSourceProvider> m_audioSourceProvider;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef Vector<RefPtr<MediaStreamTrackPrivate>> MediaStreamTrackPrivateVector;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeMediaSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp        2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp   2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -116,17 +116,6 @@
</span><span class="cx">         observer.sourceMutedChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RealtimeMediaSource::setEnabled(bool enabled)
-{
-    if (m_enabled == enabled)
-        return;
-
-    m_enabled = enabled;
-
-    for (Observer& observer : m_observers)
-        observer.sourceEnabledChanged();
-}
-
</del><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 (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h  2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h     2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx"> 
</span><del>-#include "AudioSourceProvider.h"
</del><span class="cx"> #include "CaptureDevice.h"
</span><span class="cx"> #include "Image.h"
</span><span class="cx"> #include "MediaConstraints.h"
</span><span class="lines">@@ -68,12 +67,11 @@
</span><span class="cx">     class Observer {
</span><span class="cx">     public:
</span><span class="cx">         virtual ~Observer() { }
</span><del>-        
</del><ins>+
</ins><span class="cx">         // Source state changes.
</span><span class="cx">         virtual void sourceStarted() { }
</span><span class="cx">         virtual void sourceStopped() { }
</span><span class="cx">         virtual void sourceMutedChanged() { }
</span><del>-        virtual void sourceEnabledChanged() { }
</del><span class="cx">         virtual void sourceSettingsChanged() { }
</span><span class="cx"> 
</span><span class="cx">         // Observer state queries.
</span><span class="lines">@@ -112,7 +110,7 @@
</span><span class="cx">     public:
</span><span class="cx">         virtual ~AudioCaptureFactory() = default;
</span><span class="cx">         virtual CaptureSourceOrError createAudioCaptureSource(const String& audioDeviceID, const MediaConstraints*) = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">     protected:
</span><span class="cx">         AudioCaptureFactory() = default;
</span><span class="cx">     };
</span><span class="lines">@@ -147,13 +145,10 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool interrupted() const { return m_interrupted; }
</span><span class="cx">     virtual void setInterrupted(bool, bool);
</span><del>-    
-    bool enabled() const { return m_enabled; }
-    void setEnabled(bool);
</del><span class="cx"> 
</span><span class="cx">     const String& name() const { return m_name; }
</span><span class="cx">     void setName(const String& name) { m_name = name; }
</span><del>-    
</del><ins>+
</ins><span class="cx">     unsigned fitnessScore() const { return m_fitnessScore; }
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void addObserver(Observer&);
</span><span class="lines">@@ -211,8 +206,6 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void monitorOrientation(OrientationNotifier&) { }
</span><span class="cx"> 
</span><del>-    virtual AudioSourceProvider* audioSourceProvider() { return nullptr; }
-
</del><span class="cx">     // Testing only
</span><span class="cx">     virtual void delaySamples(float) { };
</span><span class="cx"> 
</span><span class="lines">@@ -250,7 +243,6 @@
</span><span class="cx">     virtual void stopProducingData() { }
</span><span class="cx"> 
</span><span class="cx">     bool m_muted { false };
</span><del>-    bool m_enabled { true };
</del><span class="cx"> 
</span><span class="cx">     WeakPtrFactory<RealtimeMediaSource> m_weakPtrFactory;
</span><span class="cx">     String m_id;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamWebAudioSourceProviderh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/WebAudioSourceProvider.h (0 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/WebAudioSourceProvider.h                               (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/WebAudioSourceProvider.h  2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
+
+#include "AudioSourceProvider.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class WebAudioSourceProvider : public RefCounted<WebAudioSourceProvider>, public AudioSourceProvider {
+};
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVMediaCaptureSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h     2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h        2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -72,8 +72,6 @@
</span><span class="cx"> protected:
</span><span class="cx">     AVMediaCaptureSource(AVCaptureDevice*, const AtomicString&, RealtimeMediaSource::Type);
</span><span class="cx"> 
</span><del>-    AudioSourceProvider* audioSourceProvider() override;
-
</del><span class="cx">     virtual void setupCaptureSession() = 0;
</span><span class="cx">     virtual void shutdownCaptureSession() = 0;
</span><span class="cx">     virtual void updateSettings(RealtimeMediaSourceSettings&) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVMediaCaptureSourcemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -312,12 +312,6 @@
</span><span class="cx">     [audioOutput setSampleBufferDelegate:m_objcObserver.get() queue:globaAudioCaptureSerialQueue()];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AudioSourceProvider* AVMediaCaptureSource::audioSourceProvider()
-{
-    ASSERT_NOT_REACHED();
-    return nullptr;
-}
-
</del><span class="cx"> bool AVMediaCaptureSource::interrupted() const
</span><span class="cx"> {
</span><span class="cx">     if (m_interruption != InterruptionReason::None)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacCoreAudioCaptureSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp 2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp    2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -706,17 +706,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     CoreAudioSharedUnit::singleton().startProducingData();
</span><del>-
-    if (m_audioSourceProvider)
-        m_audioSourceProvider->prepare(&CoreAudioSharedUnit::singleton().microphoneFormat().streamDescription());
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CoreAudioCaptureSource::stopProducingData()
</span><span class="cx"> {
</span><span class="cx">     CoreAudioSharedUnit::singleton().stopProducingData();
</span><del>-
-    if (m_audioSourceProvider)
-        m_audioSourceProvider->unprepare();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const RealtimeMediaSourceCapabilities& CoreAudioCaptureSource::capabilities() const
</span><span class="lines">@@ -759,17 +753,6 @@
</span><span class="cx">     RealtimeMediaSource::settingsDidChange();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AudioSourceProvider* CoreAudioCaptureSource::audioSourceProvider()
-{
-    if (!m_audioSourceProvider) {
-        m_audioSourceProvider = WebAudioSourceProviderAVFObjC::create(*this);
-        if (isProducingData())
-            m_audioSourceProvider->prepare(&CoreAudioSharedUnit::singleton().microphoneFormat().streamDescription());
-    }
-
-    return m_audioSourceProvider.get();
-}
-
</del><span class="cx"> bool CoreAudioCaptureSource::applySampleRate(int sampleRate)
</span><span class="cx"> {
</span><span class="cx">     // FIXME: We should be able to describe sample rate as a discreet range constraint so that we only enter here with values that can be applied.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacCoreAudioCaptureSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h   2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h      2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -88,7 +88,6 @@
</span><span class="cx">     const RealtimeMediaSourceCapabilities& capabilities() const final;
</span><span class="cx">     const RealtimeMediaSourceSettings& settings() const final;
</span><span class="cx">     void settingsDidChange() final;
</span><del>-    AudioSourceProvider* audioSourceProvider() final;
</del><span class="cx"> 
</span><span class="cx">     uint32_t m_captureDeviceID { 0 };
</span><span class="cx"> 
</span><span class="lines">@@ -97,7 +96,6 @@
</span><span class="cx">     mutable std::optional<RealtimeMediaSourceCapabilities> m_capabilities;
</span><span class="cx">     mutable std::optional<RealtimeMediaSourceSettings> m_currentSettings;
</span><span class="cx"> 
</span><del>-    RefPtr<WebAudioSourceProviderAVFObjC> m_audioSourceProvider;
</del><span class="cx">     bool m_reconfigurationOngoing { false };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h       2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h  2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -49,8 +49,7 @@
</span><span class="cx"> class MockRealtimeAudioSourceMac final : public MockRealtimeAudioSource {
</span><span class="cx"> private:
</span><span class="cx">     friend class MockRealtimeAudioSource;
</span><del>-    MockRealtimeAudioSourceMac(const String&);
-    ~MockRealtimeAudioSourceMac();
</del><ins>+    explicit MockRealtimeAudioSourceMac(const String&);
</ins><span class="cx"> 
</span><span class="cx">     bool applySampleRate(int) final;
</span><span class="cx">     bool applySampleSize(int) final { return false; }
</span><span class="lines">@@ -59,8 +58,6 @@
</span><span class="cx">     void render(double) final;
</span><span class="cx">     void reconfigure();
</span><span class="cx"> 
</span><del>-    AudioSourceProvider* audioSourceProvider() final;
-
</del><span class="cx">     std::unique_ptr<WebAudioBufferList> m_audioBufferList;
</span><span class="cx"> 
</span><span class="cx">     uint32_t m_maximiumFrameCount;
</span><span class="lines">@@ -69,7 +66,6 @@
</span><span class="cx"> 
</span><span class="cx">     RetainPtr<CMFormatDescriptionRef> m_formatDescription;
</span><span class="cx">     AudioStreamBasicDescription m_streamFormat;
</span><del>-    RefPtr<WebAudioSourceProviderAVFObjC> m_audioSourceProvider;
</del><span class="cx"> 
</span><span class="cx">     Vector<float> m_bipBopBuffer;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm      2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm 2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -99,14 +99,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-MockRealtimeAudioSourceMac::~MockRealtimeAudioSourceMac()
-{
-    if (m_audioSourceProvider) {
-        m_audioSourceProvider->unprepare();
-        m_audioSourceProvider = nullptr;
-    }
-}
-
</del><span class="cx"> void MockRealtimeAudioSourceMac::emitSampleBuffers(uint32_t frameCount)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_formatDescription);
</span><span class="lines">@@ -151,7 +143,7 @@
</span><span class="cx">         uint32_t bipBopCount = std::min(frameCount, bipBopRemain);
</span><span class="cx">         for (auto& audioBuffer : m_audioBufferList->buffers()) {
</span><span class="cx">             audioBuffer.mDataByteSize = frameCount * m_streamFormat.mBytesPerFrame;
</span><del>-            if (!muted() && enabled()) {
</del><ins>+            if (!muted()) {
</ins><span class="cx">                 memcpy(audioBuffer.mData, &m_bipBopBuffer[bipBopStart], sizeof(Float32) * bipBopCount);
</span><span class="cx">                 addHum(HumVolume, HumFrequency, sampleRate(), m_samplesRendered, static_cast<float*>(audioBuffer.mData), bipBopCount);
</span><span class="cx">             } else
</span><span class="lines">@@ -190,19 +182,6 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AudioSourceProvider* MockRealtimeAudioSourceMac::audioSourceProvider()
-{
-    if (!m_audioSourceProvider) {
-        if (!m_audioBufferList)
-            reconfigure();
-
-        m_audioSourceProvider = WebAudioSourceProviderAVFObjC::create(*this);
-        m_audioSourceProvider->prepare(&m_streamFormat);
-    }
-
-    return m_audioSourceProvider.get();
-}
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(MEDIA_STREAM)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeIncomingAudioSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -60,10 +60,6 @@
</span><span class="cx"> 
</span><span class="cx"> RealtimeIncomingAudioSource::~RealtimeIncomingAudioSource()
</span><span class="cx"> {
</span><del>-    if (m_audioSourceProvider) {
-        m_audioSourceProvider->unprepare();
-        m_audioSourceProvider = nullptr;
-    }
</del><span class="cx">     stop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -91,24 +87,19 @@
</span><span class="cx">     m_numberOfFrames += numberOfFrames;
</span><span class="cx"> 
</span><span class="cx">     AudioStreamBasicDescription newDescription = streamDescription(sampleRate, numberOfChannels);
</span><del>-    if (newDescription != m_streamFormat) {
-        m_streamFormat = newDescription;
-        if (m_audioSourceProvider)
-            m_audioSourceProvider->prepare(&m_streamFormat);
-    }
</del><span class="cx"> 
</span><span class="cx">     // FIXME: We should not need to do the extra memory allocation and copy.
</span><span class="cx">     // Instead, we should be able to directly pass audioData pointer.
</span><del>-    WebAudioBufferList audioBufferList { CAAudioStreamDescription(m_streamFormat), WTF::safeCast<uint32_t>(numberOfFrames) };
</del><ins>+    WebAudioBufferList audioBufferList { CAAudioStreamDescription(newDescription), WTF::safeCast<uint32_t>(numberOfFrames) };
</ins><span class="cx">     audioBufferList.buffer(0)->mDataByteSize = numberOfChannels * numberOfFrames * bitsPerSample / 8;
</span><span class="cx">     audioBufferList.buffer(0)->mNumberChannels = numberOfChannels;
</span><span class="cx"> 
</span><del>-    if (muted() || !enabled())
</del><ins>+    if (muted())
</ins><span class="cx">         memset(audioBufferList.buffer(0)->mData, 0, audioBufferList.buffer(0)->mDataByteSize);
</span><span class="cx">     else
</span><span class="cx">         memcpy(audioBufferList.buffer(0)->mData, audioData, audioBufferList.buffer(0)->mDataByteSize);
</span><span class="cx"> 
</span><del>-    audioSamplesAvailable(mediaTime, audioBufferList, CAAudioStreamDescription(m_streamFormat), numberOfFrames);
</del><ins>+    audioSamplesAvailable(mediaTime, audioBufferList, CAAudioStreamDescription(newDescription), numberOfFrames);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RealtimeIncomingAudioSource::startProducingData()
</span><span class="lines">@@ -144,17 +135,6 @@
</span><span class="cx">     return m_currentSettings;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-AudioSourceProvider* RealtimeIncomingAudioSource::audioSourceProvider()
-{
-    if (!m_audioSourceProvider) {
-        m_audioSourceProvider = WebAudioSourceProviderAVFObjC::create(*this);
-        if (m_numberOfFrames)
-            m_audioSourceProvider->prepare(&m_streamFormat);
-    }
-
-    return m_audioSourceProvider.get();
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-} // namespace WebCore
-
</del><span class="cx"> #endif // USE(LIBWEBRTC)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeIncomingAudioSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h      2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h 2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -64,13 +64,9 @@
</span><span class="cx">     const RealtimeMediaSourceCapabilities& capabilities() const final;
</span><span class="cx">     const RealtimeMediaSourceSettings& settings() const final;
</span><span class="cx"> 
</span><del>-    AudioSourceProvider* audioSourceProvider() final;
-
</del><span class="cx">     RealtimeMediaSourceSettings m_currentSettings;
</span><span class="cx">     rtc::scoped_refptr<webrtc::AudioTrackInterface> m_audioTrack;
</span><span class="cx"> 
</span><del>-    RefPtr<WebAudioSourceProviderAVFObjC> m_audioSourceProvider;
-    AudioStreamBasicDescription m_streamFormat { };
</del><span class="cx">     uint64_t m_numberOfFrames { 0 };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeIncomingVideoSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.cpp    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.cpp       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> 
</span><span class="cx"> CVPixelBufferRef RealtimeIncomingVideoSource::pixelBufferFromVideoFrame(const webrtc::VideoFrame& frame)
</span><span class="cx"> {
</span><del>-    if (muted() || !enabled()) {
</del><ins>+    if (muted()) {
</ins><span class="cx">         if (!m_blackFrame || m_blackFrameWidth != frame.width() || m_blackFrameHeight != frame.height()) {
</span><span class="cx">             CVPixelBufferRef pixelBuffer = nullptr;
</span><span class="cx">             auto status = CVPixelBufferCreate(kCFAllocatorDefault, frame.width(), frame.height(), kCVPixelFormatType_420YpCbCr8Planar, nullptr, &pixelBuffer);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">     return streamFormat;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RealtimeOutgoingAudioSource::RealtimeOutgoingAudioSource(Ref<RealtimeMediaSource>&& audioSource)
</del><ins>+RealtimeOutgoingAudioSource::RealtimeOutgoingAudioSource(Ref<MediaStreamTrackPrivate>&& audioSource)
</ins><span class="cx">     : m_audioSource(WTFMove(audioSource))
</span><span class="cx">     , m_sampleConverter(AudioSampleDataSource::create(LibWebRTCAudioFormat::sampleRate * 2))
</span><span class="cx"> {
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">     initializeConverter();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RealtimeOutgoingAudioSource::setSource(Ref<RealtimeMediaSource>&& newSource)
</del><ins>+bool RealtimeOutgoingAudioSource::setSource(Ref<MediaStreamTrackPrivate>&& newSource)
</ins><span class="cx"> {
</span><span class="cx">     m_audioSource->removeObserver(*this);
</span><span class="cx">     m_audioSource = WTFMove(newSource);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h      2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h 2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "AudioSampleDataSource.h"
</span><span class="cx"> #include "LibWebRTCMacros.h"
</span><del>-#include "RealtimeMediaSource.h"
</del><ins>+#include "MediaStreamTrackPrivate.h"
</ins><span class="cx"> #include <webrtc/api/mediastreaminterface.h>
</span><span class="cx"> #include <wtf/ThreadSafeRefCounted.h>
</span><span class="cx"> 
</span><span class="lines">@@ -43,18 +43,18 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class RealtimeOutgoingAudioSource final : public ThreadSafeRefCounted<RealtimeOutgoingAudioSource>, public webrtc::AudioSourceInterface, private RealtimeMediaSource::Observer {
</del><ins>+class RealtimeOutgoingAudioSource final : public ThreadSafeRefCounted<RealtimeOutgoingAudioSource>, public webrtc::AudioSourceInterface, private MediaStreamTrackPrivate::Observer {
</ins><span class="cx"> public:
</span><del>-    static Ref<RealtimeOutgoingAudioSource> create(Ref<RealtimeMediaSource>&& audioSource) { return adoptRef(*new RealtimeOutgoingAudioSource(WTFMove(audioSource))); }
</del><ins>+    static Ref<RealtimeOutgoingAudioSource> create(Ref<MediaStreamTrackPrivate>&& audioSource) { return adoptRef(*new RealtimeOutgoingAudioSource(WTFMove(audioSource))); }
</ins><span class="cx">     ~RealtimeOutgoingAudioSource() { stop(); }
</span><span class="cx"> 
</span><span class="cx">     void stop();
</span><span class="cx"> 
</span><del>-    bool setSource(Ref<RealtimeMediaSource>&&);
-    RealtimeMediaSource& source() const { return m_audioSource.get(); }
</del><ins>+    bool setSource(Ref<MediaStreamTrackPrivate>&&);
+    MediaStreamTrackPrivate& source() const { return m_audioSource.get(); }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    explicit RealtimeOutgoingAudioSource(Ref<RealtimeMediaSource>&&);
</del><ins>+    explicit RealtimeOutgoingAudioSource(Ref<MediaStreamTrackPrivate>&&);
</ins><span class="cx"> 
</span><span class="cx">     virtual void AddSink(webrtc::AudioTrackSinkInterface* sink) { m_sinks.append(sink); }
</span><span class="cx">     virtual void RemoveSink(webrtc::AudioTrackSinkInterface* sink) { m_sinks.removeFirst(sink); }
</span><span class="lines">@@ -66,17 +66,23 @@
</span><span class="cx">     void RegisterObserver(webrtc::ObserverInterface*) final { }
</span><span class="cx">     void UnregisterObserver(webrtc::ObserverInterface*) final { }
</span><span class="cx"> 
</span><del>-    // RealtimeMediaSource::Observer API
-    void sourceMutedChanged() final;
-    void sourceEnabledChanged() final;
-    void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
</del><ins>+    void sourceMutedChanged();
+    void sourceEnabledChanged();
+    void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t);
</ins><span class="cx"> 
</span><ins>+    // MediaStreamTrackPrivate::Observer API
+    void trackMutedChanged(MediaStreamTrackPrivate&) final { sourceMutedChanged(); }
+    void trackEnabledChanged(MediaStreamTrackPrivate&) final { sourceEnabledChanged(); }
+    void audioSamplesAvailable(MediaStreamTrackPrivate&, const MediaTime& mediaTime, const PlatformAudioData& data, const AudioStreamDescription& description, size_t sampleCount) final { audioSamplesAvailable(mediaTime, data, description, sampleCount); }
+    void trackEnded(MediaStreamTrackPrivate&) final { }
+    void trackSettingsChanged(MediaStreamTrackPrivate&) final { }
+
</ins><span class="cx">     void pullAudioData();
</span><span class="cx"> 
</span><span class="cx">     void initializeConverter();
</span><span class="cx"> 
</span><span class="cx">     Vector<webrtc::AudioTrackSinkInterface*> m_sinks;
</span><del>-    Ref<RealtimeMediaSource> m_audioSource;
</del><ins>+    Ref<MediaStreamTrackPrivate> m_audioSource;
</ins><span class="cx">     Ref<AudioSampleDataSource> m_sampleConverter;
</span><span class="cx">     CAAudioStreamDescription m_inputStreamDescription;
</span><span class="cx">     CAAudioStreamDescription m_outputStreamDescription;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingVideoSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource(Ref<RealtimeMediaSource>&& videoSource)
</del><ins>+RealtimeOutgoingVideoSource::RealtimeOutgoingVideoSource(Ref<MediaStreamTrackPrivate>&& videoSource)
</ins><span class="cx">     : m_videoSource(WTFMove(videoSource))
</span><span class="cx">     , m_blackFrameTimer(*this, &RealtimeOutgoingVideoSource::sendOneBlackFrame)
</span><span class="cx"> {
</span><span class="lines">@@ -51,10 +51,10 @@
</span><span class="cx">     initializeFromSource();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RealtimeOutgoingVideoSource::setSource(Ref<RealtimeMediaSource>&& newSource)
</del><ins>+bool RealtimeOutgoingVideoSource::setSource(Ref<MediaStreamTrackPrivate>&& newSource)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_initialSettings)
</span><del>-        m_initialSettings = m_videoSource->settings();
</del><ins>+        m_initialSettings = m_videoSource->source().settings();
</ins><span class="cx"> 
</span><span class="cx">     m_videoSource->removeObserver(*this);
</span><span class="cx">     m_videoSource = WTFMove(newSource);
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx"> 
</span><span class="cx"> void RealtimeOutgoingVideoSource::initializeFromSource()
</span><span class="cx"> {
</span><del>-    const auto& settings = m_videoSource->settings();
</del><ins>+    const auto& settings = m_videoSource->source().settings();
</ins><span class="cx">     m_width = settings.width();
</span><span class="cx">     m_height = settings.height();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingVideoSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h      2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingVideoSource.h 2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx"> #if USE(LIBWEBRTC)
</span><span class="cx"> 
</span><span class="cx"> #include "LibWebRTCMacros.h"
</span><del>-#include "RealtimeMediaSource.h"
</del><ins>+#include "MediaStreamTrackPrivate.h"
</ins><span class="cx"> #include <Timer.h>
</span><span class="cx"> #include <webrtc/api/mediastreaminterface.h>
</span><span class="cx"> #include <webrtc/base/optional.h>
</span><span class="lines">@@ -42,14 +42,14 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class RealtimeOutgoingVideoSource final : public ThreadSafeRefCounted<RealtimeOutgoingVideoSource>, public webrtc::VideoTrackSourceInterface, private RealtimeMediaSource::Observer {
</del><ins>+class RealtimeOutgoingVideoSource final : public ThreadSafeRefCounted<RealtimeOutgoingVideoSource>, public webrtc::VideoTrackSourceInterface, private MediaStreamTrackPrivate::Observer {
</ins><span class="cx"> public:
</span><del>-    static Ref<RealtimeOutgoingVideoSource> create(Ref<RealtimeMediaSource>&& videoSource) { return adoptRef(*new RealtimeOutgoingVideoSource(WTFMove(videoSource))); }
</del><ins>+    static Ref<RealtimeOutgoingVideoSource> create(Ref<MediaStreamTrackPrivate>&& videoSource) { return adoptRef(*new RealtimeOutgoingVideoSource(WTFMove(videoSource))); }
</ins><span class="cx">     ~RealtimeOutgoingVideoSource() { stop(); }
</span><span class="cx"> 
</span><span class="cx">     void stop();
</span><del>-    bool setSource(Ref<RealtimeMediaSource>&&);
-    RealtimeMediaSource& source() const { return m_videoSource.get(); }
</del><ins>+    bool setSource(Ref<MediaStreamTrackPrivate>&&);
+    MediaStreamTrackPrivate& source() const { return m_videoSource.get(); }
</ins><span class="cx"> 
</span><span class="cx">     int AddRef() const final { ref(); return refCount(); }
</span><span class="cx">     int Release() const final { deref(); return refCount(); }
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx">     void setApplyRotation(bool shouldApplyRotation) { m_shouldApplyRotation = shouldApplyRotation; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    RealtimeOutgoingVideoSource(Ref<RealtimeMediaSource>&&);
</del><ins>+    RealtimeOutgoingVideoSource(Ref<MediaStreamTrackPrivate>&&);
</ins><span class="cx"> 
</span><span class="cx">     void sendFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer>&&);
</span><span class="cx">     void sendBlackFramesIfNeeded();
</span><span class="lines">@@ -82,15 +82,20 @@
</span><span class="cx">     void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>*, const rtc::VideoSinkWants&) final;
</span><span class="cx">     void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>*) final;
</span><span class="cx"> 
</span><del>-    // RealtimeMediaSource::Observer API
-    void sourceMutedChanged() final;
-    void sourceEnabledChanged() final;
-    void sourceSettingsChanged() final { initializeFromSource(); }
-    void videoSampleAvailable(MediaSample&) final;
</del><ins>+    void sourceMutedChanged();
+    void sourceEnabledChanged();
+    void videoSampleAvailable(MediaSample&);
</ins><span class="cx"> 
</span><ins>+    // MediaStreamTrackPrivate::Observer API
+    void trackMutedChanged(MediaStreamTrackPrivate&) final { sourceMutedChanged(); }
+    void trackEnabledChanged(MediaStreamTrackPrivate&) final { sourceEnabledChanged(); }
+    void trackSettingsChanged(MediaStreamTrackPrivate&) final { initializeFromSource(); }
+    void sampleBufferUpdated(MediaStreamTrackPrivate&, MediaSample& sample) final { videoSampleAvailable(sample); }
+    void trackEnded(MediaStreamTrackPrivate&) final { }
+
</ins><span class="cx">     Vector<rtc::VideoSinkInterface<webrtc::VideoFrame>*> m_sinks;
</span><span class="cx">     webrtc::I420BufferPool m_bufferPool;
</span><del>-    Ref<RealtimeMediaSource> m_videoSource;
</del><ins>+    Ref<MediaStreamTrackPrivate> m_videoSource;
</ins><span class="cx">     bool m_enabled { true };
</span><span class="cx">     bool m_muted { false };
</span><span class="cx">     std::optional<RealtimeMediaSourceSettings> m_initialSettings;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacWebAudioSourceProviderAVFObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -27,8 +27,9 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
</span><span class="cx"> 
</span><del>-#include "AudioSourceProvider.h"
-#include "RealtimeMediaSource.h"
</del><ins>+#include "MediaStreamTrackPrivate.h"
+#include "WebAudioSourceProvider.h"
+#include <CoreAudio/CoreAudioTypes.h>
</ins><span class="cx"> #include <wtf/Lock.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="lines">@@ -44,23 +45,27 @@
</span><span class="cx"> class AudioSampleDataSource;
</span><span class="cx"> class CAAudioStreamDescription;
</span><span class="cx"> 
</span><del>-class WEBCORE_EXPORT WebAudioSourceProviderAVFObjC : public RefCounted<WebAudioSourceProviderAVFObjC>, public AudioSourceProvider, RealtimeMediaSource::Observer {
</del><ins>+class WEBCORE_EXPORT WebAudioSourceProviderAVFObjC final : public WebAudioSourceProvider, MediaStreamTrackPrivate::Observer {
</ins><span class="cx"> public:
</span><del>-    static Ref<WebAudioSourceProviderAVFObjC> create(RealtimeMediaSource&);
</del><ins>+    static Ref<WebAudioSourceProviderAVFObjC> create(MediaStreamTrackPrivate&);
</ins><span class="cx">     virtual ~WebAudioSourceProviderAVFObjC();
</span><span class="cx"> 
</span><del>-    void prepare(const AudioStreamBasicDescription *);
</del><ins>+    void prepare(const AudioStreamBasicDescription*);
</ins><span class="cx">     void unprepare();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    WebAudioSourceProviderAVFObjC(RealtimeMediaSource&);
</del><ins>+    explicit WebAudioSourceProviderAVFObjC(MediaStreamTrackPrivate&);
</ins><span class="cx"> 
</span><span class="cx">     // AudioSourceProvider
</span><del>-    void provideInput(AudioBus*, size_t) override;
-    void setClient(AudioSourceProviderClient*) override;
</del><ins>+    void provideInput(AudioBus*, size_t) final;
+    void setClient(AudioSourceProviderClient*) final;
</ins><span class="cx"> 
</span><del>-    // RealtimeMediaSource::Observer
-    void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
</del><ins>+    // MediaStreamTrackPrivate::Observer
+    void audioSamplesAvailable(MediaStreamTrackPrivate&, const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t) final;
+    void trackEnded(MediaStreamTrackPrivate&) final { }
+    void trackMutedChanged(MediaStreamTrackPrivate&) final { }
+    void trackSettingsChanged(MediaStreamTrackPrivate&) final { }
+    void trackEnabledChanged(MediaStreamTrackPrivate&) final { }
</ins><span class="cx"> 
</span><span class="cx">     size_t m_listBufferSize { 0 };
</span><span class="cx">     std::unique_ptr<CAAudioStreamDescription> m_inputDescription;
</span><span class="lines">@@ -70,11 +75,12 @@
</span><span class="cx">     uint64_t m_writeCount { 0 };
</span><span class="cx">     uint64_t m_readCount { 0 };
</span><span class="cx">     AudioSourceProviderClient* m_client { nullptr };
</span><del>-    RealtimeMediaSource* m_captureSource { nullptr };
</del><ins>+    MediaStreamTrackPrivate* m_captureSource { nullptr };
</ins><span class="cx">     Lock m_mutex;
</span><span class="cx">     bool m_connected { false };
</span><ins>+    AudioStreamBasicDescription m_streamFormat;
</ins><span class="cx"> };
</span><del>-    
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacWebAudioSourceProviderAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm   2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm      2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -48,12 +48,12 @@
</span><span class="cx"> 
</span><span class="cx"> static const double kRingBufferDuration = 1;
</span><span class="cx"> 
</span><del>-Ref<WebAudioSourceProviderAVFObjC> WebAudioSourceProviderAVFObjC::create(RealtimeMediaSource& source)
</del><ins>+Ref<WebAudioSourceProviderAVFObjC> WebAudioSourceProviderAVFObjC::create(MediaStreamTrackPrivate& source)
</ins><span class="cx"> {
</span><span class="cx">     return adoptRef(*new WebAudioSourceProviderAVFObjC(source));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebAudioSourceProviderAVFObjC::WebAudioSourceProviderAVFObjC(RealtimeMediaSource& source)
</del><ins>+WebAudioSourceProviderAVFObjC::WebAudioSourceProviderAVFObjC(MediaStreamTrackPrivate& source)
</ins><span class="cx">     : m_captureSource(&source)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -109,7 +109,6 @@
</span><span class="cx">     if (m_client && !m_connected) {
</span><span class="cx">         m_connected = true;
</span><span class="cx">         m_captureSource->addObserver(*this);
</span><del>-        m_captureSource->start();
</del><span class="cx">     } else if (!m_client && m_connected) {
</span><span class="cx">         m_captureSource->removeObserver(*this);
</span><span class="cx">         m_connected = false;
</span><span class="lines">@@ -161,8 +160,14 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebAudioSourceProviderAVFObjC::audioSamplesAvailable(const MediaTime&, const PlatformAudioData& data, const AudioStreamDescription&, size_t frameCount)
</del><ins>+void WebAudioSourceProviderAVFObjC::audioSamplesAvailable(MediaStreamTrackPrivate&, const MediaTime&, const PlatformAudioData& data, const AudioStreamDescription& description, size_t frameCount)
</ins><span class="cx"> {
</span><ins>+    // FIXME: We should try to call prepare based on trackSettingsChanged callback.
+    ASSERT(description.platformDescription().type == PlatformDescription::CAAudioStreamBasicType);
+    auto& basicDescription = *WTF::get<const AudioStreamBasicDescription*>(description.platformDescription().description);
+    if (m_streamFormat != basicDescription)
+        prepare(&basicDescription);
+
</ins><span class="cx">     if (!m_dataSource)
</span><span class="cx">         return;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeVideoSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp   2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp      2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -391,7 +391,7 @@
</span><span class="cx">     FloatRect frameRect(FloatPoint(), size);
</span><span class="cx">     context.fillRect(FloatRect(FloatPoint(), size), !deviceIndex() ? Color::black : Color::darkGray);
</span><span class="cx"> 
</span><del>-    if (!muted() && enabled()) {
</del><ins>+    if (!muted()) {
</ins><span class="cx">         drawText(context);
</span><span class="cx">         drawAnimation(context);
</span><span class="cx">         drawBoxes(context);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog   2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebKit2/ChangeLog      2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-06-19  Youenn Fablet  <youenn@apple.com>
+
+        A cloned MediaStreamTrack should mute independently other tracks using the same source
+        https://bugs.webkit.org/show_bug.cgi?id=172831
+        <rdar://problem/32518527>
+
+        Reviewed by Eric Carlson.
+
+        * WebProcess/cocoa/UserMediaCaptureManager.cpp:
+        (WebKit::UserMediaCaptureManager::Source::setStorage):
+
</ins><span class="cx"> 2017-06-19  Carlos Garcia Campos  <cgarcia@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [GTK] Move GTK+ API files that could be shared to glib dirs
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUserMediaCaptureManagerProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -72,10 +72,6 @@
</span><span class="cx">         m_manager.process().send(Messages::UserMediaCaptureManager::SourceMutedChanged(m_id, m_source->muted()), 0);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    void sourceEnabledChanged() final {
-        m_manager.process().send(Messages::UserMediaCaptureManager::SourceEnabledChanged(m_id, m_source->enabled()), 0);
-    }
-
</del><span class="cx">     void sourceSettingsChanged() final {
</span><span class="cx">         m_manager.process().send(Messages::UserMediaCaptureManager::SourceSettingsChanged(m_id, m_source->settings()), 0);
</span><span class="cx">     }
</span><span class="lines">@@ -177,13 +173,6 @@
</span><span class="cx">         iter->value->source().setMuted(muted);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UserMediaCaptureManagerProxy::setEnabled(uint64_t id, bool enabled)
-{
-    auto iter = m_proxies.find(id);
-    if (iter != m_proxies.end())
-        iter->value->source().setEnabled(enabled);
-}
-
</del><span class="cx"> void UserMediaCaptureManagerProxy::applyConstraints(uint64_t id, const WebCore::MediaConstraints& constraints)
</span><span class="cx"> {
</span><span class="cx">     auto iter = m_proxies.find(id);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUserMediaCaptureManagerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h      2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h 2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -54,7 +54,6 @@
</span><span class="cx">     void stopProducingData(uint64_t);
</span><span class="cx">     void capabilities(uint64_t, WebCore::RealtimeMediaSourceCapabilities&);
</span><span class="cx">     void setMuted(uint64_t, bool);
</span><del>-    void setEnabled(uint64_t, bool);
</del><span class="cx">     void applyConstraints(uint64_t, const WebCore::MediaConstraints&);
</span><span class="cx"> 
</span><span class="cx">     class SourceProxy;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUserMediaCaptureManagerProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in    2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in       2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -27,6 +27,5 @@
</span><span class="cx">     StopProducingData(uint64_t id)
</span><span class="cx">     Capabilities(uint64_t id) -> (WebCore::RealtimeMediaSourceCapabilities capabilities)
</span><span class="cx">     SetMuted(uint64_t id, bool muted)
</span><del>-    SetEnabled(uint64_t id, bool enabled)
</del><span class="cx">     ApplyConstraints(uint64_t id, struct WebCore::MediaConstraints constraints)
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaUserMediaCaptureManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp        2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp   2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -83,8 +83,6 @@
</span><span class="cx">     void setStorage(const SharedMemory::Handle& handle, const WebCore::CAAudioStreamDescription& description, uint64_t numberOfFrames)
</span><span class="cx">     {
</span><span class="cx">         m_description = description;
</span><del>-        if (m_audioSourceProvider)
-            m_audioSourceProvider->prepare(&m_description.streamDescription());
</del><span class="cx"> 
</span><span class="cx">         if (handle.isNull()) {
</span><span class="cx">             m_ringBuffer.deallocate();
</span><span class="lines">@@ -131,15 +129,6 @@
</span><span class="cx">     void stopProducingData() final { m_manager.stopProducingData(m_id); }
</span><span class="cx">     bool isCaptureSource() const final { return true; }
</span><span class="cx"> 
</span><del>-    AudioSourceProvider* audioSourceProvider() final {
-        if (!m_audioSourceProvider) {
-            m_audioSourceProvider = WebAudioSourceProviderAVFObjC::create(*this);
-            if (m_description.format() != AudioStreamDescription::None)
-                m_audioSourceProvider->prepare(&m_description.streamDescription());
-        }
-        return m_audioSourceProvider.get();
-    }
-
</del><span class="cx">     // RealtimeMediaSource
</span><span class="cx">     void beginConfiguration() final { }
</span><span class="cx">     void commitConfiguration() final { }
</span><span class="lines">@@ -155,7 +144,6 @@
</span><span class="cx">     RealtimeMediaSourceSettings m_settings;
</span><span class="cx">     CAAudioStreamDescription m_description;
</span><span class="cx">     CARingBuffer m_ringBuffer;
</span><del>-    RefPtr<WebAudioSourceProviderAVFObjC> m_audioSourceProvider;
</del><span class="cx"> 
</span><span class="cx">     struct ApplyConstraintsCallback {
</span><span class="cx">         SuccessHandler successHandler;
</span><span class="lines">@@ -218,12 +206,6 @@
</span><span class="cx">     m_sources.get(id)->setMuted(muted);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UserMediaCaptureManager::sourceEnabledChanged(uint64_t id, bool enabled)
-{
-    ASSERT(m_sources.contains(id));
-    m_sources.get(id)->setEnabled(enabled);
-}
-
</del><span class="cx"> void UserMediaCaptureManager::sourceSettingsChanged(uint64_t id, const RealtimeMediaSourceSettings& settings)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_sources.contains(id));
</span><span class="lines">@@ -272,11 +254,6 @@
</span><span class="cx">     m_process.send(Messages::UserMediaCaptureManagerProxy::SetMuted(id, muted), 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UserMediaCaptureManager::setEnabled(uint64_t id, bool enabled)
-{
-    m_process.send(Messages::UserMediaCaptureManagerProxy::SetEnabled(id, enabled), 0);
-}
-
</del><span class="cx"> void UserMediaCaptureManager::applyConstraints(uint64_t id, const WebCore::MediaConstraints& constraints)
</span><span class="cx"> {
</span><span class="cx">     m_process.send(Messages::UserMediaCaptureManagerProxy::ApplyConstraints(id, constraints), 0);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaUserMediaCaptureManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.h (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.h  2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.h     2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -64,7 +64,6 @@
</span><span class="cx">     // Messages::UserMediaCaptureManager
</span><span class="cx">     void sourceStopped(uint64_t id);
</span><span class="cx">     void sourceMutedChanged(uint64_t id, bool muted);
</span><del>-    void sourceEnabledChanged(uint64_t id, bool enabled);
</del><span class="cx">     void sourceSettingsChanged(uint64_t id, const WebCore::RealtimeMediaSourceSettings&);
</span><span class="cx">     void storageChanged(uint64_t id, const SharedMemory::Handle&, const WebCore::CAAudioStreamDescription&, uint64_t numberOfFrames);
</span><span class="cx">     void ringBufferFrameBoundsChanged(uint64_t id, uint64_t startFrame, uint64_t endFrame);
</span><span class="lines">@@ -74,7 +73,6 @@
</span><span class="cx">     void stopProducingData(uint64_t);
</span><span class="cx">     WebCore::RealtimeMediaSourceCapabilities capabilities(uint64_t);
</span><span class="cx">     void setMuted(uint64_t, bool);
</span><del>-    void setEnabled(uint64_t, bool);
</del><span class="cx">     void applyConstraints(uint64_t, const WebCore::MediaConstraints&);
</span><span class="cx">     void applyConstraintsSucceeded(uint64_t, const WebCore::RealtimeMediaSourceSettings&);
</span><span class="cx">     void applyConstraintsFailed(uint64_t, const String&, const String&);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaUserMediaCaptureManagermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.messages.in (218496 => 218497)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.messages.in        2017-06-19 17:01:14 UTC (rev 218496)
+++ trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.messages.in   2017-06-19 17:12:57 UTC (rev 218497)
</span><span class="lines">@@ -24,7 +24,6 @@
</span><span class="cx"> messages -> UserMediaCaptureManager {
</span><span class="cx">     SourceStopped(uint64_t id)
</span><span class="cx">     SourceMutedChanged(uint64_t id, bool muted)
</span><del>-    SourceEnabledChanged(uint64_t id, bool enabled)
</del><span class="cx">     SourceSettingsChanged(uint64_t id, WebCore::RealtimeMediaSourceSettings settings)
</span><span class="cx">     StorageChanged(uint64_t id, WebKit::SharedMemory::Handle storageHandle, WebCore::CAAudioStreamDescription description, uint64_t numberOfFrames)
</span><span class="cx">     AudioSamplesAvailable(uint64_t id, MediaTime time, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame)
</span></span></pre>
</div>
</div>

</body>
</html>