diff --git a/plugins/elements/gstclocksync.c b/plugins/elements/gstclocksync.c index 2d479fc3bb..807c84265f 100644 --- a/plugins/elements/gstclocksync.c +++ b/plugins/elements/gstclocksync.c @@ -171,7 +171,6 @@ gst_clock_sync_init (GstClockSync * clocksync) 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); } @@ -180,10 +179,31 @@ gst_clock_sync_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstClockSync *clocksync = GST_CLOCKSYNC (object); + GstMessage *clock_message = NULL; + gboolean sync; switch (prop_id) { case PROP_SYNC: clocksync->sync = g_value_get_boolean (value); + sync = g_value_get_boolean (value); + GST_OBJECT_LOCK (clocksync); + if (sync != clocksync->sync) { + clocksync->sync = sync; + if (sync) { + GST_OBJECT_FLAG_SET (clocksync, GST_ELEMENT_FLAG_PROVIDE_CLOCK); + clock_message = + gst_message_new_clock_provide (GST_OBJECT_CAST (clocksync), + gst_system_clock_obtain (), TRUE); + } else { + GST_OBJECT_FLAG_UNSET (clocksync, GST_ELEMENT_FLAG_PROVIDE_CLOCK); + clock_message = + gst_message_new_clock_lost (GST_OBJECT_CAST (clocksync), + gst_system_clock_obtain ()); + } + } + GST_OBJECT_UNLOCK (clocksync); + if (clock_message) + gst_element_post_message (GST_ELEMENT_CAST (clocksync), clock_message); break; case PROP_TS_OFFSET: clocksync->ts_offset = g_value_get_int64 (value); @@ -540,5 +560,10 @@ gst_clocksync_change_state (GstElement * element, GstStateChange transition) static GstClock * gst_clocksync_provide_clock (GstElement * element) { + GstClockSync *clocksync = GST_CLOCKSYNC (element); + + if (!clocksync->sync) + return NULL; + return gst_system_clock_obtain (); } diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index d5e156e9f5..53e90ffa54 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -316,7 +316,6 @@ gst_identity_init (GstIdentity * identity) 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); } @@ -824,6 +823,8 @@ gst_identity_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstIdentity *identity; + GstMessage *clock_message = NULL; + gboolean sync; identity = GST_IDENTITY (object); @@ -853,7 +854,25 @@ gst_identity_set_property (GObject * object, guint prop_id, identity->datarate = g_value_get_int (value); break; case PROP_SYNC: - identity->sync = g_value_get_boolean (value); + sync = g_value_get_boolean (value); + GST_OBJECT_LOCK (identity); + if (sync != identity->sync) { + identity->sync = sync; + if (sync) { + GST_OBJECT_FLAG_SET (identity, GST_ELEMENT_FLAG_PROVIDE_CLOCK); + clock_message = + gst_message_new_clock_provide (GST_OBJECT_CAST (identity), + gst_system_clock_obtain (), TRUE); + } else { + GST_OBJECT_FLAG_UNSET (identity, GST_ELEMENT_FLAG_PROVIDE_CLOCK); + clock_message = + gst_message_new_clock_lost (GST_OBJECT_CAST (identity), + gst_system_clock_obtain ()); + } + } + GST_OBJECT_UNLOCK (identity); + if (clock_message) + gst_element_post_message (GST_ELEMENT_CAST (identity), clock_message); break; case PROP_TS_OFFSET: identity->ts_offset = g_value_get_int64 (value); @@ -1131,5 +1150,10 @@ gst_identity_change_state (GstElement * element, GstStateChange transition) static GstClock * gst_identity_provide_clock (GstElement * element) { + GstIdentity *identity = GST_IDENTITY (element); + + if (!identity->sync) + return NULL; + return gst_system_clock_obtain (); }