summaryrefslogtreecommitdiff
path: root/gst-libs/gst/video/gstvideometa.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst-libs/gst/video/gstvideometa.c')
-rw-r--r--gst-libs/gst/video/gstvideometa.c123
1 files changed, 123 insertions, 0 deletions
diff --git a/gst-libs/gst/video/gstvideometa.c b/gst-libs/gst/video/gstvideometa.c
index 739e9f4c3..8940beec1 100644
--- a/gst-libs/gst/video/gstvideometa.c
+++ b/gst-libs/gst/video/gstvideometa.c
@@ -18,6 +18,7 @@
*/
#include "gstvideometa.h"
+#include "video-anc.h"
#include <string.h>
@@ -1052,3 +1053,125 @@ gst_buffer_add_video_time_code_meta_full (GstBuffer * buffer, guint fps_n,
return meta;
}
+
+/* Closed Caption Meta implementation *******************************************/
+
+GType
+gst_video_caption_meta_api_get_type (void)
+{
+ static volatile GType type;
+
+ if (g_once_init_enter (&type)) {
+ static const gchar *tags[] = { NULL };
+ GType _type = gst_meta_api_type_register ("GstVideoCaptionMetaAPI", tags);
+ GST_INFO ("registering");
+ g_once_init_leave (&type, _type);
+ }
+ return type;
+}
+
+
+static gboolean
+gst_video_caption_meta_transform (GstBuffer * dest, GstMeta * meta,
+ GstBuffer * buffer, GQuark type, gpointer data)
+{
+ GstVideoCaptionMeta *dmeta, *smeta;
+
+ if (GST_META_TRANSFORM_IS_COPY (type)) {
+ smeta = (GstVideoCaptionMeta *) meta;
+
+ GST_DEBUG ("copy caption metadata");
+ dmeta =
+ gst_buffer_add_video_caption_meta (dest, smeta->caption_type,
+ smeta->data, smeta->size);
+ if (!dmeta)
+ return FALSE;
+ } else {
+ /* return FALSE, if transform type is not supported */
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static gboolean
+gst_video_caption_meta_init (GstMeta * meta, gpointer params,
+ GstBuffer * buffer)
+{
+ GstVideoCaptionMeta *emeta = (GstVideoCaptionMeta *) meta;
+
+ emeta->caption_type = GST_VIDEO_CAPTION_TYPE_UNKNOWN;
+
+ return TRUE;
+}
+
+static void
+gst_video_caption_meta_free (GstMeta * meta, GstBuffer * buffer)
+{
+ GstVideoCaptionMeta *emeta = (GstVideoCaptionMeta *) meta;
+
+ g_free (emeta->data);
+}
+
+const GstMetaInfo *
+gst_video_caption_meta_get_info (void)
+{
+ static const GstMetaInfo *meta_info = NULL;
+
+ if (g_once_init_enter ((GstMetaInfo **) & meta_info)) {
+ const GstMetaInfo *mi = gst_meta_register (GST_VIDEO_CAPTION_META_API_TYPE,
+ "GstVideoCaptionMeta",
+ sizeof (GstVideoCaptionMeta),
+ gst_video_caption_meta_init,
+ gst_video_caption_meta_free,
+ gst_video_caption_meta_transform);
+ g_once_init_leave ((GstMetaInfo **) & meta_info, (GstMetaInfo *) mi);
+ }
+ return meta_info;
+}
+
+/**
+ * gst_buffer_add_video_caption_meta:
+ * @buffer: a #GstBuffer
+ * @caption_type: The type of Closed Caption to add
+ * @data: The Closed Caption data
+ * @size: The size of @data in bytes
+ *
+ * Attaches #GstVideoCaptionMeta metadata to @buffer with the given
+ * parameters.
+ *
+ * Returns: (transfer none): the #GstVideoCaptionMeta on @buffer.
+ *
+ * Since: 1.16
+ */
+GstVideoCaptionMeta *
+gst_buffer_add_video_caption_meta (GstBuffer * buffer,
+ GstVideoCaptionType caption_type, const guint8 * data, gsize size)
+{
+ GstVideoCaptionMeta *meta;
+
+ g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
+ g_return_val_if_fail (data != NULL, NULL);
+ g_return_val_if_fail (size > 0, NULL);
+
+ switch (caption_type) {
+ case GST_VIDEO_CAPTION_TYPE_CEA608_RAW:
+ case GST_VIDEO_CAPTION_TYPE_CEA608_IN_CEA708_RAW:
+ case GST_VIDEO_CAPTION_TYPE_CEA708_RAW:
+ case GST_VIDEO_CAPTION_TYPE_CEA708_CDP:
+ break;
+ default:
+ GST_ERROR ("Unknown caption type !");
+ return NULL;
+ }
+ /* FIXME : Add checks for content ? */
+
+ meta = (GstVideoCaptionMeta *) gst_buffer_add_meta (buffer,
+ GST_VIDEO_CAPTION_META_INFO, NULL);
+ g_return_val_if_fail (meta != NULL, NULL);
+
+ meta->caption_type = caption_type;
+ meta->data = g_memdup (data, size);
+ meta->size = size;
+
+ return meta;
+}