gsttextoverlay.h 5.46 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
30
31
32
33
34
/**
 * GstTextOverlayVAlign:
 * @GST_TEXT_OVERLAY_VALIGN_BASELINE: draw text on the baseline
 * @GST_TEXT_OVERLAY_VALIGN_BOTTOM: draw text on the bottom
 * @GST_TEXT_OVERLAY_VALIGN_TOP: draw test on top
 *
 * Vertical alignment of the text.
 */
typedef enum {
Johan Dahlin's avatar
Johan Dahlin committed
35
36
    GST_TEXT_OVERLAY_VALIGN_BASELINE,
    GST_TEXT_OVERLAY_VALIGN_BOTTOM,
37
    GST_TEXT_OVERLAY_VALIGN_TOP,
38
39
    GST_TEXT_OVERLAY_VALIGN_POS,
    GST_TEXT_OVERLAY_VALIGN_CENTER
Wim Taymans's avatar
Wim Taymans committed
40
41
42
43
44
45
46
47
48
49
50
} 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
 *
 * Horizontal alignment of the text.
 */
typedef enum {
Johan Dahlin's avatar
Johan Dahlin committed
51
52
    GST_TEXT_OVERLAY_HALIGN_LEFT,
    GST_TEXT_OVERLAY_HALIGN_CENTER,
53
54
55
    GST_TEXT_OVERLAY_HALIGN_RIGHT,
    GST_TEXT_OVERLAY_HALIGN_TOP,
    GST_TEXT_OVERLAY_HALIGN_POS
Wim Taymans's avatar
Wim Taymans committed
56
57
58
59
60
61
62
63
64
65
66
67
} 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 {
68
69
70
71
    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
72
} GstTextOverlayWrapMode;
73

74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
 * 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
88
89
90
91
92
/**
 * GstTextOverlay:
 *
 * Opaque textoverlay object structure
 */
Johan Dahlin's avatar
Johan Dahlin committed
93
struct _GstTextOverlay {
94
95
96
97
98
99
    GstElement               element;

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

100
    GstSegment               segment;
101
    GstSegment               text_segment;
102
103
    GstBuffer               *text_buffer;
    gboolean                text_linked;
104
    gboolean                video_flushing;
105
    gboolean                video_eos;
106
    gboolean                text_flushing;
107
108
109
110
111
112
    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) */
113
114
115
116
117

    gint                     width;
    gint                     height;
    gint                     fps_n;
    gint                     fps_d;
118
    GstVideoFormat           format;
119
120
121
122

    GstTextOverlayVAlign     valign;
    GstTextOverlayHAlign     halign;
    GstTextOverlayWrapMode   wrap_mode;
123
    GstTextOverlayLineAlign  line_align;
124
125
126
127
128

    gint                     xpad;
    gint                     ypad;
    gint                     deltax;
    gint                     deltay;
129
130
    gdouble                  xpos;
    gdouble                  ypos;
131
132
    gchar                   *default_text;
    gboolean                 want_shading;
133
    gboolean                 silent;
134
    gboolean                 wait_text;
135
    guint                    color;
136
137

    PangoLayout             *layout;
138
139
140
141
142
    gdouble                  shadow_offset;
    gdouble                  outline_offset;
    guchar                  *text_image;
    gint                     image_width;
    gint                     image_height;
143
144
    gint                     baseline_y;

145
    gboolean                 auto_adjust_size;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
146
    gboolean                 need_render;
147
148

    gint                     shading_value;  /* for timeoverlay subclass */
149
150

    gboolean                 have_pango_markup;
151
    gboolean                 use_vertical_render;
152
153
};

Johan Dahlin's avatar
Johan Dahlin committed
154
155
struct _GstTextOverlayClass {
    GstElementClass parent_class;
156

Johan Dahlin's avatar
Johan Dahlin committed
157
    PangoContext *pango_context;
158
159

    gchar *     (*get_text) (GstTextOverlay *overlay, GstBuffer *video_frame);
160
161
};

162
GType gst_text_overlay_get_type(void) G_GNUC_CONST;
163
164

G_END_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
165

166
#endif /* __GST_TEXT_OVERLAY_H */