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>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
25 #ifndef __GST_BASE_TEXT_OVERLAY_H__
26 #define __GST_BASE_TEXT_OVERLAY_H__
29 #include <gst/video/video.h>
30 #include <gst/video/video-overlay-composition.h>
31 #include <pango/pangocairo.h>
35 #define GST_TYPE_BASE_TEXT_OVERLAY (gst_base_text_overlay_get_type())
36 #define GST_BASE_TEXT_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
37 GST_TYPE_BASE_TEXT_OVERLAY, GstBaseTextOverlay))
38 #define GST_BASE_TEXT_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
39 GST_TYPE_BASE_TEXT_OVERLAY,GstBaseTextOverlayClass))
40 #define GST_BASE_TEXT_OVERLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
41 GST_TYPE_BASE_TEXT_OVERLAY, GstBaseTextOverlayClass))
42 #define GST_IS_BASE_TEXT_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
43 GST_TYPE_BASE_TEXT_OVERLAY))
44 #define GST_IS_BASE_TEXT_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
45 GST_TYPE_BASE_TEXT_OVERLAY))
47 typedef struct _GstBaseTextOverlay GstBaseTextOverlay;
48 typedef struct _GstBaseTextOverlayClass GstBaseTextOverlayClass;
51 * GstBaseTextOverlayVAlign:
52 * @GST_BASE_TEXT_OVERLAY_VALIGN_BASELINE: draw text on the baseline
53 * @GST_BASE_TEXT_OVERLAY_VALIGN_BOTTOM: draw text on the bottom
54 * @GST_BASE_TEXT_OVERLAY_VALIGN_TOP: draw text on top
55 * @GST_BASE_TEXT_OVERLAY_VALIGN_POS: draw text according to the #GstBaseTextOverlay:ypos property
56 * @GST_BASE_TEXT_OVERLAY_VALIGN_CENTER: draw text vertically centered
58 * Vertical alignment of the text.
61 GST_BASE_TEXT_OVERLAY_VALIGN_BASELINE,
62 GST_BASE_TEXT_OVERLAY_VALIGN_BOTTOM,
63 GST_BASE_TEXT_OVERLAY_VALIGN_TOP,
64 GST_BASE_TEXT_OVERLAY_VALIGN_POS,
65 GST_BASE_TEXT_OVERLAY_VALIGN_CENTER
66 } GstBaseTextOverlayVAlign;
69 * GstBaseTextOverlayHAlign:
70 * @GST_BASE_TEXT_OVERLAY_HALIGN_LEFT: align text left
71 * @GST_BASE_TEXT_OVERLAY_HALIGN_CENTER: align text center
72 * @GST_BASE_TEXT_OVERLAY_HALIGN_RIGHT: align text right
73 * @GST_BASE_TEXT_OVERLAY_HALIGN_POS: position text according to the #GstBaseTextOverlay:xpos property
75 * Horizontal alignment of the text.
77 /* FIXME 0.11: remove GST_BASE_TEXT_OVERLAY_HALIGN_UNUSED */
79 GST_BASE_TEXT_OVERLAY_HALIGN_LEFT,
80 GST_BASE_TEXT_OVERLAY_HALIGN_CENTER,
81 GST_BASE_TEXT_OVERLAY_HALIGN_RIGHT,
82 GST_BASE_TEXT_OVERLAY_HALIGN_UNUSED,
83 GST_BASE_TEXT_OVERLAY_HALIGN_POS
84 } GstBaseTextOverlayHAlign;
87 * GstBaseTextOverlayWrapMode:
88 * @GST_BASE_TEXT_OVERLAY_WRAP_MODE_NONE: no wrapping
89 * @GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD: do word wrapping
90 * @GST_BASE_TEXT_OVERLAY_WRAP_MODE_CHAR: do char wrapping
91 * @GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR: do word and char wrapping
93 * Whether to wrap the text and if so how.
96 GST_BASE_TEXT_OVERLAY_WRAP_MODE_NONE = -1,
97 GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD = PANGO_WRAP_WORD,
98 GST_BASE_TEXT_OVERLAY_WRAP_MODE_CHAR = PANGO_WRAP_CHAR,
99 GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR = PANGO_WRAP_WORD_CHAR
100 } GstBaseTextOverlayWrapMode;
103 * GstBaseTextOverlayLineAlign:
104 * @GST_BASE_TEXT_OVERLAY_LINE_ALIGN_LEFT: lines are left-aligned
105 * @GST_BASE_TEXT_OVERLAY_LINE_ALIGN_CENTER: lines are center-aligned
106 * @GST_BASE_TEXT_OVERLAY_LINE_ALIGN_RIGHT: lines are right-aligned
108 * Alignment of text lines relative to each other
111 GST_BASE_TEXT_OVERLAY_LINE_ALIGN_LEFT = PANGO_ALIGN_LEFT,
112 GST_BASE_TEXT_OVERLAY_LINE_ALIGN_CENTER = PANGO_ALIGN_CENTER,
113 GST_BASE_TEXT_OVERLAY_LINE_ALIGN_RIGHT = PANGO_ALIGN_RIGHT
114 } GstBaseTextOverlayLineAlign;
117 * GstBaseTextOverlay:
119 * Opaque textoverlay object structure
121 struct _GstBaseTextOverlay {
124 GstPad *video_sinkpad;
125 GstPad *text_sinkpad;
129 GstSegment text_segment;
130 GstBuffer *text_buffer;
131 gboolean text_linked;
132 gboolean video_flushing;
134 gboolean text_flushing;
138 GCond cond; /* to signal removal of a queued text
139 * buffer, arrival of a text buffer,
140 * a text segment update, or a change
141 * in status (e.g. shutdown, flushing) */
144 GstVideoFormat format;
148 GstBaseTextOverlayVAlign valign;
149 GstBaseTextOverlayHAlign halign;
150 GstBaseTextOverlayWrapMode wrap_mode;
151 GstBaseTextOverlayLineAlign line_align;
160 gboolean want_shading;
163 guint color, outline_color;
166 gdouble shadow_offset;
167 gdouble outline_offset;
168 GstBuffer *text_image;
173 gboolean auto_adjust_size;
174 gboolean need_render;
176 gint shading_value; /* for timeoverlay subclass */
178 gboolean have_pango_markup;
179 gboolean use_vertical_render;
181 gboolean attach_compo_to_buffer;
183 GstVideoOverlayComposition *composition;
186 struct _GstBaseTextOverlayClass {
187 GstElementClass parent_class;
189 PangoContext *pango_context;
192 gchar * (*get_text) (GstBaseTextOverlay *overlay, GstBuffer *video_frame);
195 GType gst_base_text_overlay_get_type(void) G_GNUC_CONST;
199 #endif /* __GST_BASE_TEXT_OVERLAY_H */