From ae03de8ff811090d20e92073aa3611e2f47cb561 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Tue, 1 Jun 2010 23:43:45 +0530 Subject: [PATCH] typefindfunctions: export 3gp profile in caps This reads the 3gp profile from the major/compatible brands and puts this as a 'profile' field in caps. This can be used by demuxers to decide whether they can handle this stream or not. Also needed for DLNA. https://bugzilla.gnome.org/show_bug.cgi?id=620291 --- gst/typefind/gsttypefindfunctions.c | 46 ++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 0256117..bc88fab 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -34,11 +34,7 @@ #define USE_GIO #endif -#include -#include -#include -#include -#include +#include #include #include @@ -2359,15 +2355,31 @@ m4a_type_find (GstTypeFind * tf, gpointer unused) /*** application/x-3gp ***/ /* The Q is there because variables can't start with a number. */ - - static GstStaticCaps q3gp_caps = GST_STATIC_CAPS ("application/x-3gp"); - #define Q3GP_CAPS (gst_static_caps_get(&q3gp_caps)) + +static const gchar * +q3gp_type_find_get_profile (const guint8 * data) +{ + switch (GST_MAKE_FOURCC (data[0], data[1], data[2], 0)) { + case GST_MAKE_FOURCC ('3', 'g', 'g', 0): + return "general"; + case GST_MAKE_FOURCC ('3', 'g', 'p', 0): + return "basic"; + case GST_MAKE_FOURCC ('3', 'g', 's', 0): + return "streaming-server"; + case GST_MAKE_FOURCC ('3', 'g', 'r', 0): + return "progressive-download"; + default: + break; + } + return NULL; +} + static void q3gp_type_find (GstTypeFind * tf, gpointer unused) { - + const gchar *profile; guint32 ftyp_size = 0; gint offset = 0; guint8 *data = NULL; @@ -2383,10 +2395,9 @@ q3gp_type_find (GstTypeFind * tf, gpointer unused) /* check major brand */ data += 4; - if (memcmp (data, "3gp", 3) == 0 || - memcmp (data, "3gr", 3) == 0 || - memcmp (data, "3gs", 3) == 0 || memcmp (data, "3gg", 3) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, Q3GP_CAPS); + if ((profile = q3gp_type_find_get_profile (data))) { + gst_type_find_suggest_simple (tf, GST_TYPE_FIND_MAXIMUM, + "application/x-3gp", "profile", G_TYPE_STRING, profile, NULL); return; } @@ -2398,11 +2409,10 @@ q3gp_type_find (GstTypeFind * tf, gpointer unused) if ((data = gst_type_find_peek (tf, offset, 3)) == NULL) { break; } - if (memcmp (data, "3gp", 3) == 0 || - memcmp (data, "3gr", 3) == 0 || - memcmp (data, "3gs", 3) == 0 || memcmp (data, "3gg", 3) == 0) { - gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, Q3GP_CAPS); - break; + if ((profile = q3gp_type_find_get_profile (data))) { + gst_type_find_suggest_simple (tf, GST_TYPE_FIND_MAXIMUM, + "application/x-3gp", "profile", G_TYPE_STRING, profile, NULL); + return; } } -- 2.7.4