commit 7c67b1cbc61aa0b9c8df05cde0aea2f6b1477225
Author: John Poet <jpoet@gmail.com>
Date:   Mon Nov 14 16:07:24 2016 -0700

    Basis for reading GstVANCMeta when encoding mpeg2.

diff --git a/configure.ac b/configure.ac
index 2a4a57d..2a8ff50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,7 @@ AS_LIBTOOL(GST, 1100, 0, 1100)
 dnl *** required versions of GStreamer stuff ***
 GST_REQ=1.11.0.1
 GST_PBREQ=1.11.0.1
+GST_BADREQ=1.11.0.1
 
 ORC_REQ=0.4.16
 ORC_CHECK([$ORC_REQ])
@@ -126,6 +127,7 @@ dnl uninstalled is selected preferentially -- see pkg-config(1)
 AG_GST_CHECK_GST($GST_API_VERSION, [$GST_REQ])
 AG_GST_CHECK_GST_BASE($GST_API_VERSION, [$GST_REQ])
 AG_GST_CHECK_GST_PLUGINS_BASE($GST_API_VERSION, [$GST_PBREQ])
+AG_GST_CHECK_GST_PLUGINS_BAD($GST_API_VERSION, [$GST_BADREQ])
 AG_GST_CHECK_GST_CHECK($GST_API_VERSION, [$GST_REQ], no)
 AM_CONDITIONAL(HAVE_GST_CHECK, test "x$HAVE_GST_CHECK" = "xyes")
 
diff --git a/ext/libav/Makefile.am b/ext/libav/Makefile.am
index 4aeff59..6eabe29 100644
--- a/ext/libav/Makefile.am
+++ b/ext/libav/Makefile.am
@@ -29,8 +29,9 @@ libgstlibav_la_SOURCES = gstav.c	\
 # 	\
 # 			  gstavscale.c
 
-libgstlibav_la_CFLAGS = $(LIBAV_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-libgstlibav_la_LIBADD = $(LIBAV_LIBS) $(GST_PLUGINS_BASE_LIBS) \
+libgstlibav_la_CFLAGS = $(LIBAV_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
+libgstlibav_la_LIBADD = $(LIBAV_LIBS) $(GST_PLUGINS_BAD_LIBS) -lgstvanc-$(GST_API_VERSION) \
+	$(GST_PLUGINS_BASE_LIBS) \
 	-lgstaudio-$(GST_API_VERSION) -lgstvideo-$(GST_API_VERSION) \
 	-lgstpbutils-$(GST_API_VERSION) $(GST_BASE_LIBS) \
 	$(LIBM) $(WIN32_LIBS) -lz $(BZ2_LIBS) $(LZMA_LIBS)
diff --git a/ext/libav/gstavvidenc.c b/ext/libav/gstavvidenc.c
index 671f2f1..59faad0 100644
--- a/ext/libav/gstavvidenc.c
+++ b/ext/libav/gstavvidenc.c
@@ -32,6 +32,7 @@
 
 #include <gst/gst.h>
 #include <gst/video/gstvideometa.h>
+#include <gst/vanc/gstvancmeta.h>
 
 #include "gstav.h"
 #include "gstavcodecmap.h"
@@ -487,7 +488,7 @@ gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder,
     const gchar *codec;
 
     gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_NOMINAL_BITRATE,
-        (guint) ffmpegenc->context->bit_rate, NULL);
+        ffmpegenc->context->bit_rate, NULL);
 
     if ((codec =
             gst_ffmpeg_get_codecid_longname (ffmpegenc->context->codec_id)))
@@ -600,6 +601,29 @@ buffer_info_free (void *opaque, guint8 * data)
   g_slice_free (BufferInfo, info);
 }
 
+static gboolean
+gst_ffmpegvidenc_handle_vanc (GstBuffer * inbuf, GstMeta ** meta,
+    gpointer user_data)
+{
+  GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) user_data;
+  const GstMetaInfo *vanc_info = gst_vanc_meta_get_info ();
+  GstVANCMeta *vmeta = (GstVANCMeta *) * meta;
+
+  /*
+     Are VANC captions available?
+   */
+  if ((*meta)->info->api != vanc_info->api) {
+    return FALSE;
+  }
+
+  GST_WARNING_OBJECT (ffmpegenc,
+      "  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);
+
+  return TRUE;
+}
+
 static GstFlowReturn
 gst_ffmpegvidenc_handle_frame (GstVideoEncoder * encoder,
     GstVideoCodecFrame * frame)
@@ -660,6 +684,10 @@ gst_ffmpegvidenc_handle_frame (GstVideoEncoder * encoder,
   have_data = 0;
   pkt = g_slice_new0 (AVPacket);
 
+  GST_DEBUG_OBJECT (ffmpegenc, "Processing meta");
+  gst_buffer_foreach_meta (buffer_info->buffer, gst_ffmpegvidenc_handle_vanc,
+      ffmpegenc);
+
   ret =
       avcodec_encode_video2 (ffmpegenc->context, pkt, ffmpegenc->picture,
       &have_data);
