From 506afa54dfcb1dc3378e4394b306bbf01ee9ef83 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 20 Feb 2015 17:50:48 +0100 Subject: [PATCH] basetransform: Add a method to let subclasses cleanly update srcpad caps API: gst_base_transform_update_src https://bugzilla.gnome.org/show_bug.cgi?id=734424 --- docs/libs/gstreamer-libs-sections.txt | 1 + libs/gst/base/gstbasetransform.c | 30 +++++++++++++++++++++++++++ libs/gst/base/gstbasetransform.h | 2 ++ 3 files changed, 33 insertions(+) diff --git a/docs/libs/gstreamer-libs-sections.txt b/docs/libs/gstreamer-libs-sections.txt index 86355fb8f7..f1db3a0975 100644 --- a/docs/libs/gstreamer-libs-sections.txt +++ b/docs/libs/gstreamer-libs-sections.txt @@ -361,6 +361,7 @@ gst_base_transform_get_allocator gst_base_transform_get_buffer_pool gst_base_transform_reconfigure_sink gst_base_transform_reconfigure_src +gst_base_transform_update_src GST_BASE_TRANSFORM_SINK_NAME GST_BASE_TRANSFORM_SRC_NAME diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 073d08c774..13badd92cd 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -2786,3 +2786,33 @@ gst_base_transform_get_allocator (GstBaseTransform * trans, if (params) *params = trans->priv->params; } + +/** + * gst_base_transform_update_src_caps: + * @trans: a #GstBaseTransform + * @updated_caps: An updated version of the srcpad caps to be pushed + * downstream + * + * Updates the srcpad caps and send the caps downstream. This function + * can be used by subclasses when they have already negotiated their caps + * but found a change in them (or computed new informations). This way, + * they can notify downstream about that change without loosing any + * buffer. + * + * Returns: %TRUE if the caps could be send downstream %FALSE otherwise + */ +gboolean +gst_base_transform_update_src_caps (GstBaseTransform * trans, + GstCaps * updated_caps) +{ + g_return_val_if_fail (GST_IS_BASE_TRANSFORM (trans), FALSE); + + if (gst_pad_push_event (GST_BASE_TRANSFORM_SRC_PAD (trans), + gst_event_new_caps (updated_caps))) { + gst_pad_mark_reconfigure (trans->srcpad); + + return TRUE; + } + + return FALSE; +} diff --git a/libs/gst/base/gstbasetransform.h b/libs/gst/base/gstbasetransform.h index 3043a6294c..0eec6e992d 100644 --- a/libs/gst/base/gstbasetransform.h +++ b/libs/gst/base/gstbasetransform.h @@ -293,6 +293,8 @@ void gst_base_transform_get_allocator (GstBaseTransform *trans, void gst_base_transform_reconfigure_sink (GstBaseTransform *trans); void gst_base_transform_reconfigure_src (GstBaseTransform *trans); +gboolean gst_base_transform_update_src_caps (GstBaseTransform *trans, + GstCaps *updated_caps); G_END_DECLS #endif /* __GST_BASE_TRANSFORM_H__ */ -- 2.34.1