Skip to content

Commit

Permalink
互換性を維持するために webrtc::Environment を最後の変数として追加し、デフォルト値を指定する
Browse files Browse the repository at this point in the history
  • Loading branch information
enm10k committed May 10, 2024
1 parent 3e789b1 commit ba0da74
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions include/sora/sora_video_decoder_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <vector>

// WebRTC
#include <api/environment/environment.h>
#include <api/environment/environment_factory.h>
#include <api/video/video_codec_type.h>
#include <api/video_codecs/video_decoder_factory.h>

Expand Down Expand Up @@ -64,12 +64,12 @@ class SoraVideoDecoderFactory : public webrtc::VideoDecoderFactory {

// ハードウェアデコーダを出来るだけ使おうとして、見つからなければソフトウェアデコーダを使う設定を返す
SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig(
webrtc::Environment& env,
std::shared_ptr<CudaContext> cuda_context = nullptr,
void* jni_env = nullptr);
void* jni_env = nullptr,
webrtc::Environment env = webrtc::CreateEnvironment());
// ソフトウェアデコーダのみを使う設定を返す
SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig(
webrtc::Environment& env);
webrtc::Environment env = webrtc::CreateEnvironment());

} // namespace sora

Expand Down
4 changes: 2 additions & 2 deletions src/sora_client_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ std::shared_ptr<SoraClientContext> SoraClientContext::Create(
auto env = webrtc::CreateEnvironment();

auto config = c->config_.use_hardware_encoder
? sora::GetDefaultVideoDecoderFactoryConfig(
env, cuda_context, jni_env)
? sora::GetDefaultVideoDecoderFactoryConfig(cuda_context,
jni_env, env)
: sora::GetSoftwareOnlyVideoDecoderFactoryConfig(env);
dependencies.video_decoder_factory =
absl::make_unique<sora::SoraVideoDecoderFactory>(std::move(config));
Expand Down
2 changes: 1 addition & 1 deletion src/sora_peer_connection_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PeerConnectionFactoryWithContext : public webrtc::PeerConnectionFactory {
PeerConnectionFactoryWithContext(
webrtc::PeerConnectionFactoryDependencies dependencies)
: PeerConnectionFactoryWithContext(
// TODO(enm10k): environment を外部から設定できるようにする
// SDK の外部から webrtc::Environment を設定したくなるまで、ここで初期化する
webrtc::ConnectionContext::Create(webrtc::CreateEnvironment(),
&dependencies),
&dependencies) {}
Expand Down
6 changes: 3 additions & 3 deletions src/sora_video_decoder_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ std::unique_ptr<webrtc::VideoDecoder> SoraVideoDecoderFactory::Create(
}

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

#if defined(__APPLE__)
Expand Down Expand Up @@ -252,7 +252,7 @@ SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig(
}

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

0 comments on commit ba0da74

Please sign in to comment.