Skip to content

Commit

Permalink
--degradation-preference 引数を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
melpon committed Jan 11, 2025
1 parent 4ef1755 commit e2ce8e3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 33 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
- @torikizi
- [CHANGE] FakeNetwork 系の機能を削除
- @melpon
- [ADD] `--degradation-preference` 引数を追加
- @melpon
- [UPDATE] CMakeLists の依存から libva と libdrm を削除する
- @zztkm
- [UPDATE] CI の Ubuntu で libba と libdrm をインストールしないようにする
- [UPDATE] Sora C++ SDK を `2024.8.0` に上げる
- [UPDATE] Sora C++ SDK を `2025.1.0-canary.2` に上げる
- それに伴って以下のライブラリのバージョンも上げる
- libwebrtc のバージョンを `m132.6834.4.0` に上げる
- Boost のバージョンを `1.87.0` に上げる
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ZAKURO_VERSION=2024.2.0-canary.4
SORA_CPP_SDK_VERSION=2025.1.0-canary.1
SORA_CPP_SDK_VERSION=2025.1.0-canary.2
WEBRTC_BUILD_VERSION=m132.6834.4.0
BOOST_VERSION=1.87.0
CLI11_VERSION=v2.4.2
Expand Down
75 changes: 44 additions & 31 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ void Util::ParseArgs(const std::vector<std::string>& cargs,
app.add_option("--initial-mute-audio", config.initial_mute_audio,
"Mute audio initialy (default: false)")
->transform(CLI::CheckedTransformer(bool_map, CLI::ignore_case));
auto degradation_preference_map =
std::vector<std::pair<std::string, webrtc::DegradationPreference>>(
{{"disabled", webrtc::DegradationPreference::DISABLED},
{"maintain_framerate",
webrtc::DegradationPreference::MAINTAIN_FRAMERATE},
{"maintain_resolution",
webrtc::DegradationPreference::MAINTAIN_RESOLUTION},
{"balanced", webrtc::DegradationPreference::BALANCED}});
app.add_option("--degradation-preference", config.degradation_preference,
"Degradation preference")
->transform(CLI::CheckedTransformer(degradation_preference_map,
CLI::ignore_case));

// Sora 系オプション
app.add_option("--sora-signaling-url", config.sora_signaling_urls,
Expand Down Expand Up @@ -376,23 +388,23 @@ std::vector<std::vector<std::string>> Util::NodeToArgs(const YAML::Node& inst) {
}
}

#define DEF_SCALAR(x, prefix, key, type, type_name) \
try { \
const YAML::Node& node = x[key]; \
if (node) { \
if (!node.IsScalar()) { \
#define DEF_SCALAR(x, prefix, key, type, type_name) \
try { \
const YAML::Node& node = x[key]; \
if (node) { \
if (!node.IsScalar()) { \
std::cerr << "\"" key "\" の値は " type_name " である必要があります。" \
<< std::endl; \
has_error = true; \
} else { \
args.push_back("--" prefix key); \
args.push_back(ConvertEnv<type>(node, envs)); \
} \
} \
} catch (YAML::BadConversion & e) { \
<< std::endl; \
has_error = true; \
} else { \
args.push_back("--" prefix key); \
args.push_back(ConvertEnv<type>(node, envs)); \
} \
} \
} catch (YAML::BadConversion & e) { \
std::cerr << "\"" key "\" の値は " type_name " である必要があります。" \
<< std::endl; \
has_error = true; \
<< std::endl; \
has_error = true; \
}

#define DEF_STRING(x, prefix, key) \
Expand All @@ -401,24 +413,24 @@ std::vector<std::vector<std::string>> Util::NodeToArgs(const YAML::Node& inst) {
#define DEF_DOUBLE(x, prefix, key) DEF_SCALAR(x, prefix, key, double, "実数")
#define DEF_BOOLEAN(x, prefix, key) DEF_SCALAR(x, prefix, key, bool, "bool値")

#define DEF_FLAG(x, prefix, key) \
try { \
const YAML::Node& node = x[key]; \
if (node) { \
if (!node.IsScalar()) { \
#define DEF_FLAG(x, prefix, key) \
try { \
const YAML::Node& node = x[key]; \
if (node) { \
if (!node.IsScalar()) { \
std::cerr << "\"" key "\" の値は bool値 である必要があります。" \
<< std::endl; \
has_error = true; \
} else { \
if (node.as<bool>()) { \
args.push_back("--" prefix key); \
} \
} \
} \
} catch (YAML::BadConversion & e) { \
<< std::endl; \
has_error = true; \
} else { \
if (node.as<bool>()) { \
args.push_back("--" prefix key); \
} \
} \
} \
} catch (YAML::BadConversion & e) { \
std::cerr << "\"" key "\" の値は bool値 である必要があります。" \
<< std::endl; \
has_error = true; \
<< std::endl; \
has_error = true; \
}

for (int i = 0; i < instance_num; i++) {
Expand Down Expand Up @@ -452,6 +464,7 @@ std::vector<std::vector<std::string>> Util::NodeToArgs(const YAML::Node& inst) {
DEF_STRING(inst, "", "client-key");
DEF_BOOLEAN(inst, "", "initial-mute-video");
DEF_BOOLEAN(inst, "", "initial-mute-audio");
DEF_STRING(inst, "", "degradation-preference");

const YAML::Node& sora = inst["sora"];
if (sora) {
Expand Down
1 change: 1 addition & 0 deletions src/zakuro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ int Zakuro::Run() {
config_.sora_ignore_disconnect_websocket;
sora_config.disconnect_wait_timeout = config_.sora_disconnect_wait_timeout;
sora_config.data_channels = dcs.schannels;
sora_config.degradation_preference = config_.degradation_preference;

std::vector<VirtualClientConfig> vc_configs;
for (int i = 0; i < config_.vcs; i++) {
Expand Down
4 changes: 4 additions & 0 deletions src/zakuro.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <cstdlib>
#include <string>

// WebRTC
#include <api/rtp_parameters.h>

// Boost
#include <boost/json.hpp>
#include <boost/optional.hpp>
Expand Down Expand Up @@ -42,6 +45,7 @@ struct ZakuroConfig {
std::string client_key;
bool initial_mute_video = false;
bool initial_mute_audio = false;
std::optional<webrtc::DegradationPreference> degradation_preference;

std::vector<std::string> sora_signaling_urls;
std::string sora_channel_id;
Expand Down

0 comments on commit e2ce8e3

Please sign in to comment.