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 11 #ifndef API_VOIP_VOIP_ENGINE_FACTORY_H_ 12 #define API_VOIP_VOIP_ENGINE_FACTORY_H_ 13 14 #include <memory> 15 16 #include "api/audio_codecs/audio_decoder_factory.h" 17 #include "api/audio_codecs/audio_encoder_factory.h" 18 #include "api/scoped_refptr.h" 19 #include "api/task_queue/task_queue_factory.h" 20 #include "api/voip/voip_engine.h" 21 #include "modules/audio_device/include/audio_device.h" 22 #include "modules/audio_processing/include/audio_processing.h" 23 24 namespace webrtc { 25 26 // VoipEngineConfig is a struct that defines parameters to instantiate a 27 // VoipEngine instance through CreateVoipEngine factory method. Each member is 28 // marked with comments as either mandatory or optional and default 29 // implementations that applications can use. 30 struct VoipEngineConfig { 31 // Mandatory (e.g. api/audio_codec/builtin_audio_encoder_factory). 32 // AudioEncoderFactory provides a set of audio codecs for VoipEngine to encode 33 // the audio input sample. Application can choose to limit the set to reduce 34 // application footprint. 35 rtc::scoped_refptr<AudioEncoderFactory> encoder_factory; 36 37 // Mandatory (e.g. api/audio_codec/builtin_audio_decoder_factory). 38 // AudioDecoderFactory provides a set of audio codecs for VoipEngine to decode 39 // the received RTP packets from remote media endpoint. Application can choose 40 // to limit the set to reduce application footprint. 41 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory; 42 43 // Mandatory (e.g. api/task_queue/default_task_queue_factory). 44 // TaskQeueuFactory provided for VoipEngine to work asynchronously on its 45 // encoding flow. 46 std::unique_ptr<TaskQueueFactory> task_queue_factory; 47 48 // Mandatory (e.g. modules/audio_device/include). 49 // AudioDeviceModule that periocally provides audio input samples from 50 // recording device (e.g. microphone) and requests audio output samples to 51 // play through its output device (e.g. speaker). 52 rtc::scoped_refptr<AudioDeviceModule> audio_device_module; 53 54 // Optional (e.g. modules/audio_processing/include). 55 // AudioProcessing provides audio procesing functionalities (e.g. acoustic 56 // echo cancellation, noise suppression, gain control, etc) on audio input 57 // samples for VoipEngine. When optionally not set, VoipEngine will not have 58 // such functionalities to perform on audio input samples received from 59 // AudioDeviceModule. 60 rtc::scoped_refptr<AudioProcessing> audio_processing; 61 }; 62 63 // Creates a VoipEngine instance with provided VoipEngineConfig. 64 // This could return nullptr if AudioDeviceModule (ADM) initialization fails 65 // during construction of VoipEngine which would render VoipEngine 66 // nonfunctional. 67 std::unique_ptr<VoipEngine> CreateVoipEngine(VoipEngineConfig config); 68 69 } // namespace webrtc 70 71 #endif // API_VOIP_VOIP_ENGINE_FACTORY_H_ 72