From 90207d6e076ca3ec07f40f8fdf210abc2442c363 Mon Sep 17 00:00:00 2001 From: enm10k Date: Tue, 7 May 2024 15:32:14 +0900 Subject: [PATCH 01/16] =?UTF-8?q?libwebrtc=20=E3=82=92=20m124.6367.3.1=20?= =?UTF-8?q?=E3=81=AB=E3=81=82=E3=81=92=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- examples/VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 4c948067..a66e2774 100644 --- a/VERSION +++ b/VERSION @@ -1,5 +1,5 @@ SORA_CPP_SDK_VERSION=2024.6.1 -WEBRTC_BUILD_VERSION=m123.6312.3.5 +WEBRTC_BUILD_VERSION=m124.6367.3.1 BOOST_VERSION=1.85.0 CMAKE_VERSION=3.28.1 CUDA_VERSION=11.8.0-1 diff --git a/examples/VERSION b/examples/VERSION index b9e713d9..53dbce82 100644 --- a/examples/VERSION +++ b/examples/VERSION @@ -1,5 +1,5 @@ SORA_CPP_SDK_VERSION=2024.6.1 -WEBRTC_BUILD_VERSION=m123.6312.3.5 +WEBRTC_BUILD_VERSION=m124.6367.3.1 BOOST_VERSION=1.85.0 CMAKE_VERSION=3.28.1 SDL2_VERSION=2.30.3 From 4861e1386b5fe34ef3d152daf45b82c0b3d02207 Mon Sep 17 00:00:00 2001 From: enm10k Date: Tue, 7 May 2024 18:20:12 +0900 Subject: [PATCH 02/16] =?UTF-8?q?webrtc::VideoDecoderFactory=20=E5=88=9D?= =?UTF-8?q?=E6=9C=9F=E5=8C=96=E6=99=82=E3=81=AB=20webrtc::Environment=20?= =?UTF-8?q?=E3=81=AE=E6=8C=87=E5=AE=9A=E3=81=8C=E5=BF=85=E8=A6=81=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/VERSION | 2 +- .../src/messaging_recvonly_sample.cpp | 6 ++++- examples/sdl_sample/src/sdl_sample.cpp | 6 ++++- examples/sumomo/src/sumomo.cpp | 6 ++++- include/sora/sora_client_context.h | 3 ++- include/sora/sora_video_decoder_factory.h | 9 ++++--- src/sora_client_context.cpp | 18 +++++++------ src/sora_peer_connection_factory.cpp | 1 + src/sora_video_decoder_factory.cpp | 27 ++++++++++--------- 9 files changed, 50 insertions(+), 28 deletions(-) diff --git a/examples/VERSION b/examples/VERSION index 53dbce82..8921dc58 100644 --- a/examples/VERSION +++ b/examples/VERSION @@ -1,6 +1,6 @@ SORA_CPP_SDK_VERSION=2024.6.1 WEBRTC_BUILD_VERSION=m124.6367.3.1 -BOOST_VERSION=1.85.0 +BOOST_VERSION=1.84.0 CMAKE_VERSION=3.28.1 SDL2_VERSION=2.30.3 CLI11_VERSION=v2.4.2 diff --git a/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp b/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp index b5d85512..e6d88f4c 100644 --- a/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp +++ b/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp @@ -1,3 +1,6 @@ +// WebRTC +#include + // Sora #include @@ -194,7 +197,8 @@ int main(int argc, char* argv[]) { sora::SoraClientContextConfig context_config; context_config.use_audio_device = false; context_config.use_hardware_encoder = false; - auto context = sora::SoraClientContext::Create(context_config); + auto env = webrtc::CreateEnvironment(); + auto context = sora::SoraClientContext::Create(context_config, env); auto messaging_recvonly_sample = std::make_shared(context, config); diff --git a/examples/sdl_sample/src/sdl_sample.cpp b/examples/sdl_sample/src/sdl_sample.cpp index 20a404c9..e7875a7b 100644 --- a/examples/sdl_sample/src/sdl_sample.cpp +++ b/examples/sdl_sample/src/sdl_sample.cpp @@ -1,3 +1,6 @@ +// WebRTC +#include + // Sora #include #include @@ -248,8 +251,9 @@ int main(int argc, char* argv[]) { rtc::LogMessage::LogThreads(); } + auto env = webrtc::CreateEnvironment(); auto context = - sora::SoraClientContext::Create(sora::SoraClientContextConfig()); + sora::SoraClientContext::Create(sora::SoraClientContextConfig(), env); auto sdlsample = std::make_shared(context, config); sdlsample->Run(); diff --git a/examples/sumomo/src/sumomo.cpp b/examples/sumomo/src/sumomo.cpp index 702dbacc..516d055e 100644 --- a/examples/sumomo/src/sumomo.cpp +++ b/examples/sumomo/src/sumomo.cpp @@ -1,3 +1,6 @@ +// WebRTC +#include + // Sora #include #include @@ -447,7 +450,8 @@ int main(int argc, char* argv[]) { context_config.use_hardware_encoder = *use_hardware_encoder; } context_config.openh264 = openh264; - auto context = sora::SoraClientContext::Create(context_config); + auto env = webrtc::CreateEnvironment(); + auto context = sora::SoraClientContext::Create(context_config, env); auto sumomo = std::make_shared(context, config); sumomo->Run(); diff --git a/include/sora/sora_client_context.h b/include/sora/sora_client_context.h index bfa2dc3e..18987dad 100644 --- a/include/sora/sora_client_context.h +++ b/include/sora/sora_client_context.h @@ -56,7 +56,8 @@ struct SoraClientContextConfig { class SoraClientContext { public: static std::shared_ptr Create( - const SoraClientContextConfig& config); + const SoraClientContextConfig& config, + webrtc::Environment& env); ~SoraClientContext(); diff --git a/include/sora/sora_video_decoder_factory.h b/include/sora/sora_video_decoder_factory.h index 7983ae33..7db6b047 100644 --- a/include/sora/sora_video_decoder_factory.h +++ b/include/sora/sora_video_decoder_factory.h @@ -5,6 +5,7 @@ #include // WebRTC +#include #include #include @@ -52,7 +53,8 @@ class SoraVideoDecoderFactory : public webrtc::VideoDecoderFactory { std::vector GetSupportedFormats() const override; - std::unique_ptr CreateVideoDecoder( + std::unique_ptr Create( + const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override; private: @@ -62,10 +64,11 @@ class SoraVideoDecoderFactory : public webrtc::VideoDecoderFactory { // ハードウェアデコーダを出来るだけ使おうとして、見つからなければソフトウェアデコーダを使う設定を返す SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( + webrtc::Environment& env, std::shared_ptr cuda_context = nullptr, - void* env = nullptr); + void* jni_env = nullptr); // ソフトウェアデコーダのみを使う設定を返す -SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig(); +SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig(webrtc::Environment& env); } // namespace sora diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index d91bfc82..dd9cc778 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +// #include #include #include #include @@ -41,7 +41,8 @@ SoraClientContext::~SoraClientContext() { } std::shared_ptr SoraClientContext::Create( - const SoraClientContextConfig& config) { + const SoraClientContextConfig& config, + webrtc::Environment& env) { rtc::InitializeSSL(); std::shared_ptr c = std::make_shared(); @@ -63,7 +64,7 @@ std::shared_ptr SoraClientContext::Create( absl::make_unique( dependencies.task_queue_factory.get()); - void* env = sora::GetJNIEnv(); + void* jni_env = sora::GetJNIEnv(); dependencies.adm = c->worker_thread_->BlockingCall([&] { sora::AudioDeviceModuleConfig config; @@ -92,7 +93,7 @@ std::shared_ptr SoraClientContext::Create( { auto config = c->config_.use_hardware_encoder ? sora::GetDefaultVideoEncoderFactoryConfig( - cuda_context, env, c->config_.openh264) + cuda_context, jni_env, c->config_.openh264) : sora::GetSoftwareOnlyVideoEncoderFactoryConfig( c->config_.openh264); config.use_simulcast_adapter = true; @@ -102,10 +103,11 @@ std::shared_ptr SoraClientContext::Create( absl::make_unique(std::move(config)); } { - auto config = - c->config_.use_hardware_encoder - ? sora::GetDefaultVideoDecoderFactoryConfig(cuda_context, env) - : sora::GetSoftwareOnlyVideoDecoderFactoryConfig(); + // auto env = webrtc::CreateEnvironment(); + auto config = c->config_.use_hardware_encoder + ? sora::GetDefaultVideoDecoderFactoryConfig( + env, cuda_context, jni_env) + : sora::GetSoftwareOnlyVideoDecoderFactoryConfig(env); dependencies.video_decoder_factory = absl::make_unique(std::move(config)); } diff --git a/src/sora_peer_connection_factory.cpp b/src/sora_peer_connection_factory.cpp index 4ab8922e..1c427fa7 100644 --- a/src/sora_peer_connection_factory.cpp +++ b/src/sora_peer_connection_factory.cpp @@ -14,6 +14,7 @@ class PeerConnectionFactoryWithContext : public webrtc::PeerConnectionFactory { PeerConnectionFactoryWithContext( webrtc::PeerConnectionFactoryDependencies dependencies) : PeerConnectionFactoryWithContext( + // TODO(enm10k): environment を外部から設定できるようにする webrtc::ConnectionContext::Create(webrtc::CreateEnvironment(), &dependencies), &dependencies) {} diff --git a/src/sora_video_decoder_factory.cpp b/src/sora_video_decoder_factory.cpp index f2da1614..cf916144 100644 --- a/src/sora_video_decoder_factory.cpp +++ b/src/sora_video_decoder_factory.cpp @@ -2,6 +2,7 @@ // WebRTC #include +#include #include #include #include @@ -67,8 +68,8 @@ SoraVideoDecoderFactory::GetSupportedFormats() const { return r; } -std::unique_ptr -SoraVideoDecoderFactory::CreateVideoDecoder( +std::unique_ptr SoraVideoDecoderFactory::Create( + const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) { webrtc::VideoCodecType specified_codec = webrtc::PayloadStringToCodecType(format.name); @@ -84,10 +85,10 @@ SoraVideoDecoderFactory::CreateVideoDecoder( std::vector supported_formats = formats_[n++]; if (enc.factory != nullptr) { - create_video_decoder = - [factory = enc.factory.get()](const webrtc::SdpVideoFormat& format) { - return factory->CreateVideoDecoder(format); - }; + create_video_decoder = [factory = enc.factory.get(), + &env](const webrtc::SdpVideoFormat& format) { + return factory->Create(env, format); + }; } else if (enc.create_video_decoder != nullptr) { create_video_decoder = enc.create_video_decoder; } @@ -108,9 +109,10 @@ SoraVideoDecoderFactory::CreateVideoDecoder( } SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( + webrtc::Environment& env, std::shared_ptr cuda_context, - void* env) { - auto config = GetSoftwareOnlyVideoDecoderFactoryConfig(); + void* jni_env) { + auto config = GetSoftwareOnlyVideoDecoderFactoryConfig(env); #if defined(__APPLE__) config.decoders.insert(config.decoders.begin(), @@ -118,10 +120,10 @@ SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( #endif #if defined(SORA_CPP_SDK_ANDROID) - if (env != nullptr) { + if (jni_env != nullptr) { config.decoders.insert(config.decoders.begin(), VideoDecoderConfig(CreateAndroidVideoDecoderFactory( - static_cast(env)))); + static_cast(jni_env)))); } #endif @@ -249,11 +251,12 @@ SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( return config; } -SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig() { +SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig( + webrtc::Environment& env) { SoraVideoDecoderFactoryConfig config; config.decoders.push_back(VideoDecoderConfig( webrtc::kVideoCodecVP8, - [](auto format) { return webrtc::VP8Decoder::Create(); })); + [&env](auto format) { return webrtc::CreateVp8Decoder(env); })); config.decoders.push_back(VideoDecoderConfig( webrtc::kVideoCodecVP9, [](auto format) { return webrtc::VP9Decoder::Create(); })); From 01ad4ff937aa9a184f0e837f9f69b36dfc2ce39c Mon Sep 17 00:00:00 2001 From: enm10k Date: Tue, 7 May 2024 19:31:33 +0900 Subject: [PATCH 03/16] =?UTF-8?q?test=20=E3=81=AE=E3=83=93=E3=83=AB?= =?UTF-8?q?=E3=83=89=E3=81=8C=E9=80=9A=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/messaging_recvonly_sample.cpp | 6 +----- examples/sdl_sample/src/sdl_sample.cpp | 6 +----- examples/sumomo/src/sumomo.cpp | 6 +----- include/sora/sora_client_context.h | 8 ++++++++ src/sora_client_context.cpp | 1 - 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp b/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp index e6d88f4c..b5d85512 100644 --- a/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp +++ b/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp @@ -1,6 +1,3 @@ -// WebRTC -#include - // Sora #include @@ -197,8 +194,7 @@ int main(int argc, char* argv[]) { sora::SoraClientContextConfig context_config; context_config.use_audio_device = false; context_config.use_hardware_encoder = false; - auto env = webrtc::CreateEnvironment(); - auto context = sora::SoraClientContext::Create(context_config, env); + auto context = sora::SoraClientContext::Create(context_config); auto messaging_recvonly_sample = std::make_shared(context, config); diff --git a/examples/sdl_sample/src/sdl_sample.cpp b/examples/sdl_sample/src/sdl_sample.cpp index e7875a7b..20a404c9 100644 --- a/examples/sdl_sample/src/sdl_sample.cpp +++ b/examples/sdl_sample/src/sdl_sample.cpp @@ -1,6 +1,3 @@ -// WebRTC -#include - // Sora #include #include @@ -251,9 +248,8 @@ int main(int argc, char* argv[]) { rtc::LogMessage::LogThreads(); } - auto env = webrtc::CreateEnvironment(); auto context = - sora::SoraClientContext::Create(sora::SoraClientContextConfig(), env); + sora::SoraClientContext::Create(sora::SoraClientContextConfig()); auto sdlsample = std::make_shared(context, config); sdlsample->Run(); diff --git a/examples/sumomo/src/sumomo.cpp b/examples/sumomo/src/sumomo.cpp index 516d055e..702dbacc 100644 --- a/examples/sumomo/src/sumomo.cpp +++ b/examples/sumomo/src/sumomo.cpp @@ -1,6 +1,3 @@ -// WebRTC -#include - // Sora #include #include @@ -450,8 +447,7 @@ int main(int argc, char* argv[]) { context_config.use_hardware_encoder = *use_hardware_encoder; } context_config.openh264 = openh264; - auto env = webrtc::CreateEnvironment(); - auto context = sora::SoraClientContext::Create(context_config, env); + auto context = sora::SoraClientContext::Create(context_config); auto sumomo = std::make_shared(context, config); sumomo->Run(); diff --git a/include/sora/sora_client_context.h b/include/sora/sora_client_context.h index 18987dad..26e31ae8 100644 --- a/include/sora/sora_client_context.h +++ b/include/sora/sora_client_context.h @@ -2,6 +2,7 @@ #define SORA_SORA_CLIENT_CONTEXT_H_ // WebRTC +#include #include #include #include @@ -59,6 +60,13 @@ class SoraClientContext { const SoraClientContextConfig& config, webrtc::Environment& env); + static std::shared_ptr Create( + const SoraClientContextConfig& config) { + // TODO(enm10k): ライフタイム的には env をクラスで保持した方が良さそうだが、 Create が static なメソッドなので難しい気がする + auto env = webrtc::CreateEnvironment(); + return Create(SoraClientContextConfig(), env); + }; + ~SoraClientContext(); rtc::Thread* network_thread() const { return network_thread_.get(); } diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index dd9cc778..446b8134 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -5,7 +5,6 @@ #include #include #include -// #include #include #include #include From ba5bb616a62bfed90740534fc0ac3b23622bfa67 Mon Sep 17 00:00:00 2001 From: enm10k Date: Tue, 7 May 2024 20:31:17 +0900 Subject: [PATCH 04/16] =?UTF-8?q?sora::SoraClientContext::Create=20?= =?UTF-8?q?=E3=81=AB=20webrtc::Environment=20=E3=82=92=E6=B8=A1=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/messaging_recvonly_sample.cpp | 6 +++++- examples/sdl_sample/src/sdl_sample.cpp | 6 +++++- examples/sumomo/src/sumomo.cpp | 6 +++++- include/sora/sora_client_context.h | 7 ------- test/connect_disconnect.cpp | 4 +++- test/datachannel.cpp | 4 +++- test/e2e.cpp | 4 +++- test/hello.cpp | 4 +++- 8 files changed, 27 insertions(+), 14 deletions(-) diff --git a/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp b/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp index b5d85512..e6d88f4c 100644 --- a/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp +++ b/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp @@ -1,3 +1,6 @@ +// WebRTC +#include + // Sora #include @@ -194,7 +197,8 @@ int main(int argc, char* argv[]) { sora::SoraClientContextConfig context_config; context_config.use_audio_device = false; context_config.use_hardware_encoder = false; - auto context = sora::SoraClientContext::Create(context_config); + auto env = webrtc::CreateEnvironment(); + auto context = sora::SoraClientContext::Create(context_config, env); auto messaging_recvonly_sample = std::make_shared(context, config); diff --git a/examples/sdl_sample/src/sdl_sample.cpp b/examples/sdl_sample/src/sdl_sample.cpp index 20a404c9..e7875a7b 100644 --- a/examples/sdl_sample/src/sdl_sample.cpp +++ b/examples/sdl_sample/src/sdl_sample.cpp @@ -1,3 +1,6 @@ +// WebRTC +#include + // Sora #include #include @@ -248,8 +251,9 @@ int main(int argc, char* argv[]) { rtc::LogMessage::LogThreads(); } + auto env = webrtc::CreateEnvironment(); auto context = - sora::SoraClientContext::Create(sora::SoraClientContextConfig()); + sora::SoraClientContext::Create(sora::SoraClientContextConfig(), env); auto sdlsample = std::make_shared(context, config); sdlsample->Run(); diff --git a/examples/sumomo/src/sumomo.cpp b/examples/sumomo/src/sumomo.cpp index 702dbacc..516d055e 100644 --- a/examples/sumomo/src/sumomo.cpp +++ b/examples/sumomo/src/sumomo.cpp @@ -1,3 +1,6 @@ +// WebRTC +#include + // Sora #include #include @@ -447,7 +450,8 @@ int main(int argc, char* argv[]) { context_config.use_hardware_encoder = *use_hardware_encoder; } context_config.openh264 = openh264; - auto context = sora::SoraClientContext::Create(context_config); + auto env = webrtc::CreateEnvironment(); + auto context = sora::SoraClientContext::Create(context_config, env); auto sumomo = std::make_shared(context, config); sumomo->Run(); diff --git a/include/sora/sora_client_context.h b/include/sora/sora_client_context.h index 26e31ae8..44efad2a 100644 --- a/include/sora/sora_client_context.h +++ b/include/sora/sora_client_context.h @@ -60,13 +60,6 @@ class SoraClientContext { const SoraClientContextConfig& config, webrtc::Environment& env); - static std::shared_ptr Create( - const SoraClientContextConfig& config) { - // TODO(enm10k): ライフタイム的には env をクラスで保持した方が良さそうだが、 Create が static なメソッドなので難しい気がする - auto env = webrtc::CreateEnvironment(); - return Create(SoraClientContextConfig(), env); - }; - ~SoraClientContext(); rtc::Thread* network_thread() const { return network_thread_.get(); } diff --git a/test/connect_disconnect.cpp b/test/connect_disconnect.cpp index 3f1d4d64..aa21bfad 100644 --- a/test/connect_disconnect.cpp +++ b/test/connect_disconnect.cpp @@ -3,6 +3,7 @@ #include // WebRTC +#include #include #ifdef _WIN32 @@ -145,8 +146,9 @@ int main(int argc, char* argv[]) { //rtc::LogMessage::LogTimestamps(); //rtc::LogMessage::LogThreads(); + auto env = webrtc::CreateEnvironment(); auto context = - sora::SoraClientContext::Create(sora::SoraClientContextConfig()); + sora::SoraClientContext::Create(sora::SoraClientContextConfig(), env); boost::json::value v; { diff --git a/test/datachannel.cpp b/test/datachannel.cpp index ec6cbbec..ccf0a3c1 100644 --- a/test/datachannel.cpp +++ b/test/datachannel.cpp @@ -3,6 +3,7 @@ #include // WebRTC +#include #include #ifdef _WIN32 @@ -160,7 +161,8 @@ int main(int argc, char* argv[]) { sora::SoraClientContextConfig context_config; context_config.use_audio_device = false; context_config.use_hardware_encoder = false; - auto context = sora::SoraClientContext::Create(context_config); + auto env = webrtc::CreateEnvironment(); + auto context = sora::SoraClientContext::Create(context_config, env); boost::json::value v; { diff --git a/test/e2e.cpp b/test/e2e.cpp index 3d6316ac..2902727d 100644 --- a/test/e2e.cpp +++ b/test/e2e.cpp @@ -4,6 +4,7 @@ #include // WebRTC +#include #include #ifdef _WIN32 @@ -44,7 +45,8 @@ class SoraClient : public std::enable_shared_from_this, sora::SoraClientContextConfig context_config; context_config.use_audio_device = false; context_config.use_hardware_encoder = false; - auto context = sora::SoraClientContext::Create(context_config); + auto env = webrtc::CreateEnvironment(); + auto context = sora::SoraClientContext::Create(context_config, env); auto pc_factory = context->peer_connection_factory(); context_ = context; diff --git a/test/hello.cpp b/test/hello.cpp index 1e5ebf4e..8a13e3e8 100644 --- a/test/hello.cpp +++ b/test/hello.cpp @@ -4,6 +4,7 @@ #include // WebRTC +#include #include #ifdef _WIN32 @@ -179,7 +180,8 @@ int main(int argc, char* argv[]) { if (auto it = v.as_object().find("openh264"); it != v.as_object().end()) { context_config.openh264 = it->value().as_string(); } - auto context = sora::SoraClientContext::Create(context_config); + auto env = webrtc::CreateEnvironment(); + auto context = sora::SoraClientContext::Create(context_config, env); auto hello = std::make_shared(context, config); hello->Run(); From 78843b9b5a234118c4a62261b1915d1be18a4c10 Mon Sep 17 00:00:00 2001 From: enm10k Date: Tue, 7 May 2024 21:14:20 +0900 Subject: [PATCH 05/16] =?UTF-8?q?webrtc::Environment=20=E3=82=92=E6=B8=A1?= =?UTF-8?q?=E3=81=95=E3=81=AA=E3=81=84=E5=88=9D=E6=9C=9F=E5=8C=96=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=82=92=E7=B6=AD=E6=8C=81=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/messaging_recvonly_sample.cpp | 6 +----- examples/sdl_sample/src/sdl_sample.cpp | 6 +----- examples/sumomo/src/sumomo.cpp | 6 +----- include/sora/sora_client_context.h | 4 ++++ src/sora_client_context.cpp | 7 +++++++ test/connect_disconnect.cpp | 4 +--- test/datachannel.cpp | 4 +--- test/e2e.cpp | 4 +--- test/hello.cpp | 4 +--- 9 files changed, 18 insertions(+), 27 deletions(-) diff --git a/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp b/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp index e6d88f4c..b5d85512 100644 --- a/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp +++ b/examples/messaging_recvonly_sample/src/messaging_recvonly_sample.cpp @@ -1,6 +1,3 @@ -// WebRTC -#include - // Sora #include @@ -197,8 +194,7 @@ int main(int argc, char* argv[]) { sora::SoraClientContextConfig context_config; context_config.use_audio_device = false; context_config.use_hardware_encoder = false; - auto env = webrtc::CreateEnvironment(); - auto context = sora::SoraClientContext::Create(context_config, env); + auto context = sora::SoraClientContext::Create(context_config); auto messaging_recvonly_sample = std::make_shared(context, config); diff --git a/examples/sdl_sample/src/sdl_sample.cpp b/examples/sdl_sample/src/sdl_sample.cpp index e7875a7b..20a404c9 100644 --- a/examples/sdl_sample/src/sdl_sample.cpp +++ b/examples/sdl_sample/src/sdl_sample.cpp @@ -1,6 +1,3 @@ -// WebRTC -#include - // Sora #include #include @@ -251,9 +248,8 @@ int main(int argc, char* argv[]) { rtc::LogMessage::LogThreads(); } - auto env = webrtc::CreateEnvironment(); auto context = - sora::SoraClientContext::Create(sora::SoraClientContextConfig(), env); + sora::SoraClientContext::Create(sora::SoraClientContextConfig()); auto sdlsample = std::make_shared(context, config); sdlsample->Run(); diff --git a/examples/sumomo/src/sumomo.cpp b/examples/sumomo/src/sumomo.cpp index 516d055e..702dbacc 100644 --- a/examples/sumomo/src/sumomo.cpp +++ b/examples/sumomo/src/sumomo.cpp @@ -1,6 +1,3 @@ -// WebRTC -#include - // Sora #include #include @@ -450,8 +447,7 @@ int main(int argc, char* argv[]) { context_config.use_hardware_encoder = *use_hardware_encoder; } context_config.openh264 = openh264; - auto env = webrtc::CreateEnvironment(); - auto context = sora::SoraClientContext::Create(context_config, env); + auto context = sora::SoraClientContext::Create(context_config); auto sumomo = std::make_shared(context, config); sumomo->Run(); diff --git a/include/sora/sora_client_context.h b/include/sora/sora_client_context.h index 44efad2a..051855e0 100644 --- a/include/sora/sora_client_context.h +++ b/include/sora/sora_client_context.h @@ -60,6 +60,9 @@ class SoraClientContext { const SoraClientContextConfig& config, webrtc::Environment& env); + static std::shared_ptr Create( + const SoraClientContextConfig& config); + ~SoraClientContext(); rtc::Thread* network_thread() const { return network_thread_.get(); } @@ -78,6 +81,7 @@ class SoraClientContext { ? config_.get_android_application_context(env) : nullptr; } + std::shared_ptr env; private: SoraClientContextConfig config_; diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index 446b8134..ab8e62fa 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -53,6 +53,7 @@ std::shared_ptr SoraClientContext::Create( c->worker_thread_->Start(); c->signaling_thread_ = rtc::Thread::Create(); c->signaling_thread_->Start(); + c->env = std::make_shared(env); webrtc::PeerConnectionFactoryDependencies dependencies; dependencies.network_thread = c->network_thread_.get(); @@ -137,4 +138,10 @@ std::shared_ptr SoraClientContext::Create( return c; } +std::shared_ptr SoraClientContext::Create( + const SoraClientContextConfig& config) { + auto env = webrtc::CreateEnvironment(); + return Create(config, env); +} + } // namespace sora \ No newline at end of file diff --git a/test/connect_disconnect.cpp b/test/connect_disconnect.cpp index aa21bfad..3f1d4d64 100644 --- a/test/connect_disconnect.cpp +++ b/test/connect_disconnect.cpp @@ -3,7 +3,6 @@ #include // WebRTC -#include #include #ifdef _WIN32 @@ -146,9 +145,8 @@ int main(int argc, char* argv[]) { //rtc::LogMessage::LogTimestamps(); //rtc::LogMessage::LogThreads(); - auto env = webrtc::CreateEnvironment(); auto context = - sora::SoraClientContext::Create(sora::SoraClientContextConfig(), env); + sora::SoraClientContext::Create(sora::SoraClientContextConfig()); boost::json::value v; { diff --git a/test/datachannel.cpp b/test/datachannel.cpp index ccf0a3c1..ec6cbbec 100644 --- a/test/datachannel.cpp +++ b/test/datachannel.cpp @@ -3,7 +3,6 @@ #include // WebRTC -#include #include #ifdef _WIN32 @@ -161,8 +160,7 @@ int main(int argc, char* argv[]) { sora::SoraClientContextConfig context_config; context_config.use_audio_device = false; context_config.use_hardware_encoder = false; - auto env = webrtc::CreateEnvironment(); - auto context = sora::SoraClientContext::Create(context_config, env); + auto context = sora::SoraClientContext::Create(context_config); boost::json::value v; { diff --git a/test/e2e.cpp b/test/e2e.cpp index 2902727d..3d6316ac 100644 --- a/test/e2e.cpp +++ b/test/e2e.cpp @@ -4,7 +4,6 @@ #include // WebRTC -#include #include #ifdef _WIN32 @@ -45,8 +44,7 @@ class SoraClient : public std::enable_shared_from_this, sora::SoraClientContextConfig context_config; context_config.use_audio_device = false; context_config.use_hardware_encoder = false; - auto env = webrtc::CreateEnvironment(); - auto context = sora::SoraClientContext::Create(context_config, env); + auto context = sora::SoraClientContext::Create(context_config); auto pc_factory = context->peer_connection_factory(); context_ = context; diff --git a/test/hello.cpp b/test/hello.cpp index 8a13e3e8..1e5ebf4e 100644 --- a/test/hello.cpp +++ b/test/hello.cpp @@ -4,7 +4,6 @@ #include // WebRTC -#include #include #ifdef _WIN32 @@ -180,8 +179,7 @@ int main(int argc, char* argv[]) { if (auto it = v.as_object().find("openh264"); it != v.as_object().end()) { context_config.openh264 = it->value().as_string(); } - auto env = webrtc::CreateEnvironment(); - auto context = sora::SoraClientContext::Create(context_config, env); + auto context = sora::SoraClientContext::Create(context_config); auto hello = std::make_shared(context, config); hello->Run(); From cac00ea4836c1c1c02d39e9391cf509913702cf1 Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 8 May 2024 10:46:24 +0900 Subject: [PATCH 06/16] =?UTF-8?q?libwebrtc=20=E3=81=8B=E3=82=89=20examples?= =?UTF-8?q?/unityplugin=20=E3=81=8C=E5=89=8A=E9=99=A4=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E8=BF=BD=E5=BE=93=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/android/app/src/main/cpp/jni_onload.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/test/android/app/src/main/cpp/jni_onload.cc b/test/android/app/src/main/cpp/jni_onload.cc index e6a88c43..c28813fc 100644 --- a/test/android/app/src/main/cpp/jni_onload.cc +++ b/test/android/app/src/main/cpp/jni_onload.cc @@ -12,7 +12,6 @@ #undef JNIEXPORT #define JNIEXPORT __attribute__((visibility("default"))) -#include "examples/unityplugin/class_reference_holder.h" #include "rtc_base/logging.h" #include "rtc_base/ssl_adapter.h" #include "sdk/android/native_api/jni/class_loader.h" From 01f5ba692a8a771757be948171f28f3b056bbe73 Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 8 May 2024 14:14:36 +0900 Subject: [PATCH 07/16] =?UTF-8?q?=E8=A9=A6=E8=A1=8C=E9=8C=AF=E8=AA=A4?= =?UTF-8?q?=E3=81=97=E3=81=9F=E9=9A=9B=E3=81=AE=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sora_client_context.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index ab8e62fa..476f874c 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -103,7 +103,6 @@ std::shared_ptr SoraClientContext::Create( absl::make_unique(std::move(config)); } { - // auto env = webrtc::CreateEnvironment(); auto config = c->config_.use_hardware_encoder ? sora::GetDefaultVideoDecoderFactoryConfig( env, cuda_context, jni_env) From 7e8622b4fdd3349bd2641f9512f6a2b7f9a3ea25 Mon Sep 17 00:00:00 2001 From: enm10k Date: Wed, 8 May 2024 14:33:13 +0900 Subject: [PATCH 08/16] =?UTF-8?q?SoraClientContext=20=E3=81=A7=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E3=81=99=E3=82=8B=20webrtc::Environment=20=E3=81=AF?= =?UTF-8?q?=20private=20=E3=81=A7=E8=89=AF=E3=81=8B=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/sora/sora_client_context.h | 2 +- src/sora_client_context.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sora/sora_client_context.h b/include/sora/sora_client_context.h index 051855e0..945e378b 100644 --- a/include/sora/sora_client_context.h +++ b/include/sora/sora_client_context.h @@ -81,7 +81,6 @@ class SoraClientContext { ? config_.get_android_application_context(env) : nullptr; } - std::shared_ptr env; private: SoraClientContextConfig config_; @@ -90,6 +89,7 @@ class SoraClientContext { std::unique_ptr signaling_thread_; rtc::scoped_refptr factory_; rtc::scoped_refptr connection_context_; + std::shared_ptr env_; }; } // namespace sora diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index 476f874c..a39a659e 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -53,7 +53,7 @@ std::shared_ptr SoraClientContext::Create( c->worker_thread_->Start(); c->signaling_thread_ = rtc::Thread::Create(); c->signaling_thread_->Start(); - c->env = std::make_shared(env); + c->env_ = std::make_shared(env); webrtc::PeerConnectionFactoryDependencies dependencies; dependencies.network_thread = c->network_thread_.get(); From 3e789b1ebb3f49f88c7e700f5c0dffc41f8198cf Mon Sep 17 00:00:00 2001 From: enm10k Date: Fri, 10 May 2024 12:15:49 +0900 Subject: [PATCH 09/16] =?UTF-8?q?SoraClientContext=20=E3=81=A7=20webrtc::E?= =?UTF-8?q?nvironment=20=E3=82=92=E4=BF=9D=E6=8C=81=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=82=92=E6=AD=A2=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/sora/sora_client_context.h | 5 ----- include/sora/sora_video_decoder_factory.h | 3 ++- src/sora_client_context.cpp | 13 ++++--------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/include/sora/sora_client_context.h b/include/sora/sora_client_context.h index 945e378b..d8a21e43 100644 --- a/include/sora/sora_client_context.h +++ b/include/sora/sora_client_context.h @@ -56,10 +56,6 @@ struct SoraClientContextConfig { // auto client = std::make_shared(context); class SoraClientContext { public: - static std::shared_ptr Create( - const SoraClientContextConfig& config, - webrtc::Environment& env); - static std::shared_ptr Create( const SoraClientContextConfig& config); @@ -89,7 +85,6 @@ class SoraClientContext { std::unique_ptr signaling_thread_; rtc::scoped_refptr factory_; rtc::scoped_refptr connection_context_; - std::shared_ptr env_; }; } // namespace sora diff --git a/include/sora/sora_video_decoder_factory.h b/include/sora/sora_video_decoder_factory.h index 7db6b047..44e7249a 100644 --- a/include/sora/sora_video_decoder_factory.h +++ b/include/sora/sora_video_decoder_factory.h @@ -68,7 +68,8 @@ SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( std::shared_ptr cuda_context = nullptr, void* jni_env = nullptr); // ソフトウェアデコーダのみを使う設定を返す -SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig(webrtc::Environment& env); +SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig( + webrtc::Environment& env); } // namespace sora diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index a39a659e..7c65f1c0 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -40,8 +40,7 @@ SoraClientContext::~SoraClientContext() { } std::shared_ptr SoraClientContext::Create( - const SoraClientContextConfig& config, - webrtc::Environment& env) { + const SoraClientContextConfig& config) { rtc::InitializeSSL(); std::shared_ptr c = std::make_shared(); @@ -53,7 +52,6 @@ std::shared_ptr SoraClientContext::Create( c->worker_thread_->Start(); c->signaling_thread_ = rtc::Thread::Create(); c->signaling_thread_->Start(); - c->env_ = std::make_shared(env); webrtc::PeerConnectionFactoryDependencies dependencies; dependencies.network_thread = c->network_thread_.get(); @@ -103,6 +101,9 @@ std::shared_ptr SoraClientContext::Create( absl::make_unique(std::move(config)); } { + // SDK の外部から webrtc::Environment を設定したくなるまで、ここで初期化する + auto env = webrtc::CreateEnvironment(); + auto config = c->config_.use_hardware_encoder ? sora::GetDefaultVideoDecoderFactoryConfig( env, cuda_context, jni_env) @@ -137,10 +138,4 @@ std::shared_ptr SoraClientContext::Create( return c; } -std::shared_ptr SoraClientContext::Create( - const SoraClientContextConfig& config) { - auto env = webrtc::CreateEnvironment(); - return Create(config, env); -} - } // namespace sora \ No newline at end of file From ba0da74afb46c9d069f26c40d96cd58a96c437d9 Mon Sep 17 00:00:00 2001 From: enm10k Date: Fri, 10 May 2024 14:45:44 +0900 Subject: [PATCH 10/16] =?UTF-8?q?=E4=BA=92=E6=8F=9B=E6=80=A7=E3=82=92?= =?UTF-8?q?=E7=B6=AD=E6=8C=81=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AB?= =?UTF-8?q?=20webrtc::Environment=20=E3=82=92=E6=9C=80=E5=BE=8C=E3=81=AE?= =?UTF-8?q?=E5=A4=89=E6=95=B0=E3=81=A8=E3=81=97=E3=81=A6=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=97=E3=80=81=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB=E3=83=88?= =?UTF-8?q?=E5=80=A4=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/sora/sora_video_decoder_factory.h | 8 ++++---- src/sora_client_context.cpp | 4 ++-- src/sora_peer_connection_factory.cpp | 2 +- src/sora_video_decoder_factory.cpp | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/sora/sora_video_decoder_factory.h b/include/sora/sora_video_decoder_factory.h index 44e7249a..7518e332 100644 --- a/include/sora/sora_video_decoder_factory.h +++ b/include/sora/sora_video_decoder_factory.h @@ -5,7 +5,7 @@ #include // WebRTC -#include +#include #include #include @@ -64,12 +64,12 @@ class SoraVideoDecoderFactory : public webrtc::VideoDecoderFactory { // ハードウェアデコーダを出来るだけ使おうとして、見つからなければソフトウェアデコーダを使う設定を返す SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( - webrtc::Environment& env, std::shared_ptr 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 diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index 7c65f1c0..91ed6dfa 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -105,8 +105,8 @@ std::shared_ptr 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(std::move(config)); diff --git a/src/sora_peer_connection_factory.cpp b/src/sora_peer_connection_factory.cpp index 1c427fa7..643aacbe 100644 --- a/src/sora_peer_connection_factory.cpp +++ b/src/sora_peer_connection_factory.cpp @@ -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) {} diff --git a/src/sora_video_decoder_factory.cpp b/src/sora_video_decoder_factory.cpp index cf916144..e747b6f2 100644 --- a/src/sora_video_decoder_factory.cpp +++ b/src/sora_video_decoder_factory.cpp @@ -109,9 +109,9 @@ std::unique_ptr SoraVideoDecoderFactory::Create( } SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( - webrtc::Environment& env, std::shared_ptr cuda_context, - void* jni_env) { + void* jni_env, + webrtc::Environment env) { auto config = GetSoftwareOnlyVideoDecoderFactoryConfig(env); #if defined(__APPLE__) @@ -252,7 +252,7 @@ SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( } SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig( - webrtc::Environment& env) { + webrtc::Environment env) { SoraVideoDecoderFactoryConfig config; config.decoders.push_back(VideoDecoderConfig( webrtc::kVideoCodecVP8, From 9d5eb9b4da11ca49f929c279cc6245b1635c9738 Mon Sep 17 00:00:00 2001 From: enm10k Date: Fri, 10 May 2024 15:09:20 +0900 Subject: [PATCH 11/16] =?UTF-8?q?=E6=9C=80=E7=B5=82=E7=9A=84=E3=81=AB=20we?= =?UTF-8?q?brtc::CreateEnvironment=20=E3=82=92=E5=AE=9F=E8=A1=8C=E3=81=99?= =?UTF-8?q?=E3=82=8B=E5=9B=9E=E6=95=B0=E3=81=8C=E5=A4=89=E3=82=8F=E3=82=89?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=81=AE=E3=81=A7=E3=80=81=20webrtc::Environ?= =?UTF-8?q?ment=20=E3=82=92=E5=BC=95=E3=81=8D=E5=9B=9E=E3=81=99=E3=81=AE?= =?UTF-8?q?=E3=82=92=E6=AD=A2=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/sora/sora_video_decoder_factory.h | 6 ++---- src/sora_client_context.cpp | 11 ++++------- src/sora_video_decoder_factory.cpp | 9 ++++----- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/include/sora/sora_video_decoder_factory.h b/include/sora/sora_video_decoder_factory.h index 7518e332..6b8a3562 100644 --- a/include/sora/sora_video_decoder_factory.h +++ b/include/sora/sora_video_decoder_factory.h @@ -65,11 +65,9 @@ class SoraVideoDecoderFactory : public webrtc::VideoDecoderFactory { // ハードウェアデコーダを出来るだけ使おうとして、見つからなければソフトウェアデコーダを使う設定を返す SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( std::shared_ptr 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 diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index 91ed6dfa..ba68f013 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -101,13 +101,10 @@ std::shared_ptr SoraClientContext::Create( absl::make_unique(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(std::move(config)); } diff --git a/src/sora_video_decoder_factory.cpp b/src/sora_video_decoder_factory.cpp index e747b6f2..b944656c 100644 --- a/src/sora_video_decoder_factory.cpp +++ b/src/sora_video_decoder_factory.cpp @@ -110,9 +110,8 @@ std::unique_ptr SoraVideoDecoderFactory::Create( SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( std::shared_ptr 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(), @@ -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, From ecec7dbdcda70a5a1512271f6ebf376d189ed902 Mon Sep 17 00:00:00 2001 From: enm10k Date: Fri, 10 May 2024 16:19:10 +0900 Subject: [PATCH 12/16] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E5=B7=AE?= =?UTF-8?q?=E5=88=86=E3=82=92=E5=85=83=E3=81=AB=E6=88=BB=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/sora/sora_client_context.h | 1 - include/sora/sora_video_decoder_factory.h | 4 ++-- src/sora_client_context.cpp | 7 ++++--- src/sora_video_decoder_factory.cpp | 9 +++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/sora/sora_client_context.h b/include/sora/sora_client_context.h index d8a21e43..bfa2dc3e 100644 --- a/include/sora/sora_client_context.h +++ b/include/sora/sora_client_context.h @@ -2,7 +2,6 @@ #define SORA_SORA_CLIENT_CONTEXT_H_ // WebRTC -#include #include #include #include diff --git a/include/sora/sora_video_decoder_factory.h b/include/sora/sora_video_decoder_factory.h index 6b8a3562..2ba98fec 100644 --- a/include/sora/sora_video_decoder_factory.h +++ b/include/sora/sora_video_decoder_factory.h @@ -5,7 +5,7 @@ #include // WebRTC -#include +#include #include #include @@ -65,7 +65,7 @@ class SoraVideoDecoderFactory : public webrtc::VideoDecoderFactory { // ハードウェアデコーダを出来るだけ使おうとして、見つからなければソフトウェアデコーダを使う設定を返す SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( std::shared_ptr cuda_context = nullptr, - void* jni_env = nullptr); + void* env = nullptr); // ソフトウェアデコーダのみを使う設定を返す SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig(); diff --git a/src/sora_client_context.cpp b/src/sora_client_context.cpp index ba68f013..d91bfc82 100644 --- a/src/sora_client_context.cpp +++ b/src/sora_client_context.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,7 @@ std::shared_ptr SoraClientContext::Create( absl::make_unique( dependencies.task_queue_factory.get()); - void* jni_env = sora::GetJNIEnv(); + void* env = sora::GetJNIEnv(); dependencies.adm = c->worker_thread_->BlockingCall([&] { sora::AudioDeviceModuleConfig config; @@ -91,7 +92,7 @@ std::shared_ptr SoraClientContext::Create( { auto config = c->config_.use_hardware_encoder ? sora::GetDefaultVideoEncoderFactoryConfig( - cuda_context, jni_env, c->config_.openh264) + cuda_context, env, c->config_.openh264) : sora::GetSoftwareOnlyVideoEncoderFactoryConfig( c->config_.openh264); config.use_simulcast_adapter = true; @@ -103,7 +104,7 @@ std::shared_ptr SoraClientContext::Create( { auto config = c->config_.use_hardware_encoder - ? sora::GetDefaultVideoDecoderFactoryConfig(cuda_context, jni_env) + ? sora::GetDefaultVideoDecoderFactoryConfig(cuda_context, env) : sora::GetSoftwareOnlyVideoDecoderFactoryConfig(); dependencies.video_decoder_factory = absl::make_unique(std::move(config)); diff --git a/src/sora_video_decoder_factory.cpp b/src/sora_video_decoder_factory.cpp index b944656c..9c83b6aa 100644 --- a/src/sora_video_decoder_factory.cpp +++ b/src/sora_video_decoder_factory.cpp @@ -2,7 +2,7 @@ // WebRTC #include -#include +#include #include #include #include @@ -110,7 +110,7 @@ std::unique_ptr SoraVideoDecoderFactory::Create( SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( std::shared_ptr cuda_context, - void* jni_env) { + void* env) { auto config = GetSoftwareOnlyVideoDecoderFactoryConfig(); #if defined(__APPLE__) @@ -119,10 +119,10 @@ SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( #endif #if defined(SORA_CPP_SDK_ANDROID) - if (jni_env != nullptr) { + if (env != nullptr) { config.decoders.insert(config.decoders.begin(), VideoDecoderConfig(CreateAndroidVideoDecoderFactory( - static_cast(jni_env)))); + static_cast(env)))); } #endif @@ -251,6 +251,7 @@ SoraVideoDecoderFactoryConfig GetDefaultVideoDecoderFactoryConfig( } SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig() { + // SDK の外部から webrtc::Environment を設定したくなるまで、ここで初期化する auto env = webrtc::CreateEnvironment(); SoraVideoDecoderFactoryConfig config; config.decoders.push_back(VideoDecoderConfig( From d95ab15872a4b4cd99e73d54ca22bc0c5b5ed75d Mon Sep 17 00:00:00 2001 From: enm10k Date: Fri, 10 May 2024 16:44:16 +0900 Subject: [PATCH 13/16] =?UTF-8?q?CHANGES.md=20=E3=82=92=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 382eb0fe..3df12945 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,14 +11,15 @@ ## develop +- [CHANGE] libwebrtc を m124.6367.3.1 にあげる + - 継承元のクラスの変更に追従するため、 SoraVideoDecoderFactory の初期化に利用する関数を CreateVideoDecoder から Create に変更 + - Android の test アプリがリンクできなくなったため、リンカーを Android NDK のものから libwebrtc のものに変更 + - リンカーのバージョンの違いによる互換性の問題でエラーが発生していた + - @melpon @enm10k - [UPDATE] Boost を 1.85.0 にあげる - @enm10k - [UPDATE] SDL2 を 2.30.3 にあげる - @enm10k -- [UPDATE] libwebrtc を m123.6312.3.5 にあげる - - Android の test アプリのリンク時に発生したエラーを解決するために、リンカーを Android NDK に含まれるものから libwebrtc のものに変更した - - リンカーのバージョンの違いによる互換性の問題でエラーが発生していたため、次回 Android NDK のバージョンを更新する際に、修正箇所を元に戻せる可能性がある - - @melpon @enm10k - [UPDATE] CLI11 を 2.4.2 にあげる - @enm10k - [ADD] sumomo に `--openh264` と `--use-hardware-encoder` オプションを追加 From 2ae98b740e3a8d087f11a6d63a94579abaab02a0 Mon Sep 17 00:00:00 2001 From: enm10k Date: Fri, 10 May 2024 23:46:38 +0900 Subject: [PATCH 14/16] =?UTF-8?q?=E5=8F=82=E7=85=A7=E3=81=A7=E3=82=AD?= =?UTF-8?q?=E3=83=A3=E3=83=97=E3=83=81=E3=83=A3=E3=83=BC=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=82=92=E3=82=84=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sora_video_decoder_factory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sora_video_decoder_factory.cpp b/src/sora_video_decoder_factory.cpp index 9c83b6aa..516c26e9 100644 --- a/src/sora_video_decoder_factory.cpp +++ b/src/sora_video_decoder_factory.cpp @@ -86,7 +86,7 @@ std::unique_ptr SoraVideoDecoderFactory::Create( if (enc.factory != nullptr) { create_video_decoder = [factory = enc.factory.get(), - &env](const webrtc::SdpVideoFormat& format) { + env](const webrtc::SdpVideoFormat& format) { return factory->Create(env, format); }; } else if (enc.create_video_decoder != nullptr) { @@ -256,7 +256,7 @@ SoraVideoDecoderFactoryConfig GetSoftwareOnlyVideoDecoderFactoryConfig() { SoraVideoDecoderFactoryConfig config; config.decoders.push_back(VideoDecoderConfig( webrtc::kVideoCodecVP8, - [&env](auto format) { return webrtc::CreateVp8Decoder(env); })); + [env](auto format) { return webrtc::CreateVp8Decoder(env); })); config.decoders.push_back(VideoDecoderConfig( webrtc::kVideoCodecVP9, [](auto format) { return webrtc::VP9Decoder::Create(); })); From fdb79473bb105e80f02af79f02adcf7003ee155a Mon Sep 17 00:00:00 2001 From: enm10k Date: Sat, 11 May 2024 00:25:12 +0900 Subject: [PATCH 15/16] =?UTF-8?q?CHANGES.md=20=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3df12945..f694dd5b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,17 +11,19 @@ ## develop -- [CHANGE] libwebrtc を m124.6367.3.1 にあげる - - 継承元のクラスの変更に追従するため、 SoraVideoDecoderFactory の初期化に利用する関数を CreateVideoDecoder から Create に変更 - - Android の test アプリがリンクできなくなったため、リンカーを Android NDK のものから libwebrtc のものに変更 - - リンカーのバージョンの違いによる互換性の問題でエラーが発生していた - - @melpon @enm10k +- [CHANGE] SoraVideoDecoderFactory の初期化に利用する関数を CreateVideoDecoder から Create に変更する + - libwebrtc に定義されている継承元クラスが変更されたことに対する追従 + - @enm10k - [UPDATE] Boost を 1.85.0 にあげる - @enm10k - [UPDATE] SDL2 を 2.30.3 にあげる - @enm10k - [UPDATE] CLI11 を 2.4.2 にあげる - @enm10k +- [UPDATE] libwebrtc を m124.6367.3.1 にあげる + - Android の test アプリがリンクできなくなったため、リンカーを Android NDK のものから libwebrtc のものに変更 + - リンカーのバージョンの違いによる互換性の問題でエラーが発生していた + - @melpon @enm10k - [ADD] sumomo に `--openh264` と `--use-hardware-encoder` オプションを追加 - @melpon - [ADD] sumomo に `--video-h264-params` と `--video-h265-params` オプションを追加 From 35b1eb63bb4a92199b08e6231bd24d67e83e3b73 Mon Sep 17 00:00:00 2001 From: melpon Date: Sat, 11 May 2024 00:43:43 +0900 Subject: [PATCH 16/16] =?UTF-8?q?yaml=20=E3=81=AE=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=82=92=E7=9B=B4=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 895b1d9a..1e07167a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -323,7 +323,7 @@ jobs: needs.build-windows.result == 'failure' || needs.build-macos.result == 'failure' || needs.build-ubuntu.result == 'failure' || - needs.create-release.result == 'failure' || + needs.create-release.result == 'failure' env: SLACK_CHANNEL: sora-cpp-sdk SLACK_COLOR: danger