From 1151cab1440c6bb009b016befa69616dc9011a3f Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 24 Jan 2024 14:11:40 +0900 Subject: [PATCH] =?UTF-8?q?M121=20=E3=81=A7=E5=8B=95=E3=81=84=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/sora/sora_client_context.h | 9 ------- src/sora_client_context.cpp | 38 +++++++----------------------- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/include/sora/sora_client_context.h b/include/sora/sora_client_context.h index 77619eed..5430a1e4 100644 --- a/include/sora/sora_client_context.h +++ b/include/sora/sora_client_context.h @@ -18,12 +18,6 @@ struct SoraClientContextConfig { // false にするとソフトウェアエンコーダ/デコーダのみになる(H.264 は利用できない) bool use_hardware_encoder = true; - // MediaEngineDependencies をカスタマイズするためのコールバック関数 - // デフォルトの値が設定された上で、cricket::CreateMediaEngine を生成する直前に呼ばれる - std::function - configure_media_dependencies; - // PeerConnectionFactoryDependencies をカスタマイズするためのコールバック関数 // デフォルトの値が設定された上で、PeerConnectionFactory を生成する直前に呼ばれる std::function @@ -43,9 +37,6 @@ struct SoraClientContextConfig { // 使い方: // sora::SoraClientContextConfig context_config; // // 必要なら context_config をカスタマイズする -// context_config.configure_media_dependencies = -// [](const webrtc::PeerConnectionFactoryDependencies& dep, -// cricket::MediaEngineDependencies& mdep) { ... }; // context_config.configure_dependencies = [](webrtc::PeerConnectionFactoryDependencies& dep) { ... }; // // Android に対応する場合は get_android_application_context を設定する // context_config.get_android_application_context = [](void* env) { ... }; diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index 62ec5f4c..a6d4ab52 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -67,10 +67,7 @@ std::shared_ptr SoraClientContext::Create( void* env = sora::GetJNIEnv(); - // media_dependencies - cricket::MediaEngineDependencies media_dependencies; - media_dependencies.task_queue_factory = dependencies.task_queue_factory.get(); - media_dependencies.adm = c->worker_thread_->BlockingCall([&] { + dependencies.adm = c->worker_thread_->BlockingCall([&] { sora::AudioDeviceModuleConfig config; if (!c->config_.use_audio_device) { config.audio_layer = webrtc::AudioDeviceModule::kDummyAudio; @@ -84,10 +81,8 @@ std::shared_ptr SoraClientContext::Create( return sora::CreateAudioDeviceModule(config); }); - media_dependencies.audio_encoder_factory = - sora::CreateBuiltinAudioEncoderFactory(); - media_dependencies.audio_decoder_factory = - sora::CreateBuiltinAudioDecoderFactory(); + dependencies.audio_encoder_factory = sora::CreateBuiltinAudioEncoderFactory(); + dependencies.audio_decoder_factory = sora::CreateBuiltinAudioDecoderFactory(); std::shared_ptr cuda_context; if (c->config_.use_hardware_encoder) { @@ -100,7 +95,7 @@ std::shared_ptr SoraClientContext::Create( ? sora::GetDefaultVideoEncoderFactoryConfig(cuda_context, env) : sora::GetSoftwareOnlyVideoEncoderFactoryConfig(); config.use_simulcast_adapter = true; - media_dependencies.video_encoder_factory = + dependencies.video_encoder_factory = absl::make_unique(std::move(config)); } { @@ -108,35 +103,18 @@ std::shared_ptr SoraClientContext::Create( c->config_.use_hardware_encoder ? sora::GetDefaultVideoDecoderFactoryConfig(cuda_context, env) : sora::GetSoftwareOnlyVideoDecoderFactoryConfig(); - media_dependencies.video_decoder_factory = + dependencies.video_decoder_factory = absl::make_unique(std::move(config)); } - media_dependencies.audio_mixer = nullptr; - media_dependencies.audio_processing = - webrtc::AudioProcessingBuilder().Create(); - - if (c->config_.configure_media_dependencies) { - c->config_.configure_media_dependencies(dependencies, media_dependencies); - } - - dependencies.audio_decoder_factory = sora::CreateBuiltinAudioDecoderFactory(); - dependencies.audio_encoder_factory = sora::CreateBuiltinAudioEncoderFactory(); - std::cout << "webrtc::EnableMedia" << std::endl; - webrtc::EnableMedia(dependencies); + dependencies.audio_mixer = nullptr; + dependencies.audio_processing = webrtc::AudioProcessingBuilder().Create(); if (c->config_.configure_dependencies) { c->config_.configure_dependencies(dependencies); } - /* - auto webrtc_env = - webrtc::CreateEnvironment(dependencies.task_queue_factory.get()); - - std::cout << "HOGE: webrtc::ConnectionContext::Create(" << std::endl; - c->connection_context_ = - webrtc::ConnectionContext::Create(webrtc_env, &dependencies); -*/ + webrtc::EnableMedia(dependencies); c->factory_ = sora::CreateModularPeerConnectionFactoryWithContext( std::move(dependencies), c->connection_context_);