gsttextoverlay.h 5.79 KB
Newer Older
1
2
#ifndef __GST_TEXT_OVERLAY_H__
#define __GST_TEXT_OVERLAY_H__
3
4

#include <gst/gst.h>
5
#include <gst/video/video.h>
6
#include <gst/controller/gstcontroller.h>
7
#include <pango/pangocairo.h>
8
9

G_BEGIN_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
10

11
12
13
14
15
16
17
18
19
20
21
#define GST_TYPE_TEXT_OVERLAY            (gst_text_overlay_get_type())
#define GST_TEXT_OVERLAY(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),\
                                         GST_TYPE_TEXT_OVERLAY, GstTextOverlay))
#define GST_TEXT_OVERLAY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),\
                                         GST_TYPE_TEXT_OVERLAY,GstTextOverlayClass))
#define GST_TEXT_OVERLAY_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),\
                                         GST_TYPE_TEXT_OVERLAY, GstTextOverlayClass))
#define GST_IS_TEXT_OVERLAY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
                                         GST_TYPE_TEXT_OVERLAY))
#define GST_IS_TEXT_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
                                         GST_TYPE_TEXT_OVERLAY))
Johan Dahlin's avatar
Johan Dahlin committed
22
23

typedef struct _GstTextOverlay      GstTextOverlay;
24
25
typedef struct _GstTextOverlayClass GstTextOverlayClass;

Wim Taymans's avatar
Wim Taymans committed
26
27
28
29
/**
 * GstTextOverlayVAlign:
 * @GST_TEXT_OVERLAY_VALIGN_BASELINE: draw text on the baseline
 * @GST_TEXT_OVERLAY_VALIGN_BOTTOM: draw text on the bottom
30
31
32
 * @GST_TEXT_OVERLAY_VALIGN_TOP: draw text on top
 * @GST_TEXT_OVERLAY_VALIGN_POS: draw text according to the #GstTextOverlay:ypos property
 * @GST_TEXT_OVERLAY_VALIGN_CENTER: draw text vertically centered
Wim Taymans's avatar
Wim Taymans committed
33
34
35
36
 *
 * Vertical alignment of the text.
 */
typedef enum {
Johan Dahlin's avatar
Johan Dahlin committed
37
38
    GST_TEXT_OVERLAY_VALIGN_BASELINE,
    GST_TEXT_OVERLAY_VALIGN_BOTTOM,
39
    GST_TEXT_OVERLAY_VALIGN_TOP,
40
41
    GST_TEXT_OVERLAY_VALIGN_POS,
    GST_TEXT_OVERLAY_VALIGN_CENTER
Wim Taymans's avatar
Wim Taymans committed
42
43
44
45
46
47
48
} GstTextOverlayVAlign;

/**
 * GstTextOverlayHAlign:
 * @GST_TEXT_OVERLAY_HALIGN_LEFT: align text left
 * @GST_TEXT_OVERLAY_HALIGN_CENTER: align text center
 * @GST_TEXT_OVERLAY_HALIGN_RIGHT: align text right
49
 * @GST_TEXT_OVERLAY_HALIGN_POS: position text according to the #GstTextOverlay:xpos property
Wim Taymans's avatar
Wim Taymans committed
50
51
52
 *
 * Horizontal alignment of the text.
 */
53
/* FIXME 0.11: remove GST_TEXT_OVERLAY_HALIGN_UNUSED */
Wim Taymans's avatar
Wim Taymans committed
54
typedef enum {
Johan Dahlin's avatar
Johan Dahlin committed
55
56
    GST_TEXT_OVERLAY_HALIGN_LEFT,
    GST_TEXT_OVERLAY_HALIGN_CENTER,
57
    GST_TEXT_OVERLAY_HALIGN_RIGHT,
58
    GST_TEXT_OVERLAY_HALIGN_UNUSED,
59
    GST_TEXT_OVERLAY_HALIGN_POS
Wim Taymans's avatar
Wim Taymans committed
60
61
62
63
64
65
66
67
68
69
70
71
} GstTextOverlayHAlign;

/**
 * GstTextOverlayWrapMode:
 * @GST_TEXT_OVERLAY_WRAP_MODE_NONE: no wrapping
 * @GST_TEXT_OVERLAY_WRAP_MODE_WORD: do word wrapping
 * @GST_TEXT_OVERLAY_WRAP_MODE_CHAR: do char wrapping
 * @GST_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR: do word and char wrapping
 *
 * Whether to wrap the text and if so how.
 */
