commit a2097654fdd4d0c439ad9922e73361e5067680ed
Author: John Poet <jpoet@mythtv.org>
Date:   Thu Oct 13 14:12:30 2016 -0600

    Add libvanc.
    Extract ancillary data from decklink input, and add vanc meta data to buffer.

diff --git a/configure.ac b/configure.ac
index 7cdb1e2..0536f76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3721,6 +3721,7 @@ gst-libs/gst/wayland/Makefile
 gst-libs/gst/base/Makefile
 gst-libs/gst/player/Makefile
 gst-libs/gst/video/Makefile
+gst-libs/gst/vanc/Makefile
 gst-libs/gst/audio/Makefile
 sys/Makefile
 sys/dshowdecwrapper/Makefile
diff --git a/gst-libs/gst/Makefile.am b/gst-libs/gst/Makefile.am
index 7d0b309..25ceccc 100644
--- a/gst-libs/gst/Makefile.am
+++ b/gst-libs/gst/Makefile.am
@@ -11,11 +11,11 @@ WAYLAND_DIR=wayland
 endif
 
 SUBDIRS = uridownloader adaptivedemux interfaces basecamerabinsrc codecparsers \
-	 insertbin mpegts base video audio player $(GL_DIR) $(WAYLAND_DIR)
+	 insertbin mpegts base video audio player vanc $(GL_DIR) $(WAYLAND_DIR)
 
 noinst_HEADERS = gst-i18n-plugin.h gettext.h glib-compat-private.h
 DIST_SUBDIRS = uridownloader adaptivedemux interfaces gl basecamerabinsrc \
-	codecparsers insertbin mpegts wayland base video audio player
+	codecparsers insertbin mpegts wayland base video audio player vanc
 
 #dependencies
 video, audio: base
