diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2014-07-16 17:18:59 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2014-07-16 17:27:57 +0200 |
commit | 638a700463a96b53dc92e9db4522ca861e5c72a1 (patch) | |
tree | 048d153b6faf01fe9a9a20b749bd30a83d7d793f | |
parent | f45657f604a84a85186109b0c40fee4f807dbaab (diff) |
aacparse: Properly report in the CAPS query that we can convert ADTS<->RAW
https://bugzilla.gnome.org/show_bug.cgi?id=733190
-rw-r--r-- | gst/audioparsers/gstaacparse.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/gst/audioparsers/gstaacparse.c b/gst/audioparsers/gstaacparse.c index f693097e3..2a37c378f 100644 --- a/gst/audioparsers/gstaacparse.c +++ b/gst/audioparsers/gstaacparse.c @@ -1413,6 +1413,79 @@ remove_fields (GstCaps * caps) } } +static void +add_conversion_fields (GstCaps * caps) +{ + guint i, n; + + n = gst_caps_get_size (caps); + for (i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure (caps, i); + + if (gst_structure_has_field (s, "stream-format")) { + const GValue *v = gst_structure_get_value (s, "stream-format"); + + if (G_VALUE_HOLDS_STRING (v)) { + const gchar *str = g_value_get_string (v); + + if (strcmp (str, "adts") == 0 || strcmp (str, "raw") == 0) { + GValue va = G_VALUE_INIT; + GValue vs = G_VALUE_INIT; + + g_value_init (&va, GST_TYPE_LIST); + g_value_init (&vs, G_TYPE_STRING); + g_value_set_string (&vs, "adts"); + gst_value_list_append_value (&va, &vs); + g_value_set_string (&vs, "raw"); + gst_value_list_append_value (&va, &vs); + gst_structure_set_value (s, "stream-format", &va); + g_value_unset (&va); + g_value_unset (&vs); + } + } else if (GST_VALUE_HOLDS_LIST (v)) { + gboolean contains_raw = FALSE; + gboolean contains_adts = FALSE; + guint m = gst_value_list_get_size (v), j; + + for (j = 0; j < m; j++) { + const GValue *ve = gst_value_list_get_value (v, j); + const gchar *str; + + if (G_VALUE_HOLDS_STRING (ve) && (str = g_value_get_string (ve))) { + if (strcmp (str, "adts") == 0) + contains_adts = TRUE; + else if (strcmp (str, "raw") == 0) + contains_raw = TRUE; + } + } + + if (contains_adts || contains_raw) { + GValue va = G_VALUE_INIT; + GValue vs = G_VALUE_INIT; + + g_value_init (&va, GST_TYPE_LIST); + g_value_init (&vs, G_TYPE_STRING); + g_value_copy (v, &va); + + if (!contains_raw) { + g_value_set_string (&vs, "raw"); + gst_value_list_append_value (&va, &vs); + } + if (!contains_adts) { + g_value_set_string (&vs, "adts"); + gst_value_list_append_value (&va, &vs); + } + + gst_structure_set_value (s, "stream-format", &va); + + g_value_unset (&vs); + g_value_unset (&va); + } + } + } + } +} + static GstCaps * gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter) { @@ -1425,6 +1498,7 @@ gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter) GstCaps *fcopy = gst_caps_copy (filter); /* Remove the fields we convert */ remove_fields (fcopy); + add_conversion_fields (fcopy); peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), fcopy); gst_caps_unref (fcopy); } else @@ -1434,6 +1508,7 @@ gst_aac_parse_sink_getcaps (GstBaseParse * parse, GstCaps * filter) peercaps = gst_caps_make_writable (peercaps); /* Remove the fields we convert */ remove_fields (peercaps); + add_conversion_fields (peercaps); res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); |