Skip to content

Commit

Permalink
sora::SoraClientContext::Create に webrtc::Environment を渡す
Browse files Browse the repository at this point in the history
  • Loading branch information
enm10k committed May 7, 2024
1 parent 01ad4ff commit ba5bb61
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// WebRTC
#include <api/environment/environment_factory.h>

// Sora
#include <sora/sora_client_context.h>

Expand Down Expand Up @@ -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<MessagingRecvOnlySample>(context, config);
Expand Down
6 changes: 5 additions & 1 deletion examples/sdl_sample/src/sdl_sample.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// WebRTC
#include <api/environment/environment_factory.h>

// Sora
#include <sora/camera_device_capturer.h>
#include <sora/sora_client_context.h>
Expand Down Expand Up @@ -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<SDLSample>(context, config);
sdlsample->Run();

Expand Down
6 changes: 5 additions & 1 deletion examples/sumomo/src/sumomo.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// WebRTC
#include <api/environment/environment_factory.h>

// Sora
#include <sora/camera_device_capturer.h>
#include <sora/sora_client_context.h>
Expand Down Expand Up @@ -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<Sumomo>(context, config);
sumomo->Run();

Expand Down
7 changes: 0 additions & 7 deletions include/sora/sora_client_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ class SoraClientContext {
const SoraClientContextConfig& config,
webrtc::Environment& env);

static std::shared_ptr<SoraClientContext> 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(); }
Expand Down
4 changes: 3 additions & 1 deletion test/connect_disconnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <iostream>

// WebRTC
#include <api/environment/environment_factory.h>
#include <rtc_base/logging.h>

#ifdef _WIN32
Expand Down Expand Up @@ -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;
{
Expand Down
4 changes: 3 additions & 1 deletion test/datachannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <iostream>

// WebRTC
#include <api/environment/environment_factory.h>
#include <rtc_base/logging.h>

#ifdef _WIN32
Expand Down Expand Up @@ -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;
{
Expand Down
4 changes: 3 additions & 1 deletion test/e2e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <iostream>

// WebRTC
#include <api/environment/environment_factory.h>
#include <rtc_base/logging.h>

#ifdef _WIN32
Expand Down Expand Up @@ -44,7 +45,8 @@ class SoraClient : public std::enable_shared_from_this<SoraClient>,
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;

Expand Down
4 changes: 3 additions & 1 deletion test/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <iostream>

// WebRTC
#include <api/environment/environment_factory.h>
#include <rtc_base/logging.h>

#ifdef _WIN32
Expand Down Expand Up @@ -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<HelloSora>(context, config);
hello->Run();
Expand Down

0 comments on commit ba5bb61

Please sign in to comment.