identity, clocksync: implement provide_clock

Since those are using the clock for sync, they need to also
provide a clock for good measure. The reason is that even if
downstream elements provide a clock, we don't want to have
that clock selected because it might not be running yet.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/509>
This commit is contained in:
Mathieu Duponchelle 2020-06-01 16:18:50 +02:00 committed by GStreamer Merge Bot
parent 2cd23d67d3
commit d46e902273
3 changed files with 27 additions and 1 deletions

View file

@ -98,6 +98,7 @@ static gboolean gst_clock_sync_src_query (GstPad * pad, GstObject * parent,
GstQuery * query);
static GstStateChangeReturn gst_clocksync_change_state (GstElement * element,
GstStateChange transition);
static GstClock *gst_clocksync_provide_clock (GstElement * element);
static void
gst_clock_sync_class_init (GstClockSyncClass * klass)
@ -124,6 +125,8 @@ gst_clock_sync_class_init (GstClockSyncClass * klass)
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_clocksync_change_state);
gstelement_class->provide_clock =
GST_DEBUG_FUNCPTR (gst_clocksync_provide_clock);
gst_element_class_set_static_metadata (gstelement_class,
"ClockSync",
@ -167,6 +170,9 @@ gst_clock_sync_init (GstClockSync * clocksync)
clocksync->ts_offset = DEFAULT_TS_OFFSET;
clocksync->sync = DEFAULT_SYNC;
g_cond_init (&clocksync->blocked_cond);
GST_OBJECT_FLAG_SET (clocksync, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
GST_OBJECT_FLAG_SET (clocksync, GST_ELEMENT_FLAG_REQUIRE_CLOCK);
}
static void
@ -529,3 +535,10 @@ gst_clocksync_change_state (GstElement * element, GstStateChange transition)
return ret;
}
/* FIXME: GStreamer 2.0 */
static GstClock *
gst_clocksync_provide_clock (GstElement * element)
{
return gst_system_clock_obtain ();
}

View file

@ -125,6 +125,7 @@ static gboolean gst_identity_accept_caps (GstBaseTransform * base,
GstPadDirection direction, GstCaps * caps);
static gboolean gst_identity_query (GstBaseTransform * base,
GstPadDirection direction, GstQuery * query);
static GstClock *gst_identity_provide_clock (GstElement * element);
static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
@ -277,6 +278,8 @@ gst_identity_class_init (GstIdentityClass * klass)
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_identity_change_state);
gstelement_class->provide_clock =
GST_DEBUG_FUNCPTR (gst_identity_provide_clock);
gstbasetrans_class->sink_event = GST_DEBUG_FUNCPTR (gst_identity_sink_event);
gstbasetrans_class->src_event = GST_DEBUG_FUNCPTR (gst_identity_src_event);
@ -312,6 +315,9 @@ gst_identity_init (GstIdentity * identity)
identity->eos_after_counter = DEFAULT_EOS_AFTER;
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM_CAST (identity), TRUE);
GST_OBJECT_FLAG_SET (identity, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
GST_OBJECT_FLAG_SET (identity, GST_ELEMENT_FLAG_REQUIRE_CLOCK);
}
static void
@ -1120,3 +1126,10 @@ gst_identity_change_state (GstElement * element, GstStateChange transition)
return ret;
}
/* FIXME: GStreamer 2.0 */
static GstClock *
gst_identity_provide_clock (GstElement * element)
{
return gst_system_clock_obtain ();
}

View file

@ -1780,7 +1780,7 @@ GST_END_TEST;
expected_flags) \
G_STMT_START { \
GstBin *bin = GST_BIN (gst_bin_new ("test-bin")); \
GstElement *element = gst_element_factory_make ("identity", "test-i"); \
GstElement *element = gst_element_factory_make ("queue", "test-q"); \
GstElementFlags natural_flags = GST_OBJECT_FLAGS (bin); \
GST_OBJECT_FLAG_SET (element, element_flags); \
gst_bin_set_suppressed_flags (bin, suppressed_flags); \