commit ec0685a21ba009ffac92c40c32c1659e5ca7f99d
Author: John Poet <jppoet@gmail.com>
Date:   Tue Nov 15 17:12:05 2016 -0700

    Create libgstvanc for processing VANC metadata.

diff --git a/configure.ac b/configure.ac
index 74c53f7..7a2c4c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3758,6 +3758,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
 gst-libs/gst/opencv/Makefile
 sys/Makefile
diff --git a/gst-libs/gst/Makefile.am b/gst-libs/gst/Makefile.am
index 92130cd..f3853c4 100644
--- a/gst-libs/gst/Makefile.am
+++ b/gst-libs/gst/Makefile.am
@@ -15,12 +15,12 @@ OPENCV_DIR=opencv
 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) \
 	 $(OPENCV_DIR)
 
 noinst_HEADERS = gst-i18n-plugin.h gettext.h glib-compat-private.h
 DIST_SUBDIRS = uridownloader adaptivedemux interfaces gl basecamerabinsrc \
-	codecparsers insertbin mpegts wayland opencv base video audio player
+	codecparsers insertbin mpegts wayland opencv 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..62dda66
--- /dev/null
+++ b/gst-libs/gst/vanc/Makefile.am
@@ -0,0 +1,23 @@
+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_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..14bdabb
--- /dev/null
+++ b/gst-libs/gst/vanc/gstvancmeta.c
@@ -0,0 +1,118 @@
+/* GStreamer
+ * Copyright (C) 2016 John Poet <jppoet@digital-nirvana.com>
+ *
+ * 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
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+
+#ifndef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstvancmeta.h"
+
+GType
+gst_vanc_meta_api_get_type (void)
+{
+  static volatile GType type;
+  static const gchar *tags[] = { 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->checksum = 0;
+  vmeta->vanc_data = NULL;
+  return TRUE;
+}
+
+static gboolean
+gst_vanc_meta_transform (GstBuffer * dest, GstMeta * meta,
+    GstBuffer * buffer, GQuark type, gpointer data)
+{
+  /*
+     Just copy for all transform types
+   */
+
+  GstVANCMeta *dmeta =
+      (GstVANCMeta *) gst_buffer_add_meta (dest, GST_VANC_META_INFO, NULL);
+  GstVANCMeta *smeta = (GstVANCMeta *) meta;
+
+  if (!dmeta)
+    return FALSE;
+
+  GST_DEBUG ("copy VANC metadata");
+  dmeta->data_id = smeta->data_id;
+  dmeta->dbn_sdid = smeta->dbn_sdid;
+  g_bytes_ref (smeta->vanc_data);
+  dmeta->vanc_data = smeta->vanc_data;
+  dmeta->checksum = smeta->checksum;
+
+  return TRUE;
+}
+
+static void
+gst_vanc_meta_free (GstMeta * meta, GstBuffer * buffer)
+{
+  GstVANCMeta *vmeta = (GstVANCMeta *) meta;
+
+  g_bytes_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,
+        "GstVANCMeta",
+        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 data_id, gint dbn_sdid,
+    const 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 = data_id;
+  vmeta->dbn_sdid = dbn_sdid;
+  vmeta->checksum = checksum;
+
+  vmeta->vanc_data = g_bytes_new (data, size * sizeof (guint16));
+
+  return vmeta;
+}
diff --git a/gst-libs/gst/vanc/gstvancmeta.h b/gst-libs/gst/vanc/gstvancmeta.h
new file mode 100644
index 0000000..4afb98d
--- /dev/null
+++ b/gst-libs/gst/vanc/gstvancmeta.h
@@ -0,0 +1,71 @@
+/* GStreamer
+ * Copyright (C) 2016 John Poet <jppoet@digital-nirvana.com>
+ *
+ * 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
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
+ * Boston, MA 02110-1335, USA.
+ */
+
+/*
+  GstMeta for transmitting SMPTE 291M ancillary data
+*/
+
+#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 (type 1)
+ * @dbn_sdid: VANC data block number (type 1) or secondary data ID (type 2)
+ * @checksum: VANC checksum
+ * @vanc_data: guint16 Raw ancillary data
+ */
+struct _GstVANCMeta {
+  GstMeta          meta;
+  gint             data_id;
+  gint             dbn_sdid;
+  guint16          checksum;
+  GBytes          *vanc_data;
+};
+
+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,
+                                        const 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())
+
+#if 0
+#define gst_buffer_get_vanc_meta(b)                             \
+  ((VANCMeta*)gst_buffer_get_meta((b), GST_VANC_META_API_TYPE))
+#endif
+
+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
diff --git a/pkgconfig/gstreamer-vanc-uninstalled.pc.in b/pkgconfig/gstreamer-vanc-uninstalled.pc.in
new file mode 100644
index 0000000..d45ba3d
--- /dev/null
+++ b/pkgconfig/gstreamer-vanc-uninstalled.pc.in
@@ -0,0 +1,14 @@
+prefix=
+exec_prefix=
+libdir=@abs_top_builddir@/gst-libs/gst/vanc/.libs
+includedir=@abs_top_builddir@/gst-libs
+girdir=@abs_top_builddir@/gst-libs/gst/vanc
+typelibdir=@abs_top_builddir@/gst-libs/gst/vanc
+
+Name: GStreamer VANC library, uninstalled
+Description: VANC library for GStreamer elements, Not Installed
+Version: @VERSION@
+Requires: gstreamer-@GST_API_VERSION@ gstreamer-bad-base-@GST_API_VERSION@
+
+Libs: -L${libdir} -lgstvanc-@GST_API_VERSION@
+Cflags: -I@abs_top_srcdir@/gst-libs -I@abs_top_builddir@/gst-libs
diff --git a/pkgconfig/gstreamer-vanc.pc.in b/pkgconfig/gstreamer-vanc.pc.in
new file mode 100644
index 0000000..3f738d6
--- /dev/null
+++ b/pkgconfig/gstreamer-vanc.pc.in
@@ -0,0 +1,16 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@/gstreamer-@GST_API_VERSION@
+datarootdir=${prefix}/share
+datadir=${datarootdir}
+girdir=${datadir}/gir-1.0
+typelibdir=${libdir}/girepository-1.0
+
+Name: GStreamer VANC library
+Description: VANC library for GStreamer elements
+Version: @VERSION@
+Requires: gstreamer-@GST_API_VERSION@ gstreamer-bad-base-@GST_API_VERSION@
+
+Libs: -L${libdir} ${libdir}/libgstvanc-@GST_API_VERSION@.la
+Cflags: -I${includedir}
