X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=decklink_capture.cpp;fp=decklink_capture.cpp;h=6680de1c57be8467b42077939eab1ba5535c8ce5;hb=7d23b62323aba8fa396f6abc617c39e8c634b023;hp=e7f8eba0a16531c7341619be0cb2e8f7541b583a;hpb=3e8c584c42ae8a53e2cf335ff6c986f1b87f3f5e;p=nageru diff --git a/decklink_capture.cpp b/decklink_capture.cpp index e7f8eba..6680de1 100644 --- a/decklink_capture.cpp +++ b/decklink_capture.cpp @@ -149,6 +149,7 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived( FrameAllocator::Frame current_video_frame, current_audio_frame; VideoFormat video_format; + AudioFormat audio_format; if (video_frame) { video_format.has_signal = !(video_frame->GetFlags() & bmdFrameHasNoInputSource); @@ -174,12 +175,27 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived( } } + if (audio_frame) { + int num_samples = audio_frame->GetSampleFrameCount(); + + current_audio_frame = audio_frame_allocator->alloc_frame(); + if (current_audio_frame.data != nullptr) { + const uint8_t *frame_bytes; + audio_frame->GetBytes((void **)&frame_bytes); + + memcpy(current_audio_frame.data, frame_bytes, sizeof(int32_t) * 2 * num_samples); + + audio_format.bits_per_sample = 32; + audio_format.num_channels = 2; + } + } + if (current_video_frame.data != nullptr || current_audio_frame.data != nullptr) { // TODO: Put into a queue and put into a dequeue thread, if the // BlackMagic drivers don't already do that for us? frame_callback(timecode, current_video_frame, /*video_offset=*/0, video_format, - current_audio_frame, /*audio_offset=*/0, 0x0000); + current_audio_frame, /*audio_offset=*/0, audio_format); } timecode++;