<!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>[214027] trunk/Source</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/214027">214027</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2017-03-15 21:10:53 -0700 (Wed, 15 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Optionally capture audio in the UIProcess
https://bugs.webkit.org/show_bug.cgi?id=169609

Reviewed by Alex Christensen.

Source/WebCore:

Export some previously un-exported symbols from WebCore for use in WebKit2.

* WebCore.xcodeproj/project.pbxproj:
* platform/audio/WebAudioBufferList.h:
* platform/mediastream/RealtimeMediaSource.h:

Source/WebKit2:

Add a new class pair, UserMediaCaptureManager/Proxy, to allow a RealtimeMediaSource
requested in a WebProcess to be created in the UIProcess and push its audio data across the
process boundary to its clients in the WebProcess. Because these classes are clients of the
RealtimeMediaSourceCenter::singleton(), they must be a singleton in the WebProcess as well,
so they are attached to the WebProcess class in the web process and to WebProcessProxy in
the UIProcess.

* UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: Added.
(WebKit::UserMediaCaptureManagerProxy::SourceProxy::SourceProxy):
(WebKit::UserMediaCaptureManagerProxy::SourceProxy::~SourceProxy):
(WebKit::UserMediaCaptureManagerProxy::SourceProxy::source):
(WebKit::UserMediaCaptureManagerProxy::SourceProxy::description):
(WebKit::UserMediaCaptureManagerProxy::SourceProxy::numberOfFrames):
(WebKit::UserMediaCaptureManagerProxy::UserMediaCaptureManagerProxy):
(WebKit::UserMediaCaptureManagerProxy::~UserMediaCaptureManagerProxy):
(WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
(WebKit::UserMediaCaptureManagerProxy::startProducingData):
(WebKit::UserMediaCaptureManagerProxy::stopProducingData):
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
(WebKit::UserMediaCaptureManagerProxy::process):
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in: Added.
* WebProcess/cocoa/UserMediaCaptureManager.cpp: Added.
(WebKit::nextSessionID):
(WebKit::UserMediaCaptureManager::Source::Source):
(WebKit::UserMediaCaptureManager::Source::~Source):
(WebKit::UserMediaCaptureManager::Source::setCapabilities):
(WebKit::UserMediaCaptureManager::Source::setSettings):
(WebKit::UserMediaCaptureManager::Source::description):
(WebKit::UserMediaCaptureManager::Source::setStorage):
(WebKit::UserMediaCaptureManager::Source::setRingBufferFrameBounds):
(WebKit::UserMediaCaptureManager::Source::audioSamplesAvailable):
(WebKit::UserMediaCaptureManager::UserMediaCaptureManager):
(WebKit::UserMediaCaptureManager::~UserMediaCaptureManager):
(WebKit::UserMediaCaptureManager::supplementName):
(WebKit::UserMediaCaptureManager::initialize):
(WebKit::UserMediaCaptureManager::createMediaSourceForCaptureDeviceWithConstraints):
(WebKit::UserMediaCaptureManager::sourceStopped):
(WebKit::UserMediaCaptureManager::sourceMutedChanged):
(WebKit::UserMediaCaptureManager::sourceEnabledChanged):
(WebKit::UserMediaCaptureManager::sourceSettingsChanged):
(WebKit::UserMediaCaptureManager::storageChanged):
(WebKit::UserMediaCaptureManager::ringBufferFrameBoundsChanged):
(WebKit::UserMediaCaptureManager::audioSamplesAvailable):
(WebKit::UserMediaCaptureManager::startProducingData):
(WebKit::UserMediaCaptureManager::stopProducingData):
* WebProcess/cocoa/UserMediaCaptureManager.h: Added.
* WebProcess/cocoa/UserMediaCaptureManager.messages.in: Added.

Initialize UserMediaCaptureManager/Proxy:

* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::WebProcessProxy):
* UIProcess/WebProcessProxy.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):

WebUserMediaClientMac is no longer necessary now that the UserMediaCaptureManager overrides
the factories:

* WebProcess/WebCoreSupport/WebUserMediaClient.cpp:
(WebKit::WebUserMediaClient::WebUserMediaClient):
(WebKit::WebUserMediaClient::initializeFactories): Deleted.

Add a new preference and WebProcessCreationParameters member to control whether
capturing is done in the UIProcess:

* Shared/WebPreferencesDefinitions.h:
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:

Add new files to the project:

* DerivedSources.make:
* WebKit2.xcodeproj/project.pbxproj:</pre>

