decklink: Use audio/video timestamps from SDK
System timestamps were being used instead of timestamps from the audio/video input. This would cause potential desync as well as incremental buffering when using devices with the blackmagic video source. Using the timestamps direct from the SDK itself fixes those issues, and causes audio/video to play back properly and in sync.
This commit is contained in:
parent
1659d04fe0
commit
ae733230b7
@ -126,14 +126,23 @@ bool DeckLinkDeviceInstance::StopCapture(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
#define TIME_BASE 1000000000
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DeckLinkDeviceInstance::VideoInputFrameArrived(
|
||||
IDeckLinkVideoInputFrame *videoFrame,
|
||||
IDeckLinkAudioInputPacket *audioPacket)
|
||||
{
|
||||
const uint64_t timestamp = os_gettime_ns();
|
||||
BMDTimeValue videoTS = 0;
|
||||
BMDTimeValue videoDur = 0;
|
||||
BMDTimeValue audioTS = 0;
|
||||
|
||||
HandleVideoFrame(videoFrame, timestamp);
|
||||
HandleAudioPacket(audioPacket, timestamp);
|
||||
videoFrame->GetStreamTime(&videoTS, &videoDur, TIME_BASE);
|
||||
audioPacket->GetPacketTime(&audioTS, TIME_BASE);
|
||||
|
||||
if (videoTS >= 0)
|
||||
HandleVideoFrame(videoFrame, (uint64_t)videoTS);
|
||||
if (audioTS >= 0)
|
||||
HandleAudioPacket(audioPacket, (uint64_t)audioTS);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user