From 5f55ba792a3d07b3bc104484296294ed0b377f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 14 Dec 2007 16:52:38 +0000 Subject: [PATCH] API: Add gst_base_transform_set_gap_aware() to control whether the element correctly handles GST_BUFFER_FLAG_GAP or s... Original commit message from CVS: * docs/libs/gstreamer-libs-sections.txt: * libs/gst/base/gstbasetransform.c: (gst_base_transform_init), (gst_base_transform_prepare_output_buffer), (gst_base_transform_set_gap_aware): * libs/gst/base/gstbasetransform.h: API: Add gst_base_transform_set_gap_aware() to control whether the element correctly handles GST_BUFFER_FLAG_GAP or shouldn't get buffers with this flag at all. Fixes #503231. --- ChangeLog | 11 +++++++++ docs/libs/gstreamer-libs-sections.txt | 1 + libs/gst/base/gstbasetransform.c | 35 +++++++++++++++++++++++++++ libs/gst/base/gstbasetransform.h | 3 +++ 4 files changed, 50 insertions(+) diff --git a/ChangeLog b/ChangeLog index f0f3a8152a..9dedd4acd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-12-14 Sebastian Dröge + + * docs/libs/gstreamer-libs-sections.txt: + * libs/gst/base/gstbasetransform.c: (gst_base_transform_init), + (gst_base_transform_prepare_output_buffer), + (gst_base_transform_set_gap_aware): + * libs/gst/base/gstbasetransform.h: + API: Add gst_base_transform_set_gap_aware() to control whether + the element correctly handles GST_BUFFER_FLAG_GAP or shouldn't + get buffers with this flag at all. Fixes #503231. + 2007-12-13 Stefan Kost * libs/gst/base/gstbasesink.c: diff --git a/docs/libs/gstreamer-libs-sections.txt b/docs/libs/gstreamer-libs-sections.txt index a0f6a93bc6..fd87fc1e7b 100644 --- a/docs/libs/gstreamer-libs-sections.txt +++ b/docs/libs/gstreamer-libs-sections.txt @@ -303,6 +303,7 @@ gst_base_transform_set_in_place gst_base_transform_is_qos_enabled gst_base_transform_set_qos_enabled gst_base_transform_update_qos +gst_base_transform_set_gap_aware 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 3205e523bc..40b52d29b9 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -234,6 +234,8 @@ struct _GstBaseTransformPrivate gboolean discont; GstActivateMode pad_mode; + + gboolean gap_aware; }; static GstElementClass *parent_class = NULL; @@ -400,6 +402,7 @@ gst_base_transform_init (GstBaseTransform * trans, trans->cache_caps1 = NULL; trans->cache_caps2 = NULL; trans->priv->pad_mode = GST_ACTIVATE_NONE; + trans->priv->gap_aware = FALSE; trans->passthrough = FALSE; if (bclass->transform == NULL) { @@ -974,6 +977,12 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans, gst_buffer_copy_metadata (*out_buf, in_buf, GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS); + + /* Unset the GAP flag if the element is _not_ GAP aware. Otherwise + * it might create an output buffer that does not contain neutral data + * but still has the GAP flag on it! */ + if (!trans->priv->gap_aware) + GST_BUFFER_FLAG_UNSET (*out_buf, GST_BUFFER_FLAG_GAP); } done: @@ -1945,3 +1954,29 @@ gst_base_transform_is_qos_enabled (GstBaseTransform * trans) return result; } + +/** + * gst_base_transform_set_gap_aware: + * @trans: a #GstBaseTransform + * @gap_aware: New state + * + * If @gap_aware is %FALSE (as it is by default) subclasses will never get + * output buffers with the %GST_BUFFER_FLAG_GAP flag set. + * + * If set to %TRUE elements must handle output buffers with this flag set + * correctly, i.e. they can assume that the buffer contains neutral data + * but must unset the flag if the output is no neutral data. + * Since: 0.10.16 + * + * MT safe. + */ +void +gst_base_transform_set_gap_aware (GstBaseTransform * trans, gboolean gap_aware) +{ + g_return_if_fail (trans != NULL); + + GST_OBJECT_LOCK (trans); + trans->priv->gap_aware = gap_aware; + GST_DEBUG_OBJECT (trans, "set gap aware %d", trans->priv->gap_aware); + GST_OBJECT_UNLOCK (trans); +} diff --git a/libs/gst/base/gstbasetransform.h b/libs/gst/base/gstbasetransform.h index 7ff49e4818..d5a41e1f61 100644 --- a/libs/gst/base/gstbasetransform.h +++ b/libs/gst/base/gstbasetransform.h @@ -253,6 +253,9 @@ void gst_base_transform_set_qos_enabled (GstBaseTransform *trans, gboolean enabled); gboolean gst_base_transform_is_qos_enabled (GstBaseTransform *trans); +void gst_base_transform_set_gap_aware (GstBaseTransform *trans, + gboolean gap_aware); + G_END_DECLS #endif /* __GST_BASE_TRANSFORM_H__ */