From: Steinar H. Gunderson Date: Mon, 1 Jun 2020 10:30:11 +0000 (+0200) Subject: Add a UI toggle to turn off SRT at runtime. X-Git-Tag: 2.0.0~14 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=82eaaa3d91b33479a3dee767d5de12aeb6da5b93 Add a UI toggle to turn off SRT at runtime. This is both useful for discoveirng the feature, and also should you be on a hostile network where suddenly someone connects to you when you don't want to. Existing connections will remain just fine. --- diff --git a/nageru/flags.h b/nageru/flags.h index ad812b9..bbe84c2 100644 --- a/nageru/flags.h +++ b/nageru/flags.h @@ -59,6 +59,7 @@ struct Flags { int max_input_queue_frames = 6; int http_port = DEFAULT_HTTPD_PORT; int srt_port = DEFAULT_SRT_PORT; // -1 for none. + bool enable_srt = true; // UI toggle; not settable from the command line. See also srt_port. bool display_timecode_in_stream = false; bool display_timecode_on_stdout = false; bool enable_quick_cut_keys = false; diff --git a/nageru/mainwindow.cpp b/nageru/mainwindow.cpp index 20f8e50..0a3ec15 100644 --- a/nageru/mainwindow.cpp +++ b/nageru/mainwindow.cpp @@ -277,6 +277,26 @@ MainWindow::MainWindow() global_flags.enable_quick_cut_keys = ui->quick_cut_enable_action->isChecked(); }); +#if HAVE_SRT + if (global_flags.srt_port >= 0) { + char title[256]; + snprintf(title, sizeof(title), "Accept new SRT connections on port %d", global_flags.srt_port); + ui->srt_enable_action->setChecked(true); + ui->srt_enable_action->setText(title); + connect(ui->srt_enable_action, &QAction::changed, [this](){ + global_flags.enable_srt = ui->srt_enable_action->isChecked(); + }); + } else { + ui->srt_enable_action->setChecked(false); + ui->srt_enable_action->setEnabled(false); + ui->srt_enable_action->setText("Accept new SRT connections"); + } +#else + ui->srt_enable_action->setChecked(false); + ui->srt_enable_action->setEnabled(false); + ui->srt_enable_action->setText("Accept new SRT connections"); +#endif + last_audio_level_callback = steady_clock::now() - seconds(1); if (!global_flags.midi_mapping_filename.empty()) { diff --git a/nageru/mainwindow.ui b/nageru/mainwindow.ui index d727155..e3ce5c3 100644 --- a/nageru/mainwindow.ui +++ b/nageru/mainwindow.ui @@ -1500,6 +1500,7 @@ + @@ -1606,6 +1607,17 @@ Enable &quick-cut keys (Q, W, E, etc.) + + + true + + + true + + + Accept new SRT connections on port 9710 + + diff --git a/nageru/mixer.cpp b/nageru/mixer.cpp index 0efed5a..3b7a99c 100644 --- a/nageru/mixer.cpp +++ b/nageru/mixer.cpp @@ -2159,6 +2159,12 @@ void Mixer::start_srt() } break; } + if (!global_flags.enable_srt) { // Runtime UI toggle. + // Perhaps not as good as never listening in the first place, + // but much simpler to turn on and off. + srt_close(clientsock); + continue; + } lock_guard lock(hotplug_mutex); hotplugged_srt_cards.push_back(clientsock); }