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 GST_BASE_TEXT_OVERLAY_VALIGN_ABSOLUTE
67 } GstBaseTextOverlayVAlign;
70 * GstBaseTextOverlayHAlign:
71 * @GST_BASE_TEXT_OVERLAY_HALIGN_LEFT: align text left
72 * @GST_BASE_TEXT_OVERLAY_HALIGN_CENTER: align text center
73 * @GST_BASE_TEXT_OVERLAY_HALIGN_RIGHT: align text right
74 * @GST_BASE_TEXT_OVERLAY_HALIGN_POS: position text according to the #GstBaseTextOverlay:xpos property
76 * Horizontal alignment of the text.
78 /* FIXME 0.11: remove GST_BASE_TEXT_OVERLAY_HALIGN_UNUSED */
80 GST_BASE_TEXT_OVERLAY_HALIGN_LEFT,
81 GST_BASE_TEXT_OVERLAY_HALIGN_CENTER,
82 GST_BASE_TEXT_OVERLAY_HALIGN_RIGHT,
83 GST_BASE_TEXT_OVERLAY_HALIGN_UNUSED,
84 GST_BASE_TEXT_OVERLAY_HALIGN_POS,
85 GST_BASE_TEXT_OVERLAY_HALIGN_ABSOLUTE
86 } GstBaseTextOverlayHAlign;
89 * GstBaseTextOverlayWrapMode:
90 * @GST_BASE_TEXT_OVERLAY_WRAP_MODE_NONE: no wrapping
91 * @GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD: do word wrapping
92 * @GST_BASE_TEXT_OVERLAY_WRAP_MODE_CHAR: do char wrapping
93 * @GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR: do word and char wrapping
95 * Whether to wrap the text and if so how.
98 GST_BASE_TEXT_OVERLAY_WRAP_MODE_NONE = -1,
99 GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD = PANGO_WRAP_WORD,
100 GST_BASE_TEXT_OVERLAY_WRAP_MODE_CHAR = PANGO_WRAP_CHAR,
101 GST_BASE_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR = PANGO_WRAP_WORD_CHAR
102 } GstBaseTextOverlayWrapMode;
105 * GstBaseTextOverlayLineAlign:
106 * @GST_BASE_TEXT_OVERLAY_LINE_ALIGN_LEFT: lines are left-aligned
107 * @GST_BASE_TEXT_OVERLAY_LINE_ALIGN_CENTER: lines are center-aligned
108 * @GST_BASE_TEXT_OVERLAY_LINE_ALIGN_RIGHT: lines are right-aligned
110 * Alignment of text lines relative to each other
113 GST_BASE_TEXT_OVERLAY_LINE_ALIGN_LEFT = PANGO_ALIGN_LEFT,
114 GST_BASE_TEXT_OVERLAY_LINE_ALIGN_CENTER = PANGO_ALIGN_CENTER,
115 GST_BASE_TEXT_OVERLAY_LINE_ALIGN_RIGHT = PANGO_ALIGN_RIGHT
116 } GstBaseTextOverlayLineAlign;
119 * GstBaseTextOverlay:
121 * Opaque textoverlay object structure
123 struct _GstBaseTextOverlay {
126 GstPad *video_sinkpad;
127 GstPad *text_sinkpad;
131 GstSegment text_segment;
132 GstBuffer *text_buffer;
133 gboolean text_linked;
134 gboolean video_flushing;
136 gboolean text_flushing;
140 GCond cond; /* to signal removal of a queued text
141 * buffer, arrival of a text buffer,
142 * a text segment update, or a change
143 * in status (e.g. shutdown, flushing) */
147 GstVideoFormat format;
159 gboolean want_shading;
162 guint color, outline_color;
164 gboolean auto_adjust_size;
165 gboolean draw_shadow;
166 gboolean draw_outline;
167 gint shading_value; /* for timeoverlay subclass */
168 gboolean use_vertical_render;
169 GstBaseTextOverlayVAlign valign;
170 GstBaseTextOverlayHAlign halign;
171 GstBaseTextOverlayWrapMode wrap_mode;
172 GstBaseTextOverlayLineAlign line_align;
174 /* text pad format */
175 gboolean have_pango_markup;
177 /* rendering state */
178 gboolean need_render;
179 GstBuffer *text_image;
181 /* dimension relative to witch the render is done, this is the stream size
182 * or a portion of the window_size (adapted to aspect ratio) */
185 /* This is (render_width / width) uses to convert to stream scale */
186 gdouble render_scale;
188 /* dimension of text_image, the physical dimension */
192 /* position of rendering in image coordinates */
196 /* window dimension, reported in the composition meta params. This is set
197 * to stream width, height if missing */
201 gdouble shadow_offset;
202 gdouble outline_offset;
204 PangoRectangle ink_rect;
205 PangoRectangle logical_rect;
207 gboolean attach_compo_to_buffer;
208 GstVideoOverlayComposition *composition;
209 GstVideoOverlayComposition *upstream_composition;
212 struct _GstBaseTextOverlayClass {
213 GstElementClass parent_class;
215 PangoContext *pango_context;
218 gchar * (*get_text) (GstBaseTextOverlay *overlay, GstBuffer *video_frame);
221 GType gst_base_text_overlay_get_type(void) G_GNUC_CONST;
225 #endif /* __GST_BASE_TEXT_OVERLAY_H */