Skip to content

Commit

Permalink
M121 で動いた
Browse files Browse the repository at this point in the history
  • Loading branch information
enm10k committed Jan 24, 2024
1 parent 12bcfab commit 1151cab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 39 deletions.
9 changes: 0 additions & 9 deletions include/sora/sora_client_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ struct SoraClientContextConfig {
// false にするとソフトウェアエンコーダ/デコーダのみになる(H.264 は利用できない)
bool use_hardware_encoder = true;

// MediaEngineDependencies をカスタマイズするためのコールバック関数
// デフォルトの値が設定された上で、cricket::CreateMediaEngine を生成する直前に呼ばれる
std::function<void(const webrtc::PeerConnectionFactoryDependencies&,
cricket::MediaEngineDependencies&)>
configure_media_dependencies;

// PeerConnectionFactoryDependencies をカスタマイズするためのコールバック関数
// デフォルトの値が設定された上で、PeerConnectionFactory を生成する直前に呼ばれる
std::function<void(webrtc::PeerConnectionFactoryDependencies&)>
Expand All @@ -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) { ... };
Expand Down
38 changes: 8 additions & 30 deletions src/sora_client_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ std::shared_ptr<SoraClientContext> 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;
Expand All @@ -84,10 +81,8 @@ std::shared_ptr<SoraClientContext> 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<sora::CudaContext> cuda_context;
if (c->config_.use_hardware_encoder) {
Expand All @@ -100,43 +95,26 @@ std::shared_ptr<SoraClientContext> 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<sora::SoraVideoEncoderFactory>(std::move(config));
}
{
auto config =
c->config_.use_hardware_encoder
? sora::GetDefaultVideoDecoderFactoryConfig(cuda_context, env)
: sora::GetSoftwareOnlyVideoDecoderFactoryConfig();
media_dependencies.video_decoder_factory =
dependencies.video_decoder_factory =
absl::make_unique<sora::SoraVideoDecoderFactory>(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_);
Expand Down

0 comments on commit 1151cab

Please sign in to comment.