+void DeckLinkCapture::set_video_mode(uint32_t video_mode_id)
+{
+ if (input->StopStreams() != S_OK) {
+ fprintf(stderr, "StopStreams failed\n");
+ exit(1);
+ }
+
+ set_video_mode_no_restart(video_mode_id);
+
+ if (input->StartStreams() != S_OK) {
+ fprintf(stderr, "StartStreams failed\n");
+ exit(1);
+ }
+}
+
+void DeckLinkCapture::set_video_mode_no_restart(uint32_t video_mode_id)
+{
+ BMDDisplayModeSupport support;
+ IDeckLinkDisplayMode *display_mode;
+ if (input->DoesSupportVideoMode(video_mode_id, bmdFormat8BitYUV, /*flags=*/0, &support, &display_mode)) {
+ fprintf(stderr, "Failed to query display mode for card %d\n", card_index);
+ exit(1);
+ }
+
+ if (support == bmdDisplayModeNotSupported) {
+ fprintf(stderr, "Card %d does not support display mode\n", card_index);
+ exit(1);
+ }
+
+ if (display_mode->GetFrameRate(&frame_duration, &time_scale) != S_OK) {
+ fprintf(stderr, "Could not get frame rate for card %d\n", card_index);
+ exit(1);
+ }
+
+ if (input->EnableVideoInput(video_mode_id, bmdFormat8BitYUV, 0) != S_OK) {
+ fprintf(stderr, "Failed to set video mode 0x%04x for card %d\n", video_mode_id, card_index);
+ exit(1);
+ }
+
+ current_video_mode = video_mode_id;
+}
+
+void DeckLinkCapture::set_video_input(uint32_t video_input_id)
+{
+ if (config->SetInt(bmdDeckLinkConfigVideoInputConnection, video_input_id) != S_OK) {
+ fprintf(stderr, "Failed to set video input connection for card %d\n", card_index);
+ exit(1);
+ }
+
+ current_video_input = video_input_id;
+}
+
+void DeckLinkCapture::set_audio_input(uint32_t audio_input_id)
+{
+ if (config->SetInt(bmdDeckLinkConfigAudioInputConnection, audio_input_id) != S_OK) {
+ fprintf(stderr, "Failed to set audio input connection for card %d\n", card_index);
+ exit(1);
+ }
+
+ current_audio_input = audio_input_id;
+}