2 * Copyright (C) <2015> British Broadcasting Corporation
3 * Author: Chris Bass <dash@rd.bbc.co.uk>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 * SECTION:gstsubtitlemeta
23 * @title: GstSubtitleMeta
24 * @short_description: Metadata class for timed-text subtitles.
26 * The GstSubtitleMeta class enables the layout and styling information needed
27 * to render subtitle text to be attached to a #GstBuffer containing that text.
30 #include "subtitlemeta.h"
33 gst_subtitle_meta_api_get_type (void)
35 static volatile GType type;
36 static const gchar *tags[] = { "memory", NULL };
38 if (g_once_init_enter (&type)) {
39 GType _type = gst_meta_api_type_register ("GstSubtitleMetaAPI", tags);
40 g_once_init_leave (&type, _type);
46 gst_subtitle_meta_init (GstMeta * meta, gpointer params, GstBuffer * buffer)
48 GstSubtitleMeta *subtitle_meta = (GstSubtitleMeta *) meta;
50 subtitle_meta->regions = NULL;
55 gst_subtitle_meta_free (GstMeta * meta, GstBuffer * buffer)
57 GstSubtitleMeta *subtitle_meta = (GstSubtitleMeta *) meta;
59 if (subtitle_meta->regions)
60 g_ptr_array_unref (subtitle_meta->regions);
64 gst_subtitle_meta_get_info (void)
66 static const GstMetaInfo *subtitle_meta_info = NULL;
68 if (g_once_init_enter (&subtitle_meta_info)) {
69 const GstMetaInfo *meta =
70 gst_meta_register (GST_SUBTITLE_META_API_TYPE, "GstSubtitleMeta",
71 sizeof (GstSubtitleMeta), gst_subtitle_meta_init,
72 gst_subtitle_meta_free, (GstMetaTransformFunction) NULL);
73 g_once_init_leave (&subtitle_meta_info, meta);
75 return subtitle_meta_info;
79 * gst_buffer_add_subtitle_meta:
80 * @buffer: (transfer none): #GstBuffer holding subtitle text, to which
81 * subtitle metadata should be added.
82 * @regions: (transfer full): A #GPtrArray of #GstSubtitleRegions.
84 * Attaches subtitle metadata to a #GstBuffer.
86 * Returns: A pointer to the added #GstSubtitleMeta if successful; %NULL if
90 gst_buffer_add_subtitle_meta (GstBuffer * buffer, GPtrArray * regions)
92 GstSubtitleMeta *meta;
94 g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
95 g_return_val_if_fail (regions != NULL, NULL);
97 meta = (GstSubtitleMeta *) gst_buffer_add_meta (buffer,
98 GST_SUBTITLE_META_INFO, NULL);
100 meta->regions = regions;