<!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>[210742] 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/210742">210742</a></dd>
<dt>Author</dt> <dd>eric.carlson@apple.com</dd>
<dt>Date</dt> <dd>2017-01-13 13:27:30 -0800 (Fri, 13 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[MediaStream, Mac] Add mock audio source
https://bugs.webkit.org/show_bug.cgi?id=166974
Reviewed by Jer Noble.
Source/WebCore:
Add a mock audio source for testing media streams.
No new tests, updated webaudio/mediastreamaudiosourcenode.html.
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueAudioSample):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample):
* platform/mediastream/mac/AVAudioCaptureSource.h:
(WebCore::AVAudioCaptureSource::Observer::~Observer): Deleted.
* platform/mediastream/mac/AVAudioCaptureSource.mm:
(WebCore::AVAudioCaptureSource::addObserver):
(WebCore::AVAudioCaptureSource::removeObserver):
(WebCore::AVAudioCaptureSource::start):
* platform/mediastream/mac/MockRealtimeAudioSourceMac.h: Added.
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm: Added.
(WebCore::MockRealtimeAudioSource::create):
(WebCore::MockRealtimeAudioSourceMac::MockRealtimeAudioSourceMac):
(WebCore::MockRealtimeAudioSource::createMuted):
(WebCore::MockRealtimeAudioSourceMac::addObserver):
(WebCore::MockRealtimeAudioSourceMac::removeObserver):
(WebCore::MockRealtimeAudioSourceMac::start):
(WebCore::MockRealtimeAudioSourceMac::emitSampleBuffers):
(WebCore::MockRealtimeAudioSourceMac::reconfigure):
(WebCore::MockRealtimeAudioSourceMac::render):
(WebCore::MockRealtimeAudioSourceMac::applySampleRate):
(WebCore::MockRealtimeAudioSourceMac::audioSourceProvider):
* platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h:
* platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm:
(WebCore::WebAudioSourceProviderAVFObjC::create):
(WebCore::WebAudioSourceProviderAVFObjC::WebAudioSourceProviderAVFObjC):
(WebCore::WebAudioSourceProviderAVFObjC::~WebAudioSourceProviderAVFObjC):
(WebCore::WebAudioSourceProviderAVFObjC::provideInput):
(WebCore::WebAudioSourceProviderAVFObjC::setClient):
(WebCore::WebAudioSourceProviderAVFObjC::startProducingData): Deleted.
(WebCore::WebAudioSourceProviderAVFObjC::stopProducingData): Deleted.
* platform/mock/MockRealtimeAudioSource.cpp:
(WebCore::MockRealtimeAudioSource::MockRealtimeAudioSource):
(WebCore::MockRealtimeAudioSource::startProducingData):
(WebCore::MockRealtimeAudioSource::stopProducingData):
(WebCore::MockRealtimeAudioSource::elapsedTime):
(WebCore::MockRealtimeAudioSource::tick):
* platform/mock/MockRealtimeAudioSource.h:
(WebCore::MockRealtimeAudioSource::render):
(WebCore::MockRealtimeAudioSource::renderInterval):
(WebCore::MockRealtimeAudioSource::~MockRealtimeAudioSource): Deleted.
LayoutTests:
* webaudio/mediastreamaudiosourcenode-expected.txt:
* webaudio/mediastreamaudiosourcenode.html:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestswebaudiomediastreamaudiosourcenodeexpectedtxt">trunk/LayoutTests/webaudio/mediastreamaudiosourcenode-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebaudiomediastreamaudiosourcenodehtml">trunk/LayoutTests/webaudio/mediastreamaudiosourcenode.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaStreamAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAVAudioCaptureSourceh">trunk/Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAVAudioCaptureSourcemm">trunk/Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.mm</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="#trunkSourceWebCoreplatformmockMockRealtimeAudioSourcecpp">trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeAudioSourceh">trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAudioCaptureSourceProviderObjCh">trunk/Source/WebCore/platform/mediastream/mac/AudioCaptureSourceProviderObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAudioSourceObserverObjCh">trunk/Source/WebCore/platform/mediastream/mac/AudioSourceObserverObjC.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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/LayoutTests/ChangeLog        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2017-01-13 Eric Carlson <eric.carlson@apple.com>
+
+ [MediaStream, Mac] Add mock audio source
+ https://bugs.webkit.org/show_bug.cgi?id=166974
+
+ Reviewed by Jer Noble.
+
+ * webaudio/mediastreamaudiosourcenode-expected.txt:
+ * webaudio/mediastreamaudiosourcenode.html:
+
</ins><span class="cx"> 2017-01-13 Sam Weinig <sam@webkit.org>
</span><span class="cx">
</span><span class="cx"> [WebIDL] Remove custom bindings for DeviceMotionEvent and DeviceOrientationEvent
</span></span></pre></div>
<a id="trunkLayoutTestswebaudiomediastreamaudiosourcenodeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webaudio/mediastreamaudiosourcenode-expected.txt (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webaudio/mediastreamaudiosourcenode-expected.txt        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/LayoutTests/webaudio/mediastreamaudiosourcenode-expected.txt        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -3,14 +3,15 @@
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><span class="cx">
</span><span class="cx"> PASS {audio:true} generated stream
</span><del>-PASS s.getAudioTracks().length is 1
-PASS s.getVideoTracks().length is 0
</del><ins>+PASS stream.getAudioTracks().length is 1
+PASS stream.getVideoTracks().length is 0
</ins><span class="cx"> PASS Source AudioNode has no inputs.
</span><span class="cx"> PASS Source AudioNode has one output.
</span><del>-PASS connect() exception thrown for illegal destination AudioNode.
-PASS connect() exception thrown for illegal output index.
-PASS connect() exception thrown for illegal input index.
</del><ins>+PASS connect() exception {"TypeError", "Argument 1 ('destination') to AudioNode.connect must be an instance of AudioNode"} thrown for illegal destination AudioNode
+PASS connect() exception {"IndexSizeError", "The index is not in the allowed range."} thrown for illegal output index
+PASS connect() exception {"IndexSizeError", "The index is not in the allowed range."} thrown for illegal input index
</ins><span class="cx"> PASS mediaStreamSource.connect(context.destination) succeeded.
</span><ins>+PASS onaudioprocess was called
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx">
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestswebaudiomediastreamaudiosourcenodehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webaudio/mediastreamaudiosourcenode.html (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webaudio/mediastreamaudiosourcenode.html        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/LayoutTests/webaudio/mediastreamaudiosourcenode.html        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -1,96 +1,114 @@
</span><span class="cx"> <!DOCTYPE html>
</span><del>-
</del><span class="cx"> <html>
</span><del>-<head>
-<script src="../resources/js-test-pre.js"></script>
-<script src="resources/audio-testing.js"></script>
-</head>
</del><ins>+ <head>
+ <script src="../resources/js-test-pre.js"></script>
+ </head>
</ins><span class="cx">
</span><del>-<body>
-<div id="description"></div>
-<div id="console"></div>
</del><ins>+ <body>
+ <div id="description"></div>
+ <div id="console"></div>
</ins><span class="cx">
</span><del>-<script>
-description("Basic tests for MediaStreamAudioSourceNode API.");
</del><ins>+ <script>
+ description("Basic tests for MediaStreamAudioSourceNode API.");
</ins><span class="cx">
</span><del>-var context = 0;
</del><ins>+ let context;
+ let stream;
+ let finished = false;
+ const numberOfOutputChannels = 2;
+ const numberOfInputChannels = 2;
+ const bufferSize = 512;
</ins><span class="cx">
</span><del>-function error() {
- testFailed('Stream generation failed.');
- finishJSTest();
-}
</del><ins>+ function processAudioData(event)
+ {
+ if (finished)
+ return;
</ins><span class="cx">
</span><del>-function getUserMedia(dictionary, callback) {
- try {
- navigator.webkitGetUserMedia(dictionary, callback, error);
- } catch (e) {
- testFailed('webkitGetUserMedia threw exception :' + e);
- finishJSTest();
- }
-}
</del><ins>+ if (event.inputBuffer.numberOfChannels != numberOfInputChannels)
+ testFailed(`numberOfInputChannels doesn't match: have ${event.inputBuffer.numberOfChannels}, expect ${numberOfInputChannels}!`);
</ins><span class="cx">
</span><del>-function gotStream(stream) {
- s = stream;
- testPassed('{audio:true} generated stream');
- shouldBe('s.getAudioTracks().length', '1');
- shouldBe('s.getVideoTracks().length', '0');
</del><ins>+ if (event.outputBuffer.numberOfChannels != numberOfOutputChannels)
+ testFailed(`numberOfOutputChannels doesn't match: have ${event.outputBuffer.numberOfChannels}, expect ${numberOfOutputChannels}!`);
</ins><span class="cx">
</span><del>- context = new webkitAudioContext();
</del><ins>+ stream.getAudioTracks()[0].stop();
+ testPassed("onaudioprocess was called");
+ finishJSTest();
+ finished = true;
+ }
</ins><span class="cx">
</span><del>- // Create an AudioNode from the stream.
- var mediaStreamSource = context.createMediaStreamSource(stream);
</del><ins>+ function gotStream(s)
+ {
+ stream = s;
+ testPassed('{audio:true} generated stream');
+ shouldBe('stream.getAudioTracks().length', '1');
+ shouldBe('stream.getVideoTracks().length', '0');
</ins><span class="cx">
</span><del>- // Check number of inputs and outputs.
- if (mediaStreamSource.numberOfInputs == 0)
- testPassed("Source AudioNode has no inputs.");
- else
- testFailed("Source AudioNode should not have inputs.");
</del><ins>+ context = new webkitAudioContext();
</ins><span class="cx">
</span><del>- if (mediaStreamSource.numberOfOutputs == 1)
- testPassed("Source AudioNode has one output.");
- else
- testFailed("Source AudioNode should have one output.");
</del><ins>+ // Create an AudioNode from the stream.
+ let mediaStreamSource = context.createMediaStreamSource(stream);
</ins><span class="cx">
</span><del>- // Try calling connect() method with illegal values.
</del><ins>+ // Check number of inputs and outputs.
+ if (mediaStreamSource.numberOfInputs == 0)
+ testPassed("Source AudioNode has no inputs.");
+ else
+ testFailed("Source AudioNode should not have inputs.");
</ins><span class="cx">
</span><del>- try {
- mediaStreamSource.connect(0, 0, 0);
- testFailed("connect() exception should be thrown for illegal destination AudioNode.");
- } catch(e) {
- testPassed("connect() exception thrown for illegal destination AudioNode.");
- }
</del><ins>+ if (mediaStreamSource.numberOfOutputs == 1)
+ testPassed("Source AudioNode has one output.");
+ else
+ testFailed("Source AudioNode should have one output.");
</ins><span class="cx">
</span><del>- try {
- mediaStreamSource.connect(context.destination, 5, 0);
- testFailed("connect() exception should be thrown for illegal output index.");
- } catch(e) {
- testPassed("connect() exception thrown for illegal output index.");
- }
</del><ins>+ // Try calling connect() method with illegal values.
+ try {
+ mediaStreamSource.connect(0, 0, 0);
+ testFailed("connect() exception should be thrown for illegal destination AudioNode.");
+ } catch(err) {
+ testPassed(`connect() exception {"${err.name}", "${err.message}"} thrown for illegal destination AudioNode`);
+ }
</ins><span class="cx">
</span><del>- try {
- mediaStreamSource.connect(context.destination, 0, 5);
- testFailed("connect() exception should be thrown for illegal input index.");
- } catch(e) {
- testPassed("connect() exception thrown for illegal input index.");
- }
</del><ins>+ try {
+ mediaStreamSource.connect(context.destination, 5, 0);
+ testFailed("connect() exception should be thrown for illegal output index.");
+ } catch(err) {
+ testPassed(`connect() exception {"${err.name}", "${err.message}"} thrown for illegal output index`);
+ }
</ins><span class="cx">
</span><del>- // Try calling connect() with proper values.
- try {
- mediaStreamSource.connect(context.destination, 0, 0);
- testPassed("mediaStreamSource.connect(context.destination) succeeded.");
- } catch(e) {
- testFailed("mediaStreamSource.connect(context.destination) failed.");
- }
</del><ins>+ try {
+ mediaStreamSource.connect(context.destination, 0, 5);
+ testFailed("connect() exception should be thrown for illegal input index.");
+ } catch(err) {
+ testPassed(`connect() exception {"${err.name}", "${err.message}"} thrown for illegal input index`);
+ }
</ins><span class="cx">
</span><del>- finishJSTest();
-}
</del><ins>+ // Try calling connect() with legal values.
+ try {
+ mediaStreamSource.connect(context.destination, 0, 0);
+ testPassed("mediaStreamSource.connect(context.destination) succeeded.");
+ } catch(err) {
+ testFailed(`mediaStreamSource.connect(context.destination) failed with "${err.name}": "${err.message}"`);
+ }
</ins><span class="cx">
</span><del>-getUserMedia({audio:true}, gotStream);
-window.jsTestIsAsync = true;
-window.successfullyParsed = true;
</del><ins>+ let scriptProcessorNode = context.createScriptProcessor(bufferSize, numberOfInputChannels, numberOfOutputChannels);
+ scriptProcessorNode.onaudioprocess = processAudioData;
</ins><span class="cx">
</span><del>-</script>
</del><ins>+ mediaStreamSource.connect(scriptProcessorNode);
+ scriptProcessorNode.connect(context.destination);
+ }
</ins><span class="cx">
</span><del>-<script src="../resources/js-test-post.js"></script>
-</body>
</del><ins>+ if (window.testRunner)
+ testRunner.setUserMediaPermission(true);
+
+ navigator.mediaDevices.getUserMedia({audio:true})
+ .then(stream => gotStream(stream))
+ .catch(function(err) {
+ testFailed(`mediaDevices.getUserMedia() failed with "${err.name}": "${err.message}"`);
+ finishJSTest();
+ });
+
+ window.jsTestIsAsync = true;
+ window.successfullyParsed = true;
+ </script>
+ <script src="../resources/js-test-post.js"></script>
+
+ </body>
</ins><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/Source/WebCore/ChangeLog        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -1,3 +1,63 @@
</span><ins>+2017-01-13 Eric Carlson <eric.carlson@apple.com>
+
+ [MediaStream, Mac] Add mock audio source
+ https://bugs.webkit.org/show_bug.cgi?id=166974
+
+ Reviewed by Jer Noble.
+
+ Add a mock audio source for testing media streams.
+
+ No new tests, updated webaudio/mediastreamaudiosourcenode.html.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueAudioSample):
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample):
+
+ * platform/mediastream/mac/AVAudioCaptureSource.h:
+ (WebCore::AVAudioCaptureSource::Observer::~Observer): Deleted.
+
+ * platform/mediastream/mac/AVAudioCaptureSource.mm:
+ (WebCore::AVAudioCaptureSource::addObserver):
+ (WebCore::AVAudioCaptureSource::removeObserver):
+ (WebCore::AVAudioCaptureSource::start):
+
+ * platform/mediastream/mac/MockRealtimeAudioSourceMac.h: Added.
+ * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm: Added.
+ (WebCore::MockRealtimeAudioSource::create):
+ (WebCore::MockRealtimeAudioSourceMac::MockRealtimeAudioSourceMac):
+ (WebCore::MockRealtimeAudioSource::createMuted):
+ (WebCore::MockRealtimeAudioSourceMac::addObserver):
+ (WebCore::MockRealtimeAudioSourceMac::removeObserver):
+ (WebCore::MockRealtimeAudioSourceMac::start):
+ (WebCore::MockRealtimeAudioSourceMac::emitSampleBuffers):
+ (WebCore::MockRealtimeAudioSourceMac::reconfigure):
+ (WebCore::MockRealtimeAudioSourceMac::render):
+ (WebCore::MockRealtimeAudioSourceMac::applySampleRate):
+ (WebCore::MockRealtimeAudioSourceMac::audioSourceProvider):
+
+ * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h:
+ * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm:
+ (WebCore::WebAudioSourceProviderAVFObjC::create):
+ (WebCore::WebAudioSourceProviderAVFObjC::WebAudioSourceProviderAVFObjC):
+ (WebCore::WebAudioSourceProviderAVFObjC::~WebAudioSourceProviderAVFObjC):
+ (WebCore::WebAudioSourceProviderAVFObjC::provideInput):
+ (WebCore::WebAudioSourceProviderAVFObjC::setClient):
+ (WebCore::WebAudioSourceProviderAVFObjC::startProducingData): Deleted.
+ (WebCore::WebAudioSourceProviderAVFObjC::stopProducingData): Deleted.
+
+ * platform/mock/MockRealtimeAudioSource.cpp:
+ (WebCore::MockRealtimeAudioSource::MockRealtimeAudioSource):
+ (WebCore::MockRealtimeAudioSource::startProducingData):
+ (WebCore::MockRealtimeAudioSource::stopProducingData):
+ (WebCore::MockRealtimeAudioSource::elapsedTime):
+ (WebCore::MockRealtimeAudioSource::tick):
+
+ * platform/mock/MockRealtimeAudioSource.h:
+ (WebCore::MockRealtimeAudioSource::render):
+ (WebCore::MockRealtimeAudioSource::renderInterval):
+ (WebCore::MockRealtimeAudioSource::~MockRealtimeAudioSource): Deleted.
+
</ins><span class="cx"> 2017-01-13 Sam Weinig <sam@webkit.org>
</span><span class="cx">
</span><span class="cx"> [WebIDL] Remove custom bindings for DeviceMotionEvent and DeviceOrientationEvent
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -146,6 +146,7 @@
</span><span class="cx">                 073BE34117D17E01002BD431 /* JSNavigatorUserMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = 073BE33F17D17E01002BD431 /* JSNavigatorUserMedia.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 073BE34E17D180B2002BD431 /* RTCSessionDescriptionDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221BAB17CF0AD400848E51 /* RTCSessionDescriptionDescriptor.cpp */; };
</span><span class="cx">                 073BE34F17D18183002BD431 /* RTCIceCandidateDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221BA617CF0AD400848E51 /* RTCIceCandidateDescriptor.cpp */; };
</span><ins>+                0744ECED1E0C4E30000D0944 /* MockRealtimeAudioSourceMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0744ECEC1E0C4AE5000D0944 /* MockRealtimeAudioSourceMac.mm */; };
</ins><span class="cx">                 074E82BA18A69F0E007EF54C /* PlatformTimeRanges.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 074E82B818A69F0E007EF54C /* PlatformTimeRanges.cpp */; };
</span><span class="cx">                 074E82BB18A69F0E007EF54C /* PlatformTimeRanges.h in Headers */ = {isa = PBXBuildFile; fileRef = 074E82B918A69F0E007EF54C /* PlatformTimeRanges.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 0753860214489E9800B78452 /* CachedTextTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0753860014489E9800B78452 /* CachedTextTrack.cpp */; };
</span><span class="lines">@@ -155,6 +156,7 @@
</span><span class="cx">                 076970861463AD8700F502CF /* TextTrackList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 076970841463AD8700F502CF /* TextTrackList.cpp */; };
</span><span class="cx">                 076970871463AD8700F502CF /* TextTrackList.h in Headers */ = {isa = PBXBuildFile; fileRef = 076970851463AD8700F502CF /* TextTrackList.h */; };
</span><span class="cx">                 076F0D0E12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 076F0D0A12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h */; };
</span><ins>+                07707CB01E205EE300005BF7 /* AudioSourceObserverObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 07707CAF1E205EC400005BF7 /* AudioSourceObserverObjC.h */; };
</ins><span class="cx">                 077664FC183E6B5C00133B92 /* JSQuickTimePluginReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 077664FA183E6B5C00133B92 /* JSQuickTimePluginReplacement.cpp */; };
</span><span class="cx">                 077664FD183E6B5C00133B92 /* JSQuickTimePluginReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 077664FB183E6B5C00133B92 /* JSQuickTimePluginReplacement.h */; };
</span><span class="cx">                 0779BF0D18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0779BF0A18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp */; };
</span><span class="lines">@@ -7156,6 +7158,8 @@
</span><span class="cx">                 07394EC91BAB2CD700BE99CD /* MediaDevicesRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDevicesRequest.h; sourceTree = "<group>"; };
</span><span class="cx">                 073BE33E17D17E01002BD431 /* JSNavigatorUserMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNavigatorUserMedia.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 073BE33F17D17E01002BD431 /* JSNavigatorUserMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNavigatorUserMedia.h; sourceTree = "<group>"; };
</span><ins>+                0744ECEB1E0C4AE5000D0944 /* MockRealtimeAudioSourceMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeAudioSourceMac.h; sourceTree = "<group>"; };
+                0744ECEC1E0C4AE5000D0944 /* MockRealtimeAudioSourceMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MockRealtimeAudioSourceMac.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 074E82B818A69F0E007EF54C /* PlatformTimeRanges.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformTimeRanges.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 074E82B918A69F0E007EF54C /* PlatformTimeRanges.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformTimeRanges.h; sourceTree = "<group>"; };
</span><span class="cx">                 0753860014489E9800B78452 /* CachedTextTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedTextTrack.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -7166,6 +7170,8 @@
</span><span class="cx">                 076970851463AD8700F502CF /* TextTrackList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackList.h; sourceTree = "<group>"; };
</span><span class="cx">                 076F0D0912B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaPlayerPrivateAVFoundation.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 076F0D0A12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlayerPrivateAVFoundation.h; sourceTree = "<group>"; };
</span><ins>+                07707CAF1E205EC400005BF7 /* AudioSourceObserverObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioSourceObserverObjC.h; sourceTree = "<group>"; };
+                07707CB11E20649C00005BF7 /* AudioCaptureSourceProviderObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioCaptureSourceProviderObjC.h; sourceTree = "<group>"; };
</ins><span class="cx">                 077664FA183E6B5C00133B92 /* JSQuickTimePluginReplacement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSQuickTimePluginReplacement.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 077664FB183E6B5C00133B92 /* JSQuickTimePluginReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSQuickTimePluginReplacement.h; sourceTree = "<group>"; };
</span><span class="cx">                 0779BF0A18453168000B6AE7 /* HTMLMediaElementMediaStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLMediaElementMediaStream.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -15219,6 +15225,10 @@
</span><span class="cx">                 0729B14D17CFCCA0004F1D60 /* mac */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                07707CB11E20649C00005BF7 /* AudioCaptureSourceProviderObjC.h */,
+                                07707CAF1E205EC400005BF7 /* AudioSourceObserverObjC.h */,
+                                0744ECEB1E0C4AE5000D0944 /* MockRealtimeAudioSourceMac.h */,
+                                0744ECEC1E0C4AE5000D0944 /* MockRealtimeAudioSourceMac.mm */,
</ins><span class="cx">                                 070363D8181A1CDC00C074A5 /* AVAudioCaptureSource.h */,
</span><span class="cx">                                 070363D9181A1CDC00C074A5 /* AVAudioCaptureSource.mm */,
</span><span class="cx">                                 070363DA181A1CDC00C074A5 /* AVCaptureDeviceManager.h */,
</span><span class="lines">@@ -25931,6 +25941,7 @@
</span><span class="cx">                                 5185FCAD1BB4C4E80012898F /* IDBTransaction.h in Headers */,
</span><span class="cx">                                 5198F7AD1BBDD3EB00E2CC5F /* IDBTransactionInfo.h in Headers */,
</span><span class="cx">                                 838EF5381DC149E2008F0C39 /* IDBTransactionMode.h in Headers */,
</span><ins>+                                07707CB01E205EE300005BF7 /* AudioSourceObserverObjC.h in Headers */,
</ins><span class="cx">                                 516103AF1CADBA770016B4C7 /* IDBValue.h in Headers */,
</span><span class="cx">                                 5185FCB01BB4C4E80012898F /* IDBVersionChangeEvent.h in Headers */,
</span><span class="cx">                                 E4A814E01C7338EB00BF85AC /* IdChangeInvalidation.h in Headers */,
</span><span class="lines">@@ -30348,6 +30359,7 @@
</span><span class="cx">                                 B2FA3DC80AB75A6F000E5AC4 /* JSSVGPathSegCurvetoQuadraticRel.cpp in Sources */,
</span><span class="cx">                                 B2FA3DCA0AB75A6F000E5AC4 /* JSSVGPathSegCurvetoQuadraticSmoothAbs.cpp in Sources */,
</span><span class="cx">                                 B2FA3DCC0AB75A6F000E5AC4 /* JSSVGPathSegCurvetoQuadraticSmoothRel.cpp in Sources */,
</span><ins>+                                0744ECED1E0C4E30000D0944 /* MockRealtimeAudioSourceMac.mm in Sources */,
</ins><span class="cx">                                 B2C96D8D0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp in Sources */,
</span><span class="cx">                                 B2FA3DCE0AB75A6F000E5AC4 /* JSSVGPathSegLinetoAbs.cpp in Sources */,
</span><span class="cx">                                 B2FA3DD00AB75A6F000E5AC4 /* JSSVGPathSegLinetoHorizontalAbs.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaStreamAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -326,7 +326,7 @@
</span><span class="cx"> if (timelineOffset == MediaTime::invalidTime()) {
</span><span class="cx"> timelineOffset = calculateTimelineOffset(sample, rendererLatency);
</span><span class="cx"> audioTrack->setTimelineOffset(timelineOffset);
</span><del>- LOG(MediaCaptureSamples, "MediaPlayerPrivateMediaStreamAVFObjC::enqueueAudioSample: timeline offset for track %s set to (%lld/%d)", track.id().utf8().data(), timelineOffset.timeValue(), timelineOffset.timeScale());
</del><ins>+ LOG(MediaCaptureSamples, "MediaPlayerPrivateMediaStreamAVFObjC::enqueueAudioSample: timeline offset for track %s set to %s", track.id().utf8().data(), toString(timelineOffset).utf8().data());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> updateSampleTimes(sample, timelineOffset, "MediaPlayerPrivateMediaStreamAVFObjC::enqueueAudioSample");
</span><span class="lines">@@ -359,7 +359,7 @@
</span><span class="cx"> if (timelineOffset == MediaTime::invalidTime()) {
</span><span class="cx"> timelineOffset = calculateTimelineOffset(sample, rendererLatency);
</span><span class="cx"> videoTrack->setTimelineOffset(timelineOffset);
</span><del>- LOG(MediaCaptureSamples, "MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample: timeline offset for track %s set to %f", track.id().utf8().data(), timelineOffset.toDouble());
</del><ins>+ LOG(MediaCaptureSamples, "MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample: timeline offset for track %s set to %s", track.id().utf8().data(), toString(timelineOffset).utf8().data());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> updateSampleTimes(sample, timelineOffset, "MediaPlayerPrivateMediaStreamAVFObjC::enqueueVideoSample");
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVAudioCaptureSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.h (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.h        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.h        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(MEDIA_STREAM) && USE(AVFOUNDATION)
</span><span class="cx">
</span><span class="cx"> #include "AVMediaCaptureSource.h"
</span><ins>+#include "AudioCaptureSourceProviderObjC.h"
</ins><span class="cx"> #include <wtf/Lock.h>
</span><span class="cx">
</span><span class="cx"> typedef struct AudioStreamBasicDescription AudioStreamBasicDescription;
</span><span class="lines">@@ -38,26 +39,20 @@
</span><span class="cx">
</span><span class="cx"> class WebAudioSourceProviderAVFObjC;
</span><span class="cx">
</span><del>-class AVAudioCaptureSource : public AVMediaCaptureSource {
</del><ins>+class AVAudioCaptureSource : public AVMediaCaptureSource, public AudioCaptureSourceProviderObjC {
</ins><span class="cx"> public:
</span><span class="cx">
</span><del>- class Observer {
- public:
- virtual ~Observer() { }
- virtual void prepare(const AudioStreamBasicDescription *) = 0;
- virtual void unprepare() = 0;
- virtual void process(CMFormatDescriptionRef, CMSampleBufferRef) = 0;
- };
-
</del><span class="cx"> static RefPtr<AVMediaCaptureSource> create(AVCaptureDevice*, const AtomicString&, const MediaConstraints*, String&);
</span><span class="cx">
</span><del>- void addObserver(Observer*);
- void removeObserver(Observer*);
-
</del><span class="cx"> private:
</span><span class="cx"> AVAudioCaptureSource(AVCaptureDevice*, const AtomicString&);
</span><span class="cx"> virtual ~AVAudioCaptureSource();
</span><span class="cx">
</span><ins>+ // AudioCaptureSourceProviderObjC
+ void addObserver(AudioSourceObserverObjC&) final;
+ void removeObserver(AudioSourceObserverObjC&) final;
+ void start() final;
+
</ins><span class="cx"> void initializeCapabilities(RealtimeMediaSourceCapabilities&) override;
</span><span class="cx"> void initializeSupportedConstraints(RealtimeMediaSourceSupportedConstraints&) override;
</span><span class="cx">
</span><span class="lines">@@ -72,7 +67,7 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<WebAudioSourceProviderAVFObjC> m_audioSourceProvider;
</span><span class="cx"> std::unique_ptr<AudioStreamBasicDescription> m_inputDescription;
</span><del>- Vector<Observer*> m_observers;
</del><ins>+ Vector<AudioSourceObserverObjC*> m_observers;
</ins><span class="cx"> Lock m_lock;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVAudioCaptureSourcemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.mm (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.mm        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.mm        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MEDIA_STREAM) && USE(AVFOUNDATION)
</span><span class="cx">
</span><ins>+#import "AudioSourceObserverObjC.h"
</ins><span class="cx"> #import "Logging.h"
</span><span class="cx"> #import "MediaConstraints.h"
</span><span class="cx"> #import "MediaSampleAVFObjC.h"
</span><span class="lines">@@ -115,22 +116,25 @@
</span><span class="cx"> settings.setDeviceId(id());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void AVAudioCaptureSource::addObserver(AVAudioCaptureSource::Observer* observer)
</del><ins>+void AVAudioCaptureSource::addObserver(AudioSourceObserverObjC& observer)
</ins><span class="cx"> {
</span><span class="cx"> LockHolder lock(m_lock);
</span><del>- m_observers.append(observer);
</del><ins>+ m_observers.append(&observer);
</ins><span class="cx"> if (m_inputDescription->mSampleRate)
</span><del>- observer->prepare(m_inputDescription.get());
</del><ins>+ observer.prepare(m_inputDescription.get());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void AVAudioCaptureSource::removeObserver(AVAudioCaptureSource::Observer* observer)
</del><ins>+void AVAudioCaptureSource::removeObserver(AudioSourceObserverObjC& observer)
</ins><span class="cx"> {
</span><span class="cx"> LockHolder lock(m_lock);
</span><del>- size_t pos = m_observers.find(observer);
- if (pos != notFound)
- m_observers.remove(pos);
</del><ins>+ m_observers.removeFirst(&observer);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void AVAudioCaptureSource::start()
+{
+ startProducingData();
+}
+
</ins><span class="cx"> void AVAudioCaptureSource::setupCaptureSession()
</span><span class="cx"> {
</span><span class="cx"> RetainPtr<AVCaptureDeviceInputType> audioIn = adoptNS([allocAVCaptureDeviceInputInstance() initWithDevice:device() error:nil]);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAudioCaptureSourceProviderObjCh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/mac/AudioCaptureSourceProviderObjC.h (0 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AudioCaptureSourceProviderObjC.h         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/AudioCaptureSourceProviderObjC.h        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -0,0 +1,50 @@
</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 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 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(MEDIA_STREAM) && USE(AVFOUNDATION)
+
+typedef struct AudioStreamBasicDescription AudioStreamBasicDescription;
+typedef const struct opaqueCMFormatDescription *CMFormatDescriptionRef;
+typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
+
+namespace WebCore {
+
+class AudioSourceObserverObjC;
+
+class AudioCaptureSourceProviderObjC {
+public:
+ virtual ~AudioCaptureSourceProviderObjC() = default;
+
+ virtual void addObserver(AudioSourceObserverObjC&) = 0;
+ virtual void removeObserver(AudioSourceObserverObjC&) = 0;
+
+ virtual void start() = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAudioSourceObserverObjCh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/mac/AudioSourceObserverObjC.h (0 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AudioSourceObserverObjC.h         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/AudioSourceObserverObjC.h        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -0,0 +1,47 @@
</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 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 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(MEDIA_STREAM) && USE(AVFOUNDATION)
+
+typedef struct AudioStreamBasicDescription AudioStreamBasicDescription;
+typedef const struct opaqueCMFormatDescription *CMFormatDescriptionRef;
+typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
+
+namespace WebCore {
+
+class AudioSourceObserverObjC {
+public:
+ virtual ~AudioSourceObserverObjC() = default;
+
+ virtual void prepare(const AudioStreamBasicDescription*) = 0;
+ virtual void unprepare() = 0;
+ virtual void process(CMFormatDescriptionRef, CMSampleBufferRef) = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMachfromrev210741trunkSourceWebCoreplatformmockMockRealtimeAudioSourceh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h (from rev 210741, trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h) (0 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.h        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ * 3. Neither the name of Ericsson nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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(MEDIA_STREAM)
+
+#include "AudioCaptureSourceProviderObjC.h"
+#include "FontCascade.h"
+#include "MockRealtimeAudioSource.h"
+#include <CoreAudio/CoreAudioTypes.h>
+
+OBJC_CLASS AVAudioPCMBuffer;
+typedef struct AudioBufferList AudioBufferList;
+typedef struct OpaqueCMClock* CMClockRef;
+typedef const struct opaqueCMFormatDescription* CMFormatDescriptionRef;
+
+namespace WebCore {
+
+class WebAudioSourceProviderAVFObjC;
+
+class MockRealtimeAudioSourceMac final : public MockRealtimeAudioSource, public AudioCaptureSourceProviderObjC {
+public:
+
+ // AudioCaptureSourceProviderObjC
+ void addObserver(AudioSourceObserverObjC&) final;
+ void removeObserver(AudioSourceObserverObjC&) final;
+ void start() final;
+
+private:
+ friend class MockRealtimeAudioSource;
+ MockRealtimeAudioSourceMac(const String&);
+
+ bool applySampleRate(int) final;
+ bool applySampleSize(int) final { return false; }
+
+ void emitSampleBuffers(uint32_t);
+ void render(double) final;
+ void reconfigure();
+
+ AudioSourceProvider* audioSourceProvider() final;
+
+ size_t m_audioBufferListBufferSize { 0 };
+ std::unique_ptr<AudioBufferList> m_audioBufferList;
+
+ uint32_t m_maximiumFrameCount;
+ uint32_t m_sampleRate { 44100 };
+ double m_bytesPerFrame { sizeof(Float32) };
+
+ RetainPtr<CMFormatDescriptionRef> m_formatDescription;
+ AudioStreamBasicDescription m_streamFormat;
+ RefPtr<WebAudioSourceProviderAVFObjC> m_audioSourceProvider;
+ Vector<AudioSourceObserverObjC*> m_observers;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeAudioSourceMacmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm (0 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -0,0 +1,236 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+#import "config.h"
+#import "MockRealtimeAudioSourceMac.h"
+
+#if ENABLE(MEDIA_STREAM)
+#import "MediaConstraints.h"
+#import "MediaSampleAVFObjC.h"
+#import "NotImplemented.h"
+#import "RealtimeMediaSourceSettings.h"
+#import "WebAudioSourceProviderAVFObjC.h"
+#import <AVFoundation/AVAudioBuffer.h>
+#import <AudioToolbox/AudioConverter.h>
+#import <CoreAudio/CoreAudioTypes.h>
+
+#import "CoreMediaSoftLink.h"
+
+SOFT_LINK_FRAMEWORK(AudioToolbox)
+
+SOFT_LINK(AudioToolbox, AudioConverterNew, OSStatus, (const AudioStreamBasicDescription* inSourceFormat, const AudioStreamBasicDescription* inDestinationFormat, AudioConverterRef* outAudioConverter), (inSourceFormat, inDestinationFormat, outAudioConverter))
+
+namespace WebCore {
+
+RefPtr<MockRealtimeAudioSource> MockRealtimeAudioSource::create(const String& name, const MediaConstraints* constraints)
+{
+ auto source = adoptRef(new MockRealtimeAudioSourceMac(name));
+ if (constraints && source->applyConstraints(*constraints))
+ source = nullptr;
+
+ return source;
+}
+
+MockRealtimeAudioSourceMac::MockRealtimeAudioSourceMac(const String& name)
+ : MockRealtimeAudioSource(name)
+{
+}
+
+RefPtr<MockRealtimeAudioSource> MockRealtimeAudioSource::createMuted(const String& name)
+{
+ auto source = adoptRef(new MockRealtimeAudioSource(name));
+ source->m_muted = true;
+ return source;
+}
+
+void MockRealtimeAudioSourceMac::addObserver(AudioSourceObserverObjC& observer)
+{
+ m_observers.append(&observer);
+ if (m_streamFormat.mSampleRate)
+ observer.prepare(&m_streamFormat);
+}
+
+void MockRealtimeAudioSourceMac::removeObserver(AudioSourceObserverObjC& observer)
+{
+ m_observers.removeFirst(&observer);
+}
+
+void MockRealtimeAudioSourceMac::start()
+{
+ startProducingData();
+}
+
+
+void MockRealtimeAudioSourceMac::emitSampleBuffers(uint32_t frameCount)
+{
+ ASSERT(m_formatDescription);
+
+ CMTime startTime = CMTimeMake(elapsedTime() * m_sampleRate, m_sampleRate);
+ CMSampleBufferRef sampleBuffer;
+ OSStatus result = CMAudioSampleBufferCreateWithPacketDescriptions(nullptr, nullptr, true, nullptr, nullptr, m_formatDescription.get(), frameCount, startTime, nullptr, &sampleBuffer);
+ ASSERT(sampleBuffer);
+ ASSERT(!result);
+
+ if (!sampleBuffer)
+ return;
+
+ auto buffer = adoptCF(sampleBuffer);
+ result = CMSampleBufferSetDataBufferFromAudioBufferList(sampleBuffer, kCFAllocatorDefault, kCFAllocatorDefault, 0, m_audioBufferList.get());
+ ASSERT(!result);
+
+ result = CMSampleBufferSetDataReady(sampleBuffer);
+ ASSERT(!result);
+
+ mediaDataUpdated(MediaSampleAVFObjC::create(sampleBuffer));
+
+ for (auto& observer : m_observers)
+ observer->process(m_formatDescription.get(), sampleBuffer);
+}
+
+void MockRealtimeAudioSourceMac::reconfigure()
+{
+ m_maximiumFrameCount = WTF::roundUpToPowerOfTwo(renderInterval() / 1000. * m_sampleRate * 2);
+ ASSERT(m_maximiumFrameCount);
+
+ // AudioBufferList is a variable-length struct, so create on the heap with a generic new() operator
+ // with a custom size, and initialize the struct manually.
+ uint32_t bufferDataSize = m_bytesPerFrame * m_maximiumFrameCount;
+ uint32_t baseSize = offsetof(AudioBufferList, mBuffers) + sizeof(AudioBuffer);
+ uint64_t bufferListSize = baseSize + bufferDataSize;
+ ASSERT(bufferListSize <= SIZE_MAX);
+ if (bufferListSize > SIZE_MAX)
+ return;
+
+ m_audioBufferListBufferSize = static_cast<size_t>(bufferListSize);
+ m_audioBufferList = std::unique_ptr<AudioBufferList>(static_cast<AudioBufferList*>(::operator new (m_audioBufferListBufferSize)));
+ memset(m_audioBufferList.get(), 0, m_audioBufferListBufferSize);
+
+ m_audioBufferList->mNumberBuffers = 1;
+ auto& buffer = m_audioBufferList->mBuffers[0];
+ buffer.mNumberChannels = 1;
+ buffer.mDataByteSize = bufferDataSize;
+ buffer.mData = reinterpret_cast<uint8_t*>(m_audioBufferList.get()) + baseSize;
+
+ const int bytesPerFloat = sizeof(Float32);
+ const int bitsPerByte = 8;
+ m_streamFormat = { };
+ m_streamFormat.mSampleRate = m_sampleRate;
+ m_streamFormat.mFormatID = kAudioFormatLinearPCM;
+ m_streamFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked | kAudioFormatFlagIsNonInterleaved;
+ m_streamFormat.mBytesPerPacket = bytesPerFloat;
+ m_streamFormat.mFramesPerPacket = 1;
+ m_streamFormat.mBytesPerFrame = bytesPerFloat;
+ m_streamFormat.mChannelsPerFrame = 1;
+ m_streamFormat.mBitsPerChannel = bitsPerByte * bytesPerFloat;
+
+ CMFormatDescriptionRef formatDescription;
+ CMAudioFormatDescriptionCreate(NULL, &m_streamFormat, 0, NULL, 0, NULL, NULL, &formatDescription);
+ m_formatDescription = adoptCF(formatDescription);
+
+ for (auto& observer : m_observers)
+ observer->prepare(&m_streamFormat);
+}
+
+void MockRealtimeAudioSourceMac::render(double delta)
+{
+ static double theta;
+ static const double frequencies[] = { 1500., 500. };
+
+ if (!m_audioBufferList)
+ reconfigure();
+
+ uint32_t totalFrameCount = delta * m_sampleRate;
+ uint32_t frameCount = std::min(totalFrameCount, m_maximiumFrameCount);
+ double elapsed = elapsedTime();
+ while (frameCount) {
+ float *buffer = static_cast<float *>(m_audioBufferList->mBuffers[0].mData);
+ for (uint32_t frame = 0; frame < frameCount; ++frame) {
+ int phase = fmod(elapsed, 2) * 15;
+ double increment = 0;
+ bool silent = true;
+
+ switch (phase) {
+ case 0:
+ case 14: {
+ int index = fmod(elapsed, 1) * 2;
+ increment = 2.0 * M_PI * frequencies[index] / m_sampleRate;
+ silent = false;
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (silent) {
+ buffer[frame] = 0;
+ continue;
+ }
+
+ buffer[frame] = sin(theta) * 0.25;
+ theta += increment;
+ if (theta > 2.0 * M_PI)
+ theta -= 2.0 * M_PI;
+ elapsed += 1 / m_sampleRate;
+ }
+
+ m_audioBufferList->mBuffers[0].mDataByteSize = frameCount * sizeof(float);
+ emitSampleBuffers(frameCount);
+ totalFrameCount -= frameCount;
+ frameCount = std::min(totalFrameCount, m_maximiumFrameCount);
+ }
+}
+
+bool MockRealtimeAudioSourceMac::applySampleRate(int sampleRate)
+{
+ if (sampleRate < 44100 || sampleRate > 48000)
+ return false;
+
+ if (static_cast<uint32_t>(sampleRate) == m_sampleRate)
+ return true;
+
+ m_sampleRate = sampleRate;
+ m_formatDescription = nullptr;
+ m_audioBufferList = nullptr;
+ m_audioBufferListBufferSize = 0;
+
+ return true;
+}
+
+AudioSourceProvider* MockRealtimeAudioSourceMac::audioSourceProvider()
+{
+ if (!m_audioSourceProvider)
+ m_audioSourceProvider = WebAudioSourceProviderAVFObjC::create(*this);
+
+ return m_audioSourceProvider.get();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacWebAudioSourceProviderAVFObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.h        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -28,9 +28,9 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
</span><span class="cx">
</span><del>-#include "AVAudioCaptureSource.h"
</del><ins>+#include "AudioCaptureSourceProviderObjC.h"
+#include "AudioSourceObserverObjC.h"
</ins><span class="cx"> #include "AudioSourceProvider.h"
</span><del>-#include <wtf/Lock.h>
</del><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx">
</span><span class="lines">@@ -42,28 +42,24 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-class AVAudioCaptureSource;
</del><span class="cx"> class CARingBuffer;
</span><span class="cx">
</span><del>-class WebAudioSourceProviderAVFObjC : public RefCounted<WebAudioSourceProviderAVFObjC>, public AudioSourceProvider, public AVAudioCaptureSource::Observer {
</del><ins>+class WebAudioSourceProviderAVFObjC : public RefCounted<WebAudioSourceProviderAVFObjC>, public AudioSourceProvider, public AudioSourceObserverObjC {
</ins><span class="cx"> public:
</span><del>- static Ref<WebAudioSourceProviderAVFObjC> create(AVAudioCaptureSource&);
</del><ins>+ static Ref<WebAudioSourceProviderAVFObjC> create(AudioCaptureSourceProviderObjC&);
</ins><span class="cx"> virtual ~WebAudioSourceProviderAVFObjC();
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- WebAudioSourceProviderAVFObjC(AVAudioCaptureSource&);
</del><ins>+ WebAudioSourceProviderAVFObjC(AudioCaptureSourceProviderObjC&);
</ins><span class="cx">
</span><del>- void startProducingData();
- void stopProducingData();
-
</del><span class="cx"> // AudioSourceProvider
</span><span class="cx"> void provideInput(AudioBus*, size_t) override;
</span><span class="cx"> void setClient(AudioSourceProviderClient*) override;
</span><span class="cx">
</span><del>- // AVAudioCaptureSource::Observer
- void prepare(const AudioStreamBasicDescription *) override;
- void unprepare() override;
- void process(CMFormatDescriptionRef, CMSampleBufferRef) override;
</del><ins>+ // AudioSourceObserverObjC
+ void prepare(const AudioStreamBasicDescription *) final;
+ void unprepare() final;
+ void process(CMFormatDescriptionRef, CMSampleBufferRef) final;
</ins><span class="cx">
</span><span class="cx"> size_t m_listBufferSize { 0 };
</span><span class="cx"> std::unique_ptr<AudioBufferList> m_list;
</span><span class="lines">@@ -76,7 +72,7 @@
</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>- AVAudioCaptureSource* m_captureSource { nullptr };
</del><ins>+ AudioCaptureSourceProviderObjC* m_captureSource { nullptr };
</ins><span class="cx"> bool m_connected { false };
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacWebAudioSourceProviderAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/Source/WebCore/platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -53,12 +53,12 @@
</span><span class="cx">
</span><span class="cx"> static const double kRingBufferDuration = 1;
</span><span class="cx">
</span><del>-Ref<WebAudioSourceProviderAVFObjC> WebAudioSourceProviderAVFObjC::create(AVAudioCaptureSource& source)
</del><ins>+Ref<WebAudioSourceProviderAVFObjC> WebAudioSourceProviderAVFObjC::create(AudioCaptureSourceProviderObjC& 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(AVAudioCaptureSource& source)
</del><ins>+WebAudioSourceProviderAVFObjC::WebAudioSourceProviderAVFObjC(AudioCaptureSourceProviderObjC& source)
</ins><span class="cx"> : m_captureSource(&source)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -71,19 +71,9 @@
</span><span class="cx"> m_converter = nullptr;
</span><span class="cx"> }
</span><span class="cx"> if (m_connected)
</span><del>- m_captureSource->removeObserver(this);
</del><ins>+ m_captureSource->removeObserver(*this);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void WebAudioSourceProviderAVFObjC::startProducingData()
-{
- m_captureSource->startProducingData();
-}
-
-void WebAudioSourceProviderAVFObjC::stopProducingData()
-{
- m_captureSource->stopProducingData();
-}
-
</del><span class="cx"> void WebAudioSourceProviderAVFObjC::provideInput(AudioBus* bus, size_t framesToProcess)
</span><span class="cx"> {
</span><span class="cx"> if (!m_ringBuffer) {
</span><span class="lines">@@ -107,6 +97,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ASSERT(bus->numberOfChannels() == m_ringBuffer->channelCount());
</span><ins>+ if (bus->numberOfChannels() != m_ringBuffer->channelCount()) {
+ bus->zero();
+ return;
+ }
</ins><span class="cx">
</span><span class="cx"> for (unsigned i = 0; i < m_list->mNumberBuffers; ++i) {
</span><span class="cx"> AudioChannel& channel = *bus->channel(i);
</span><span class="lines">@@ -132,10 +126,10 @@
</span><span class="cx">
</span><span class="cx"> if (m_client && !m_connected) {
</span><span class="cx"> m_connected = true;
</span><del>- m_captureSource->addObserver(this);
- m_captureSource->startProducingData();
</del><ins>+ m_captureSource->addObserver(*this);
+ m_captureSource->start();
</ins><span class="cx"> } else if (!m_client && m_connected) {
</span><del>- m_captureSource->removeObserver(this);
</del><ins>+ m_captureSource->removeObserver(*this);
</ins><span class="cx"> m_connected = false;
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeAudioSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+#if !PLATFORM(MAC) && !PLATFORM(IOS)
</ins><span class="cx"> RefPtr<MockRealtimeAudioSource> MockRealtimeAudioSource::create(const String& name, const MediaConstraints* constraints)
</span><span class="cx"> {
</span><span class="cx"> auto source = adoptRef(new MockRealtimeAudioSource(name));
</span><span class="lines">@@ -55,9 +56,11 @@
</span><span class="cx"> source->m_muted = true;
</span><span class="cx"> return source;
</span><span class="cx"> }
</span><del>-
</del><ins>+#endif
+
</ins><span class="cx"> MockRealtimeAudioSource::MockRealtimeAudioSource(const String& name)
</span><span class="cx"> : MockRealtimeMediaSource(createCanonicalUUIDString(), RealtimeMediaSource::Audio, name)
</span><ins>+ , m_timer(RunLoop::current(), this, &MockRealtimeAudioSource::tick)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -82,6 +85,41 @@
</span><span class="cx"> supportedConstraints.setSupportsSampleRate(true);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void MockRealtimeAudioSource::startProducingData()
+{
+ MockRealtimeMediaSource::startProducingData();
+
+ m_startTime = monotonicallyIncreasingTime();
+ m_timer.startRepeating(std::chrono::milliseconds(renderInterval()));
+}
+
+void MockRealtimeAudioSource::stopProducingData()
+{
+ MockRealtimeMediaSource::stopProducingData();
+ m_timer.stop();
+ m_elapsedTime += monotonicallyIncreasingTime() - m_startTime;
+ m_startTime = NAN;
+}
+
+double MockRealtimeAudioSource::elapsedTime()
+{
+ if (std::isnan(m_startTime))
+ return m_elapsedTime;
+
+ return m_elapsedTime + (monotonicallyIncreasingTime() - m_startTime);
+}
+
+void MockRealtimeAudioSource::tick()
+{
+ if (std::isnan(m_lastRenderTime))
+ m_lastRenderTime = monotonicallyIncreasingTime();
+
+ double now = monotonicallyIncreasingTime();
+ double delta = now - m_lastRenderTime;
+ m_lastRenderTime = now;
+ render(delta);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(MEDIA_STREAM)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeAudioSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h (210741 => 210742)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h        2017-01-13 21:19:55 UTC (rev 210741)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h        2017-01-13 21:27:30 UTC (rev 210742)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -28,8 +28,7 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#ifndef MockRealtimeAudioSource_h
-#define MockRealtimeAudioSource_h
</del><ins>+#pragma once
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">
</span><span class="lines">@@ -36,6 +35,7 @@
</span><span class="cx"> #include "FontCascade.h"
</span><span class="cx"> #include "ImageBuffer.h"
</span><span class="cx"> #include "MockRealtimeMediaSource.h"
</span><ins>+#include <wtf/RunLoop.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -45,11 +45,19 @@
</span><span class="cx"> static RefPtr<MockRealtimeAudioSource> create(const String&, const MediaConstraints*);
</span><span class="cx"> static RefPtr<MockRealtimeAudioSource> createMuted(const String& name);
</span><span class="cx">
</span><del>- virtual ~MockRealtimeAudioSource() { }
</del><ins>+ virtual ~MockRealtimeAudioSource() = default;
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> MockRealtimeAudioSource(const String& name = ASCIILiteral("Mock audio device"));
</span><span class="cx">
</span><ins>+ void startProducingData() final;
+ void stopProducingData() final;
+
+ virtual void render(double) { }
+
+ double elapsedTime();
+ static int renderInterval() { return 125; }
+
</ins><span class="cx"> private:
</span><span class="cx">
</span><span class="cx"> bool applyVolume(double) override { return true; }
</span><span class="lines">@@ -60,10 +68,15 @@
</span><span class="cx"> void updateSettings(RealtimeMediaSourceSettings&) override;
</span><span class="cx"> void initializeCapabilities(RealtimeMediaSourceCapabilities&) override;
</span><span class="cx"> void initializeSupportedConstraints(RealtimeMediaSourceSupportedConstraints&) override;
</span><ins>+
+ void tick();
+
+ RunLoop::Timer<MockRealtimeAudioSource> m_timer;
+ double m_startTime { NAN };
+ double m_lastRenderTime { NAN };
+ double m_elapsedTime { 0 };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(MEDIA_STREAM)
</span><del>-
-#endif // MockRealtimeAudioSource_h
</del></span></pre>
</div>
</div>
</body>
</html>