Skip to content

Commit

Permalink
--duration および --repeat-interval オプションを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
melpon committed May 15, 2023
1 parent 8f4ac41 commit 661ce04
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
- @melpon
- [ADD] `--sora-client-id` および `--sora-bundle-id` オプションを追加
- @melpon
- [ADD] `--duration` および `--repeat-interval` オプションを追加
- @melpon
- [FIX] 廃止になった `--sora-audio-opus-params-clock-rate` を削除する
- @torikizi
- [FIX] "data-channels" の "interval" 項目を指定するとエラーになる問題を修正
Expand Down
7 changes: 7 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ void Util::ParseArgs(const std::vector<std::string>& cargs,
app.add_option("--vcs-hatch-rate", config.vcs_hatch_rate,
"Spawned virtual clients per seconds")
->check(CLI::Range(0.1, 100.0));
app.add_option(
"--duration", config.duration,
"(Experimental) Duration of virtual client running in seconds");
app.add_option("--repeat-interval", config.repeat_interval,
"(Experimental) Interval to reconnect after disconnection");

app.add_flag("--no-video-device", config.no_video_device,
"Do not use video device");
Expand Down Expand Up @@ -474,6 +479,8 @@ std::vector<std::vector<std::string>> Util::NodeToArgs(const YAML::Node& inst) {
DEF_STRING(inst, "", "name");
DEF_INTEGER(inst, "", "vcs");
DEF_DOUBLE(inst, "", "vcs-hatch-rate");
DEF_DOUBLE(inst, "", "duration");
DEF_DOUBLE(inst, "", "repeat-interval");
DEF_FLAG(inst, "", "no-video-device");
DEF_FLAG(inst, "", "no-audio-device");
DEF_FLAG(inst, "", "fake-capture-device");
Expand Down
1 change: 1 addition & 0 deletions src/virtual_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ std::shared_ptr<VirtualClient> VirtualClient::Create(

void VirtualClient::Connect() {
if (closing_) {
need_reconnect_ = true;
return;
}

Expand Down
23 changes: 20 additions & 3 deletions src/zakuro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,26 @@ int Zakuro::Run() {
for (const auto& d : dcs_data) {
data.PlaySubScenario(std::get<0>(d), std::get<1>(d), 0);
}
data.Sleep(1000, 5000);
data.PlayVoiceNumberClient();
loop_index = 1 + dcs_data.size();
ScenarioData sd;
sd.Sleep(1000, 5000);
sd.PlayVoiceNumberClient();
data.PlaySubScenario("scenario-voice-number-client", sd, 0);
if (config_.duration == 0) {
data.Sleep(10000, 10000);
} else {
// duration が設定されている場合、duration 秒待って切断し、
// repeat_interval 秒待ってから再接続する
data.Sleep((int)(config_.duration * 1000),
(int)(config_.duration * 1000));
data.Disconnect();
// repeat_interval == 0 の場合は再接続しない
if (config_.repeat_interval != 0) {
data.Sleep((int)(config_.repeat_interval * 1000),
(int)(config_.repeat_interval * 1000));
data.Reconnect();
}
}
loop_index = 1 + dcs_data.size() + 1;
} else if (config_.scenario == "reconnect") {
data.Reconnect();
data.Sleep(1000, 5000);
Expand Down
2 changes: 2 additions & 0 deletions src/zakuro.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ struct ZakuroConfig {
std::string name = "zakuro";
int vcs = 1;
double vcs_hatch_rate = 1.0;
double duration = 0;
double repeat_interval = 0;

bool no_video_device = false;
bool no_audio_device = false;
Expand Down

0 comments on commit 661ce04

Please sign in to comment.