<h3>Modified Paths</h3>
<ul>
<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="#trunkSourceWebCoreplatformaudioWebAudioBufferListh">trunk/Source/WebCore/platform/audio/WebAudioBufferList.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiomacCAAudioStreamDescriptionh">trunk/Source/WebCore/platform/audio/mac/CAAudioStreamDescription.h</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiomacCARingBufferh">trunk/Source/WebCore/platform/audio/mac/CARingBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceh">trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2DerivedSourcesmake">trunk/Source/WebKit2/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPreferencesDefinitionsh">trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebProcessCreationParameterscpp">trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebProcessCreationParametersh">trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebProcessPoolCocoamm">trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessProxycpp">trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessProxyh">trunk/Source/WebKit2/UIProcess/WebProcessProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebUserMediaClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcesscpp">trunk/Source/WebKit2/WebProcess/WebProcess.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<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>Removed Paths</h3>
<ul>
<li>trunk/Source/WebKit2/WebProcess/WebCoreSupport/cocoa/</li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebCore/ChangeLog        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2017-03-15  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Optionally capture audio in the UIProcess
+        https://bugs.webkit.org/show_bug.cgi?id=169609
+
+        Reviewed by Alex Christensen.
+
+        Export some previously un-exported symbols from WebCore for use in WebKit2.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/audio/WebAudioBufferList.h:
+        * platform/mediastream/RealtimeMediaSource.h:
+
</ins><span class="cx"> 2017-03-15  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Do not reparent floating object until after intruding/overhanging dependency is cleared.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -6174,7 +6174,7 @@
</span><span class="cx">                 CDE595971BF26E2100A1CBE8 /* CDMSessionMediaSourceAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE595961BF26E2100A1CBE8 /* CDMSessionMediaSourceAVFObjC.h */; };
</span><span class="cx">                 CDE5959D1BF2757100A1CBE8 /* CDMSessionMediaSourceAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDE5959C1BF2757100A1CBE8 /* CDMSessionMediaSourceAVFObjC.mm */; };
</span><span class="cx">                 CDE667A41E4BBF1500E8154A /* WebAudioBufferList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDE667A21E4BBF1500E8154A /* WebAudioBufferList.cpp */; };
</span><del>-                CDE667A51E4BBF1500E8154A /* WebAudioBufferList.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE667A31E4BBF1500E8154A /* WebAudioBufferList.h */; };
</del><ins>+                CDE667A51E4BBF1500E8154A /* WebAudioBufferList.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE667A31E4BBF1500E8154A /* WebAudioBufferList.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 CDE7FC44181904B1002BBB77 /* OrderIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDE7FC42181904B1002BBB77 /* OrderIterator.cpp */; };
</span><span class="cx">                 CDE7FC45181904B1002BBB77 /* OrderIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE7FC43181904B1002BBB77 /* OrderIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 CDE83DB1183C44060031EAA3 /* VideoPlaybackQuality.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDE83DAF183C44060031EAA3 /* VideoPlaybackQuality.cpp */; };
</span><span class="lines">@@ -6191,6 +6191,7 @@
</span><span class="cx">                 CDEA7C851276230400B846DD /* RenderFullScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDEA7C831276230400B846DD /* RenderFullScreen.cpp */; };
</span><span class="cx">                 CDEE393717974259001D7580 /* PublicURLManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDEE393617974259001D7580 /* PublicURLManager.cpp */; };
</span><span class="cx">                 CDEF4FD717E85C8F00AEE24B /* GridLength.h in Headers */ = {isa = PBXBuildFile; fileRef = CDEF4FD617E85C8F00AEE24B /* GridLength.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                CDEFA2281E7669E8000AE99C /* PlatformAudioData.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE667A11E4BBA4D00E8154A /* PlatformAudioData.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 CDF2B004181F059C00F2B424 /* MediaDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF2B003181F059C00F2B424 /* MediaDescription.h */; };
</span><span class="cx">                 CDF2B0101820540600F2B424 /* MockBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDF2B0061820540600F2B424 /* MockBox.cpp */; };
</span><span class="cx">                 CDF2B0111820540600F2B424 /* MockBox.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF2B0071820540600F2B424 /* MockBox.h */; };
</span><span class="lines">@@ -27017,6 +27018,7 @@
</span><span class="cx">                                 FD31609912B026F700C1A359 /* HRTFDatabase.h in Headers */,
</span><span class="cx">                                 FD31609B12B026F700C1A359 /* HRTFDatabaseLoader.h in Headers */,
</span><span class="cx">                                 FD31609D12B026F700C1A359 /* HRTFElevation.h in Headers */,
</span><ins>+                                CDEFA2281E7669E8000AE99C /* PlatformAudioData.h in Headers */,
</ins><span class="cx">                                 FD31609F12B026F700C1A359 /* HRTFKernel.h in Headers */,
</span><span class="cx">                                 FD3160A112B026F700C1A359 /* HRTFPanner.h in Headers */,
</span><span class="cx">                                 BC97E23A109144950010D361 /* HTMLAllCollection.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudioWebAudioBufferListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/WebAudioBufferList.h (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/WebAudioBufferList.h        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebCore/platform/audio/WebAudioBufferList.h        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> class WebAudioBufferList : public PlatformAudioData {
</span><span class="cx"> public:
</span><span class="cx">     WebAudioBufferList(const CAAudioStreamDescription&amp;);
</span><del>-    WebAudioBufferList(const CAAudioStreamDescription&amp;, uint32_t sampleCount);
</del><ins>+    WEBCORE_EXPORT WebAudioBufferList(const CAAudioStreamDescription&amp;, uint32_t sampleCount);
</ins><span class="cx">     WebAudioBufferList(const CAAudioStreamDescription&amp;, CMSampleBufferRef);
</span><span class="cx"> 
</span><span class="cx">     AudioBufferList* list() const { return m_list.get(); }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiomacCAAudioStreamDescriptionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/mac/CAAudioStreamDescription.h (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/CAAudioStreamDescription.h        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebCore/platform/audio/mac/CAAudioStreamDescription.h        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -90,31 +90,13 @@
</span><span class="cx"> template&lt;class Encoder&gt;
</span><span class="cx"> void CAAudioStreamDescription::encode(Encoder&amp; encoder) const
</span><span class="cx"> {
</span><del>-    encoder &lt;&lt; m_streamDescription.mSampleRate
-        &lt;&lt; m_streamDescription.mFormatID
-        &lt;&lt; m_streamDescription.mFormatFlags
-        &lt;&lt; m_streamDescription.mBytesPerPacket
-        &lt;&lt; m_streamDescription.mFramesPerPacket
-        &lt;&lt; m_streamDescription.mBytesPerFrame
-        &lt;&lt; m_streamDescription.mChannelsPerFrame
-        &lt;&lt; m_streamDescription.mBitsPerChannel
-        &lt;&lt; m_streamDescription.mReserved;
-    encoder.encodeEnum(m_format);
</del><ins>+    encoder.encodeFixedLengthData(reinterpret_cast&lt;const uint8_t*&gt;(&amp;m_streamDescription), sizeof(m_streamDescription), 1);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;class Decoder&gt;
</span><span class="cx"> bool CAAudioStreamDescription::decode(Decoder&amp; decoder, CAAudioStreamDescription&amp; description)
</span><span class="cx"> {
</span><del>-    return decoder.decode(description.m_streamDescription.mSampleRate)
-        &amp;&amp; decoder.decode(description.m_streamDescription.mFormatID)
-        &amp;&amp; decoder.decode(description.m_streamDescription.mFormatFlags)
-        &amp;&amp; decoder.decode(description.m_streamDescription.mBytesPerPacket)
-        &amp;&amp; decoder.decode(description.m_streamDescription.mFramesPerPacket)
-        &amp;&amp; decoder.decode(description.m_streamDescription.mBytesPerFrame)
-        &amp;&amp; decoder.decode(description.m_streamDescription.mChannelsPerFrame)
-        &amp;&amp; decoder.decode(description.m_streamDescription.mBitsPerChannel)
-        &amp;&amp; decoder.decode(description.m_streamDescription.mReserved)
-        &amp;&amp; decoder.decodeEnum(description.m_format);
</del><ins>+    return decoder.decodeFixedLengthData(reinterpret_cast&lt;uint8_t*&gt;(&amp;description.m_streamDescription), sizeof(description.m_streamDescription), 1);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline CAAudioStreamDescription toCAAudioStreamDescription(const AudioStreamDescription&amp; description)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiomacCARingBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/mac/CARingBuffer.h (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/mac/CARingBuffer.h        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebCore/platform/audio/mac/CARingBuffer.h        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -85,6 +85,7 @@
</span><span class="cx">     WEBCORE_EXPORT void setCurrentFrameBounds(uint64_t startFrame, uint64_t endFrame);
</span><span class="cx"> 
</span><span class="cx">     uint32_t channelCount() const { return m_channelCount; }
</span><ins>+    CARingBufferStorage&amp; storage() { return m_buffers; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     size_t frameOffset(uint64_t frameNumber) { return (frameNumber &amp; m_frameCountMask) * m_bytesPerFrame; }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamRealtimeMediaSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx"> class PlatformAudioData;
</span><span class="cx"> class RealtimeMediaSourceSettings;
</span><span class="cx"> 
</span><del>-class RealtimeMediaSource : public RefCounted&lt;RealtimeMediaSource&gt; {
</del><ins>+class WEBCORE_EXPORT RealtimeMediaSource : public RefCounted&lt;RealtimeMediaSource&gt; {
</ins><span class="cx"> public:
</span><span class="cx">     class Observer {
</span><span class="cx">     public:
</span><span class="lines">@@ -200,6 +200,8 @@
</span><span class="cx">     virtual void applyConstraints(const FlattenedConstraint&amp;);
</span><span class="cx">     virtual void applySizeAndFrameRate(std::optional&lt;int&gt; width, std::optional&lt;int&gt; height, std::optional&lt;double&gt;);
</span><span class="cx"> 
</span><ins>+    const Vector&lt;Observer*&gt; observers() const { return m_observers; }
+
</ins><span class="cx">     bool m_muted { false };
</span><span class="cx">     bool m_enabled { true };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -1,3 +1,89 @@
</span><ins>+2017-03-15  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Optionally capture audio in the UIProcess
+        https://bugs.webkit.org/show_bug.cgi?id=169609
+
+        Reviewed by Alex Christensen.
+
+        Add a new class pair, UserMediaCaptureManager/Proxy, to allow a RealtimeMediaSource
+        requested in a WebProcess to be created in the UIProcess and push its audio data across the
+        process boundary to its clients in the WebProcess. Because these classes are clients of the
+        RealtimeMediaSourceCenter::singleton(), they must be a singleton in the WebProcess as well,
+        so they are attached to the WebProcess class in the web process and to WebProcessProxy in
+        the UIProcess.
+
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: Added.
+        (WebKit::UserMediaCaptureManagerProxy::SourceProxy::SourceProxy):
+        (WebKit::UserMediaCaptureManagerProxy::SourceProxy::~SourceProxy):
+        (WebKit::UserMediaCaptureManagerProxy::SourceProxy::source):
+        (WebKit::UserMediaCaptureManagerProxy::SourceProxy::description):
+        (WebKit::UserMediaCaptureManagerProxy::SourceProxy::numberOfFrames):
+        (WebKit::UserMediaCaptureManagerProxy::UserMediaCaptureManagerProxy):
+        (WebKit::UserMediaCaptureManagerProxy::~UserMediaCaptureManagerProxy):
+        (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
+        (WebKit::UserMediaCaptureManagerProxy::startProducingData):
+        (WebKit::UserMediaCaptureManagerProxy::stopProducingData):
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+        (WebKit::UserMediaCaptureManagerProxy::process):
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in: Added.
+        * WebProcess/cocoa/UserMediaCaptureManager.cpp: Added.
+        (WebKit::nextSessionID):
+        (WebKit::UserMediaCaptureManager::Source::Source):
+        (WebKit::UserMediaCaptureManager::Source::~Source):
+        (WebKit::UserMediaCaptureManager::Source::setCapabilities):
+        (WebKit::UserMediaCaptureManager::Source::setSettings):
+        (WebKit::UserMediaCaptureManager::Source::description):
+        (WebKit::UserMediaCaptureManager::Source::setStorage):
+        (WebKit::UserMediaCaptureManager::Source::setRingBufferFrameBounds):
+        (WebKit::UserMediaCaptureManager::Source::audioSamplesAvailable):
+        (WebKit::UserMediaCaptureManager::UserMediaCaptureManager):
+        (WebKit::UserMediaCaptureManager::~UserMediaCaptureManager):
+        (WebKit::UserMediaCaptureManager::supplementName):
+        (WebKit::UserMediaCaptureManager::initialize):
+        (WebKit::UserMediaCaptureManager::createMediaSourceForCaptureDeviceWithConstraints):
+        (WebKit::UserMediaCaptureManager::sourceStopped):
+        (WebKit::UserMediaCaptureManager::sourceMutedChanged):
+        (WebKit::UserMediaCaptureManager::sourceEnabledChanged):
+        (WebKit::UserMediaCaptureManager::sourceSettingsChanged):
+        (WebKit::UserMediaCaptureManager::storageChanged):
+        (WebKit::UserMediaCaptureManager::ringBufferFrameBoundsChanged):
+        (WebKit::UserMediaCaptureManager::audioSamplesAvailable):
+        (WebKit::UserMediaCaptureManager::startProducingData):
+        (WebKit::UserMediaCaptureManager::stopProducingData):
+        * WebProcess/cocoa/UserMediaCaptureManager.h: Added.
+        * WebProcess/cocoa/UserMediaCaptureManager.messages.in: Added.
+
+        Initialize UserMediaCaptureManager/Proxy:
+
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::WebProcessProxy):
+        * UIProcess/WebProcessProxy.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+
+        WebUserMediaClientMac is no longer necessary now that the UserMediaCaptureManager overrides
+        the factories:
+
+        * WebProcess/WebCoreSupport/WebUserMediaClient.cpp:
+        (WebKit::WebUserMediaClient::WebUserMediaClient):
+        (WebKit::WebUserMediaClient::initializeFactories): Deleted.
+
+        Add a new preference and WebProcessCreationParameters member to control whether
+        capturing is done in the UIProcess:
+
+        * Shared/WebPreferencesDefinitions.h:
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+
+        Add new files to the project:
+
+        * DerivedSources.make:
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2017-03-15  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Null deref under callAfterNextPresentationUpdate
</span></span></pre></div>
<a id="trunkSourceWebKit2DerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DerivedSources.make (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DerivedSources.make        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/DerivedSources.make        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx">     $(WebKit2)/WebProcess/Geolocation \
</span><span class="cx">     $(WebKit2)/WebProcess/IconDatabase \
</span><span class="cx">     $(WebKit2)/WebProcess/MediaCache \
</span><ins>+    $(WebKit2)/WebProcess/MediaStream \
</ins><span class="cx">     $(WebKit2)/WebProcess/Network \
</span><span class="cx">     $(WebKit2)/WebProcess/Network/webrtc \
</span><span class="cx">     $(WebKit2)/WebProcess/Notifications \
</span><span class="lines">@@ -65,6 +66,7 @@
</span><span class="cx">     $(WebKit2)/UIProcess/Cocoa \
</span><span class="cx">     $(WebKit2)/UIProcess/Databases \
</span><span class="cx">     $(WebKit2)/UIProcess/Downloads \
</span><ins>+    $(WebKit2)/UIProcess/MediaStream \
</ins><span class="cx">     $(WebKit2)/UIProcess/Network \
</span><span class="cx">     $(WebKit2)/UIProcess/Network/CustomProtocols \
</span><span class="cx">     $(WebKit2)/UIProcess/Notifications \
</span><span class="lines">@@ -121,6 +123,8 @@
</span><span class="cx">     SmartMagnificationController \
</span><span class="cx">     StorageAreaMap \
</span><span class="cx">     StorageManager \
</span><ins>+    UserMediaCaptureManager \
+    UserMediaCaptureManagerProxy \
</ins><span class="cx">     ViewGestureController \
</span><span class="cx">     ViewGestureGeometryCollector \
</span><span class="cx">     ViewUpdateDispatcher \
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPreferencesDefinitionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -103,6 +103,12 @@
</span><span class="cx"> #define DEFAULT_CANVAS_USES_ACCELERATED_DRAWING true
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(COCOA)
+#define DEFAULT_SHOULD_CAPTURE_AUDIO_IN_UIPROCESS true
+#else
+#define DEFAULT_SHOULD_CAPTURE_AUDIO_IN_UIPROCESS false
+#endif
+
</ins><span class="cx"> // macro(KeyUpper, KeyLower, TypeNameUpper, TypeName, DefaultValue, HumanReadableName, HumanReadableDescription)
</span><span class="cx"> 
</span><span class="cx"> #define FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
</span><span class="lines">@@ -252,6 +258,7 @@
</span><span class="cx">     macro(GamepadsEnabled, gamepadsEnabled, Bool, bool, true, &quot;Gamepads&quot;, &quot;Web Gamepad API support&quot;) \
</span><span class="cx">     macro(InputEventsEnabled, inputEventsEnabled, Bool, bool, true, &quot;Input Events&quot;, &quot;Enable InputEvents support&quot;) \
</span><span class="cx">     macro(CredentialManagementEnabled, credentialManagementEnabled, Bool, bool, false, &quot;Credential Management&quot;, &quot;Enable Credential Management support&quot;) \
</span><ins>+    macro(ShouldCaptureAudioInUIProcess, shouldCaptureAudioInUIProcess, Bool, bool, DEFAULT_SHOULD_CAPTURE_AUDIO_IN_UIPROCESS, &quot;Capture&quot;, &quot;Capture Audio in UIProcess&quot;) \
</ins><span class="cx">     \
</span><span class="cx"> 
</span><span class="cx"> #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebProcessCreationParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx">     encoder &lt;&lt; mediaKeyStorageDirectoryExtensionHandle;
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">     encoder &lt;&lt; audioCaptureExtensionHandle;
</span><ins>+    encoder &lt;&lt; shouldCaptureAudioInUIProcess;
</ins><span class="cx"> #endif
</span><span class="cx">     encoder &lt;&lt; shouldUseTestingNetworkSession;
</span><span class="cx">     encoder &lt;&lt; urlSchemesRegisteredAsEmptyDocument;
</span><span class="lines">@@ -189,6 +190,8 @@
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">     if (!decoder.decode(parameters.audioCaptureExtensionHandle))
</span><span class="cx">         return false;
</span><ins>+    if (!decoder.decode(parameters.shouldCaptureAudioInUIProcess))
+        return false;
</ins><span class="cx"> #endif
</span><span class="cx">     if (!decoder.decode(parameters.shouldUseTestingNetworkSession))
</span><span class="cx">         return false;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebProcessCreationParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -88,6 +88,7 @@
</span><span class="cx">     SandboxExtension::Handle mediaKeyStorageDirectoryExtensionHandle;
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><span class="cx">     SandboxExtension::Handle audioCaptureExtensionHandle;
</span><ins>+    bool shouldCaptureAudioInUIProcess { false };
</ins><span class="cx"> #endif
</span><span class="cx">     String mediaKeyStorageDirectory;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUserMediaCaptureManagerProxycpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp (0 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -0,0 +1,154 @@
</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. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;UserMediaCaptureManagerProxy.h&quot;
+
+#if PLATFORM(COCOA) &amp;&amp; ENABLE(MEDIA_STREAM)
+
+#include &quot;SharedRingBufferStorage.h&quot;
+#include &quot;UserMediaCaptureManagerMessages.h&quot;
+#include &quot;WebCoreArgumentCoders.h&quot;
+#include &quot;WebProcessProxy.h&quot;
+#include &lt;WebCore/CARingBuffer.h&gt;
+#include &lt;WebCore/MediaConstraintsImpl.h&gt;
+#include &lt;WebCore/RealtimeMediaSourceCenter.h&gt;
+#include &lt;WebCore/WebAudioBufferList.h&gt;
+#include &lt;wtf/UniqueRef.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class UserMediaCaptureManagerProxy::SourceProxy : public RealtimeMediaSource::Observer, public SharedRingBufferStorage::Client {
+public:
+    SourceProxy(uint64_t id, UserMediaCaptureManagerProxy&amp; manager, Ref&lt;RealtimeMediaSource&gt;&amp;&amp; source)
+        : m_id(id)
+        , m_manager(manager)
+        , m_source(WTFMove(source))
+        , m_ringBuffer(makeUniqueRef&lt;SharedRingBufferStorage&gt;(makeUniqueRef&lt;SharedRingBufferStorage&gt;(this)))
+    {
+        m_source-&gt;addObserver(*this);
+    }
+
+    ~SourceProxy()
+    {
+        storage().invalidate();
+        m_source-&gt;removeObserver(*this);
+    }
+
+    RealtimeMediaSource&amp; source() { return m_source; }
+    SharedRingBufferStorage&amp; storage() { return static_cast&lt;SharedRingBufferStorage&amp;&gt;(m_ringBuffer.storage()); }
+    CAAudioStreamDescription&amp; description() { return m_description; }
+    int64_t numberOfFrames() { return m_numberOfFrames; }
+
+    void sourceStopped() final {
+        m_manager.process().send(Messages::UserMediaCaptureManager::SourceStopped(m_id), 0);
+    }
+
+    void sourceMutedChanged() final {
+        m_manager.process().send(Messages::UserMediaCaptureManager::SourceMutedChanged(m_id, m_source-&gt;muted()), 0);
+    }
+
+    void sourceEnabledChanged() final {
+        m_manager.process().send(Messages::UserMediaCaptureManager::SourceEnabledChanged(m_id, m_source-&gt;enabled()), 0);
+    }
+
+    void sourceSettingsChanged() final {
+        m_manager.process().send(Messages::UserMediaCaptureManager::SourceSettingsChanged(m_id, m_source-&gt;settings()), 0);
+    }
+
+    void audioSamplesAvailable(const MediaTime&amp; time, const PlatformAudioData&amp; audioData, const AudioStreamDescription&amp; description, size_t numberOfFrames) final {
+        if (m_description != description) {
+            ASSERT(description.platformDescription().type == PlatformDescription::CAAudioStreamBasicType);
+            m_description = *WTF::get&lt;const AudioStreamBasicDescription*&gt;(description.platformDescription().description);
+
+            // Allocate a ring buffer large enough to contain 2 seconds of audio.
+            m_numberOfFrames = m_description.sampleRate() * 2;
+            m_ringBuffer.allocate(m_description.streamDescription(), m_numberOfFrames);
+        }
+
+        ASSERT(is&lt;WebAudioBufferList&gt;(audioData));
+        m_ringBuffer.store(downcast&lt;WebAudioBufferList&gt;(audioData).list(), numberOfFrames, time.timeValue());
+        uint64_t startFrame;
+        uint64_t endFrame;
+        m_ringBuffer.getCurrentFrameBounds(startFrame, endFrame);
+        m_manager.process().send(Messages::UserMediaCaptureManager::AudioSamplesAvailable(m_id, time, numberOfFrames, startFrame, endFrame), 0);
+    }
+
+    void storageChanged(SharedMemory* storage) final {
+        SharedMemory::Handle handle;
+        if (storage)
+            storage-&gt;createHandle(handle, SharedMemory::Protection::ReadOnly);
+        m_manager.process().send(Messages::UserMediaCaptureManager::StorageChanged(m_id, handle, m_description, m_numberOfFrames), 0);
+    }
+
+protected:
+    uint64_t m_id;
+    UserMediaCaptureManagerProxy&amp; m_manager;
+    Ref&lt;RealtimeMediaSource&gt; m_source;
+    CARingBuffer m_ringBuffer;
+    CAAudioStreamDescription m_description { };
+    int64_t m_numberOfFrames { 0 };
+};
+
+UserMediaCaptureManagerProxy::UserMediaCaptureManagerProxy(WebProcessProxy&amp; process)
+    : m_process(process)
+{
+    m_process.addMessageReceiver(Messages::UserMediaCaptureManagerProxy::messageReceiverName(), *this);
+}
+
+UserMediaCaptureManagerProxy::~UserMediaCaptureManagerProxy()
+{
+    m_process.removeMessageReceiver(Messages::UserMediaCaptureManagerProxy::messageReceiverName());
+}
+
+void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const CaptureDevice&amp; device, const MediaConstraintsData&amp; constraintsData, bool&amp; succeeded, String&amp; invalidConstraints)
+{
+    auto constraints = MediaConstraintsImpl::create(constraintsData);
+    RefPtr&lt;RealtimeMediaSource&gt; source = RealtimeMediaSourceCenter::singleton().defaultAudioFactory()-&gt;createMediaSourceForCaptureDeviceWithConstraints(device, constraints.ptr(), invalidConstraints);
+    succeeded = !!source;
+    
+    if (source)
+        m_proxies.set(id, std::make_unique&lt;SourceProxy&gt;(id, *this, source.releaseNonNull()));
+}
+
+void UserMediaCaptureManagerProxy::startProducingData(uint64_t id)
+{
+    auto iter = m_proxies.find(id);
+    if (iter != m_proxies.end())
+        iter-&gt;value-&gt;source().startProducingData();
+}
+
+void UserMediaCaptureManagerProxy::stopProducingData(uint64_t id)
+{
+    auto iter = m_proxies.find(id);
+    if (iter != m_proxies.end())
+        iter-&gt;value-&gt;source().stopProducingData();
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUserMediaCaptureManagerProxyhfromrev214026trunkSourceWebKit2WebProcessWebCoreSupportcocoaWebUserMediaClientMacmm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h (from rev 214026, trunk/Source/WebKit2/WebProcess/WebCoreSupport/cocoa/WebUserMediaClientMac.mm) (0 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -0,0 +1,64 @@
</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. AND ITS 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 APPLE INC. OR ITS 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 PLATFORM(COCOA) &amp;&amp; ENABLE(MEDIA_STREAM)
+
+#include &quot;Connection.h&quot;
+#include &quot;MessageReceiver.h&quot;
+#include &quot;UserMediaCaptureManagerProxyMessages.h&quot;
+#include &lt;WebCore/RealtimeMediaSource.h&gt;
+
+namespace WebKit {
+
+class SharedMemory;
+class WebProcessProxy;
+
+class UserMediaCaptureManagerProxy : private IPC::MessageReceiver {
+public:
+    UserMediaCaptureManagerProxy(WebProcessProxy&amp;);
+    ~UserMediaCaptureManagerProxy();
+
+    WebProcessProxy&amp; process() const { return m_process; }
+
+private:
+    // IPC::MessageReceiver
+    void didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;) final;
+    void didReceiveSyncMessage(IPC::Connection&amp;, IPC::Decoder&amp;, std::unique_ptr&lt;IPC::Encoder&gt;&amp;) final;
+
+    void createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const WebCore::CaptureDevice&amp;, const WebCore::MediaConstraintsData&amp;, bool&amp; succeeded, String&amp; invalidConstraints);
+    void startProducingData(uint64_t);
+    void stopProducingData(uint64_t);
+
+    class SourceProxy;
+    friend class SourceProxy;
+    HashMap&lt;uint64_t, std::unique_ptr&lt;SourceProxy&gt;&gt; m_proxies;
+    WebProcessProxy&amp; m_process;
+};
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUserMediaCaptureManagerProxymessagesin"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in (0 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -0,0 +1,28 @@
</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. AND ITS 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 APPLE INC. OR ITS 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.
+
+messages -&gt; UserMediaCaptureManagerProxy {
+    CreateMediaSourceForCaptureDeviceWithConstraints(uint64_t id, WebCore::CaptureDevice device, struct WebCore::MediaConstraintsData constraints) -&gt; (bool success, String invalidConstraints)
+    StartProducingData(uint64_t id)
+    StopProducingData(uint64_t id)
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebProcessPoolCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -258,6 +258,8 @@
</span><span class="cx">     // FIXME: Remove this and related parameter when &lt;rdar://problem/29448368&gt; is fixed.
</span><span class="cx">     if (mediaStreamEnabled || webRTCEnabled)
</span><span class="cx">         SandboxExtension::createHandleForGenericExtension(&quot;com.apple.webkit.microphone&quot;, parameters.audioCaptureExtensionHandle);
</span><ins>+
+    parameters.shouldCaptureAudioInUIProcess = m_defaultPageGroup-&gt;preferences().shouldCaptureAudioInUIProcess();
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> #include &quot;ObjCObjectGraph.h&quot;
</span><span class="cx"> #include &quot;PDFPlugin.h&quot;
</span><ins>+#include &quot;UserMediaCaptureManagerProxy.h&quot;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SEC_ITEM_SHIM)
</span><span class="lines">@@ -104,9 +105,14 @@
</span><span class="cx">     , m_isResponsive(NoOrMaybe::Maybe)
</span><span class="cx">     , m_visiblePageCounter([this](RefCounterEvent) { updateBackgroundResponsivenessTimer(); })
</span><span class="cx">     , m_websiteDataStore(websiteDataStore)
</span><ins>+#if PLATFORM(COCOA) &amp;&amp; ENABLE(MEDIA_STREAM)
+    , m_userMediaCaptureManagerProxy(std::make_unique&lt;UserMediaCaptureManagerProxy&gt;(*this))
+#endif
</ins><span class="cx"> {
</span><span class="cx">     WebPasteboardProxy::singleton().addWebProcessProxy(*this);
</span><span class="cx"> 
</span><ins>+
+
</ins><span class="cx">     connect();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class NetworkProcessProxy;
</span><ins>+class UserMediaCaptureManagerProxy;
</ins><span class="cx"> class WebBackForwardListItem;
</span><span class="cx"> class WebPageGroup;
</span><span class="cx"> class WebProcessPool;
</span><span class="lines">@@ -273,6 +274,10 @@
</span><span class="cx">     RefPtr&lt;WebsiteDataStore&gt; m_websiteDataStore;
</span><span class="cx"> 
</span><span class="cx">     bool m_isUnderMemoryPressure { false };
</span><ins>+
+#if PLATFORM(COCOA) &amp;&amp; ENABLE(MEDIA_STREAM)
+    std::unique_ptr&lt;UserMediaCaptureManagerProxy&gt; m_userMediaCaptureManagerProxy;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -1878,11 +1878,18 @@
</span><span class="cx">                 CD003A5319D49B5D005ABCE0 /* WebMediaKeyStorageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CD003A5119D49B5D005ABCE0 /* WebMediaKeyStorageManager.h */; };
</span><span class="cx">                 CD19A26D1A13E82A008D650E /* WebDiagnosticLoggingClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD19A2691A13E820008D650E /* WebDiagnosticLoggingClient.cpp */; };
</span><span class="cx">                 CD19A26E1A13E834008D650E /* WebDiagnosticLoggingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19A26A1A13E821008D650E /* WebDiagnosticLoggingClient.h */; };
</span><ins>+                CD491B071E70D05F00009066 /* UserMediaCaptureManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD491B051E70D05F00009066 /* UserMediaCaptureManager.cpp */; };
+                CD491B081E70D05F00009066 /* UserMediaCaptureManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CD491B061E70D05F00009066 /* UserMediaCaptureManager.h */; };
+                CD491B0D1E732E4D00009066 /* UserMediaCaptureManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD491B0B1E732E4D00009066 /* UserMediaCaptureManagerMessageReceiver.cpp */; };
+                CD491B0E1E732E4D00009066 /* UserMediaCaptureManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = CD491B0C1E732E4D00009066 /* UserMediaCaptureManagerMessages.h */; };
+                CD491B121E73482100009066 /* UserMediaCaptureManagerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD491B101E73482100009066 /* UserMediaCaptureManagerProxy.cpp */; };
+                CD491B131E73482100009066 /* UserMediaCaptureManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = CD491B111E73482100009066 /* UserMediaCaptureManagerProxy.h */; };
+                CD491B171E73525500009066 /* UserMediaCaptureManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD491B151E73525500009066 /* UserMediaCaptureManagerProxyMessageReceiver.cpp */; };
+                CD491B181E73525500009066 /* UserMediaCaptureManagerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = CD491B161E73525500009066 /* UserMediaCaptureManagerProxyMessages.h */; };
</ins><span class="cx">                 CD4B4D9C1E765E0000D27092 /* SharedRingBufferStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD4B4D9A1E765E0000D27092 /* SharedRingBufferStorage.cpp */; };
</span><span class="cx">                 CD4B4D9D1E765E0000D27092 /* SharedRingBufferStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = CD4B4D9B1E765E0000D27092 /* SharedRingBufferStorage.h */; };
</span><span class="cx">                 CD5C66A0134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5C669E134B9D36004FE2A8 /* InjectedBundlePageFullScreenClient.cpp */; };
</span><span class="cx">                 CD5C66A1134B9D38004FE2A8 /* InjectedBundlePageFullScreenClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5C669F134B9D37004FE2A8 /* InjectedBundlePageFullScreenClient.h */; };
</span><del>-                CD6178141E6DE9A000FDA57D /* WebUserMediaClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD6178121E6DE9A000FDA57D /* WebUserMediaClientMac.mm */; };
</del><span class="cx">                 CD6F75F4131B66D000D6B21E /* WebFullScreenManagerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA3E131A2E8A00EEDED2 /* WebFullScreenManagerProxy.cpp */; };
</span><span class="cx">                 CD73BA47131ACC9A00EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA45131ACC8800EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp */; };
</span><span class="cx">                 CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */; };
</span><span class="lines">@@ -4165,11 +4172,20 @@
</span><span class="cx">                 CD003A5119D49B5D005ABCE0 /* WebMediaKeyStorageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebMediaKeyStorageManager.h; path = MediaCache/WebMediaKeyStorageManager.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD19A2691A13E820008D650E /* WebDiagnosticLoggingClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebDiagnosticLoggingClient.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD19A26A1A13E821008D650E /* WebDiagnosticLoggingClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDiagnosticLoggingClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                CD491B051E70D05F00009066 /* UserMediaCaptureManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaCaptureManager.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD491B061E70D05F00009066 /* UserMediaCaptureManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaCaptureManager.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD491B0A1E732D1200009066 /* UserMediaCaptureManager.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = UserMediaCaptureManager.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD491B0B1E732E4D00009066 /* UserMediaCaptureManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaCaptureManagerMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD491B0C1E732E4D00009066 /* UserMediaCaptureManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaCaptureManagerMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD491B101E73482100009066 /* UserMediaCaptureManagerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserMediaCaptureManagerProxy.cpp; path = ../Cocoa/UserMediaCaptureManagerProxy.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD491B111E73482100009066 /* UserMediaCaptureManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserMediaCaptureManagerProxy.h; path = ../Cocoa/UserMediaCaptureManagerProxy.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD491B141E7349F300009066 /* UserMediaCaptureManagerProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = UserMediaCaptureManagerProxy.messages.in; path = ../Cocoa/UserMediaCaptureManagerProxy.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD491B151E73525500009066 /* UserMediaCaptureManagerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaCaptureManagerProxyMessageReceiver.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CD491B161E73525500009066 /* UserMediaCaptureManagerProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaCaptureManagerProxyMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 CD4B4D9A1E765E0000D27092 /* SharedRingBufferStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedRingBufferStorage.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD4B4D9B1E765E0000D27092 /* SharedRingBufferStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedRingBufferStorage.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD5C669E134B9D36004FE2A8 /* InjectedBundlePageFullScreenClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageFullScreenClient.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD5C669F134B9D37004FE2A8 /* InjectedBundlePageFullScreenClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageFullScreenClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                CD6178121E6DE9A000FDA57D /* WebUserMediaClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebUserMediaClientMac.mm; path = cocoa/WebUserMediaClientMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 CD73BA37131A29FE00EEDED2 /* WebFullScreenManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebFullScreenManager.cpp; path = FullScreen/WebFullScreenManager.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD73BA38131A29FE00EEDED2 /* WebFullScreenManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebFullScreenManager.h; path = FullScreen/WebFullScreenManager.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CD73BA39131A29FE00EEDED2 /* WebFullScreenManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebFullScreenManager.messages.in; path = FullScreen/WebFullScreenManager.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -6277,6 +6293,9 @@
</span><span class="cx">                 7C6E70F818B2D47E00F24E2E /* cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                CD491B051E70D05F00009066 /* UserMediaCaptureManager.cpp */,
+                                CD491B061E70D05F00009066 /* UserMediaCaptureManager.h */,
+                                CD491B0A1E732D1200009066 /* UserMediaCaptureManager.messages.in */,
</ins><span class="cx">                                 CDA29A191CBDBF4100901CCF /* WebPlaybackSessionManager.h */,
</span><span class="cx">                                 CDA29A1C1CBDBF5B00901CCF /* WebPlaybackSessionManager.messages.in */,
</span><span class="cx">                                 CDA29A181CBDBF4100901CCF /* WebPlaybackSessionManager.mm */,
</span><span class="lines">@@ -7444,6 +7463,9 @@
</span><span class="cx">                                 1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */,
</span><span class="cx">                                 1AF05D8514688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.h */,
</span><span class="cx">                                 1AF05D8414688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.mm */,
</span><ins>+                                CD491B101E73482100009066 /* UserMediaCaptureManagerProxy.cpp */,
+                                CD491B111E73482100009066 /* UserMediaCaptureManagerProxy.h */,
+                                CD491B141E7349F300009066 /* UserMediaCaptureManagerProxy.messages.in */,
</ins><span class="cx">                                 2D125C5D1857EA05003BA3CB /* ViewGestureControllerMac.mm */,
</span><span class="cx">                                 2D6CD117189058A500E5A4A0 /* ViewSnapshotStore.h */,
</span><span class="cx">                                 2D6CD118189058A500E5A4A0 /* ViewSnapshotStore.mm */,
</span><span class="lines">@@ -7689,6 +7711,10 @@
</span><span class="cx">                                 1A334DEC16DE8F88006A8E38 /* StorageAreaMapMessages.h */,
</span><span class="cx">                                 1AB31A9416BC688100F6DBC9 /* StorageManagerMessageReceiver.cpp */,
</span><span class="cx">                                 1AB31A9516BC688100F6DBC9 /* StorageManagerMessages.h */,
</span><ins>+                                CD491B151E73525500009066 /* UserMediaCaptureManagerProxyMessageReceiver.cpp */,
+                                CD491B161E73525500009066 /* UserMediaCaptureManagerProxyMessages.h */,
+                                CD491B0B1E732E4D00009066 /* UserMediaCaptureManagerMessageReceiver.cpp */,
+                                CD491B0C1E732E4D00009066 /* UserMediaCaptureManagerMessages.h */,
</ins><span class="cx">                                 2D1B5D5B185869C8006C6596 /* ViewGestureControllerMessageReceiver.cpp */,
</span><span class="cx">                                 2D1B5D5C185869C8006C6596 /* ViewGestureControllerMessages.h */,
</span><span class="cx">                                 2D819B9F1862800E001F03D1 /* ViewGestureGeometryCollectorMessageReceiver.cpp */,
</span><span class="lines">@@ -7820,7 +7846,6 @@
</span><span class="cx">                 CD6178111E6DE98000FDA57D /* cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><del>-                                CD6178121E6DE9A000FDA57D /* WebUserMediaClientMac.mm */,
</del><span class="cx">                         );
</span><span class="cx">                         name = cocoa;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -8038,6 +8063,7 @@
</span><span class="cx">                                 7C2413031AACFA7500A58C15 /* _WKUserContentExtensionStore.h in Headers */,
</span><span class="cx">                                 7C2413051AACFA9C00A58C15 /* _WKUserContentExtensionStoreInternal.h in Headers */,
</span><span class="cx">                                 7CA3793E1AC378B30079DC37 /* _WKUserContentExtensionStorePrivate.h in Headers */,
</span><ins>+                                CD491B131E73482100009066 /* UserMediaCaptureManagerProxy.h in Headers */,
</ins><span class="cx">                                 7C89D2BA1A6B0F2C003A5FDE /* _WKUserContentFilter.h in Headers */,
</span><span class="cx">                                 7C89D2BC1A6B0F5B003A5FDE /* _WKUserContentFilterInternal.h in Headers */,
</span><span class="cx">                                 5CD286531E7235AA0094FDC8 /* _WKUserContentFilterPrivate.h in Headers */,
</span><span class="lines">@@ -8045,6 +8071,7 @@
</span><span class="cx">                                 7C882DF91C7E996F006BF731 /* _WKUserContentWorldInternal.h in Headers */,
</span><span class="cx">                                 7CB365AA1D31DB70007158CA /* _WKUserInitiatedAction.h in Headers */,
</span><span class="cx">                                 7CB365AD1D31DC10007158CA /* _WKUserInitiatedActionInternal.h in Headers */,
</span><ins>+                                CD491B0E1E732E4D00009066 /* UserMediaCaptureManagerMessages.h in Headers */,
</ins><span class="cx">                                 2D87861D1BDB54BF00D02ABB /* _WKUserStyleSheet.h in Headers */,
</span><span class="cx">                                 2D8786201BDB57F500D02ABB /* _WKUserStyleSheetInternal.h in Headers */,
</span><span class="cx">                                 1A81B38118BD66AD0007FDAC /* _WKVisitedLinkStore.h in Headers */,
</span><span class="lines">@@ -8090,6 +8117,7 @@
</span><span class="cx">                                 1A2464F31891E45100234C5B /* APILoaderClient.h in Headers */,
</span><span class="cx">                                 7CD3A4831A5D02FA009623B8 /* APINavigation.h in Headers */,
</span><span class="cx">                                 2DF9EEEC1A7836EE00B6CFBE /* APINavigationAction.h in Headers */,
</span><ins>+                                CD491B081E70D05F00009066 /* UserMediaCaptureManager.h in Headers */,
</ins><span class="cx">                                 2DD9EB2D1A6F012500BB1267 /* APINavigationClient.h in Headers */,
</span><span class="cx">                                 BCF69FA21176D01400471A52 /* APINavigationData.h in Headers */,
</span><span class="cx">                                 2DF9EEEE1A786EAD00B6CFBE /* APINavigationResponse.h in Headers */,
</span><span class="lines">@@ -8415,6 +8443,7 @@
</span><span class="cx">                                 E18E690C169B563F009B6670 /* SecItemShimProxy.h in Headers */,
</span><span class="cx">                                 E18E6918169B667B009B6670 /* SecItemShimProxyMessages.h in Headers */,
</span><span class="cx">                                 514D9F5719119D35000063A7 /* ServicesController.h in Headers */,
</span><ins>+                                CD491B181E73525500009066 /* UserMediaCaptureManagerProxyMessages.h in Headers */,
</ins><span class="cx">                                 1AFDE65A1954A42B00C48FFA /* SessionState.h in Headers */,
</span><span class="cx">                                 1A002D49196B345D00B9AD44 /* SessionStateCoding.h in Headers */,
</span><span class="cx">                                 753E3E0E1887398900188496 /* SessionTracker.h in Headers */,
</span><span class="lines">@@ -9594,6 +9623,7 @@
</span><span class="cx">                                 373D122218A473010066D9CC /* _WKFrameHandle.mm in Sources */,
</span><span class="cx">                                 93A88B391BC70F3F00ABA5C2 /* _WKHitTestResult.mm in Sources */,
</span><span class="cx">                                 510F59121DDE297700412FF5 /* _WKLinkIconParameters.mm in Sources */,
</span><ins>+                                CD491B0D1E732E4D00009066 /* UserMediaCaptureManagerMessageReceiver.cpp in Sources */,
</ins><span class="cx">                                 A118A9F21908B8EA00F7C92B /* _WKNSFileManagerExtras.mm in Sources */,
</span><span class="cx">                                 1A43E829188F3CDC009E4D30 /* _WKProcessPoolConfiguration.mm in Sources */,
</span><span class="cx">                                 1A9E328E182165A900F5D04C /* _WKRemoteObjectInterface.mm in Sources */,
</span><span class="lines">@@ -9630,6 +9660,7 @@
</span><span class="cx">                                 51D124911E74BF3C002B2820 /* APIHTTPCookieStore.cpp in Sources */,
</span><span class="cx">                                 7CD3A4821A5D02FA009623B8 /* APINavigation.cpp in Sources */,
</span><span class="cx">                                 BCF69FA31176D01400471A52 /* APINavigationData.cpp in Sources */,
</span><ins>+                                CD491B171E73525500009066 /* UserMediaCaptureManagerProxyMessageReceiver.cpp in Sources */,
</ins><span class="cx">                                 B63403F914910D57001070B5 /* APIObject.cpp in Sources */,
</span><span class="cx">                                 378E1A3D181ED6FF0031007A /* APIObject.mm in Sources */,
</span><span class="cx">                                 BC857FB612B830E600EDEB2E /* APIOpenPanelParameters.cpp in Sources */,
</span><span class="lines">@@ -9652,6 +9683,7 @@
</span><span class="cx">                                 1A3635A91A3144A300ED6197 /* APIWebsiteDataStore.cpp in Sources */,
</span><span class="cx">                                 1A3635AD1A3145E500ED6197 /* APIWebsiteDataStoreCocoa.mm in Sources */,
</span><span class="cx">                                 5CB237911DF0E2E600117AA3 /* APIWebsitePolicies.cpp in Sources */,
</span><ins>+                                CD491B121E73482100009066 /* UserMediaCaptureManagerProxy.cpp in Sources */,
</ins><span class="cx">                                 1A6563E41B7A8C50009CF787 /* APIWindowFeatures.cpp in Sources */,
</span><span class="cx">                                 1AD4C1921B39F33200ABC28E /* ApplicationStateTracker.mm in Sources */,
</span><span class="cx">                                 1A3D610513A7F03A00F95D4E /* ArgumentCoders.cpp in Sources */,
</span><span class="lines">@@ -10178,6 +10210,7 @@
</span><span class="cx">                                 7C4694D01A51E36800AD5845 /* WebPasteboardProxy.cpp in Sources */,
</span><span class="cx">                                 7C4694CC1A4B510A00AD5845 /* WebPasteboardProxyCocoa.mm in Sources */,
</span><span class="cx">                                 7C4694C91A4B4EA100AD5845 /* WebPasteboardProxyMessageReceiver.cpp in Sources */,
</span><ins>+                                CD491B071E70D05F00009066 /* UserMediaCaptureManager.cpp in Sources */,
</ins><span class="cx">                                 1AB1F7741D1B2F8A007C9BD1 /* WebPaymentCoordinator.cpp in Sources */,
</span><span class="cx">                                 1AB1F7961D1B3613007C9BD1 /* WebPaymentCoordinatorMessageReceiver.cpp in Sources */,
</span><span class="cx">                                 1AB1F78B1D1B3355007C9BD1 /* WebPaymentCoordinatorProxy.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebUserMediaClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.cpp (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.cpp        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.cpp        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -33,7 +33,6 @@
</span><span class="cx"> WebUserMediaClient::WebUserMediaClient(WebPage&amp; page)
</span><span class="cx">     : m_page(page)
</span><span class="cx"> {
</span><del>-    initializeFactories();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebUserMediaClient::pageDestroyed()
</span><span class="lines">@@ -61,13 +60,6 @@
</span><span class="cx">     m_page.userMediaPermissionRequestManager().cancelMediaDevicesEnumeration(request);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if !PLATFORM(COCOA)
-void WebUserMediaClient::initializeFactories()
-{
-
-}
-#endif
-
</del><span class="cx"> } // namespace WebKit;
</span><span class="cx"> 
</span><span class="cx"> #endif // MEDIA_STREAM
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (214026 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2017-03-16 03:41:09 UTC (rev 214026)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -114,13 +114,11 @@
</span><span class="cx"> #include &lt;wtf/text/StringHash.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><ins>+#include &quot;CookieStorageShim.h&quot;
</ins><span class="cx"> #include &quot;ObjCObjectGraph.h&quot;
</span><ins>+#include &quot;UserMediaCaptureManager.h&quot;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(COCOA)
-#include &quot;CookieStorageShim.h&quot;
-#endif
-
</del><span class="cx"> #if ENABLE(SEC_ITEM_SHIM)
</span><span class="cx"> #include &quot;SecItemShim.h&quot;
</span><span class="cx"> #endif
</span><span class="lines">@@ -191,6 +189,10 @@
</span><span class="cx">     addSupplement&lt;WebMediaKeyStorageManager&gt;();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if PLATFORM(COCOA) &amp;&amp; ENABLE(MEDIA_STREAM)
+    addSupplement&lt;UserMediaCaptureManager&gt;();
+#endif
+
</ins><span class="cx">     m_plugInAutoStartOriginHashes.add(SessionID::defaultSessionID(), HashMap&lt;unsigned, double&gt;());
</span><span class="cx"> 
</span><span class="cx">     ResourceLoadObserver::sharedObserver().setStatisticsStore(m_resourceLoadStatisticsStore.copyRef());
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaUserMediaCaptureManagercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp (0 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -0,0 +1,226 @@
</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. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;UserMediaCaptureManager.h&quot;
+
+#if PLATFORM(COCOA) &amp;&amp; ENABLE(MEDIA_STREAM)
+
+#include &quot;SharedRingBufferStorage.h&quot;
+#include &quot;UserMediaCaptureManagerMessages.h&quot;
+#include &quot;UserMediaCaptureManagerProxyMessages.h&quot;
+#include &quot;WebCoreArgumentCoders.h&quot;
+#include &quot;WebProcess.h&quot;
+#include &quot;WebProcessCreationParameters.h&quot;
+#include &lt;WebCore/CaptureDevice.h&gt;
+#include &lt;WebCore/MediaConstraintsImpl.h&gt;
+#include &lt;WebCore/RealtimeMediaSourceCenter.h&gt;
+#include &lt;WebCore/WebAudioBufferList.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static uint64_t nextSessionID()
+{
+    static uint64_t nextID = 0;
+    return ++nextID;
+}
+
+class UserMediaCaptureManager::Source : public RealtimeMediaSource {
+public:
+    Source(const String&amp; sourceID, Type type, const String&amp; name, uint64_t id, UserMediaCaptureManager&amp; manager)
+        : RealtimeMediaSource(sourceID, type, name)
+        , m_id(id)
+        , m_manager(manager)
+        , m_ringBuffer(makeUniqueRef&lt;SharedRingBufferStorage&gt;(nullptr))
+    {
+    }
+
+    ~Source()
+    {
+        storage().invalidate();
+    }
+
+    SharedRingBufferStorage&amp; storage() { return static_cast&lt;SharedRingBufferStorage&amp;&gt;(m_ringBuffer.storage()); }
+    RefPtr&lt;RealtimeMediaSourceCapabilities&gt; capabilities() const final { return m_capabilities; }
+    void setCapabilities(RefPtr&lt;RealtimeMediaSourceCapabilities&gt; capabilities) { m_capabilities = capabilities; }
+
+    const RealtimeMediaSourceSettings&amp; settings() const final { return m_settings; }
+    void setSettings(const RealtimeMediaSourceSettings&amp; settings)
+    {
+        m_settings = settings;
+        settingsDidChange();
+    }
+
+    const CAAudioStreamDescription&amp; description() const { return m_description; }
+    void setStorage(const SharedMemory::Handle&amp; handle, const WebCore::CAAudioStreamDescription&amp; description, uint64_t numberOfFrames)
+    {
+        m_description = description;
+        if (handle.isNull()) {
+            m_ringBuffer.deallocate();
+            storage().setReadOnly(false);
+            storage().setStorage(nullptr);
+            return;
+        }
+
+        RefPtr&lt;SharedMemory&gt; memory = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
+        storage().setStorage(WTFMove(memory));
+        storage().setReadOnly(true);
+
+        m_ringBuffer.allocate(description, numberOfFrames);
+    }
+
+    void setRingBufferFrameBounds(uint64_t startFrame, uint64_t endFrame)
+    {
+        m_ringBuffer.setCurrentFrameBounds(startFrame, endFrame);
+    }
+
+    void audioSamplesAvailable(MediaTime time, uint64_t numberOfFrames)
+    {
+        WebAudioBufferList audioData(m_description, numberOfFrames);
+        m_ringBuffer.fetch(audioData.list(), numberOfFrames, time.timeValue());
+
+        for (auto* observer : observers())
+            observer-&gt;audioSamplesAvailable(time, audioData, m_description, numberOfFrames);
+    }
+
+    void startProducingData() final { m_manager.startProducingData(m_id); }
+    void stopProducingData() final { m_manager.stopProducingData(m_id); }
+
+    AudioSourceProvider* audioSourceProvider() final { return nullptr; }
+
+private:
+    // RealtimeMediaSource
+    void beginConfiguration() final { }
+    void commitConfiguration() final { }
+
+    uint64_t m_id;
+    UserMediaCaptureManager&amp; m_manager;
+    RefPtr&lt;RealtimeMediaSourceCapabilities&gt; m_capabilities;
+    RealtimeMediaSourceSettings m_settings;
+    CAAudioStreamDescription m_description;
+    CARingBuffer m_ringBuffer;
+};
+
+UserMediaCaptureManager::UserMediaCaptureManager(WebProcess* process)
+    : m_process(*process)
+{
+    m_process.addMessageReceiver(Messages::UserMediaCaptureManager::messageReceiverName(), *this);
+}
+
+UserMediaCaptureManager::~UserMediaCaptureManager()
+{
+    RealtimeMediaSourceCenter::singleton().unsetAudioFactory(*this);
+    m_process.removeMessageReceiver(Messages::UserMediaCaptureManager::messageReceiverName());
+}
+
+const char* UserMediaCaptureManager::supplementName()
+{
+    return &quot;UserMediaCaptureManager&quot;;
+}
+
+void UserMediaCaptureManager::initialize(const WebProcessCreationParameters&amp; parameters)
+{
+    if (parameters.shouldCaptureAudioInUIProcess)
+        RealtimeMediaSourceCenter::singleton().setAudioFactory(*this);
+}
+
+RefPtr&lt;RealtimeMediaSource&gt; UserMediaCaptureManager::createMediaSourceForCaptureDeviceWithConstraints(const CaptureDevice&amp; device, const MediaConstraints* constraints, String&amp; invalidConstraints)
+{
+    if (!constraints)
+        return nullptr;
+
+    uint64_t id = nextSessionID();
+    MediaConstraintsData constraintsData;
+    constraintsData.mandatoryConstraints = constraints-&gt;mandatoryConstraints();
+    constraintsData.advancedConstraints = constraints-&gt;advancedConstraints();
+    constraintsData.isValid = constraints-&gt;isValid();
+    bool succeeded;
+
+    m_process.sendSync(Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints(id, device, constraintsData), Messages::UserMediaCaptureManagerProxy::CreateMediaSourceForCaptureDeviceWithConstraints::Reply(succeeded, invalidConstraints), 0);
+
+    auto source = adoptRef(new Source(String::number(id), RealtimeMediaSource::Type::Audio, device.label(), id, *this));
+    m_sources.set(id, source);
+    return source;
+}
+
+void UserMediaCaptureManager::sourceStopped(uint64_t id)
+{
+    ASSERT(m_sources.contains(id));
+    m_sources.get(id)-&gt;stop();
+}
+
+void UserMediaCaptureManager::sourceMutedChanged(uint64_t id, bool muted)
+{
+    ASSERT(m_sources.contains(id));
+    m_sources.get(id)-&gt;setMuted(muted);
+}
+
+void UserMediaCaptureManager::sourceEnabledChanged(uint64_t id, bool enabled)
+{
+    ASSERT(m_sources.contains(id));
+    m_sources.get(id)-&gt;setEnabled(enabled);
+}
+
+void UserMediaCaptureManager::sourceSettingsChanged(uint64_t id, const RealtimeMediaSourceSettings&amp; settings)
+{
+    ASSERT(m_sources.contains(id));
+    m_sources.get(id)-&gt;setSettings(settings);
+}
+
+void UserMediaCaptureManager::storageChanged(uint64_t id, const SharedMemory::Handle&amp; handle, const WebCore::CAAudioStreamDescription&amp; description, uint64_t numberOfFrames)
+{
+    ASSERT(m_sources.contains(id));
+    m_sources.get(id)-&gt;setStorage(handle, description, numberOfFrames);
+}
+
+void UserMediaCaptureManager::ringBufferFrameBoundsChanged(uint64_t id, uint64_t startFrame, uint64_t endFrame)
+{
+    ASSERT(m_sources.contains(id));
+    m_sources.get(id)-&gt;setRingBufferFrameBounds(startFrame, endFrame);
+}
+
+void UserMediaCaptureManager::audioSamplesAvailable(uint64_t id, MediaTime time, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame)
+{
+    ASSERT(m_sources.contains(id));
+    auto&amp; source = *m_sources.get(id);
+    source.setRingBufferFrameBounds(startFrame, endFrame);
+    source.audioSamplesAvailable(time, numberOfFrames);
+}
+
+void UserMediaCaptureManager::startProducingData(uint64_t id)
+{
+    m_process.send(Messages::UserMediaCaptureManagerProxy::StartProducingData(id), 0);
+}
+
+void UserMediaCaptureManager::stopProducingData(uint64_t id)
+{
+    m_process.send(Messages::UserMediaCaptureManagerProxy::StopProducingData(id), 0);
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaUserMediaCaptureManagerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.h (0 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.h                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.h        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -0,0 +1,82 @@
</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. AND ITS 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 APPLE INC. OR ITS 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 PLATFORM(COCOA) &amp;&amp; ENABLE(MEDIA_STREAM)
+
+#include &quot;MessageReceiver.h&quot;
+#include &quot;SharedMemory.h&quot;
+#include &quot;WebProcessSupplement.h&quot;
+#include &lt;WebCore/RealtimeMediaSource.h&gt;
+#include &lt;wtf/HashMap.h&gt;
+
+namespace WebCore {
+class CAAudioStreamDescription;
+}
+
+namespace WebKit {
+
+class CrossProcessRealtimeAudioSource;
+class WebProcess;
+
+class UserMediaCaptureManager : public WebProcessSupplement, public IPC::MessageReceiver, public WebCore::RealtimeMediaSource::CaptureFactory {
+public:
+    explicit UserMediaCaptureManager(WebProcess*);
+    ~UserMediaCaptureManager();
+
+    static const char* supplementName();
+
+private:
+    // WebProcessSupplement
+    void initialize(const WebProcessCreationParameters&amp;) final;
+
+    // WebCore::RealtimeMediaSource::Factory:
+    RefPtr&lt;WebCore::RealtimeMediaSource&gt; createMediaSourceForCaptureDeviceWithConstraints(const WebCore::CaptureDevice&amp;, const WebCore::MediaConstraints*, String&amp;) final;
+
+    // IPC::MessageReceiver
+    void didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;) final;
+
+    // Messages::UserMediaCaptureManager
+    void sourceStopped(uint64_t id);
+    void sourceMutedChanged(uint64_t id, bool muted);
+    void sourceEnabledChanged(uint64_t id, bool enabled);
+    void sourceSettingsChanged(uint64_t id, const WebCore::RealtimeMediaSourceSettings&amp;);
+    void storageChanged(uint64_t id, const SharedMemory::Handle&amp;, const WebCore::CAAudioStreamDescription&amp;, uint64_t numberOfFrames);
+    void ringBufferFrameBoundsChanged(uint64_t id, uint64_t startFrame, uint64_t endFrame);
+    void audioSamplesAvailable(uint64_t id, MediaTime, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame);
+
+    void startProducingData(uint64_t);
+    void stopProducingData(uint64_t);
+
+    class Source;
+    friend class Source;
+    HashMap&lt;uint64_t, RefPtr&lt;Source&gt;&gt; m_sources;
+    WebProcess&amp; m_process;
+};
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcesscocoaUserMediaCaptureManagermessagesin"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.messages.in (0 => 214027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.messages.in                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.messages.in        2017-03-16 04:10:53 UTC (rev 214027)
</span><span class="lines">@@ -0,0 +1,31 @@
</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. AND ITS 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 APPLE INC. OR ITS 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.
+
+messages -&gt; UserMediaCaptureManager {
+    SourceStopped(uint64_t id)
+    SourceMutedChanged(uint64_t id, bool muted)
+    SourceEnabledChanged(uint64_t id, bool enabled)
+    SourceSettingsChanged(uint64_t id, WebCore::RealtimeMediaSourceSettings settings)
+    StorageChanged(uint64_t id, WebKit::SharedMemory::Handle storageHandle, WebCore::CAAudioStreamDescription description, uint64_t numberOfFrames)
+    AudioSamplesAvailable(uint64_t id, MediaTime time, uint64_t numberOfFrames, uint64_t startFrame, uint64_t endFrame)
+}
</ins></span></pre>
</div>
</div>

</body>
</html>