voip_engine_factory.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef API_VOIP_VOIP_ENGINE_FACTORY_H_
  11. #define API_VOIP_VOIP_ENGINE_FACTORY_H_
  12. #include <memory>
  13. #include "api/audio_codecs/audio_decoder_factory.h"
  14. #include "api/audio_codecs/audio_encoder_factory.h"
  15. #include "api/scoped_refptr.h"
  16. #include "api/task_queue/task_queue_factory.h"
  17. #include "api/voip/voip_engine.h"
  18. #include "modules/audio_device/include/audio_device.h"
  19. #include "modules/audio_processing/include/audio_processing.h"
  20. namespace webrtc {
  21. // VoipEngineConfig is a struct that defines parameters to instantiate a
  22. // VoipEngine instance through CreateVoipEngine factory method. Each member is
  23. // marked with comments as either mandatory or optional and default
  24. // implementations that applications can use.
  25. struct VoipEngineConfig {
  26. // Mandatory (e.g. api/audio_codec/builtin_audio_encoder_factory).
  27. // AudioEncoderFactory provides a set of audio codecs for VoipEngine to encode
  28. // the audio input sample. Application can choose to limit the set to reduce
  29. // application footprint.
  30. rtc::scoped_refptr<AudioEncoderFactory> encoder_factory;
  31. // Mandatory (e.g. api/audio_codec/builtin_audio_decoder_factory).
  32. // AudioDecoderFactory provides a set of audio codecs for VoipEngine to decode
  33. // the received RTP packets from remote media endpoint. Application can choose
  34. // to limit the set to reduce application footprint.
  35. rtc::scoped_refptr<AudioDecoderFactory> decoder_factory;
  36. // Mandatory (e.g. api/task_queue/default_task_queue_factory).
  37. // TaskQeueuFactory provided for VoipEngine to work asynchronously on its
  38. // encoding flow.
  39. std::unique_ptr<TaskQueueFactory> task_queue_factory;
  40. // Mandatory (e.g. modules/audio_device/include).
  41. // AudioDeviceModule that periocally provides audio input samples from
  42. // recording device (e.g. microphone) and requests audio output samples to
  43. // play through its output device (e.g. speaker).
  44. rtc::scoped_refptr<AudioDeviceModule> audio_device_module;
  45. // Optional (e.g. modules/audio_processing/include).
  46. // AudioProcessing provides audio procesing functionalities (e.g. acoustic
  47. // echo cancellation, noise suppression, gain control, etc) on audio input
  48. // samples for VoipEngine. When optionally not set, VoipEngine will not have
  49. // such functionalities to perform on audio input samples received from
  50. // AudioDeviceModule.
  51. rtc::scoped_refptr<AudioProcessing> audio_processing;
  52. };
  53. // Creates a VoipEngine instance with provided VoipEngineConfig.
  54. // This could return nullptr if AudioDeviceModule (ADM) initialization fails
  55. // during construction of VoipEngine which would render VoipEngine
  56. // nonfunctional.
  57. std::unique_ptr<VoipEngine> CreateVoipEngine(VoipEngineConfig config);
  58. } // namespace webrtc
  59. #endif // API_VOIP_VOIP_ENGINE_FACTORY_H_