From 493d47dca33d437194755d1c3f7e61d13e8e06bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 27 Dec 2018 11:41:54 +0200 Subject: [PATCH] typefindfunctions: Extend MCC typefinder to also cover version 2.0 Both versions are basically the same, but version 2.0 also allows 60000/1001 as framerate and allows to specify the field and line number for each payload. Put the major version into the caps so that elements can limit via caps negotiation which versions they can support. --- gst/typefind/gsttypefindfunctions.c | 31 +++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 7f1f3c0767..c91b632571 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -5645,6 +5645,32 @@ ssa_type_find (GstTypeFind * tf, gpointer private) g_free (str); } +/*** application/x-mcc ***/ +static GstStaticCaps mcc_caps = GST_STATIC_CAPS ("application/x-mcc"); + +#define MCC_CAPS gst_static_caps_get(&mcc_caps) + +static void +mcc_type_find (GstTypeFind * tf, gpointer private) +{ + const guint8 *data; + + data = gst_type_find_peek (tf, 0, 31); + + if (data == NULL) + return; + + /* MCC files always start with this followed by the version */ + if (memcmp (data, "File Format=MacCaption_MCC V", 28) != 0 || + !g_ascii_isdigit (data[28]) || data[29] != '.' || + !g_ascii_isdigit (data[30])) { + return; + } + + gst_type_find_suggest_simple (tf, GST_TYPE_FIND_MAXIMUM, + "application/x-mcc", "version", G_TYPE_INT, data[28] - '0', NULL); +} + /*** video/x-pva ***/ static GstStaticCaps pva_caps = GST_STATIC_CAPS ("video/x-pva"); @@ -5811,8 +5837,9 @@ plugin_init (GstPlugin * plugin) "imy,ime,imelody", "BEGIN:IMELODY", 13, GST_TYPE_FIND_MAXIMUM); TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-scc", GST_RANK_PRIMARY, "scc", "Scenarist_SCC V1.0", 18, GST_TYPE_FIND_MAXIMUM); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-mcc", GST_RANK_PRIMARY, - "mcc", "File Format=MacCaption_MCC V1.0", 31, GST_TYPE_FIND_MAXIMUM); + TYPE_FIND_REGISTER (plugin, "application/x-mcc", GST_RANK_PRIMARY, + mcc_type_find, "mcc", MCC_CAPS, NULL, NULL); + #if 0 TYPE_FIND_REGISTER_START_WITH (plugin, "video/x-smoke", GST_RANK_PRIMARY, NULL, "\x80smoke\x00\x01\x00", 6, GST_TYPE_FIND_MAXIMUM);