webrtc_create_adm.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #include "webrtc/webrtc_create_adm.h"
  8. #include "webrtc/details/webrtc_openal_adm.h"
  9. #include <api/make_ref_counted.h>
  10. #include <modules/audio_device/include/audio_device_factory.h>
  11. #ifdef WEBRTC_WIN
  12. #include "webrtc/platform/win/webrtc_loopback_adm_win.h"
  13. #endif // WEBRTC_WIN
  14. namespace Webrtc {
  15. rtc::scoped_refptr<webrtc::AudioDeviceModule> CreateAudioDeviceModule(
  16. webrtc::TaskQueueFactory *factory,
  17. Fn<void(Fn<void(DeviceResolvedId)>)> saveSetDeviceIdCallback) {
  18. auto result = rtc::make_ref_counted<details::AudioDeviceOpenAL>(factory);
  19. if (!result || result->Init() != 0) {
  20. return nullptr;
  21. }
  22. saveSetDeviceIdCallback(result->setDeviceIdCallback());
  23. return result;
  24. }
  25. auto AudioDeviceModuleCreator(
  26. Fn<void(Fn<void(DeviceResolvedId)>)> saveSetDeviceIdCallback)
  27. -> std::function<AudioDeviceModulePtr(webrtc::TaskQueueFactory*)> {
  28. return [=](webrtc::TaskQueueFactory *factory) {
  29. return CreateAudioDeviceModule(factory, saveSetDeviceIdCallback);
  30. };
  31. }
  32. AudioDeviceModulePtr CreateLoopbackAudioDeviceModule(
  33. webrtc::TaskQueueFactory* factory) {
  34. #ifdef WEBRTC_WIN
  35. auto result = rtc::make_ref_counted<details::AudioDeviceLoopbackWin>(
  36. factory);
  37. if (result->Init() == 0) {
  38. return result;
  39. }
  40. #endif // WEBRTC_WIN
  41. return nullptr;
  42. }
  43. auto LoopbackAudioDeviceModuleCreator()
  44. -> std::function<AudioDeviceModulePtr(webrtc::TaskQueueFactory*)> {
  45. return CreateLoopbackAudioDeviceModule;
  46. }
  47. } // namespace Webrtc