Skip to content

Commit

Permalink
First attempt at LoopBack ADM on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jul 9, 2021
1 parent 9a5a5de commit 5d16a97
Show file tree
Hide file tree
Showing 6 changed files with 931 additions and 5 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,28 @@ PRIVATE
webrtc/webrtc_video_track.cpp
webrtc/webrtc_video_track.h

webrtc/linux/webrtc_media_devices_linux.h
webrtc/details/webrtc_openal_adm.cpp
webrtc/details/webrtc_openal_adm.h

webrtc/linux/webrtc_media_devices_linux.cpp
webrtc/linux/webrtc_media_devices_linux.h

webrtc/mac/webrtc_media_devices_mac.h
webrtc/mac/webrtc_media_devices_mac.mm

webrtc/details/webrtc_openal_adm.cpp
webrtc/details/webrtc_openal_adm.h
webrtc/win/webrtc_loopback_adm_win.cpp
webrtc/win/webrtc_loopback_adm_win.h

webrtc/webrtc_pch.h
)

if (APPLE)
if (WIN32)
target_compile_definitions(lib_webrtc
PRIVATE
WEBRTC_WIN
)
nuget_add_winrt(lib_webrtc)
elseif (APPLE)
target_compile_definitions(lib_webrtc
PRIVATE
WEBRTC_MAC
Expand Down
1 change: 0 additions & 1 deletion webrtc/details/webrtc_openal_adm.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class AudioDeviceOpenAL : public webrtc::AudioDeviceModule {
explicit AudioDeviceOpenAL(webrtc::TaskQueueFactory *taskQueueFactory);
~AudioDeviceOpenAL();


int32_t ActiveAudioLayer(AudioLayer *audioLayer) const override;
int32_t RegisterAudioCallback(
webrtc::AudioTransport *audioCallback) override;
Expand Down
25 changes: 25 additions & 0 deletions webrtc/webrtc_create_adm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "rtc_base/ref_counted_object.h"
#include "modules/audio_device/include/audio_device_factory.h"

#ifdef WEBRTC_WIN
#include "webrtc/win/webrtc_loopback_adm_win.h"
#endif // WEBRTC_WIN

namespace Webrtc {

rtc::scoped_refptr<webrtc::AudioDeviceModule> CreateAudioDeviceModule(
Expand Down Expand Up @@ -55,4 +59,25 @@ auto AudioDeviceModuleCreator(Backend backend)
};
}

AudioDeviceModulePtr CreateLoopbackAudioDeviceModule(
webrtc::TaskQueueFactory* factory) {
const auto check = [&](
const rtc::scoped_refptr<webrtc::AudioDeviceModule> &result) {
return (result && (result->Init() == 0)) ? result : nullptr;
};
#ifdef WEBRTC_WIN
auto result = rtc::scoped_refptr<webrtc::AudioDeviceModule>(
new rtc::RefCountedObject<details::AudioDeviceLoopbackWin>(factory));
if (result->Init() == 0) {
return result;
}
#endif // WEBRTC_WIN
return nullptr;
}

auto LoopbackAudioDeviceModuleCreator()
-> std::function<AudioDeviceModulePtr(webrtc::TaskQueueFactory*)> {
return CreateLoopbackAudioDeviceModule;
}

} // namespace Webrtc
6 changes: 6 additions & 0 deletions webrtc/webrtc_create_adm.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ AudioDeviceModulePtr CreateAudioDeviceModule(
auto AudioDeviceModuleCreator(Backend backend)
-> std::function<AudioDeviceModulePtr(webrtc::TaskQueueFactory*)>;

AudioDeviceModulePtr CreateLoopbackAudioDeviceModule(
webrtc::TaskQueueFactory* factory);

auto LoopbackAudioDeviceModuleCreator()
-> std::function<AudioDeviceModulePtr(webrtc::TaskQueueFactory*)>;

} // namespace Webrtc
Loading

0 comments on commit 5d16a97

Please sign in to comment.