voip_engine_factory.h (3430B)
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 #include <optional> 16 17 #include "api/audio/audio_device.h" 18 #include "api/audio/audio_processing.h" 19 #include "api/audio_codecs/audio_decoder_factory.h" 20 #include "api/audio_codecs/audio_encoder_factory.h" 21 #include "api/environment/environment.h" 22 #include "api/scoped_refptr.h" 23 #include "api/task_queue/task_queue_factory.h" 24 #include "api/voip/voip_engine.h" 25 26 namespace webrtc { 27 28 // VoipEngineConfig is a struct that defines parameters to instantiate a 29 // VoipEngine instance through CreateVoipEngine factory method. Each member is 30 // marked with comments as either mandatory or optional and default 31 // implementations that applications can use. 32 struct VoipEngineConfig { 33 // Mandatory (e.g. api/audio_codec/builtin_audio_encoder_factory). 34 // AudioEncoderFactory provides a set of audio codecs for VoipEngine to encode 35 // the audio input sample. Application can choose to limit the set to reduce 36 // application footprint. 37 scoped_refptr<AudioEncoderFactory> encoder_factory; 38 39 // Mandatory (e.g. api/audio_codec/builtin_audio_decoder_factory). 40 // AudioDecoderFactory provides a set of audio codecs for VoipEngine to decode 41 // the received RTP packets from remote media endpoint. Application can choose 42 // to limit the set to reduce application footprint. 43 scoped_refptr<AudioDecoderFactory> decoder_factory; 44 45 // Optional (e.g. api/task_queue/default_task_queue_factory). 46 // TaskQueueFactory provided for VoipEngine to work asynchronously on its 47 // encoding flow. 48 // It is an error to provide both `env` and `task_queue_factory`. 49 std::unique_ptr<TaskQueueFactory> task_queue_factory; 50 51 // Mandatory (e.g. modules/audio_device/include). 52 // AudioDeviceModule that periocally provides audio input samples from 53 // recording device (e.g. microphone) and requests audio output samples to 54 // play through its output device (e.g. speaker). 55 scoped_refptr<AudioDeviceModule> audio_device_module; 56 57 // Optional. When not set, VoipEngine will use a default Environment created 58 // with `CreateEnvironment`, see api/environment/environment_factory.h 59 // Provides 60 // - TaskQueueFactory to work asynchronously on VoipEngine encoding flow 61 // - FieldTrialsView for experimentations 62 std::optional<Environment> env; 63 64 // Optional (e.g. api/audio/builtin_audio_processing_builder). 65 // AudioProcessing provides audio procesing functionalities (e.g. acoustic 66 // echo cancellation, noise suppression, gain control, etc) on audio input 67 // samples for VoipEngine. When optionally not set, VoipEngine will not have 68 // such functionalities to perform on audio input samples received from 69 // AudioDeviceModule. 70 std::unique_ptr<AudioProcessingBuilderInterface> audio_processing_builder; 71 }; 72 73 // Creates a VoipEngine instance with provided VoipEngineConfig. 74 std::unique_ptr<VoipEngine> CreateVoipEngine(VoipEngineConfig config); 75 76 } // namespace webrtc 77 78 #endif // API_VOIP_VOIP_ENGINE_FACTORY_H_