From b8e3ebcbc87d63673cd063a04af44b50ad244f89 Mon Sep 17 00:00:00 2001 From: Michael Fien Date: Thu, 19 Oct 2017 15:36:30 -0400 Subject: [PATCH] Add typefind support for meta/x-klv --- gst-libs/gst/pbutils/descriptions.c | 13 +++++++++++-- gst/typefind/gsttypefindfunctions.c | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/pbutils/descriptions.c b/gst-libs/gst/pbutils/descriptions.c index 66b8316..a5e6728 100644 --- a/gst-libs/gst/pbutils/descriptions.c +++ b/gst-libs/gst/pbutils/descriptions.c @@ -1,6 +1,9 @@ /* GStreamer Plugins Base utils library source/sink/codec description support * Copyright (C) 2006 Tim-Philipp Müller * + * Authors + * Michael Fien + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either @@ -56,7 +59,8 @@ typedef enum FLAG_IMAGE = (1 << 4), /* format is an image format, or image container/tag */ FLAG_SUB = (1 << 5), /* format is a subtitle format, or subtitle container */ FLAG_TAG = (1 << 6), /* format is a tag/container */ - FLAG_GENERIC = (1 << 7) /* format is a generic container (e.g. multipart) */ + FLAG_GENERIC = (1 << 7), /* format is a generic container (e.g. multipart) */ + FLAG_METADATA = (1 << 8) /* format is a KLV metadata container */ } FormatFlags; typedef struct @@ -326,7 +330,9 @@ static const FormatInfo formats[] = { {"video/x-svq", NULL, FLAG_VIDEO, ""}, {"video/x-wmv", NULL, FLAG_VIDEO, ""}, {"video/x-xan", NULL, FLAG_VIDEO, ""}, - {"video/x-tscc", NULL, FLAG_VIDEO, ""} + {"video/x-tscc", NULL, FLAG_VIDEO, ""}, + + {"meta/x-klv", "KLV", FLAG_METADATA, "klva"} }; static const gchar * @@ -847,6 +853,9 @@ format_info_get_desc (const FormatInfo * info, const GstCaps * caps) GST_WARNING ("Unexpected version in %" GST_PTR_FORMAT, caps); return g_strdup ("TechSmith Screen Capture"); } + else if (strcmp (info->type, "meta/x-klv") == 0) { + return g_strdup (info->desc); + } return NULL; } diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 4caa2fe..2960877 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -5646,6 +5646,28 @@ aa_type_find (GstTypeFind * tf, gpointer private) } } +/*** meta/x-klv ***/ +/* SMPTE 336M-2007 - 4 byte prefix for universal label key + * MISB ST1402.2 - MPEG-2 Transport Stream for Class 1/Class 2 Motion Imagery, Audio and Metadata + */ +static GstStaticCaps klv_caps = GST_STATIC_CAPS ("meta/x-klv"); +#define KLV_CAPS gst_static_caps_get(&klv_caps) + +static void +klv_type_find (GstTypeFind * tf, gpointer ununsed) +{ + const guint8 *data = gst_type_find_peek (tf, 0, 9); + guint8 header[4] = { 0x06, 0x0E, 0x2B, 0x34 }; + + if (data) { + if (memcmp (data, header, 4) == 0) { + gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, KLV_CAPS); + } else if (memcmp (data+5, header, 4) == 0) { //Check for MPEG2-TS synchronous metadata per MISB ST1402.2 section 9.4.1 + gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, KLV_CAPS); + } + } +} + /*** generic typefind for streams that have some data at a specific position***/ typedef struct { @@ -6054,6 +6076,9 @@ plugin_init (GstPlugin * plugin) TYPE_FIND_REGISTER (plugin, "audio/audible", GST_RANK_MARGINAL, aa_type_find, "aa,aax", AA_CAPS, NULL, NULL); + + TYPE_FIND_REGISTER (plugin, "meta/x-klv", GST_RANK_PRIMARY, + klv_type_find, NULL, KLV_CAPS, NULL, NULL); return TRUE; } -- 1.9.1