diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-02-08 21:53:58 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-02-08 21:56:04 +0100 |
commit | 22b0a4dad534b5713af042bd4d1d3fb50bea5f8b (patch) | |
tree | e55280f880acae76c8d33830837c519ef0ece2d6 /sys | |
parent | 6725ff5598c7385b7759e25d1fba3660906d3f3f (diff) | |
download | gstreamer-plugins-bad-22b0a4dad534b5713af042bd4d1d3fb50bea5f8b.tar.gz |
decklink{audio,video}src: Take the capture times from the pipeline clock
Not from the decklink clock. Both will return exactly the same time once the
decklink clock got slaved to the pipeline clock and received the first
observation, but until then it will return bogus values. But as both return
exactly the same values, we can as well use the pipeline clock directly.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/decklink/gstdecklink.cpp | 37 | ||||
-rw-r--r-- | sys/decklink/gstdecklink.h | 4 | ||||
-rw-r--r-- | sys/decklink/gstdecklinkaudiosrc.cpp | 31 | ||||
-rw-r--r-- | sys/decklink/gstdecklinkvideosrc.cpp | 32 |
4 files changed, 61 insertions, 43 deletions
diff --git a/sys/decklink/gstdecklink.cpp b/sys/decklink/gstdecklink.cpp index a06b812af..0c79b4479 100644 --- a/sys/decklink/gstdecklink.cpp +++ b/sys/decklink/gstdecklink.cpp @@ -474,24 +474,37 @@ public: VideoInputFrameArrived (IDeckLinkVideoInputFrame * video_frame, IDeckLinkAudioInputPacket * audio_packet) { - GstClockTime clock_time = gst_clock_get_time (m_input->clock); + GstElement *videosrc = NULL, *audiosrc = NULL; + void (*got_video_frame) (GstElement * videosrc, + IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode) = NULL; + void (*got_audio_packet) (GstElement * videosrc, + IDeckLinkAudioInputPacket * packet) = NULL; + GstDecklinkModeEnum mode; g_mutex_lock (&m_input->lock); - if (m_input->got_video_frame) { - GstClockTime capture_time = clock_time - - gst_element_get_base_time (m_input->videosrc); - m_input->got_video_frame (m_input->videosrc, video_frame, - gst_decklink_get_mode_enum_from_bmd (m_input->mode->mode), - capture_time); + if (m_input->videosrc) { + videosrc = GST_ELEMENT_CAST (gst_object_ref (m_input->videosrc)); + got_video_frame = m_input->got_video_frame; } + mode = gst_decklink_get_mode_enum_from_bmd (m_input->mode->mode); - if (m_input->got_audio_packet) { - GstClockTime capture_time = clock_time - - gst_element_get_base_time (m_input->audiosrc); - m_input->got_audio_packet (m_input->audiosrc, audio_packet, capture_time); + if (m_input->audiosrc) { + audiosrc = GST_ELEMENT_CAST (gst_object_ref (m_input->audiosrc)); + got_audio_packet = m_input->got_audio_packet; } - g_mutex_unlock (&m_input->lock); + + if (got_video_frame && videosrc) { + got_video_frame (videosrc, video_frame, mode); + } + + if (got_audio_packet && audiosrc) { + m_input->got_audio_packet (audiosrc, audio_packet); + } + + gst_object_replace ((GstObject **) & videosrc, NULL); + gst_object_replace ((GstObject **) & audiosrc, NULL); + return S_OK; } }; diff --git a/sys/decklink/gstdecklink.h b/sys/decklink/gstdecklink.h index e1ef4e697..cd472f65d 100644 --- a/sys/decklink/gstdecklink.h +++ b/sys/decklink/gstdecklink.h @@ -169,12 +169,12 @@ struct _GstDecklinkInput { GMutex lock; /* Set by the video source */ - void (*got_video_frame) (GstElement *videosrc, IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode, GstClockTime capture_time); + void (*got_video_frame) (GstElement *videosrc, IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode); /* Configured mode or NULL */ const GstDecklinkMode *mode; /* Set by the audio source */ - void (*got_audio_packet) (GstElement *videosrc, IDeckLinkAudioInputPacket * packet, GstClockTime capture_time); + void (*got_audio_packet) (GstElement *videosrc, IDeckLinkAudioInputPacket * packet); GstElement *audiosrc; gboolean audio_enabled; diff --git a/sys/decklink/gstdecklinkaudiosrc.cpp b/sys/decklink/gstdecklinkaudiosrc.cpp index 1a63f379b..c267e3138 100644 --- a/sys/decklink/gstdecklinkaudiosrc.cpp +++ b/sys/decklink/gstdecklinkaudiosrc.cpp @@ -411,9 +411,25 @@ gst_decklink_audio_src_get_caps (GstBaseSrc * bsrc, GstCaps * filter) static void gst_decklink_audio_src_got_packet (GstElement * element, - IDeckLinkAudioInputPacket * packet, GstClockTime capture_time) + IDeckLinkAudioInputPacket * packet) { GstDecklinkAudioSrc *self = GST_DECKLINK_AUDIO_SRC_CAST (element); + GstClock *clock; + GstClockTime capture_time; + + clock = gst_element_get_clock (element); + if (clock) { + GstClockTime clock_time, base_time; + + clock_time = gst_clock_get_time (clock); + g_return_if_fail (clock_time != GST_CLOCK_TIME_NONE); + base_time = gst_element_get_base_time (element); + g_return_if_fail (base_time != GST_CLOCK_TIME_NONE); + capture_time = clock_time - base_time; + gst_object_unref (clock); + } else { + capture_time = GST_CLOCK_TIME_NONE; + } GST_LOG_OBJECT (self, "Got audio packet at %" GST_TIME_FORMAT, GST_TIME_ARGS (capture_time)); @@ -748,18 +764,6 @@ gst_decklink_audio_src_change_state (GstElement * element, self->next_offset = -1; break; } - case GST_STATE_CHANGE_PAUSED_TO_PLAYING:{ - GstClock *clock; - - clock = gst_element_get_clock (GST_ELEMENT_CAST (self)); - if (clock && clock != self->input->clock) { - gst_clock_set_master (self->input->clock, clock); - } - if (clock) - gst_object_unref (clock); - - break; - } default: break; } @@ -773,7 +777,6 @@ gst_decklink_audio_src_change_state (GstElement * element, gst_element_post_message (element, gst_message_new_clock_lost (GST_OBJECT_CAST (element), self->input->clock)); - gst_clock_set_master (self->input->clock, NULL); g_queue_foreach (&self->current_packets, (GFunc) capture_packet_free, NULL); diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp index 112f7b078..45542612c 100644 --- a/sys/decklink/gstdecklinkvideosrc.cpp +++ b/sys/decklink/gstdecklinkvideosrc.cpp @@ -364,10 +364,25 @@ gst_decklink_video_src_get_caps (GstBaseSrc * bsrc, GstCaps * filter) static void gst_decklink_video_src_got_frame (GstElement * element, - IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode, - GstClockTime capture_time) + IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode) { GstDecklinkVideoSrc *self = GST_DECKLINK_VIDEO_SRC_CAST (element); + GstClock *clock; + GstClockTime capture_time; + + clock = gst_element_get_clock (element); + if (clock) { + GstClockTime clock_time, base_time; + + clock_time = gst_clock_get_time (clock); + g_return_if_fail (clock_time != GST_CLOCK_TIME_NONE); + base_time = gst_element_get_base_time (element); + g_return_if_fail (base_time != GST_CLOCK_TIME_NONE); + capture_time = clock_time - base_time; + gst_object_unref (clock); + } else { + capture_time = GST_CLOCK_TIME_NONE; + } GST_LOG_OBJECT (self, "Got video frame at %" GST_TIME_FORMAT, GST_TIME_ARGS (capture_time)); @@ -637,18 +652,6 @@ gst_decklink_video_src_change_state (GstElement * element, self->input->clock, TRUE)); self->flushing = FALSE; break; - case GST_STATE_CHANGE_PAUSED_TO_PLAYING:{ - GstClock *clock; - - clock = gst_element_get_clock (GST_ELEMENT_CAST (self)); - if (clock && clock != self->input->clock) { - gst_clock_set_master (self->input->clock, clock); - } - if (clock) - gst_object_unref (clock); - - break; - } default: break; } @@ -662,7 +665,6 @@ gst_decklink_video_src_change_state (GstElement * element, gst_element_post_message (element, gst_message_new_clock_lost (GST_OBJECT_CAST (element), self->input->clock)); - gst_clock_set_master (self->input->clock, NULL); g_mutex_lock (&self->input->lock); self->input->clock_start_time = GST_CLOCK_TIME_NONE; self->input->clock_last_time = 0; |