summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2016-12-01 11:23:02 +0100
committerEdward Hervey <bilboed@bilboed.com>2016-12-02 08:52:06 +0100
commit50bb6630f52cee37c46f500e4a87d8802c73f30c (patch)
tree2812e21e13dcb2b995667fb36af327b7be723ac9
parent9a4b1e9cdc73f8ebb1e48ddc10a1918162232fc8 (diff)
qtdemux: Sanitize unknown codec caps
We might have non-printable characters in the unknown fourcc, replace them with '_', in the same way we do it for unknown tags.
-rw-r--r--gst/isomp4/qtdemux.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c
index 4b369af73..71a303c61 100644
--- a/gst/isomp4/qtdemux.c
+++ b/gst/isomp4/qtdemux.c
@@ -13215,6 +13215,24 @@ gst_qtdemux_handle_esds (GstQTDemux * qtdemux, QtDemuxStream * stream,
}
+static inline GstCaps *
+_get_unknown_codec_name (const gchar * type, guint32 fourcc)
+{
+ GstCaps *caps;
+ guint i;
+ char *s, fourstr[5];
+
+ g_snprintf (fourstr, 5, "%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
+ for (i = 0; i < 4; i++) {
+ if (!g_ascii_isalnum (fourstr[i]))
+ fourstr[i] = '_';
+ }
+ s = g_strdup_printf ("%s/x-gst-fourcc-%s", type, g_strstrip (fourstr));
+ caps = gst_caps_new_empty_simple (s);
+ g_free (s);
+ return caps;
+}
+
#define _codec(name) \
do { \
if (codec_name) { \
@@ -13617,12 +13635,7 @@ qtdemux_video_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
case GST_MAKE_FOURCC ('k', 'p', 'c', 'd'):
default:
{
- char *s, fourstr[5];
-
- g_snprintf (fourstr, 5, "%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
- s = g_strdup_printf ("video/x-gst-fourcc-%s", g_strstrip (fourstr));
- caps = gst_caps_new_empty_simple (s);
- g_free (s);
+ caps = _get_unknown_codec_name ("video", fourcc);
break;
}
}
@@ -13938,12 +13951,7 @@ qtdemux_audio_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
/* ? */
default:
{
- char *s, fourstr[5];
-
- g_snprintf (fourstr, 5, "%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
- s = g_strdup_printf ("audio/x-gst-fourcc-%s", g_strstrip (fourstr));
- caps = gst_caps_new_empty_simple (s);
- g_free (s);
+ caps = _get_unknown_codec_name ("audio", fourcc);
break;
}
}
@@ -13999,12 +14007,7 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
break;
default:
{
- char *s, fourstr[5];
-
- g_snprintf (fourstr, 5, "%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
- s = g_strdup_printf ("text/x-gst-fourcc-%s", g_strstrip (fourstr));
- caps = gst_caps_new_empty_simple (s);
- g_free (s);
+ caps = _get_unknown_codec_name ("text", fourcc);
break;
}
}