]> git.sesse.net Git - nageru/commitdiff
Add a UI toggle to turn off SRT at runtime.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 Jun 2020 10:30:11 +0000 (12:30 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 Jun 2020 10:30:11 +0000 (12:30 +0200)
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.

nageru/flags.h
nageru/mainwindow.cpp
nageru/mainwindow.ui
nageru/mixer.cpp

index ad812b938431ba778286af7997245594fdda9444..bbe84c254e17c73f6977e983134ffe04f39c1176 100644 (file)
@@ -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;
index 20f8e50dbc6ec189310b20e6b7337d19b826062d..0a3ec15677cbcfba95f5455c47999079aeab331c 100644 (file)
@@ -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()) {
index d727155c1d3a557d229a4602070c49da67a7e559..e3ce5c311556e33300cf75f1e03f2735b9a032c1 100644 (file)
     <addaction name="hdmi_sdi_output_resolution_menu"/>
     <addaction name="display_timecode_menu"/>
     <addaction name="quick_cut_enable_action"/>
+    <addaction name="srt_enable_action"/>
     <addaction name="exit_action"/>
    </widget>
    <widget class="QMenu" name="menu_Help">
     <string>Enable &amp;quick-cut keys (Q, W, E, etc.)</string>
    </property>
   </action>
+  <action name="srt_enable_action">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="checked">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Accept new SRT connections on port 9710</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>
index 0efed5aa2d89137eb1bcc7a3baa2be7895984f04..3b7a99c0319ea567a0f5fcb38f17075ef9d7151d 100644 (file)
@@ -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<mutex> lock(hotplug_mutex);
                        hotplugged_srt_cards.push_back(clientsock);
                }