Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
enm10k committed May 7, 2024
1 parent ba5bb61 commit 7061b78
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// WebRTC
#include <api/environment/environment_factory.h>

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

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

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

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

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

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

static std::shared_ptr<SoraClientContext> Create(
const SoraClientContextConfig& config);

~SoraClientContext();

rtc::Thread* network_thread() const { return network_thread_.get(); }
Expand All @@ -78,6 +81,7 @@ class SoraClientContext {
? config_.get_android_application_context(env)
: nullptr;
}
std::shared_ptr<webrtc::Environment> env;

private:
SoraClientContextConfig config_;
Expand Down
7 changes: 7 additions & 0 deletions src/sora_client_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ std::shared_ptr<SoraClientContext> SoraClientContext::Create(
c->worker_thread_->Start();
c->signaling_thread_ = rtc::Thread::Create();
c->signaling_thread_->Start();
c->env = std::make_shared<webrtc::Environment>(env);

webrtc::PeerConnectionFactoryDependencies dependencies;
dependencies.network_thread = c->network_thread_.get();
Expand Down Expand Up @@ -137,4 +138,10 @@ std::shared_ptr<SoraClientContext> SoraClientContext::Create(
return c;
}

std::shared_ptr<SoraClientContext> SoraClientContext::Create(
const SoraClientContextConfig& config) {
auto env = webrtc::CreateEnvironment();
return Create(config, env);
}

} // namespace sora
4 changes: 1 addition & 3 deletions test/connect_disconnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <iostream>

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

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

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

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

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

#ifdef _WIN32
Expand Down Expand Up @@ -45,8 +44,7 @@ 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 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;

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

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

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

0 comments on commit 7061b78

Please sign in to comment.