voip_engine_factory.cc (1733B)
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 #include "api/voip/voip_engine_factory.h" 12 13 #include <memory> 14 #include <utility> 15 16 #include "api/audio/audio_processing.h" 17 #include "api/environment/environment.h" 18 #include "api/environment/environment_factory.h" 19 #include "api/scoped_refptr.h" 20 #include "api/voip/voip_engine.h" 21 #include "audio/voip/voip_core.h" 22 #include "rtc_base/checks.h" 23 #include "rtc_base/logging.h" 24 25 namespace webrtc { 26 27 std::unique_ptr<VoipEngine> CreateVoipEngine(VoipEngineConfig config) { 28 RTC_CHECK(config.encoder_factory); 29 RTC_CHECK(config.decoder_factory); 30 RTC_CHECK(config.audio_device_module); 31 32 RTC_CHECK(config.task_queue_factory == nullptr || !config.env.has_value()); 33 Environment env = 34 config.env.has_value() 35 ? *config.env 36 : CreateEnvironment(std::move(config.task_queue_factory)); 37 38 scoped_refptr<AudioProcessing> audio_processing; 39 if (config.audio_processing_builder != nullptr) { 40 audio_processing = std::move(config.audio_processing_builder)->Build(env); 41 } 42 43 if (audio_processing == nullptr) { 44 RTC_DLOG(LS_INFO) << "No audio processing functionality provided."; 45 } 46 47 return std::make_unique<VoipCore>( 48 env, std::move(config.encoder_factory), std::move(config.decoder_factory), 49 std::move(config.audio_device_module), std::move(audio_processing)); 50 } 51 52 } // namespace webrtc