Skip to content

Commit

Permalink
指定できるオプションを増やす
Browse files Browse the repository at this point in the history
  • Loading branch information
melpon committed Dec 8, 2023
1 parent 8e6dc4c commit af93aa3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
40 changes: 32 additions & 8 deletions test/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void HelloSora::Run() {

if (config_.mode == HelloSoraConfig::Mode::Hello) {
FakeVideoCapturerConfig fake_config;
fake_config.width = 1024;
fake_config.height = 768;
fake_config.width = config_.capture_width;
fake_config.height = config_.capture_height;
fake_config.fps = 30;
video_source_ = CreateFakeVideoCapturer(fake_config);
std::string video_track_id = rtc::CreateRandomString(16);
Expand All @@ -68,8 +68,10 @@ void HelloSora::Run() {
config.channel_id = config_.channel_id;
config.sora_client = "Hello Sora";
config.role = config_.role;
config.video_codec_type = "H264";
config.video_codec_type = config_.video_codec_type;
config.video_bit_rate = config_.video_bit_rate;
config.multistream = true;
config.simulcast = config_.simulcast;
if (config_.mode == HelloSoraConfig::Mode::Lyra) {
config.video = false;
config.sora_client = "Hello Sora with Lyra";
Expand Down Expand Up @@ -131,10 +133,6 @@ int main(int argc, char* argv[]) {
rtc::LogMessage::LogTimestamps();
rtc::LogMessage::LogThreads();

sora::SoraClientContextConfig context_config;
context_config.get_android_application_context = GetAndroidApplicationContext;
auto context = sora::SoraClientContext::Create(context_config);

boost::json::value v;
{
std::ifstream ifs(argv[1]);
Expand All @@ -148,7 +146,6 @@ int main(int argc, char* argv[]) {
config.signaling_urls.push_back(x.as_string().c_str());
}
config.channel_id = v.as_object().at("channel_id").as_string().c_str();
config.role = "sendonly";
if (auto it = v.as_object().find("role"); it != v.as_object().end()) {
config.role = it->value().as_string();
}
Expand All @@ -157,6 +154,33 @@ int main(int argc, char* argv[]) {
config.mode = HelloSoraConfig::Mode::Lyra;
}
}
if (auto it = v.as_object().find("capture_width");
it != v.as_object().end()) {
config.capture_width = boost::json::value_to<int>(it->value());
}
if (auto it = v.as_object().find("capture_height");
it != v.as_object().end()) {
config.capture_height = boost::json::value_to<int>(it->value());
}
if (auto it = v.as_object().find("video_bit_rate");
it != v.as_object().end()) {
config.video_bit_rate = boost::json::value_to<int>(it->value());
}
if (auto it = v.as_object().find("video_codec_type");
it != v.as_object().end()) {
config.video_codec_type = it->value().as_string();
}
if (auto it = v.as_object().find("simulcast"); it != v.as_object().end()) {
config.simulcast = it->value().as_bool();
}

sora::SoraClientContextConfig context_config;
context_config.get_android_application_context = GetAndroidApplicationContext;
if (auto it = v.as_object().find("use_hardware_encoder");
it != v.as_object().end()) {
context_config.use_hardware_encoder = it->value().as_bool();
}
auto context = sora::SoraClientContext::Create(context_config);

auto hello = std::make_shared<HelloSora>(context, config);
hello->Run();
Expand Down
7 changes: 6 additions & 1 deletion test/hello.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
struct HelloSoraConfig {
std::vector<std::string> signaling_urls;
std::string channel_id;
std::string role;
std::string role = "sendonly";
enum class Mode {
Hello,
Lyra,
};
Mode mode = Mode::Hello;
int capture_width = 1024;
int capture_height = 768;
int video_bit_rate = 0;
std::string video_codec_type = "H264";
bool simulcast = false;
};

class HelloSora : public std::enable_shared_from_this<HelloSora>,
Expand Down

0 comments on commit af93aa3

Please sign in to comment.