diff options
author | Vivia Nikolaidou <vivia@ahiru.eu> | 2017-01-05 15:41:06 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-01-09 18:37:50 +0200 |
commit | 3cb43f35b837111a376924503a73dfda425731e0 (patch) | |
tree | e816e45930c9265c66f0bcfde84beda90091b4a6 /sys | |
parent | d9f553bff50b15bd476c648926f5d2ae5cf30c72 (diff) | |
download | gstreamer-plugins-bad-3cb43f35b837111a376924503a73dfda425731e0.tar.gz |
decklinkvideosrc: Do not append a zero timecode if none is found on the source
If the source doesn't give us timecode information, do not append a zero
timecode to the frames.
https://bugzilla.gnome.org/show_bug.cgi?id=776900
Diffstat (limited to 'sys')
-rw-r--r-- | sys/decklink/gstdecklink.cpp | 27 | ||||
-rw-r--r-- | sys/decklink/gstdecklink.h | 2 | ||||
-rw-r--r-- | sys/decklink/gstdecklinkvideosrc.cpp | 58 |
3 files changed, 44 insertions, 43 deletions
diff --git a/sys/decklink/gstdecklink.cpp b/sys/decklink/gstdecklink.cpp index bae740673..f7dee2186 100644 --- a/sys/decklink/gstdecklink.cpp +++ b/sys/decklink/gstdecklink.cpp @@ -756,8 +756,8 @@ public: void (*got_video_frame) (GstElement * videosrc, IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode, GstClockTime capture_time, GstClockTime stream_time, - GstClockTime stream_duration, guint hours, guint minutes, guint seconds, - guint frames, BMDTimecodeFlags bflags, gboolean no_signal) = NULL; + GstClockTime stream_duration, IDeckLinkTimecode *dtc, gboolean + no_signal) = NULL; void (*got_audio_packet) (GstElement * videosrc, IDeckLinkAudioInputPacket * packet, GstClockTime capture_time, GstClockTime packet_time, gboolean no_signal) = NULL; @@ -808,10 +808,6 @@ public: BMDTimeValue stream_time = GST_CLOCK_TIME_NONE; BMDTimeValue stream_duration = GST_CLOCK_TIME_NONE; IDeckLinkTimecode *dtc; - uint8_t hours, minutes, seconds, frames; - BMDTimecodeFlags bflags; - - hours = minutes = seconds = frames = bflags = 0; res = video_frame->GetStreamTime (&stream_time, &stream_duration, @@ -833,27 +829,12 @@ public: if (res != S_OK) { GST_DEBUG_OBJECT (videosrc, "Failed to get timecode: 0x%08x", res); dtc = NULL; - } else { - res = dtc->GetComponents (&hours, &minutes, &seconds, &frames); - if (res != S_OK) { - GST_ERROR ("Could not get components for timecode %p: 0x%08x", dtc, - res); - hours = 0; - minutes = 0; - seconds = 0; - frames = 0; - bflags = 0; - } else { - GST_DEBUG_OBJECT (videosrc, "Got timecode %02d:%02d:%02d:%02d", - hours, minutes, seconds, frames); - bflags = dtc->GetFlags (); - } } } + /* passing dtc reference */ got_video_frame (videosrc, video_frame, mode, capture_time, - stream_time, stream_duration, (guint8) hours, (guint8) minutes, - (guint8) seconds, (guint8) frames, bflags, no_signal); + stream_time, stream_duration, dtc, no_signal); } if (got_audio_packet && audiosrc && audio_packet) { diff --git a/sys/decklink/gstdecklink.h b/sys/decklink/gstdecklink.h index 5b940334d..df1971ec2 100644 --- a/sys/decklink/gstdecklink.h +++ b/sys/decklink/gstdecklink.h @@ -209,7 +209,7 @@ struct _GstDecklinkInput { GMutex lock; /* Set by the video source */ - void (*got_video_frame) (GstElement *videosrc, IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode, GstClockTime capture_time, GstClockTime stream_time, GstClockTime stream_duration, guint hours, guint minutes, guint seconds, guint frames, BMDTimecodeFlags bflags, gboolean no_signal); + void (*got_video_frame) (GstElement *videosrc, IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode, GstClockTime capture_time, GstClockTime stream_time, GstClockTime stream_duration, IDeckLinkTimecode *dtc, gboolean no_signal); /* Configured mode or NULL */ const GstDecklinkMode *mode; BMDPixelFormat format; diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp index 6acce28bb..4abe042af 100644 --- a/sys/decklink/gstdecklinkvideosrc.cpp +++ b/sys/decklink/gstdecklinkvideosrc.cpp @@ -601,8 +601,8 @@ static void gst_decklink_video_src_got_frame (GstElement * element, IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode, GstClockTime capture_time, GstClockTime stream_time, - GstClockTime stream_duration, guint hours, guint minutes, guint seconds, - guint frames, BMDTimecodeFlags bflags, gboolean no_signal) + GstClockTime stream_duration, IDeckLinkTimecode *dtc, + gboolean no_signal) { GstDecklinkVideoSrc *self = GST_DECKLINK_VIDEO_SRC_CAST (element); GstClockTime timestamp, duration; @@ -667,23 +667,42 @@ gst_decklink_video_src_got_frame (GstElement * element, f->mode = mode; f->format = frame->GetPixelFormat (); f->no_signal = no_signal; - bmode = gst_decklink_get_mode (mode); - if (bmode->interlaced) { - flags = - (GstVideoTimeCodeFlags) (flags | - GST_VIDEO_TIME_CODE_FLAGS_INTERLACED); - if (bflags & bmdTimecodeFieldMark) - field_count = 2; - else - field_count = 1; + if (dtc != NULL) { + uint8_t hours, minutes, seconds, frames; + BMDTimecodeFlags bflags; + HRESULT res; + + res = dtc->GetComponents (&hours, &minutes, &seconds, &frames); + if (res != S_OK) { + GST_ERROR ("Could not get components for timecode %p: 0x%08x", dtc, + res); + f->tc = NULL; + } else { + bflags = dtc->GetFlags (); + GST_DEBUG_OBJECT (self, "Got timecode %02d:%02d:%02d:%02d", + hours, minutes, seconds, frames); + bmode = gst_decklink_get_mode (mode); + if (bmode->interlaced) { + flags = + (GstVideoTimeCodeFlags) (flags | + GST_VIDEO_TIME_CODE_FLAGS_INTERLACED); + if (bflags & bmdTimecodeFieldMark) + field_count = 2; + else + field_count = 1; + } + if (bflags & bmdTimecodeIsDropFrame) + flags = + (GstVideoTimeCodeFlags) (flags | + GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME); + f->tc = + gst_video_time_code_new (bmode->fps_n, bmode->fps_d, NULL, flags, hours, + minutes, seconds, frames, field_count); + } + dtc->Release (); + } else { + f->tc = NULL; } - if (bflags & bmdTimecodeIsDropFrame) - flags = - (GstVideoTimeCodeFlags) (flags | - GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME); - f->tc = - gst_video_time_code_new (bmode->fps_n, bmode->fps_d, NULL, flags, hours, - minutes, seconds, frames, field_count); frame->AddRef (); g_queue_push_tail (&self->current_frames, f); @@ -798,7 +817,8 @@ gst_decklink_video_src_create (GstPushSrc * bsrc, GstBuffer ** buffer) GST_BUFFER_FLAG_SET (*buffer, GST_BUFFER_FLAG_GAP); GST_BUFFER_TIMESTAMP (*buffer) = f->timestamp; GST_BUFFER_DURATION (*buffer) = f->duration; - gst_buffer_add_video_time_code_meta (*buffer, f->tc); + if (f->tc != NULL) + gst_buffer_add_video_time_code_meta (*buffer, f->tc); mode = gst_decklink_get_mode (self->mode); if (mode->interlaced && mode->tff) |