diff --git a/gst-libs/gst/vanc/Makefile.am b/gst-libs/gst/vanc/Makefile.am
new file mode 100644
index 0000000..309e064
--- /dev/null
+++ b/gst-libs/gst/vanc/Makefile.am
@@ -0,0 +1,29 @@
+lib_LTLIBRARIES = libgstvanc-@GST_API_VERSION@.la
+
+CLEANFILES = $(BUILT_SOURCES)
+
+libgstvanc_@GST_API_VERSION@include_HEADERS = \
+	gstvancmeta.h
+libgstvanc_@GST_API_VERSION@_la_SOURCES = \
+	gstvancmeta.c
+
+libgstvanc_@GST_API_VERSION@includedir = \
+	$(includedir)/gstreamer-@GST_API_VERSION@/gst/vanc
+
+libgstvanc_@GST_API_VERSION@_la_CFLAGS = \
+	$(GST_PLUGINS_BAD_CFLAGS) \
+	$(GST_PLUGINS_BASE_CFLAGS) \
+	-DGST_USE_UNSTABLE_API \
+	$(GST_CFLAGS)
+
+libgstvanc_@GST_API_VERSION@_la_CPPFLAGS = \
+	$(GST_PLUGINS_BAD_CFLAGS) \
+	$(GST_PLUGINS_BASE_CFLAGS) \
+	-DGST_USE_UNSTABLE_API \
+	$(GST_CXXFLAGS)
+
+libgstvanc_@GST_API_VERSION@_la_LIBADD = \
+	$(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS)
+
+libgstvanc_@GST_API_VERSION@_la_LDFLAGS = \
+	$(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
diff --git a/gst-libs/gst/vanc/gstvancmeta.c b/gst-libs/gst/vanc/gstvancmeta.c
new file mode 100644
index 0000000..4ac7606
--- /dev/null
+++ b/gst-libs/gst/vanc/gstvancmeta.c
@@ -0,0 +1,122 @@
+#include "gstvancmeta.h"
+
+GType
+gst_vanc_meta_api_get_type (void)
+{
+  static volatile GType type;
+  static const gchar *tags[] = { "VANC", NULL };
+
+  if (g_once_init_enter (&type)) {
+    GType _type = gst_meta_api_type_register ("GstVANCMetaAPI", tags);
+    g_once_init_leave (&type, _type);
+  }
+  return type;
+}
+
+static gboolean
+gst_vanc_meta_init (GstMeta * meta, gpointer params, GstBuffer * buffer)
+{
+  GstVANCMeta *vmeta = (GstVANCMeta *) meta;
+  vmeta->data_id = vmeta->dbn_sdid = 0;
+  vmeta->vanc_data = NULL;
+  return TRUE;
+}
+
+static gboolean
+gst_vanc_meta_transform (GstBuffer * dest, GstMeta * meta,
+    GstBuffer * buffer, GQuark type, gpointer data)
+{
+  GstVANCMeta *dmeta, *smeta;
+
+  smeta = (GstVANCMeta *) meta;
+
+  if (GST_META_TRANSFORM_IS_COPY (type)) {
+    GstMetaTransformCopy *copy = data;
+
+    if (!copy->region) {
+      /* only copy if the complete data is copied as well */
+      dmeta =
+          (GstVANCMeta *) gst_buffer_add_meta (dest, GST_VANC_META_INFO, NULL);
+
+      if (!dmeta)
+        return FALSE;
+
+      dmeta->buffer = dest;
+
+      GST_DEBUG ("copy VANC metadata");
+      dmeta->data_id = smeta->data_id;
+      dmeta->dbn_sdid = smeta->dbn_sdid;
+      g_array_ref (smeta->vanc_data);
+      dmeta->vanc_data = smeta->vanc_data;
+      dmeta->checksum = smeta->checksum;
+
+#if 1
+      GST_WARNING
+          ("gst_vanc_meta_transform    did %d sdid %d checksum %d first %d len %d",
+          dmeta->data_id, dmeta->dbn_sdid, dmeta->checksum,
+          ((guint16 *) dmeta->vanc_data->data)[0], dmeta->vanc_data->len);
+#endif
+
+    }
+  } else {
+    GST_WARNING ("gst_vanc_meta_transform type not supported");
+    /* return FALSE, if transform type is not supported */
+    return FALSE;
+  }
+  return TRUE;
+}
+
+static void
+gst_vanc_meta_free (GstMeta * meta, GstBuffer * buffer)
+{
+  GstVANCMeta *vmeta = (GstVANCMeta *) meta;
+
+  g_array_unref (vmeta->vanc_data);
+}
+
+
+const GstMetaInfo *
+gst_vanc_meta_get_info (void)
+{
+  static const GstMetaInfo *meta_info = NULL;
+
+  if (g_once_init_enter (&meta_info)) {
+    const GstMetaInfo *mi = gst_meta_register (GST_VANC_META_API_TYPE,
+        "VANCMeta",
+        sizeof (GstVANCMeta),
+        gst_vanc_meta_init,
+        gst_vanc_meta_free,
+        gst_vanc_meta_transform);
+    g_once_init_leave (&meta_info, mi);
+  }
+  return meta_info;
+}
+
+GstVANCMeta *
+gst_buffer_add_vanc_meta (GstBuffer * buffer,
+    gint did, gint dbn_sdid, guint16 * data, gsize size, guint16 checksum)
+{
+  GstVANCMeta *vmeta;
+
+  g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
+
+  vmeta =
+      (GstVANCMeta *) gst_buffer_add_meta (buffer, GST_VANC_META_INFO, NULL);
+
+  vmeta->data_id = did;
+  vmeta->dbn_sdid = dbn_sdid;
+  vmeta->checksum = checksum;
+
+  vmeta->vanc_data = g_array_sized_new (FALSE, FALSE, sizeof (guint16), size);
+
+  g_array_append_vals (vmeta->vanc_data, data, size);
+
+#if 1
+  GST_WARNING
+      ("gst_buffer_add_vanc_meta did %d sdid %d checksum %d first %d len %d",
+      vmeta->data_id, vmeta->dbn_sdid, vmeta->checksum,
+      ((guint16 *) vmeta->vanc_data->data)[0], vmeta->vanc_data->len);
+#endif
+
+  return vmeta;
+}
diff --git a/gst-libs/gst/vanc/gstvancmeta.h b/gst-libs/gst/vanc/gstvancmeta.h
new file mode 100644
index 0000000..1579721
--- /dev/null
+++ b/gst-libs/gst/vanc/gstvancmeta.h
@@ -0,0 +1,47 @@
+#ifndef _GST_VANC_META_H_
+#define _GST_VANC_META_H_
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GstVANCMeta GstVANCMeta;
+
+/**
+ * GstVANCMeta:
+ * @meta: parent #GstMeta
+ * @buffer: the buffer this metadata belongs to
+ * @data_id: VANC data ID
+ * @dbn_sdid: VANC dbn sdata ID
+ * @vanc_data: VANC data
+ * @checksum: VANC checksum
+ */
+struct _GstVANCMeta {
+  GstMeta          meta;
+  GstBuffer       *buffer;
+  gint             data_id;
+  gint             dbn_sdid;
+  GArray          *vanc_data;
+  guint16          checksum;
+};
+
+GType vanc_meta_api_get_type (void);
+
+/* implementation */
+const GstMetaInfo *gst_vanc_meta_get_info (void);
+#define GST_VANC_META_INFO (gst_vanc_meta_get_info ())
+
+GstVANCMeta * gst_buffer_add_vanc_meta (GstBuffer * buffer,
+                                        gint did, gint dbn_sdid,
+                                        guint16 * data, gsize size,
+                                        guint16 checksum);
+
+GType gst_vanc_meta_api_get_type (void);
+#define GST_VANC_META_API_TYPE (gst_vanc_meta_api_get_type())
+
+#define gst_buffer_get_vanc_meta(b)                             \
+  ((VANCMeta*)gst_buffer_get_meta((b), GST_VANC_META_API_TYPE))
+
+G_END_DECLS
+
+#endif
diff --git a/pkgconfig/gstreamer-plugins-bad-uninstalled.pc.in b/pkgconfig/gstreamer-plugins-bad-uninstalled.pc.in
index df9a9c5..2692251 100644
--- a/pkgconfig/gstreamer-plugins-bad-uninstalled.pc.in
+++ b/pkgconfig/gstreamer-plugins-bad-uninstalled.pc.in
@@ -10,5 +10,5 @@ Name: GStreamer Bad Plugin libraries, Uninstalled
 Description: Streaming media framework, bad plugins libraries, uninstalled
 Version: @VERSION@
 Requires: gstreamer-@GST_API_VERSION@
-Libs: -L@abs_top_builddir@/gst-libs/gst/audio/.libs -L@abs_top_builddir@/gst-libs/gst/basecamerabinsrc/.libs -L@abs_top_builddir@/gst-libs/gst/codecparsers/.libs -L@abs_top_builddir@/gst-libs/gst/gl/.libs -L@abs_top_builddir@/gst-libs/gst/insertbin/.libs -L@abs_top_builddir@/gst-libs/gst/interfaces/.libs -L@abs_top_builddir@/gst-libs/gst/mpegts/.libs -L@abs_top_builddir@/gst-libs/gst/player/.libs -L@abs_top_builddir@/gst-libs/gst/signalprocessor/.libs -L@abs_top_builddir@/gst-libs/gst/video/.libs -L@abs_top_builddir@/gst-libs/gst/wayland/.libs
+Libs: -L@abs_top_builddir@/gst-libs/gst/audio/.libs -L@abs_top_builddir@/gst-libs/gst/basecamerabinsrc/.libs -L@abs_top_builddir@/gst-libs/gst/codecparsers/.libs -L@abs_top_builddir@/gst-libs/gst/gl/.libs -L@abs_top_builddir@/gst-libs/gst/insertbin/.libs -L@abs_top_builddir@/gst-libs/gst/interfaces/.libs -L@abs_top_builddir@/gst-libs/gst/mpegts/.libs -L@abs_top_builddir@/gst-libs/gst/player/.libs -L@abs_top_builddir@/gst-libs/gst/signalprocessor/.libs -L@abs_top_builddir@/gst-libs/gst/video/.libs -L@abs_top_builddir@/gst-libs/gst/vanc/.libs -L@abs_top_builddir@/gst-libs/gst/wayland/.libs
 Cflags: -I@abs_top_srcdir@/gst-libs -I@abs_top_builddir@/gst-libs
