set_video_mode_no_restart(bmdModeHD720p5994);
- if (input->EnableAudioInput(48000, bmdAudioSampleType32bitInteger, 2) != S_OK) {
- fprintf(stderr, "Failed to enable audio input for card %d\n", card_index);
- exit(1);
- }
-
input->SetCallback(this);
}
fprintf(stderr, "Could not get new frame rate\n");
exit(1);
}
+ field_dominance = display_mode->GetFieldDominance();
return S_OK;
}
video_format.frame_rate_nom = time_scale;
video_format.frame_rate_den = frame_duration;
+ // TODO: Respect the TFF/BFF flag.
+ video_format.interlaced = (field_dominance == bmdLowerFieldFirst || field_dominance == bmdUpperFieldFirst);
+ video_format.second_field_start = 1;
if (video_frame) {
video_format.has_signal = !(video_frame->GetFlags() & bmdFrameHasNoInputSource);
void DeckLinkCapture::start_bm_capture()
{
+ if (running) {
+ return;
+ }
+ if (input->EnableVideoInput(current_video_mode, bmdFormat8BitYUV, 0) != S_OK) {
+ fprintf(stderr, "Failed to set video mode 0x%04x for card %d\n", current_video_mode, card_index);
+ exit(1);
+ }
+ if (input->EnableAudioInput(48000, bmdAudioSampleType32bitInteger, 2) != S_OK) {
+ fprintf(stderr, "Failed to enable audio input for card %d\n", card_index);
+ exit(1);
+ }
+
if (input->StartStreams() != S_OK) {
fprintf(stderr, "StartStreams failed\n");
exit(1);
}
+ running = true;
}
void DeckLinkCapture::stop_dequeue_thread()
{
- if (input->StopStreams() != S_OK) {
- fprintf(stderr, "StopStreams failed\n");
+ if (!running) {
+ return;
+ }
+ HRESULT result = input->StopStreams();
+ if (result != S_OK) {
+ fprintf(stderr, "StopStreams failed with error 0x%x\n", result);
+ exit(1);
+ }
+ if (input->DisableVideoInput() != S_OK) {
+ fprintf(stderr, "Failed to disable video input for card %d\n", card_index);
exit(1);
}
+ if (input->DisableAudioInput() != S_OK) {
+ fprintf(stderr, "Failed to disable audio input for card %d\n", card_index);
+ exit(1);
+ }
+ running = false;
}
void DeckLinkCapture::set_video_mode(uint32_t video_mode_id)
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);
+ field_dominance = display_mode->GetFieldDominance();
+
+ if (running) {
+ 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;