Skip to content

Commit

Permalink
最終的に webrtc::CreateEnvironment を実行する回数が変わらないので、 webrtc::Environment を…
Browse files Browse the repository at this point in the history
…引き回すのを止める
  • Loading branch information
enm10k committed May 10, 2024
1 parent ba0da74 commit 9d5eb9b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
6 changes: 2 additions & 4 deletions include/sora/sora_video_decoder_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ class SoraVideoDecoderFactory : public webrtc::VideoDecoderFactory {
// ハードウェアデコーダを出来るだけ使おうとして、見つからなければソフトウェアデコーダを使う設定を返す
SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig(
std::shared_ptr<CudaContext> cuda_context = nullptr,
void* jni_env = nullptr,
webrtc::Environment env = webrtc::CreateEnvironment());
void* jni_env = nullptr);
// ソフトウェアデコーダのみを使う設定を返す
SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig(
webrtc::Environment env = webrtc::CreateEnvironment());
SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig();

} // namespace sora

Expand Down
11 changes: 4 additions & 7 deletions src/sora_client_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,10 @@ std::shared_ptr<SoraClientContext> SoraClientContext::Create(
absl::make_unique<sora::SoraVideoEncoderFactory>(std::move(config));
}
{
// SDK の外部から webrtc::Environment を設定したくなるまで、ここで初期化する
auto env = webrtc::CreateEnvironment();

auto config = c->config_.use_hardware_encoder
? sora::GetDefaultVideoDecoderFactoryConfig(cuda_context,
jni_env, env)
: sora::GetSoftwareOnlyVideoDecoderFactoryConfig(env);
auto config =
c->config_.use_hardware_encoder
? sora::GetDefaultVideoDecoderFactoryConfig(cuda_context, jni_env)
: sora::GetSoftwareOnlyVideoDecoderFactoryConfig();
dependencies.video_decoder_factory =
absl::make_unique<sora::SoraVideoDecoderFactory>(std::move(config));
}
Expand Down
9 changes: 4 additions & 5 deletions src/sora_video_decoder_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ std::unique_ptr<webrtc::VideoDecoder> SoraVideoDecoderFactory::Create(

SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig(
std::shared_ptr<CudaContext> cuda_context,
void* jni_env,
webrtc::Environment env) {
auto config = GetSoftwareOnlyVideoDecoderFactoryConfig(env);
void* jni_env) {
auto config = GetSoftwareOnlyVideoDecoderFactoryConfig();

#if defined(__APPLE__)
config.decoders.insert(config.decoders.begin(),
Expand Down Expand Up @@ -251,8 +250,8 @@ SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig(
return config;
}

SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig(
webrtc::Environment env) {
SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig() {
auto env = webrtc::CreateEnvironment();
SoraVideoDecoderFactoryConfig config;
config.decoders.push_back(VideoDecoderConfig(
webrtc::kVideoCodecVP8,
Expand Down

0 comments on commit 9d5eb9b

Please sign in to comment.