1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  * Copyright (C) <2003> David Schleef <ds@schleef.org>
4  * Copyright (C) <2006> Julien Moutte <julien@moutte.net>
5  * Copyright (C) <2006> Zeeshan Ali <zeeshan.ali@nokia.com>
6  * Copyright (C) <2006-2008> Tim-Philipp Müller <tim centricular net>
7  * Copyright (C) <2009> Young-Ho Cha <ganadist@gmail.com>
8  * Copyright (C) <2015> British Broadcasting Corporation <dash@rd.bbc.co.uk>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  */
25 
26 #ifndef __GST_TTML_RENDER_H__
27 #define __GST_TTML_RENDER_H__
28 
29 #include <gst/gst.h>
30 #include <gst/video/video.h>
31 #include <pango/pango.h>
32 
33 G_BEGIN_DECLS
34 
35 #define GST_TYPE_TTML_RENDER            (gst_ttml_render_get_type())
36 #define GST_TTML_RENDER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),\
37                                          GST_TYPE_TTML_RENDER, GstTtmlRender))
38 #define GST_TTML_RENDER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),\
39                                          GST_TYPE_TTML_RENDER, \
40                                          GstTtmlRenderClass))
41 #define GST_TTML_RENDER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),\
42                                          GST_TYPE_TTML_RENDER, \
43                                          GstTtmlRenderClass))
44 #define GST_IS_TTML_RENDER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
45                                          GST_TYPE_TTML_RENDER))
46 #define GST_IS_TTML_RENDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
47                                          GST_TYPE_TTML_RENDER))
48 
49 typedef struct _GstTtmlRender GstTtmlRender;
50 typedef struct _GstTtmlRenderClass GstTtmlRenderClass;
51 typedef struct _GstTtmlRenderRenderedImage GstTtmlRenderRenderedImage;
52 
53 struct _GstTtmlRenderRenderedImage {
54   GstBuffer *image;
55   gint x;
56   gint y;
57   guint width;
58   guint height;
59 };
60 
61 
62 struct _GstTtmlRender {
63     GstElement               element;
64 
65     GstPad                  *video_sinkpad;
66     GstPad                  *text_sinkpad;
67     GstPad                  *srcpad;
68 
69     GstSegment               segment;
70     GstSegment               text_segment;
71     GstBuffer               *text_buffer;
72     gboolean                text_linked;
73     gboolean                video_flushing;
74     gboolean                video_eos;
75     gboolean                text_flushing;
76     gboolean                text_eos;
77 
78     GMutex                   lock;
79     GCond                    cond;  /* to signal removal of a queued text
80                                      * buffer, arrival of a text buffer,
81                                      * a text segment update, or a change
82                                      * in status (e.g. shutdown, flushing) */
83 
84     GstVideoInfo             info;
85     GstVideoFormat           format;
86     gint                     width;
87     gint                     height;
88 
89     gboolean                 want_background;
90     gboolean                 wait_text;
91 
92     gboolean                 need_render;
93 
94     PangoLayout             *layout;
95     GList * compositions;
96 };
97 
98 struct _GstTtmlRenderClass {
99     GstElementClass parent_class;
100 
101     PangoContext *pango_context;
102     GMutex       *pango_lock;
103 };
104 
105 GType gst_ttml_render_get_type(void) G_GNUC_CONST;
106 
107 G_END_DECLS
108 
109 #endif /* __GST_TTML_RENDER_H */
110