mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-04 17:52:29 +00:00
capsfilter: implement custom accept_caps method
Implement a custom acceptcaps function. We can simply check if there is an intersection with the new caps. This makes the accept caps function much faster. See #621190
This commit is contained in:
parent
76f7a001fc
commit
d612442fde
1 changed files with 31 additions and 0 deletions
|
@ -70,6 +70,8 @@ static void gst_capsfilter_dispose (GObject * object);
|
|||
|
||||
static GstCaps *gst_capsfilter_transform_caps (GstBaseTransform * base,
|
||||
GstPadDirection direction, GstCaps * caps);
|
||||
static gboolean gst_capsfilter_accept_caps (GstBaseTransform * base,
|
||||
GstPadDirection direction, GstCaps * caps);
|
||||
static GstFlowReturn gst_capsfilter_transform_ip (GstBaseTransform * base,
|
||||
GstBuffer * buf);
|
||||
static GstFlowReturn gst_capsfilter_prepare_buf (GstBaseTransform * trans,
|
||||
|
@ -113,6 +115,7 @@ gst_capsfilter_class_init (GstCapsFilterClass * klass)
|
|||
trans_class->transform_caps =
|
||||
GST_DEBUG_FUNCPTR (gst_capsfilter_transform_caps);
|
||||
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_capsfilter_transform_ip);
|
||||
trans_class->accept_caps = GST_DEBUG_FUNCPTR (gst_capsfilter_accept_caps);
|
||||
trans_class->prepare_output_buffer =
|
||||
GST_DEBUG_FUNCPTR (gst_capsfilter_prepare_buf);
|
||||
}
|
||||
|
@ -263,6 +266,34 @@ gst_capsfilter_transform_caps (GstBaseTransform * base,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_capsfilter_accept_caps (GstBaseTransform * base,
|
||||
GstPadDirection direction, GstCaps * caps)
|
||||
{
|
||||
GstCapsFilter *capsfilter = GST_CAPSFILTER (base);
|
||||
GstCaps *filter_caps;
|
||||
gboolean ret;
|
||||
|
||||
GST_OBJECT_LOCK (capsfilter);
|
||||
filter_caps = gst_caps_ref (capsfilter->filter_caps);
|
||||
GST_OBJECT_UNLOCK (capsfilter);
|
||||
|
||||
ret = gst_caps_can_intersect (caps, filter_caps);
|
||||
GST_DEBUG_OBJECT (capsfilter, "can intersect: %" GST_PTR_FORMAT, ret);
|
||||
if (ret) {
|
||||
/* if we can intersect, see if the other end also accepts */
|
||||
if (direction == GST_PAD_SRC)
|
||||
ret = gst_pad_peer_accept_caps (GST_BASE_TRANSFORM_SINK_PAD (base), caps);
|
||||
else
|
||||
ret = gst_pad_peer_accept_caps (GST_BASE_TRANSFORM_SRC_PAD (base), caps);
|
||||
GST_DEBUG_OBJECT (capsfilter, "peer accept: %" GST_PTR_FORMAT, ret);
|
||||
}
|
||||
|
||||
gst_caps_unref (filter_caps);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_capsfilter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue