Diff
Modified: trunk/Source/WebCore/ChangeLog (211438 => 211439)
--- trunk/Source/WebCore/ChangeLog 2017-01-31 18:41:54 UTC (rev 211438)
+++ trunk/Source/WebCore/ChangeLog 2017-01-31 18:57:57 UTC (rev 211439)
@@ -1,3 +1,29 @@
+2017-01-31 Youenn Fablet <you...@apple.com>
+
+ [WebRTC] Add a libwebrtc AudioModule specific to WebKit
+ https://bugs.webkit.org/show_bug.cgi?id=167572
+
+ Reviewed by Alex Christensen.
+
+ To be covered by webrtc audio tests.
+ Adding an AudioModule to circumvent the default LibWebRTC Audio Module which does the audio directly.
+ The implementation of the AudioModule is restricted to enable fueling the incoming audio tracks with incoming data.
+ Code inspired from https://chromium.googlesource.com/chromium/src/+/master/remoting/protocol/webrtc_audio_module.h
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp: Added.
+ (WebCore::LibWebRTCAudioModule::LibWebRTCAudioModule):
+ (WebCore::LibWebRTCAudioModule::RegisterAudioCallback):
+ (WebCore::LibWebRTCAudioModule::OnMessage):
+ (WebCore::LibWebRTCAudioModule::StartPlayout):
+ (WebCore::LibWebRTCAudioModule::StopPlayout):
+ (WebCore::LibWebRTCAudioModule::StartPlayoutOnAudioThread):
+ (WebCore::LibWebRTCAudioModule::PollFromSource):
+ * platform/mediastream/libwebrtc/LibWebRTCAudioModule.h: Added.
+ * platform/mediastream/libwebrtc/LibWebRTCUtils.cpp:
+ (WebCore::ThreadMessageData::ThreadMessageData):
+ (WebCore::initializePeerConnectionFactoryAndThreads):
+
2017-01-31 Jessie Berlin <jber...@webkit.org>
Build fix.
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (211438 => 211439)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-01-31 18:41:54 UTC (rev 211438)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-01-31 18:57:57 UTC (rev 211439)
@@ -1535,6 +1535,8 @@
414B82051D6DF0E50077EBE3 /* StructuredClone.h in Headers */ = {isa = PBXBuildFile; fileRef = 414B82031D6DF0D90077EBE3 /* StructuredClone.h */; };
415071571685067300C3C7B3 /* SelectorFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 415071551685067300C3C7B3 /* SelectorFilter.cpp */; };
415071581685067300C3C7B3 /* SelectorFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 415071561685067300C3C7B3 /* SelectorFilter.h */; };
+ 415080361E3F00AD0051D75D /* LibWebRTCAudioModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 415080341E3F00AA0051D75D /* LibWebRTCAudioModule.cpp */; };
+ 415080371E3F00B00051D75D /* LibWebRTCAudioModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 415080351E3F00AA0051D75D /* LibWebRTCAudioModule.h */; };
4150F9F112B6E0E70008C860 /* SliderThumbElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4150F9EF12B6E0E70008C860 /* SliderThumbElement.h */; };
4150F9F212B6E0E70008C860 /* SliderThumbElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4150F9F012B6E0E70008C860 /* SliderThumbElement.cpp */; };
415670471DBE1533009AC3BB /* PeerConnectionStates.h in Headers */ = {isa = PBXBuildFile; fileRef = 415670461DBE1524009AC3BB /* PeerConnectionStates.h */; };
@@ -8744,6 +8746,8 @@
414B82031D6DF0D90077EBE3 /* StructuredClone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructuredClone.h; sourceTree = "<group>"; };
415071551685067300C3C7B3 /* SelectorFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectorFilter.cpp; sourceTree = "<group>"; };
415071561685067300C3C7B3 /* SelectorFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectorFilter.h; sourceTree = "<group>"; };
+ 415080341E3F00AA0051D75D /* LibWebRTCAudioModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCAudioModule.cpp; path = libwebrtc/LibWebRTCAudioModule.cpp; sourceTree = "<group>"; };
+ 415080351E3F00AA0051D75D /* LibWebRTCAudioModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCAudioModule.h; path = libwebrtc/LibWebRTCAudioModule.h; sourceTree = "<group>"; };
4150F9EF12B6E0E70008C860 /* SliderThumbElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SliderThumbElement.h; sourceTree = "<group>"; };
4150F9F012B6E0E70008C860 /* SliderThumbElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SliderThumbElement.cpp; sourceTree = "<group>"; };
415670461DBE1524009AC3BB /* PeerConnectionStates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PeerConnectionStates.h; sourceTree = "<group>"; };
@@ -16709,6 +16713,8 @@
415747421E38698000E914D8 /* libwebrtc */ = {
isa = PBXGroup;
children = (
+ 415080341E3F00AA0051D75D /* LibWebRTCAudioModule.cpp */,
+ 415080351E3F00AA0051D75D /* LibWebRTCAudioModule.h */,
415747431E38699E00E914D8 /* LibWebRTCMacros.h */,
415747441E38699E00E914D8 /* LibWebRTCProvider.h */,
415747451E38699E00E914D8 /* LibWebRTCUtils.cpp */,
@@ -26226,6 +26232,7 @@
0F8B45721DC3FBA300443C3F /* IntersectionObserverCallback.h in Headers */,
0F4710DF1DB6FE22002DCEC3 /* IntersectionObserverEntry.h in Headers */,
B27535720B053814002CE64F /* IntPoint.h in Headers */,
+ 415080371E3F00B00051D75D /* LibWebRTCAudioModule.h in Headers */,
E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */,
B27535740B053814002CE64F /* IntRect.h in Headers */,
A2B9217316C5CC420041DCD9 /* IntRectExtent.h in Headers */,
@@ -31669,6 +31676,7 @@
B2227A080D00BF220071B782 /* SVGFETurbulenceElement.cpp in Sources */,
845E72FB0FD2623900A87D79 /* SVGFilter.cpp in Sources */,
081EBF3A0FD34F4100DA7559 /* SVGFilterBuilder.cpp in Sources */,
+ 415080361E3F00AD0051D75D /* LibWebRTCAudioModule.cpp in Sources */,
B2227A0B0D00BF220071B782 /* SVGFilterElement.cpp in Sources */,
B2227A0E0D00BF220071B782 /* SVGFilterPrimitiveStandardAttributes.cpp in Sources */,
B2227A110D00BF220071B782 /* SVGFitToViewBox.cpp in Sources */,
Added: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp (0 => 211439)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.cpp 2017-01-31 18:57:57 UTC (rev 211439)
@@ -0,0 +1,101 @@
+/*
+ * 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 "config.h"
+#include "LibWebRTCAudioModule.h"
+
+#if USE(LIBWEBRTC)
+
+namespace WebCore {
+
+LibWebRTCAudioModule::LibWebRTCAudioModule()
+ : m_audioTaskRunner(rtc::Thread::Create())
+{
+ m_audioTaskRunner->Start();
+}
+
+int32_t LibWebRTCAudioModule::RegisterAudioCallback(webrtc::AudioTransport* audioTransport)
+{
+ m_audioTransport = audioTransport;
+ return 0;
+}
+
+void LibWebRTCAudioModule::OnMessage(rtc::Message* message)
+{
+ ASSERT(message->message_id == 1);
+ StartPlayoutOnAudioThread();
+}
+
+int32_t LibWebRTCAudioModule::StartPlayout()
+{
+ if (!m_isPlaying && m_audioTaskRunner) {
+ m_audioTaskRunner->Post(RTC_FROM_HERE, this, 1);
+ m_isPlaying = true;
+ }
+ return 0;
+}
+
+int32_t LibWebRTCAudioModule::StopPlayout()
+{
+ if (m_isPlaying)
+ m_isPlaying = false;
+ return 0;
+}
+
+// libwebrtc uses 10ms frames.
+const unsigned samplingRate = 48000;
+const unsigned frameLengthMs = 10;
+const unsigned samplesPerFrame = samplingRate * frameLengthMs / 1000;
+const unsigned pollSamples = 5;
+const unsigned pollInterval = 5 * frameLengthMs;
+const unsigned channels = 2;
+const unsigned bytesPerSample = 2;
+
+void LibWebRTCAudioModule::StartPlayoutOnAudioThread()
+{
+ while (true) {
+ PollFromSource();
+ m_audioTaskRunner->SleepMs(pollInterval);
+ if (!m_isPlaying)
+ return;
+ }
+}
+
+void LibWebRTCAudioModule::PollFromSource()
+{
+ if (!m_audioTransport)
+ return;
+
+ for (unsigned i = 0; i < pollSamples; i++) {
+ int64_t elapsedTime = -1;
+ int64_t ntpTime = -1;
+ char data[(bytesPerSample * channels * samplesPerFrame)];
+ m_audioTransport->PullRenderData(bytesPerSample * 8, samplingRate, channels, samplesPerFrame, data, &elapsedTime, &ntpTime);
+ }
+}
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
Added: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.h (0 => 211439)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.h (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCAudioModule.h 2017-01-31 18:57:57 UTC (rev 211439)
@@ -0,0 +1,162 @@
+/*
+ * 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 USE(LIBWEBRTC)
+
+#include "LibWebRTCMacros.h"
+#include <webrtc/base/messagehandler.h>
+#include <webrtc/base/thread.h>
+#include <webrtc/modules/audio_device/include/audio_device.h>
+
+namespace WebCore {
+
+// LibWebRTCAudioModule is pulling streamed data to ensure audio data is passed to the audio track.
+class LibWebRTCAudioModule final : public webrtc::AudioDeviceModule, private rtc::MessageHandler {
+public:
+ LibWebRTCAudioModule();
+
+private:
+ template<typename U> U shouldNotBeCalled(U value) const
+ {
+ ASSERT_NOT_REACHED();
+ return value;
+ }
+
+ int32_t AddRef() const final { return 1; }
+ int32_t Release() const final { return 1; }
+ void OnMessage(rtc::Message*);
+
+ // webrtc::AudioDeviceModule API
+ int32_t StartPlayout() final;
+ int32_t StopPlayout() final;
+ int32_t RegisterAudioCallback(webrtc::AudioTransport*) final;
+ bool Playing() const final { return m_isPlaying; }
+
+ int64_t TimeUntilNextProcess() final { return std::numeric_limits<int64_t>::max(); }
+ void Process() final { }
+ int32_t ActiveAudioLayer(AudioLayer*) const final { return shouldNotBeCalled(-1); }
+ ErrorCode LastError() const final { return kAdmErrNone; }
+ int32_t RegisterEventObserver(webrtc::AudioDeviceObserver*) final { return 0; }
+ int32_t Init() final { return 0; }
+ int32_t Terminate() final { return 0; }
+ bool Initialized() const final { return true; }
+ int16_t PlayoutDevices() final { return 0; }
+ int16_t RecordingDevices() final { return 0; }
+ int32_t PlayoutDeviceName(uint16_t, char[webrtc::kAdmMaxDeviceNameSize], char[webrtc::kAdmMaxGuidSize]) final { return 0; }
+ int32_t RecordingDeviceName(uint16_t, char[webrtc::kAdmMaxDeviceNameSize], char[webrtc::kAdmMaxGuidSize]) final { return 0; }
+ int32_t SetPlayoutDevice(uint16_t) final { return 0; }
+ int32_t SetPlayoutDevice(WindowsDeviceType) final { return 0; }
+ int32_t SetRecordingDevice(uint16_t) final { return 0; }
+ int32_t SetRecordingDevice(WindowsDeviceType) final { return 0; }
+ int32_t PlayoutIsAvailable(bool*) final { return shouldNotBeCalled(-1); }
+ int32_t InitPlayout() final { return 0; }
+ bool PlayoutIsInitialized() const final { return true; }
+ int32_t RecordingIsAvailable(bool*) final { return shouldNotBeCalled(-1); }
+ int32_t InitRecording() final { return 0; }
+ bool RecordingIsInitialized() const final { return false; }
+ int32_t StartRecording() final { return 0; }
+ int32_t StopRecording() final { return 0; }
+ bool Recording() const final { return 0; }
+ int32_t SetAGC(bool) final { return 0; }
+ bool AGC() const final { return shouldNotBeCalled(0); }
+ int32_t SetWaveOutVolume(uint16_t, uint16_t) final { return shouldNotBeCalled(-1); }
+ int32_t WaveOutVolume(uint16_t*, uint16_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t InitSpeaker() final { return 0; }
+ bool SpeakerIsInitialized() const final { return false; }
+ int32_t InitMicrophone() final { return 0; }
+ bool MicrophoneIsInitialized() const final { return false; }
+ int32_t SpeakerVolumeIsAvailable(bool*) final { return shouldNotBeCalled(-1); }
+ int32_t SetSpeakerVolume(uint32_t) final { return shouldNotBeCalled(-1); }
+ int32_t SpeakerVolume(uint32_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t MaxSpeakerVolume(uint32_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t MinSpeakerVolume(uint32_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t SpeakerVolumeStepSize(uint16_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t MicrophoneVolumeIsAvailable(bool*) final { return shouldNotBeCalled(-1); }
+ int32_t SetMicrophoneVolume(uint32_t) final { return shouldNotBeCalled(-1); }
+ int32_t MicrophoneVolume(uint32_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t MaxMicrophoneVolume(uint32_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t MinMicrophoneVolume(uint32_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t MicrophoneVolumeStepSize(uint16_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t SpeakerMuteIsAvailable(bool*) final { return shouldNotBeCalled(-1); }
+ int32_t SetSpeakerMute(bool) final { return shouldNotBeCalled(-1); }
+ int32_t SpeakerMute(bool*) const final { return shouldNotBeCalled(-1); }
+ int32_t MicrophoneMuteIsAvailable(bool*) final { return shouldNotBeCalled(-1); }
+ int32_t SetMicrophoneMute(bool) final { return shouldNotBeCalled(-1); }
+ int32_t MicrophoneMute(bool*) const final { return shouldNotBeCalled(-1); }
+ int32_t MicrophoneBoostIsAvailable(bool*) final { return shouldNotBeCalled(-1); }
+ int32_t SetMicrophoneBoost(bool) final { return shouldNotBeCalled(-1); }
+ int32_t MicrophoneBoost(bool*) const final { return shouldNotBeCalled(-1); }
+ int32_t StereoPlayoutIsAvailable(bool* available) const final { *available = false; return 0; }
+ int32_t SetStereoPlayout(bool) final { return 0; }
+ int32_t StereoPlayout(bool*) const final { return shouldNotBeCalled(-1); }
+ int32_t StereoRecordingIsAvailable(bool* available) const final { *available = false; return 0; }
+ int32_t SetStereoRecording(bool) final { return 0; }
+ int32_t StereoRecording(bool*) const final { return shouldNotBeCalled(-1); }
+ int32_t SetRecordingChannel(const ChannelType) final { return 0; }
+ int32_t RecordingChannel(ChannelType*) const final { return shouldNotBeCalled(-1); }
+ int32_t SetPlayoutBuffer(const BufferType, uint16_t) final { return shouldNotBeCalled(-1); }
+ int32_t PlayoutBuffer(BufferType*, uint16_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t PlayoutDelay(uint16_t* delay) const final { *delay = 0; return 0; }
+ int32_t RecordingDelay(uint16_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t CPULoad(uint16_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t StartRawOutputFileRecording(const char[webrtc::kAdmMaxFileNameSize]) final { return shouldNotBeCalled(-1); }
+ int32_t StopRawOutputFileRecording() final { return shouldNotBeCalled(-1); }
+ int32_t StartRawInputFileRecording(const char[webrtc::kAdmMaxFileNameSize]) final { return shouldNotBeCalled(-1); }
+ int32_t StopRawInputFileRecording() final { return shouldNotBeCalled(-1); }
+ int32_t SetRecordingSampleRate(const uint32_t) final { return shouldNotBeCalled(-1); }
+ int32_t RecordingSampleRate(uint32_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t SetPlayoutSampleRate(const uint32_t) final { return shouldNotBeCalled(-1); }
+ int32_t PlayoutSampleRate(uint32_t*) const final { return shouldNotBeCalled(-1); }
+ int32_t ResetAudioDevice() final { return shouldNotBeCalled(-1); }
+ int32_t SetLoudspeakerStatus(bool) final { return shouldNotBeCalled(-1); }
+ int32_t GetLoudspeakerStatus(bool*) const final { return shouldNotBeCalled(-1); }
+ bool BuiltInAECIsAvailable() const final { return false; }
+ bool BuiltInAGCIsAvailable() const final { return false; }
+ bool BuiltInNSIsAvailable() const final { return false; }
+ int32_t EnableBuiltInAEC(bool) final { return shouldNotBeCalled(-1); }
+ int32_t EnableBuiltInAGC(bool) final { return shouldNotBeCalled(-1); }
+ int32_t EnableBuiltInNS(bool) final { return shouldNotBeCalled(-1); }
+
+#if defined(WEBRTC_IOS)
+ int GetPlayoutAudioParameters(webrtc::AudioParameters*) const final { return shouldNotBeCalled(-1); }
+ int GetRecordAudioParameters(webrtc::AudioParameters*) const final { return shouldNotBeCalled(-1); }
+#endif
+
+private:
+ void StartPlayoutOnAudioThread();
+
+ void PollFromSource();
+
+ std::unique_ptr<rtc::Thread> m_audioTaskRunner;
+
+ bool m_isPlaying = false;
+ webrtc::AudioTransport* m_audioTransport = nullptr;
+};
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCUtils.cpp (211438 => 211439)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCUtils.cpp 2017-01-31 18:41:54 UTC (rev 211438)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCUtils.cpp 2017-01-31 18:57:57 UTC (rev 211439)
@@ -1,29 +1,26 @@
/*
- * Copyright (C) 2017 Apple Inc.
+ * 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 required to be met:
+ * 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.
*
- * 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.
+ * 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 "config.h"
@@ -31,6 +28,7 @@
#if USE(LIBWEBRTC)
+#include "LibWebRTCAudioModule.h"
#include <webrtc/api/peerconnectionfactoryproxy.h>
#include <webrtc/api/peerconnectionfactory.h>
#include <webrtc/base/physicalsocketserver.h>
@@ -42,6 +40,7 @@
namespace WebCore {
struct PeerConnectionFactoryAndThreads : public rtc::MessageHandler {
+ std::unique_ptr<LibWebRTCAudioModule> audioDeviceModule;
std::unique_ptr<rtc::Thread> networkThread;
std::unique_ptr<rtc::Thread> signalingThread;
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory;
@@ -96,8 +95,10 @@
result = factoryAndThreads.signalingThread->Start();
ASSERT(result);
- factoryAndThreads.factory = webrtc::CreatePeerConnectionFactory(factoryAndThreads.networkThread.get(), factoryAndThreads.networkThread.get(), factoryAndThreads.signalingThread.get(), nullptr, new webrtc::VideoToolboxVideoEncoderFactory() , new webrtc::VideoToolboxVideoDecoderFactory());
+ factoryAndThreads.audioDeviceModule = std::make_unique<LibWebRTCAudioModule>();
+ factoryAndThreads.factory = webrtc::CreatePeerConnectionFactory(factoryAndThreads.networkThread.get(), factoryAndThreads.networkThread.get(), factoryAndThreads.signalingThread.get(), factoryAndThreads.audioDeviceModule.get(), new webrtc::VideoToolboxVideoEncoderFactory(), new webrtc::VideoToolboxVideoDecoderFactory());
+
ASSERT(factoryAndThreads.factory);
}