mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
basesrc: implement a default get_caps function
Don't rely on the return value of a vmethod to trigger the default implementation but make a real defaul implementation of the method that the subclass can chain up to.
This commit is contained in:
parent
86a45f236e
commit
54a9c5d3f8
1 changed files with 30 additions and 18 deletions
|
@ -278,6 +278,8 @@ gst_base_src_get_type (void)
|
||||||
return base_src_type;
|
return base_src_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstCaps *gst_base_src_default_get_caps (GstBaseSrc * bsrc,
|
||||||
|
GstCaps * filter);
|
||||||
static GstCaps *gst_base_src_getcaps (GstPad * pad, GstCaps * filter);
|
static GstCaps *gst_base_src_getcaps (GstPad * pad, GstCaps * filter);
|
||||||
static void gst_base_src_default_fixate (GstBaseSrc * src, GstCaps * caps);
|
static void gst_base_src_default_fixate (GstBaseSrc * src, GstCaps * caps);
|
||||||
static void gst_base_src_fixate (GstBaseSrc * src, GstCaps * caps);
|
static void gst_base_src_fixate (GstBaseSrc * src, GstCaps * caps);
|
||||||
|
@ -367,6 +369,7 @@ gst_base_src_class_init (GstBaseSrcClass * klass)
|
||||||
GST_DEBUG_FUNCPTR (gst_base_src_change_state);
|
GST_DEBUG_FUNCPTR (gst_base_src_change_state);
|
||||||
gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_base_src_send_event);
|
gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_base_src_send_event);
|
||||||
|
|
||||||
|
klass->get_caps = GST_DEBUG_FUNCPTR (gst_base_src_default_get_caps);
|
||||||
klass->negotiate = GST_DEBUG_FUNCPTR (gst_base_src_default_negotiate);
|
klass->negotiate = GST_DEBUG_FUNCPTR (gst_base_src_default_negotiate);
|
||||||
klass->fixate = GST_DEBUG_FUNCPTR (gst_base_src_default_fixate);
|
klass->fixate = GST_DEBUG_FUNCPTR (gst_base_src_default_fixate);
|
||||||
klass->prepare_seek_segment =
|
klass->prepare_seek_segment =
|
||||||
|
@ -806,6 +809,33 @@ gst_base_src_set_caps (GstBaseSrc * src, GstCaps * caps)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
gst_base_src_default_get_caps (GstBaseSrc * bsrc, GstCaps * filter)
|
||||||
|
{
|
||||||
|
GstCaps *caps = NULL;
|
||||||
|
GstPadTemplate *pad_template;
|
||||||
|
GstBaseSrcClass *bclass;
|
||||||
|
|
||||||
|
bclass = GST_BASE_SRC_GET_CLASS (bsrc);
|
||||||
|
|
||||||
|
pad_template =
|
||||||
|
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (bclass), "src");
|
||||||
|
|
||||||
|
if (pad_template != NULL) {
|
||||||
|
caps = gst_pad_template_get_caps (pad_template);
|
||||||
|
|
||||||
|
if (filter) {
|
||||||
|
GstCaps *intersection;
|
||||||
|
|
||||||
|
intersection =
|
||||||
|
gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
caps = intersection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return caps;
|
||||||
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_base_src_getcaps (GstPad * pad, GstCaps * filter)
|
gst_base_src_getcaps (GstPad * pad, GstCaps * filter)
|
||||||
{
|
{
|
||||||
|
@ -818,24 +848,6 @@ gst_base_src_getcaps (GstPad * pad, GstCaps * filter)
|
||||||
if (bclass->get_caps)
|
if (bclass->get_caps)
|
||||||
caps = bclass->get_caps (bsrc, filter);
|
caps = bclass->get_caps (bsrc, filter);
|
||||||
|
|
||||||
if (caps == NULL) {
|
|
||||||
GstPadTemplate *pad_template;
|
|
||||||
|
|
||||||
pad_template =
|
|
||||||
gst_element_class_get_pad_template (GST_ELEMENT_CLASS (bclass), "src");
|
|
||||||
if (pad_template != NULL) {
|
|
||||||
caps = gst_pad_template_get_caps (pad_template);
|
|
||||||
|
|
||||||
if (filter) {
|
|
||||||
GstCaps *intersection;
|
|
||||||
|
|
||||||
intersection =
|
|
||||||
gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
caps = intersection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue