<!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>[211191] trunk/Source/WebCore</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/211191">211191</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-01-25 17:43:44 -0800 (Wed, 25 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[WebRTC] Add support for incoming and outgoing libwebrtc audio tracks
https://bugs.webkit.org/show_bug.cgi?id=167438
Patch by Youenn Fablet <youenn@apple.com> on 2017-01-25
Reviewed by Eric Carlson.
RealtimeIncomingAudioSource consumes audio buffers given by libwebrtc.
RealtimeOutgoingAudioSource consumes audio buffers from WebCore tracks (capture typically) and feeds libwebrtc with them.
To be covered by Layout/mock tests once LibWebRTC peer connection will be added.
These are only skeletons right now, the conversion between WebCore and LibWebRTC data is not yet implemented.
* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/mac/RealtimeIncomingAudioSource.cpp: Added.
(WebCore::RealtimeIncomingAudioSource::create):
(WebCore::RealtimeIncomingAudioSource::RealtimeIncomingAudioSource):
(WebCore::RealtimeIncomingAudioSource::OnData):
(WebCore::RealtimeIncomingAudioSource::startProducingData):
(WebCore::RealtimeIncomingAudioSource::stopProducingData):
(WebCore::RealtimeIncomingAudioSource::capabilities):
(WebCore::RealtimeIncomingAudioSource::settings):
(WebCore::RealtimeIncomingAudioSource::supportedConstraints):
(WebCore::RealtimeIncomingAudioSource::addObserver):
(WebCore::RealtimeIncomingAudioSource::removeObserver):
(WebCore::RealtimeIncomingAudioSource::start):
(WebCore::RealtimeIncomingAudioSource::audioSourceProvider):
* platform/mediastream/mac/RealtimeIncomingAudioSource.h: Added.
* platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: Added.
(WebCore::RealtimeOutgoingAudioSource::sourceHasMoreMediaData):
* platform/mediastream/mac/RealtimeOutgoingAudioSource.h: Added.</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>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeIncomingAudioSourcecpp">trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeIncomingAudioSourceh">trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourcecpp">trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourceh">trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211190 => 211191)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-26 01:41:11 UTC (rev 211190)
+++ trunk/Source/WebCore/ChangeLog        2017-01-26 01:43:44 UTC (rev 211191)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2017-01-25 Youenn Fablet <youenn@apple.com>
</span><span class="cx">
</span><ins>+ [WebRTC] Add support for incoming and outgoing libwebrtc audio tracks
+ https://bugs.webkit.org/show_bug.cgi?id=167438
+
+ Reviewed by Eric Carlson.
+
+ RealtimeIncomingAudioSource consumes audio buffers given by libwebrtc.
+ RealtimeOutgoingAudioSource consumes audio buffers from WebCore tracks (capture typically) and feeds libwebrtc with them.
+ To be covered by Layout/mock tests once LibWebRTC peer connection will be added.
+ These are only skeletons right now, the conversion between WebCore and LibWebRTC data is not yet implemented.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/mediastream/mac/RealtimeIncomingAudioSource.cpp: Added.
+ (WebCore::RealtimeIncomingAudioSource::create):
+ (WebCore::RealtimeIncomingAudioSource::RealtimeIncomingAudioSource):
+ (WebCore::RealtimeIncomingAudioSource::OnData):
+ (WebCore::RealtimeIncomingAudioSource::startProducingData):
+ (WebCore::RealtimeIncomingAudioSource::stopProducingData):
+ (WebCore::RealtimeIncomingAudioSource::capabilities):
+ (WebCore::RealtimeIncomingAudioSource::settings):
+ (WebCore::RealtimeIncomingAudioSource::supportedConstraints):
+ (WebCore::RealtimeIncomingAudioSource::addObserver):
+ (WebCore::RealtimeIncomingAudioSource::removeObserver):
+ (WebCore::RealtimeIncomingAudioSource::start):
+ (WebCore::RealtimeIncomingAudioSource::audioSourceProvider):
+ * platform/mediastream/mac/RealtimeIncomingAudioSource.h: Added.
+ * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: Added.
+ (WebCore::RealtimeOutgoingAudioSource::sourceHasMoreMediaData):
+ * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: Added.
+
+2017-01-25 Youenn Fablet <youenn@apple.com>
+
</ins><span class="cx"> [WebRTC] Add support for libwebrtc video incoming and outgoing video tracks
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=167432
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (211190 => 211191)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-26 01:41:11 UTC (rev 211190)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-01-26 01:43:44 UTC (rev 211191)
</span><span class="lines">@@ -1510,6 +1510,10 @@
</span><span class="cx">                 40ECAE7E16B8B67200C36103 /* JSDOMError.h in Headers */ = {isa = PBXBuildFile; fileRef = 40ECAE7D16B8B67200C36103 /* JSDOMError.h */; };
</span><span class="cx">                 40ECAE8116B8B68A00C36103 /* JSDOMError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 40ECAE8016B8B68A00C36103 /* JSDOMError.cpp */; };
</span><span class="cx">                 410B7E721045FAB000D8224F /* JSMessageEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */; };
</span><ins>+                41103AAB1E39791000769F03 /* RealtimeOutgoingAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41103AA71E39790A00769F03 /* RealtimeOutgoingAudioSource.cpp */; };
+                41103AAC1E39791000769F03 /* RealtimeOutgoingAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 41103AA81E39790A00769F03 /* RealtimeOutgoingAudioSource.h */; };
+                41103AAD1E39791000769F03 /* RealtimeIncomingAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 41103AA91E39790A00769F03 /* RealtimeIncomingAudioSource.h */; };
+                41103AAE1E39791000769F03 /* RealtimeIncomingAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */; };
</ins><span class="cx">                 4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; };
</span><span class="cx">                 41230913138C42FF00BCCFCA /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* JavaScriptCore.framework */; };
</span><span class="cx">                 4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */; };
</span><span class="lines">@@ -8680,6 +8684,10 @@
</span><span class="cx">                 40ECAE7D16B8B67200C36103 /* JSDOMError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMError.h; sourceTree = "<group>"; };
</span><span class="cx">                 40ECAE8016B8B68A00C36103 /* JSDOMError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMError.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageEventCustom.cpp; sourceTree = "<group>"; };
</span><ins>+                41103AA71E39790A00769F03 /* RealtimeOutgoingAudioSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeOutgoingAudioSource.cpp; sourceTree = "<group>"; };
+                41103AA81E39790A00769F03 /* RealtimeOutgoingAudioSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeOutgoingAudioSource.h; sourceTree = "<group>"; };
+                41103AA91E39790A00769F03 /* RealtimeIncomingAudioSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RealtimeIncomingAudioSource.h; sourceTree = "<group>"; };
+                41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealtimeIncomingAudioSource.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 41189EF71AD8232800B90A0D /* ReadableStreamDefaultController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamDefaultController.idl; sourceTree = "<group>"; };
</span><span class="cx">                 41189EF71AD8232800B93F64 /* ReadableByteStreamController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableByteStreamController.idl; sourceTree = "<group>"; };
</span><span class="cx">                 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptState.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -15294,6 +15302,10 @@
</span><span class="cx">                                 07EE76EE1BEA619800F89133 /* MockRealtimeVideoSourceMac.mm */,
</span><span class="cx">                                 4A0FFAA31AAF5EF60062803B /* RealtimeMediaSourceCenterMac.cpp */,
</span><span class="cx">                                 4A0FFAA41AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h */,
</span><ins>+                                41103AA71E39790A00769F03 /* RealtimeOutgoingAudioSource.cpp */,
+                                41103AA81E39790A00769F03 /* RealtimeOutgoingAudioSource.h */,
+                                41103AA91E39790A00769F03 /* RealtimeIncomingAudioSource.h */,
+                                41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */,
</ins><span class="cx">                                 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */,
</span><span class="cx">                                 07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm */,
</span><span class="cx">                         );
</span><span class="lines">@@ -25808,6 +25820,7 @@
</span><span class="cx">                                 A80D67080E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h in Headers */,
</span><span class="cx">                                 0F580B0D0F12A2690051D689 /* GraphicsLayer.h in Headers */,
</span><span class="cx">                                 499B3ED7128CD31400E726C2 /* GraphicsLayerCA.h in Headers */,
</span><ins>+                                41103AAD1E39791000769F03 /* RealtimeIncomingAudioSource.h in Headers */,
</ins><span class="cx">                                 0F580B0E0F12A2690051D689 /* GraphicsLayerClient.h in Headers */,
</span><span class="cx">                                 1AC69593161A1E53003732CB /* GraphicsLayerFactory.h in Headers */,
</span><span class="cx">                                 0FA24D7A162DF91900A3F4C0 /* GraphicsLayerUpdater.h in Headers */,
</span><span class="lines">@@ -27887,6 +27900,7 @@
</span><span class="cx">                                 B22279AE0D00BF220071B782 /* SVGDefsElement.h in Headers */,
</span><span class="cx">                                 B22279B10D00BF220071B782 /* SVGDescElement.h in Headers */,
</span><span class="cx">                                 B22279B40D00BF220071B782 /* SVGDocument.h in Headers */,
</span><ins>+                                41103AAC1E39791000769F03 /* RealtimeOutgoingAudioSource.h in Headers */,
</ins><span class="cx">                                 B28C6A280D00C44800334AA4 /* SVGDocumentExtensions.h in Headers */,
</span><span class="cx">                                 B22279B70D00BF220071B782 /* SVGElement.h in Headers */,
</span><span class="cx">                                 656581FE09D1508D000E61D7 /* SVGElementFactory.h in Headers */,
</span><span class="lines">@@ -29392,6 +29406,7 @@
</span><span class="cx">                                 15FCC9FC1B4DF7F200E72326 /* DOMURLMediaStream.cpp in Sources */,
</span><span class="cx">                                 1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */,
</span><span class="cx">                                 517FBA1E151AB17C00B57959 /* DOMWindowExtension.cpp in Sources */,
</span><ins>+                                41103AAE1E39791000769F03 /* RealtimeIncomingAudioSource.cpp in Sources */,
</ins><span class="cx">                                 418C39561C8DAC7F0051C8A3 /* DOMWindowFetch.cpp in Sources */,
</span><span class="cx">                                 5185FC741BB4C4E80012898F /* DOMWindowIndexedDatabase.cpp in Sources */,
</span><span class="cx">                                 97B38E28151C4273004622E9 /* DOMWindowNotifications.cpp in Sources */,
</span><span class="lines">@@ -31669,6 +31684,7 @@
</span><span class="cx">                                 93309E1B099E64920056E581 /* TextIterator.cpp in Sources */,
</span><span class="cx">                                 E4D988B617BFEB210084FB88 /* TextNodeTraversal.cpp in Sources */,
</span><span class="cx">                                 1C18DA58181AF6A500C4EF22 /* TextPainter.cpp in Sources */,
</span><ins>+                                41103AAB1E39791000769F03 /* RealtimeOutgoingAudioSource.cpp in Sources */,
</ins><span class="cx">                                 E4C91A101802343900A17F6D /* TextPaintStyle.cpp in Sources */,
</span><span class="cx">                                 93F19A9D08245E59001E9ABC /* TextResourceDecoder.cpp in Sources */,
</span><span class="cx">                                 376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeIncomingAudioSourcecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp (0 => 211191)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp        2017-01-26 01:43:44 UTC (rev 211191)
</span><span class="lines">@@ -0,0 +1,131 @@
</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.
+ * 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.
+ */
+
+#include "config.h"
+#include "RealtimeIncomingAudioSource.h"
+
+#if USE(LIBWEBRTC)
+
+#include "RealtimeMediaSourceSettings.h"
+#include "WebAudioSourceProviderAVFObjC.h"
+
+#include "CoreMediaSoftLink.h"
+
+namespace WebCore {
+
+Ref<RealtimeIncomingAudioSource> RealtimeIncomingAudioSource::create(rtc::scoped_refptr<webrtc::AudioTrackInterface>&& audioTrack, String&& audioTrackId)
+{
+ return adoptRef(*new RealtimeIncomingAudioSource(WTFMove(audioTrack), WTFMove(audioTrackId)));
+}
+
+RealtimeIncomingAudioSource::RealtimeIncomingAudioSource(rtc::scoped_refptr<webrtc::AudioTrackInterface>&& audioTrack, String&& audioTrackId)
+ : RealtimeMediaSource(WTFMove(audioTrackId), RealtimeMediaSource::Type::Audio, String())
+ , m_audioTrack(WTFMove(audioTrack))
+{
+}
+
+void RealtimeIncomingAudioSource::OnData(const void* audioData, int bitsPerSample, int sampleRate, size_t numberOfChannels, size_t numberOfFrames)
+{
+ // FIXME: Implement this.
+ UNUSED_PARAM(audioData);
+ UNUSED_PARAM(bitsPerSample);
+ UNUSED_PARAM(sampleRate);
+ UNUSED_PARAM(numberOfChannels);
+ UNUSED_PARAM(numberOfFrames);
+}
+
+void RealtimeIncomingAudioSource::startProducingData()
+{
+ if (m_isProducingData)
+ return;
+
+ m_isProducingData = true;
+ if (m_audioTrack)
+ m_audioTrack->AddSink(this);
+}
+
+void RealtimeIncomingAudioSource::stopProducingData()
+{
+ if (m_isProducingData)
+ return;
+
+ m_isProducingData = false;
+ if (m_audioTrack)
+ m_audioTrack->RemoveSink(this);
+}
+
+
+RefPtr<RealtimeMediaSourceCapabilities> RealtimeIncomingAudioSource::capabilities() const
+{
+ return m_capabilities;
+}
+
+const RealtimeMediaSourceSettings& RealtimeIncomingAudioSource::settings() const
+{
+ return m_currentSettings;
+}
+
+RealtimeMediaSourceSupportedConstraints& RealtimeIncomingAudioSource::supportedConstraints()
+{
+ return m_supportedConstraints;
+}
+
+void RealtimeIncomingAudioSource::addObserver(AudioSourceObserverObjC& observer)
+{
+ m_audioSourceObservers.append(observer);
+ if (m_formatDescription) {
+ const auto* description = CMAudioFormatDescriptionGetStreamBasicDescription(m_formatDescription.get());
+ observer.prepare(description);
+ }
+}
+
+void RealtimeIncomingAudioSource::removeObserver(AudioSourceObserverObjC& observer)
+{
+ m_audioSourceObservers.removeFirstMatching([&observer](const auto& registeredObserver) {
+ return &observer == &registeredObserver.get();
+ });
+}
+
+void RealtimeIncomingAudioSource::start()
+{
+ startProducingData();
+}
+
+AudioSourceProvider* RealtimeIncomingAudioSource::audioSourceProvider()
+{
+ if (!m_audioSourceProvider)
+ m_audioSourceProvider = WebAudioSourceProviderAVFObjC::create(*this);
+
+ return m_audioSourceProvider.get();
+}
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeIncomingAudioSourceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h (0 => 211191)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h        2017-01-26 01:43:44 UTC (rev 211191)
</span><span class="lines">@@ -0,0 +1,89 @@
</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.
+ * 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 USE(LIBWEBRTC)
+
+#include "AudioCaptureSourceProviderObjC.h"
+#include "LibWebRTCMacros.h"
+#include "RealtimeMediaSource.h"
+#include <CoreAudio/CoreAudioTypes.h>
+#include <webrtc/api/mediastreaminterface.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class WebAudioSourceProviderAVFObjC;
+
+class RealtimeIncomingAudioSource final : public RealtimeMediaSource, private webrtc::AudioTrackSinkInterface, private AudioCaptureSourceProviderObjC {
+public:
+ static Ref<RealtimeIncomingAudioSource> create(rtc::scoped_refptr<webrtc::AudioTrackInterface>&&, String&&);
+
+private:
+ RealtimeIncomingAudioSource(rtc::scoped_refptr<webrtc::AudioTrackInterface>&&, String&&);
+
+ // webrtc::AudioTrackSinkInterface API
+ void OnData(const void* audioData, int bitsPerSample, int sampleRate, size_t numberOfChannels, size_t numberOfFrames) final;
+
+ // RealtimeMediaSource API
+ void startProducingData() final;
+ void stopProducingData() final;
+
+ RefPtr<RealtimeMediaSourceCapabilities> capabilities() const final;
+ const RealtimeMediaSourceSettings& settings() const final;
+
+ MediaConstraints& constraints() { return *m_constraints.get(); }
+ RealtimeMediaSourceSupportedConstraints& supportedConstraints();
+
+ bool isProducingData() const final { return m_isProducingData; }
+
+ AudioSourceProvider* audioSourceProvider() final;
+
+ // AudioCaptureSourceProviderObjC API
+ void addObserver(AudioSourceObserverObjC&) final;
+ void removeObserver(AudioSourceObserverObjC&) final;
+ void start() final;
+
+ RealtimeMediaSourceSettings m_currentSettings;
+ RealtimeMediaSourceSupportedConstraints m_supportedConstraints;
+ RefPtr<RealtimeMediaSourceCapabilities> m_capabilities;
+ RefPtr<MediaConstraints> m_constraints;
+ bool m_isProducingData { false };
+ rtc::scoped_refptr<webrtc::AudioTrackInterface> m_audioTrack;
+
+ RefPtr<WebAudioSourceProviderAVFObjC> m_audioSourceProvider;
+ RetainPtr<CMFormatDescriptionRef> m_formatDescription;
+ Vector<std::reference_wrapper<AudioSourceObserverObjC>> m_audioSourceObservers;
+};
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourcecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp (0 => 211191)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp        2017-01-26 01:43:44 UTC (rev 211191)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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 Apple 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 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. AND 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 "config.h"
+#include "RealtimeOutgoingAudioSource.h"
+
+#if USE(LIBWEBRTC)
+
+namespace WebCore {
+
+void RealtimeOutgoingAudioSource::sourceHasMoreMediaData(MediaSample& mediaSample)
+{
+ // FIXME: Implement this.
+ UNUSED_PARAM(mediaSample);
+}
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacRealtimeOutgoingAudioSourceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h (0 => 211191)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h        2017-01-26 01:43:44 UTC (rev 211191)
</span><span class="lines">@@ -0,0 +1,81 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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 Apple 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 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. AND 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 USE(LIBWEBRTC)
+
+#include "LibWebRTCMacros.h"
+#include "RealtimeMediaSource.h"
+#include <webrtc/api/mediastreaminterface.h>
+
+namespace webrtc {
+class AudioTrackInterface;
+class AudioTrackSinkInterface;
+}
+
+namespace WebCore {
+
+class RealtimeOutgoingAudioSource final : public RefCounted<RealtimeOutgoingAudioSource>, public webrtc::AudioSourceInterface, private RealtimeMediaSource::Observer {
+public:
+ static Ref<RealtimeOutgoingAudioSource> create(Ref<RealtimeMediaSource>&& audioSource) { return adoptRef(*new RealtimeOutgoingAudioSource(WTFMove(audioSource))); }
+ ~RealtimeOutgoingAudioSource() { m_audioSource->removeObserver(this); }
+
+ void setTrack(rtc::scoped_refptr<webrtc::AudioTrackInterface>&& track) { m_track = WTFMove(track); }
+
+private:
+ explicit RealtimeOutgoingAudioSource(Ref<RealtimeMediaSource>&& audioSource) : m_audioSource(WTFMove(audioSource)) { m_audioSource->addObserver(this); }
+
+ virtual void AddSink(webrtc::AudioTrackSinkInterface* sink) { m_sinks.append(sink); }
+ virtual void RemoveSink(webrtc::AudioTrackSinkInterface* sink) { m_sinks.removeFirst(sink); }
+
+ int AddRef() const final { ref(); return refCount(); }
+ int Release() const final { deref(); return refCount(); }
+ SourceState state() const final { return kLive; }
+ bool remote() const final { return false; }
+ void RegisterObserver(webrtc::ObserverInterface*) final { }
+ void UnregisterObserver(webrtc::ObserverInterface*) final { }
+
+ // RealtimeMediaSource::Observer API
+ void sourceStopped() final { }
+ void sourceMutedChanged() final { }
+ void sourceSettingsChanged() final { }
+ bool preventSourceFromStopping() final { return false; }
+ void sourceHasMoreMediaData(MediaSample&) final;
+
+ void convertAndSendMonoSamples();
+ void convertAndSendStereoSamples();
+
+ Vector<webrtc::AudioTrackSinkInterface*> m_sinks;
+ Ref<RealtimeMediaSource> m_audioSource;
+ rtc::scoped_refptr<webrtc::AudioTrackInterface> m_track;
+};
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
</ins></span></pre>
</div>
</div>
</body>
</html>