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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4472>
This commit is contained in:
Guillaume Desmottes 2023-04-21 17:49:50 +02:00
parent 9dc4d48ff5
commit ba4ab9dc16
3 changed files with 43 additions and 0 deletions

View file

@ -32902,6 +32902,22 @@ clock, even if the pipeline is not in the PLAYING state.</doc>
</instance-parameter>
</parameters>
</method>
<method name="is_live" c:identifier="gst_pipeline_is_live" version="1.24">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstpipeline.c">Check if @pipeline is live.</doc>
<source-position filename="../subprojects/gstreamer/gst/gstpipeline.h"/>
<return-value transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstpipeline.c">%TRUE if @pipeline is live, %FALSE if not or if it did not reach the PAUSED state yet.
MT safe.</doc>
<type name="gboolean" c:type="gboolean"/>
</return-value>
<parameters>
<instance-parameter name="pipeline" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstpipeline.c">a #GstPipeline</doc>
<type name="Pipeline" c:type="GstPipeline*"/>
</instance-parameter>
</parameters>
</method>
<method name="set_auto_flush_bus" c:identifier="gst_pipeline_set_auto_flush_bus">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstpipeline.c">Usually, when a pipeline goes from READY to NULL state, it automatically
flushes all pending messages on the bus, which is done for refcounting

View file

@ -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;
}

View file

@ -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