+ // --- The choices in the next few options depend a lot on which card is active ---
+
+ bool has_auto_mode = false;
+ QAction *change_url_action = nullptr;
+ if (is_ffmpeg) {
+ // Add a menu to change the source URL if we're an FFmpeg card.
+ // (The theme can still override.)
+ if (global_mixer->card_is_ffmpeg(current_card)) {
+ change_url_action = new QAction("Change source filename/URL…", &menu);
+ menu.addAction(change_url_action);
+ }
+ } else {
+ // Add a submenu for selecting video input, with an action for each input.
+ std::map<uint32_t, string> video_inputs = global_mixer->get_available_video_inputs(current_card);
+ uint32_t current_video_input = global_mixer->get_current_video_input(current_card);
+ for (const auto &mode : video_inputs) {
+ QString description(QString::fromStdString(mode.second));
+ QAction *action = new QAction(description, &video_input_group);
+ action->setCheckable(true);
+ if (mode.first == current_video_input) {
+ action->setChecked(true);
+ }
+ action->setData(QList<QVariant>{"video_input", mode.first});
+ video_input_submenu.addAction(action);
+ }
+
+ video_input_submenu.setTitle("Video input");
+ menu.addMenu(&video_input_submenu);
+
+ // The same for audio input.
+ std::map<uint32_t, string> audio_inputs = global_mixer->get_available_audio_inputs(current_card);
+ uint32_t current_audio_input = global_mixer->get_current_audio_input(current_card);
+ for (const auto &mode : audio_inputs) {
+ QString description(QString::fromStdString(mode.second));
+ QAction *action = new QAction(description, &audio_input_group);
+ action->setCheckable(true);
+ if (mode.first == current_audio_input) {
+ action->setChecked(true);
+ }
+ action->setData(QList<QVariant>{"audio_input", mode.first});
+ audio_input_submenu.addAction(action);
+ }
+
+ audio_input_submenu.setTitle("Audio input");
+ menu.addMenu(&audio_input_submenu);
+
+ // The same for resolution.
+ std::map<uint32_t, bmusb::VideoMode> video_modes = global_mixer->get_available_video_modes(current_card);
+ uint32_t current_video_mode = global_mixer->get_current_video_mode(current_card);
+ for (const auto &mode : video_modes) {
+ QString description(QString::fromStdString(mode.second.name));
+ QAction *action = new QAction(description, &mode_group);
+ action->setCheckable(true);
+ if (mode.first == current_video_mode) {
+ action->setChecked(true);
+ }
+ action->setData(QList<QVariant>{"video_mode", mode.first});
+ mode_submenu.addAction(action);
+
+ // TODO: Relying on the 0 value here (from bmusb.h) is ugly, it should be a named constant.
+ if (mode.first == 0) {
+ has_auto_mode = true;
+ }
+ }
+
+ // Add a “scan” menu if there's no “auto” mode.
+ if (!has_auto_mode) {
+ QAction *action = new QAction("Scan", &mode_group);
+ action->setData(QList<QVariant>{"video_mode", 0});
+ mode_submenu.addSeparator();
+ mode_submenu.addAction(action);
+ }
+
+ mode_submenu.setTitle("Input mode");
+ menu.addMenu(&mode_submenu);
+ }
+
+ // --- End of card-dependent choices ---