From ba4ab9dc16950ed954b62fc92561ae92b7998bef Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 21 Apr 2023 17:49:50 +0200 Subject: [PATCH] core: pipeline: add gst_pipeline_is_live() Convenient API for applications wanting to check if a pipeline is live or not. Save them from checking the change_state return value or sending latency queries. Part-of: --- girs/Gst-1.0.gir | 16 ++++++++++++++++ subprojects/gstreamer/gst/gstpipeline.c | 24 ++++++++++++++++++++++++ subprojects/gstreamer/gst/gstpipeline.h | 3 +++ 3 files changed, 43 insertions(+) diff --git a/girs/Gst-1.0.gir b/girs/Gst-1.0.gir index 6ec4fff2a0..788a3dc67b 100644 --- a/girs/Gst-1.0.gir +++ b/girs/Gst-1.0.gir @@ -32902,6 +32902,22 @@ clock, even if the pipeline is not in the PLAYING state. + + Check if @pipeline is live. + + + %TRUE if @pipeline is live, %FALSE if not or if it did not reach the PAUSED state yet. + +MT safe. + + + + + a #GstPipeline + + + + Usually, when a pipeline goes from READY to NULL state, it automatically flushes all pending messages on the bus, which is done for refcounting diff --git a/subprojects/gstreamer/gst/gstpipeline.c b/subprojects/gstreamer/gst/gstpipeline.c index 8ba8643680..af31c95bc5 100644 --- a/subprojects/gstreamer/gst/gstpipeline.c +++ b/subprojects/gstreamer/gst/gstpipeline.c @@ -1176,3 +1176,27 @@ gst_pipeline_handle_instant_rate (GstPipeline * pipeline, gdouble rate, return gst_element_send_event (GST_ELEMENT_CAST (pipeline), event); } + +/** + * gst_pipeline_is_live: + * @pipeline: a #GstPipeline + * + * Check if @pipeline is live. + * + * Returns: %TRUE if @pipeline is live, %FALSE if not or if it did not reach the PAUSED state yet. + * + * MT safe. + * + * Since: 1.24 + */ +gboolean +gst_pipeline_is_live (GstPipeline * pipeline) +{ + gboolean is_live; + + GST_OBJECT_LOCK (pipeline); + is_live = pipeline->priv->is_live; + GST_OBJECT_UNLOCK (pipeline); + + return is_live; +} diff --git a/subprojects/gstreamer/gst/gstpipeline.h b/subprojects/gstreamer/gst/gstpipeline.h index 6406fb86d3..4d5b805884 100644 --- a/subprojects/gstreamer/gst/gstpipeline.h +++ b/subprojects/gstreamer/gst/gstpipeline.h @@ -130,6 +130,9 @@ void gst_pipeline_set_auto_flush_bus (GstPipeline *pipeline, gboolean GST_API gboolean gst_pipeline_get_auto_flush_bus (GstPipeline *pipeline); +GST_API +gboolean gst_pipeline_is_live (GstPipeline *pipeline); + G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPipeline, gst_object_unref) G_END_DECLS