typedef enum {
72
73
74
75
    GST_TEXT_OVERLAY_WRAP_MODE_NONE = -1,
    GST_TEXT_OVERLAY_WRAP_MODE_WORD = PANGO_WRAP_WORD,
    GST_TEXT_OVERLAY_WRAP_MODE_CHAR = PANGO_WRAP_CHAR,
    GST_TEXT_OVERLAY_WRAP_MODE_WORD_CHAR = PANGO_WRAP_WORD_CHAR
Wim Taymans's avatar
Wim Taymans committed
76
} GstTextOverlayWrapMode;
77

78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
 * GstTextOverlayLineAlign:
 * @GST_TEXT_OVERLAY_LINE_ALIGN_LEFT: lines are left-aligned
 * @GST_TEXT_OVERLAY_LINE_ALIGN_CENTER: lines are center-aligned
 * @GST_TEXT_OVERLAY_LINE_ALIGN_RIGHT: lines are right-aligned
 *
 * Alignment of text lines relative to each other
 */
typedef enum {
    GST_TEXT_OVERLAY_LINE_ALIGN_LEFT = PANGO_ALIGN_LEFT,
    GST_TEXT_OVERLAY_LINE_ALIGN_CENTER = PANGO_ALIGN_CENTER,
    GST_TEXT_OVERLAY_LINE_ALIGN_RIGHT = PANGO_ALIGN_RIGHT
} GstTextOverlayLineAlign;

Wim Taymans's avatar
Wim Taymans committed
92
93
94
95
96
/**
 * GstTextOverlay:
 *
 * Opaque textoverlay object structure
 */
Johan Dahlin's avatar
Johan Dahlin committed
97
struct _GstTextOverlay {
98
99
100
101
102
103
    GstElement               element;

    GstPad                  *video_sinkpad;
    GstPad                  *text_sinkpad;
    GstPad                  *srcpad;

104
    GstSegment               segment;
105
    GstSegment               text_segment;
106
107
    GstBuffer               *text_buffer;
    gboolean                text_linked;
108
    gboolean                video_flushing;
109
    gboolean                video_eos;
110
    gboolean                text_flushing;
111
112
113
114
115
116
    gboolean                text_eos;

    GCond                   *cond;  /* to signal removal of a queued text
                                     * buffer, arrival of a text buffer,
                                     * a text segment update, or a change
                                     * in status (e.g. shutdown, flushing) */
117
118
119
120
121

    gint                     width;
    gint                     height;
    gint                     fps_n;
    gint                     fps_d;
122
    GstVideoFormat           format;
123
124
125
126

    GstTextOverlayVAlign     valign;
    GstTextOverlayHAlign     halign;
    GstTextOverlayWrapMode   wrap_mode;
127
    GstTextOverlayLineAlign  line_align;
128
129
130
131
132

    gint                     xpad;
    gint                     ypad;
    gint                     deltax;
    gint                     deltay;
133
134
    gdouble                  xpos;
    gdouble                  ypos;
135
136
    gchar                   *default_text;
    gboolean                 want_shading;
137
    gboolean                 silent;
138
    gboolean                 wait_text;
139
    guint                    color;
140
141

    PangoLayout             *layout;
142
143
144
145
146
    gdouble                  shadow_offset;
    gdouble                  outline_offset;
    guchar                  *text_image;
    gint                     image_width;
    gint                     image_height;
147
148
    gint                     baseline_y;

149
    gboolean                 auto_adjust_size;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
150
    gboolean                 need_render;
151
152

    gint                     shading_value;  /* for timeoverlay subclass */
153
154

    gboolean                 have_pango_markup;
155
    gboolean                 use_vertical_render;
156
157
};

Johan Dahlin's avatar
Johan Dahlin committed
158
159
struct _GstTextOverlayClass {
    GstElementClass parent_class;
160

Johan Dahlin's avatar
Johan Dahlin committed
161
    PangoContext *pango_context;
162
    GMutex       *pango_lock;
163
164

    gchar *     (*get_text) (GstTextOverlay *overlay, GstBuffer *video_frame);
165
166
};

167
GType gst_text_overlay_get_type(void) G_GNUC_CONST;
168
169

G_END_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
170

171
#endif /* __GST_TEXT_OVERLAY_H */