Title: [211191] trunk/Source/WebCore
Revision
211191
Author
commit-qu...@webkit.org
Date
2017-01-25 17:43:44 -0800 (Wed, 25 Jan 2017)

Log Message

[WebRTC] Add support for incoming and outgoing libwebrtc audio tracks
https://bugs.webkit.org/show_bug.cgi?id=167438

Patch by Youenn Fablet <you...@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.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211190 => 211191)


--- 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)
@@ -1,5 +1,36 @@
 2017-01-25  Youenn Fablet  <you...@apple.com>
 
+        [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  <you...@apple.com>
+
         [WebRTC] Add support for libwebrtc video incoming and outgoing video tracks
         https://bugs.webkit.org/show_bug.cgi?id=167432
 

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (211190 => 211191)


--- 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)
@@ -1510,6 +1510,10 @@
 		40ECAE7E16B8B67200C36103 /* JSDOMError.h in Headers */ = {isa = PBXBuildFile; fileRef = 40ECAE7D16B8B67200C36103 /* JSDOMError.h */; };
 		40ECAE8116B8B68A00C36103 /* JSDOMError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 40ECAE8016B8B68A00C36103 /* JSDOMError.cpp */; };
 		410B7E721045FAB000D8224F /* JSMessageEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */; };
+		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 */; };
 		4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F19B1A08245E5A001E9ABC /* WebCore.framework */; };
 		41230913138C42FF00BCCFCA /* _javascript_Core.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* _javascript_Core.framework */; };
 		4127D5370F8AAB1D00E424F5 /* ScriptState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */; };
@@ -8680,6 +8684,10 @@
 		40ECAE7D16B8B67200C36103 /* JSDOMError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMError.h; sourceTree = "<group>"; };
 		40ECAE8016B8B68A00C36103 /* JSDOMError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMError.cpp; sourceTree = "<group>"; };
 		410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageEventCustom.cpp; sourceTree = "<group>"; };
+		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>"; };
 		41189EF71AD8232800B90A0D /* ReadableStreamDefaultController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamDefaultController.idl; sourceTree = "<group>"; };
 		41189EF71AD8232800B93F64 /* ReadableByteStreamController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableByteStreamController.idl; sourceTree = "<group>"; };
 		4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptState.cpp; sourceTree = "<group>"; };
@@ -15294,6 +15302,10 @@
 				07EE76EE1BEA619800F89133 /* MockRealtimeVideoSourceMac.mm */,
 				4A0FFAA31AAF5EF60062803B /* RealtimeMediaSourceCenterMac.cpp */,
 				4A0FFAA41AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h */,
+				41103AA71E39790A00769F03 /* RealtimeOutgoingAudioSource.cpp */,
+				41103AA81E39790A00769F03 /* RealtimeOutgoingAudioSource.h */,
+				41103AA91E39790A00769F03 /* RealtimeIncomingAudioSource.h */,
+				41103AAA1E39790A00769F03 /* RealtimeIncomingAudioSource.cpp */,
 				07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */,
 				07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm */,
 			);
@@ -25808,6 +25820,7 @@
 				A80D67080E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h in Headers */,
 				0F580B0D0F12A2690051D689 /* GraphicsLayer.h in Headers */,
 				499B3ED7128CD31400E726C2 /* GraphicsLayerCA.h in Headers */,
+				41103AAD1E39791000769F03 /* RealtimeIncomingAudioSource.h in Headers */,
 				0F580B0E0F12A2690051D689 /* GraphicsLayerClient.h in Headers */,
 				1AC69593161A1E53003732CB /* GraphicsLayerFactory.h in Headers */,
 				0FA24D7A162DF91900A3F4C0 /* GraphicsLayerUpdater.h in Headers */,
@@ -27887,6 +27900,7 @@
 				B22279AE0D00BF220071B782 /* SVGDefsElement.h in Headers */,
 				B22279B10D00BF220071B782 /* SVGDescElement.h in Headers */,
 				B22279B40D00BF220071B782 /* SVGDocument.h in Headers */,
+				41103AAC1E39791000769F03 /* RealtimeOutgoingAudioSource.h in Headers */,
 				B28C6A280D00C44800334AA4 /* SVGDocumentExtensions.h in Headers */,
 				B22279B70D00BF220071B782 /* SVGElement.h in Headers */,
 				656581FE09D1508D000E61D7 /* SVGElementFactory.h in Headers */,
@@ -29392,6 +29406,7 @@
 				15FCC9FC1B4DF7F200E72326 /* DOMURLMediaStream.cpp in Sources */,
 				1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */,
 				517FBA1E151AB17C00B57959 /* DOMWindowExtension.cpp in Sources */,
+				41103AAE1E39791000769F03 /* RealtimeIncomingAudioSource.cpp in Sources */,
 				418C39561C8DAC7F0051C8A3 /* DOMWindowFetch.cpp in Sources */,
 				5185FC741BB4C4E80012898F /* DOMWindowIndexedDatabase.cpp in Sources */,
 				97B38E28151C4273004622E9 /* DOMWindowNotifications.cpp in Sources */,
@@ -31669,6 +31684,7 @@
 				93309E1B099E64920056E581 /* TextIterator.cpp in Sources */,
 				E4D988B617BFEB210084FB88 /* TextNodeTraversal.cpp in Sources */,
 				1C18DA58181AF6A500C4EF22 /* TextPainter.cpp in Sources */,
+				41103AAB1E39791000769F03 /* RealtimeOutgoingAudioSource.cpp in Sources */,
 				E4C91A101802343900A17F6D /* TextPaintStyle.cpp in Sources */,
 				93F19A9D08245E59001E9ABC /* TextResourceDecoder.cpp in Sources */,
 				376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */,

Added: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp (0 => 211191)


--- 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)
@@ -0,0 +1,131 @@
+/*
+ * 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)

Added: trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h (0 => 211191)


--- 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)
@@ -0,0 +1,89 @@
+/*
+ * 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)

Added: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp (0 => 211191)


--- 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)
@@ -0,0 +1,44 @@
+/*
+ * 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)

Added: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h (0 => 211191)


--- 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)
@@ -0,0 +1,81 @@
+/*
+ * 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)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to