diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2017-02-25 12:37:46 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-05-12 11:42:00 +0200 |
commit | 5dc10399375df74c3cb0e84dac39bc05a3fcdb82 (patch) | |
tree | 885a881222a8a74125da3069a12df327d3a01037 /sys/decklink | |
parent | 4df6be45f0cfff0332e95d5af6a90b16966a16ee (diff) |
decklinkvideo/audiosrc: Add GstReferenceTimestampMeta with the stream time to each buffer
This is basically a frame counter provided by the driver and it's
advancing at the speed of the HDMI/SDI input. Having this available on
each buffer allows to know what constant-framerate-based timestamp each
frame is corresponding to and can be used e.g. to write out files
accordingly without having the local pipeline clock timestamps used.
https://bugzilla.gnome.org/show_bug.cgi?id=779213
Diffstat (limited to 'sys/decklink')
-rw-r--r-- | sys/decklink/gstdecklinkaudiosrc.cpp | 10 | ||||
-rw-r--r-- | sys/decklink/gstdecklinkvideosrc.cpp | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/sys/decklink/gstdecklinkaudiosrc.cpp b/sys/decklink/gstdecklinkaudiosrc.cpp index 1de018a21..7a03c938a 100644 --- a/sys/decklink/gstdecklinkaudiosrc.cpp +++ b/sys/decklink/gstdecklinkaudiosrc.cpp @@ -61,6 +61,8 @@ typedef struct { IDeckLinkAudioInputPacket *packet; GstClockTime timestamp; + GstClockTime stream_timestamp; + GstClockTime stream_duration; gboolean no_signal; } CapturePacket; @@ -531,6 +533,8 @@ gst_decklink_audio_src_got_packet (GstElement * element, memset (&p, 0, sizeof (p)); p.packet = packet; p.timestamp = timestamp; + p.stream_timestamp = stream_time; + p.stream_duration = stream_duration; p.no_signal = no_signal; packet->AddRef (); gst_queue_array_push_tail_struct (self->current_packets, &p); @@ -553,6 +557,8 @@ gst_decklink_audio_src_create (GstPushSrc * bsrc, GstBuffer ** buffer) GstClockTime start_time, end_time; guint64 start_offset, end_offset; gboolean discont = FALSE; + static GstStaticCaps stream_reference = + GST_STATIC_CAPS ("timestamp/x-stream"); retry: g_mutex_lock (&self->lock); @@ -667,6 +673,10 @@ retry: GST_BUFFER_TIMESTAMP (*buffer) = timestamp; GST_BUFFER_DURATION (*buffer) = duration; + gst_buffer_add_reference_timestamp_meta (*buffer, + gst_static_caps_get (&stream_reference), p.stream_timestamp, + p.stream_duration); + GST_DEBUG_OBJECT (self, "Outputting buffer %p with timestamp %" GST_TIME_FORMAT " and duration %" GST_TIME_FORMAT, *buffer, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*buffer)), diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp index 5f3ff75a8..34c716f51 100644 --- a/sys/decklink/gstdecklinkvideosrc.cpp +++ b/sys/decklink/gstdecklinkvideosrc.cpp @@ -55,6 +55,8 @@ typedef struct { IDeckLinkVideoInputFrame *frame; GstClockTime timestamp, duration; + GstClockTime stream_timestamp; + GstClockTime stream_duration; GstDecklinkModeEnum mode; BMDPixelFormat format; GstVideoTimeCode *tc; @@ -684,6 +686,8 @@ gst_decklink_video_src_got_frame (GstElement * element, f.frame = frame; f.timestamp = timestamp; f.duration = duration; + f.stream_timestamp = stream_time; + f.stream_duration = stream_duration; f.mode = mode; f.format = frame->GetPixelFormat (); f.no_signal = no_signal; @@ -743,6 +747,8 @@ gst_decklink_video_src_create (GstPushSrc * bsrc, GstBuffer ** buffer) GstCaps *caps; gboolean caps_changed = FALSE; const GstDecklinkMode *mode; + static GstStaticCaps stream_reference = + GST_STATIC_CAPS ("timestamp/x-stream"); g_mutex_lock (&self->lock); while (gst_queue_array_is_empty (self->current_frames) && !self->flushing) { @@ -840,6 +846,9 @@ gst_decklink_video_src_create (GstPushSrc * bsrc, GstBuffer ** buffer) GST_BUFFER_DURATION (*buffer) = f.duration; if (f.tc != NULL) gst_buffer_add_video_time_code_meta (*buffer, f.tc); + gst_buffer_add_reference_timestamp_meta (*buffer, + gst_static_caps_get (&stream_reference), f.stream_timestamp, + f.stream_duration); mode = gst_decklink_get_mode (self->mode); if (mode->interlaced && mode->tff) |