mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
amrparse: Implement ::get_sink_caps vfunc to propagate downstream caps constraints upstream
This commit is contained in:
parent
5203b0884a
commit
c5b770df09
1 changed files with 38 additions and 0 deletions
|
@ -76,6 +76,7 @@ static gboolean gst_amr_parse_stop (GstBaseParse * parse);
|
|||
|
||||
static gboolean gst_amr_parse_sink_setcaps (GstBaseParse * parse,
|
||||
GstCaps * caps);
|
||||
static GstCaps *gst_amr_parse_sink_getcaps (GstBaseParse * parse);
|
||||
|
||||
static gboolean gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
||||
GstBaseParseFrame * frame, guint * framesize, gint * skipsize);
|
||||
|
@ -125,6 +126,7 @@ gst_amr_parse_class_init (GstAmrParseClass * klass)
|
|||
parse_class->start = GST_DEBUG_FUNCPTR (gst_amr_parse_start);
|
||||
parse_class->stop = GST_DEBUG_FUNCPTR (gst_amr_parse_stop);
|
||||
parse_class->set_sink_caps = GST_DEBUG_FUNCPTR (gst_amr_parse_sink_setcaps);
|
||||
parse_class->get_sink_caps = GST_DEBUG_FUNCPTR (gst_amr_parse_sink_getcaps);
|
||||
parse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_amr_parse_parse_frame);
|
||||
parse_class->check_valid_frame =
|
||||
GST_DEBUG_FUNCPTR (gst_amr_parse_check_valid_frame);
|
||||
|
@ -392,3 +394,39 @@ gst_amr_parse_stop (GstBaseParse * parse)
|
|||
amrparse->header = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gst_amr_parse_sink_getcaps (GstBaseParse * parse)
|
||||
{
|
||||
GstCaps *peercaps;
|
||||
GstCaps *res;
|
||||
|
||||
peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));
|
||||
if (peercaps) {
|
||||
guint i, n;
|
||||
|
||||
/* Rename structure names */
|
||||
peercaps = gst_caps_make_writable (peercaps);
|
||||
n = gst_caps_get_size (peercaps);
|
||||
for (i = 0; i < n; i++) {
|
||||
GstStructure *s = gst_caps_get_structure (peercaps, i);
|
||||
|
||||
if (gst_structure_has_name (s, "audio/AMR"))
|
||||
gst_structure_set_name (s, "audio/x-amr-nb-sh");
|
||||
else
|
||||
gst_structure_set_name (s, "audio/x-amr-wb-sh");
|
||||
}
|
||||
|
||||
res =
|
||||
gst_caps_intersect_full (peercaps,
|
||||
gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)),
|
||||
GST_CAPS_INTERSECT_FIRST);
|
||||
gst_caps_unref (peercaps);
|
||||
} else {
|
||||
res =
|
||||
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD
|
||||
(parse)));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue