1 /* GStreamer
2 * Copyright (C) <2015> British Broadcasting Corporation
3 * Author: Chris Bass <dash@rd.bbc.co.uk>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef __GST_SUBTITLE_H__
22 #define __GST_SUBTITLE_H__
23
24 #include <glib.h>
25 #include <gst/gst.h>
26 #include <gst/gstminiobject.h>
27
28 G_BEGIN_DECLS
29
30 typedef struct _GstSubtitleColor GstSubtitleColor;
31 typedef struct _GstSubtitleStyleSet GstSubtitleStyleSet;
32 typedef struct _GstSubtitleElement GstSubtitleElement;
33 typedef struct _GstSubtitleBlock GstSubtitleBlock;
34 typedef struct _GstSubtitleRegion GstSubtitleRegion;
35
36 /**
37 * GstSubtitleWritingMode:
38 * @GST_SUBTITLE_WRITING_MODE_LRTB: Text progression is left-to-right,
39 * top-to-bottom.
40 * @GST_SUBTITLE_WRITING_MODE_RLTB: Text progression is right-to-left,
41 * top-to-bottom.
42 * @GST_SUBTITLE_WRITING_MODE_TBRL: Text progression is top-to-bottom,
43 * right-to-left.
44 * @GST_SUBTITLE_WRITING_MODE_TBLR: Text progression is top-to-bottom,
45 * left-to-right.
46 *
47 * Writing mode of text content. The values define the direction of progression
48 * of both inline text (#GstSubtitleElements) and blocks of text
49 * (#GstSubtitleBlocks).
50 */
51 typedef enum {
52 GST_SUBTITLE_WRITING_MODE_LRTB,
53 GST_SUBTITLE_WRITING_MODE_RLTB,
54 GST_SUBTITLE_WRITING_MODE_TBRL,
55 GST_SUBTITLE_WRITING_MODE_TBLR
56 } GstSubtitleWritingMode;
57
58 /**
59 * GstSubtitleDisplayAlign:
60 * @GST_SUBTITLE_DISPLAY_ALIGN_BEFORE: Blocks should be aligned at the start of
61 * the containing region.
62 * @GST_SUBTITLE_DISPLAY_ALIGN_CENTER: Blocks should be aligned in the center
63 * of the containing region.
64 * @GST_SUBTITLE_DISPLAY_ALIGN_AFTER: Blocks should be aligned to the end of
65 * the containing region.
66 *
67 * Defines the alignment of text blocks within a region in the direction in
68 * which blocks are being stacked. For text that is written left-to-right and
69 * top-to-bottom, this corresponds to the vertical alignment of text blocks.
70 */
71 typedef enum {
72 GST_SUBTITLE_DISPLAY_ALIGN_BEFORE,
73 GST_SUBTITLE_DISPLAY_ALIGN_CENTER,
74 GST_SUBTITLE_DISPLAY_ALIGN_AFTER
75 } GstSubtitleDisplayAlign;
76
77 /**
78 * GstSubtitleBackgroundMode:
79 * @GST_SUBTITLE_BACKGROUND_MODE_ALWAYS: Background rectangle should be visible
80 * at all times.
81 * @GST_SUBTITLE_BACKGROUND_MODE_WHEN_ACTIVE: Background rectangle should be
82 * visible only when text is rendered into the corresponding region.
83 *
84 * Defines whether the background rectangle of a region should be visible at
85 * all times or only when text is rendered within it.
86 */
87 typedef enum {
88 GST_SUBTITLE_BACKGROUND_MODE_ALWAYS,
89 GST_SUBTITLE_BACKGROUND_MODE_WHEN_ACTIVE
90 } GstSubtitleBackgroundMode;
91
92 /**
93 * GstSubtitleOverflowMode:
94 * @GST_SUBTITLE_OVERFLOW_MODE_HIDDEN: If text and/or background rectangles
95 * flowed into the region overflow the bounds of that region, they should
96 * be clipped at the region boundary.
97 * @GST_SUBTITLE_OVERFLOW_MODE_VISIBLE: If text and/or background rectangles
98 * flowed into the region overflow the bounds of that region, they should be
99 * allowed to overflow the region boundary.
100 *
101 * Defines what should happen to text that overflows its containing region.
102 */
103 typedef enum {
104 GST_SUBTITLE_OVERFLOW_MODE_HIDDEN,
105 GST_SUBTITLE_OVERFLOW_MODE_VISIBLE
106 } GstSubtitleOverflowMode;
107
108 /**
109 * GstSubtitleColor:
110 * @r: Red value.
111 * @g: Green value.
112 * @b: Blue value.
113 * @a: Alpha value (0 = totally transparent; 255 = totally opaque).
114 *
115 * Describes an RGBA color.
116 */
117 struct _GstSubtitleColor {
118 guint8 r;
119 guint8 g;
120 guint8 b;
121 guint8 a;
122 };
123
124 /**
125 * GstSubtitleTextDirection:
126 * @GST_SUBTITLE_TEXT_DIRECTION_LTR: Text direction is left-to-right.
127 * @GST_SUBTITLE_TEXT_DIRECTION_RTL: Text direction is right-to-left.
128 *
129 * Defines the progression direction of unicode text that is being treated by
130 * the unicode bidirectional algorithm as embedded or overridden (see
131 * http://unicode.org/reports/tr9/ for more details of the unicode
132 * bidirectional algorithm).
133 */
134 typedef enum {
135 GST_SUBTITLE_TEXT_DIRECTION_LTR,
136 GST_SUBTITLE_TEXT_DIRECTION_RTL
137 } GstSubtitleTextDirection;
138
139 /**
140 * GstSubtitleTextAlign:
141 * @GST_SUBTITLE_TEXT_ALIGN_START: Text areas should be rendered at the
142 * start of the block area, with respect to the direction in which text is
143 * being rendered. For text that is rendered left-to-right this corresponds to
144 * the left of the block area; for text that is rendered right-to-left this
145 * corresponds to the right of the block area.
146 * @GST_SUBTITLE_TEXT_ALIGN_LEFT: Text areas should be rendered at the left of
147 * the block area.
148 * @GST_SUBTITLE_TEXT_ALIGN_CENTER: Text areas should be rendered at the center
149 * of the block area.
150 * @GST_SUBTITLE_TEXT_ALIGN_RIGHT: Text areas should be rendered at the right
151 * of the block area.
152 * @GST_SUBTITLE_TEXT_ALIGN_END: Text areas should be rendered at the end of
153 * the block area, with respect to the direction in which text is being
154 * rendered. For text that is rendered left-to-right this corresponds to the
155 * right of the block area; for text that is rendered right-to-left this
156 * corresponds to end of the block area.
157 *
158 * Defines how inline text areas within a block should be aligned within the
159 * block area.
160 */
161 typedef enum {
162 GST_SUBTITLE_TEXT_ALIGN_START,
163 GST_SUBTITLE_TEXT_ALIGN_LEFT,
164 GST_SUBTITLE_TEXT_ALIGN_CENTER,
165 GST_SUBTITLE_TEXT_ALIGN_RIGHT,
166 GST_SUBTITLE_TEXT_ALIGN_END
167 } GstSubtitleTextAlign;
168
169 /**
170 * GstSubtitleFontStyle:
171 * @GST_SUBTITLE_FONT_STYLE_NORMAL: Normal font style.
172 * @GST_SUBTITLE_FONT_STYLE_ITALIC: Italic font style.
173 *
174 * Defines styling that should be applied to the glyphs of a font used to
175 * render text within an inline text element.
176 */
177 typedef enum {
178 GST_SUBTITLE_FONT_STYLE_NORMAL,
179 GST_SUBTITLE_FONT_STYLE_ITALIC
180 } GstSubtitleFontStyle;
181
182 /**
183 * GstSubtitleFontWeight:
184 * @GST_SUBTITLE_FONT_WEIGHT_NORMAL: Normal weight.
185 * @GST_SUBTITLE_FONT_WEIGHT_BOLD: Bold weight.
186 *
187 * Defines the font weight that should be applied to the glyphs of a font used
188 * to render text within an inline text element.
189 */
190 typedef enum {
191 GST_SUBTITLE_FONT_WEIGHT_NORMAL,
192 GST_SUBTITLE_FONT_WEIGHT_BOLD
193 } GstSubtitleFontWeight;
194
195 /**
196 * GstSubtitleTextDecoration:
197 * @GST_SUBTITLE_TEXT_DECORATION_NONE: Text should not be decorated.
198 * @GST_SUBTITLE_TEXT_DECORATION_UNDERLINE: Text should be underlined.
199 *
200 * Defines the decoration that should be applied to the glyphs of a font used
201 * to render text within an inline text element.
202 */
203 typedef enum {
204 GST_SUBTITLE_TEXT_DECORATION_NONE,
205 GST_SUBTITLE_TEXT_DECORATION_UNDERLINE
206 } GstSubtitleTextDecoration;
207
208 /**
209 * GstSubtitleUnicodeBidi:
210 * @GST_SUBTITLE_UNICODE_BIDI_NORMAL: Text should progress according the the
211 * default behaviour of the Unicode bidirectional algorithm.
212 * @GST_SUBTITLE_UNICODE_BIDI_EMBED: Text should be treated as being embedded
213 * with a specific direction (given by a #GstSubtitleTextDecoration value
214 * defined elsewhere).
215 * @GST_SUBTITLE_UNICODE_BIDI_OVERRIDE: Text should be forced to have a
216 * specific direction (given by a #GstSubtitleTextDecoration value defined
217 * elsewhere).
218 *
219 * Defines directional embedding or override according to the Unicode
220 * bidirectional algorithm. See http://unicode.org/reports/tr9/ for more
221 * details of the Unicode bidirectional algorithm.
222 */
223 typedef enum {
224 GST_SUBTITLE_UNICODE_BIDI_NORMAL,
225 GST_SUBTITLE_UNICODE_BIDI_EMBED,
226 GST_SUBTITLE_UNICODE_BIDI_OVERRIDE
227 } GstSubtitleUnicodeBidi;
228
229 /**
230 * GstSubtitleWrapping:
231 * @GST_SUBTITLE_WRAPPING_ON: Lines that overflow the region boundary should be
232 * wrapped.
233 * @GST_SUBTITLE_WRAPPING_OFF: Lines that overflow the region boundary should
234 * not be wrapped.
235 *
236 * Defines how a renderer should treat lines of text that overflow the boundary
237 * of the region into which they are being rendered.
238 */
239 typedef enum {
240 GST_SUBTITLE_WRAPPING_ON,
241 GST_SUBTITLE_WRAPPING_OFF
242 } GstSubtitleWrapping;
243
244 /**
245 * GstSubtitleMultiRowAlign:
246 * @GST_SUBTITLE_MULTI_ROW_ALIGN_AUTO: Lines should be aligned according to the
247 * value of #GstSubtitleTextAlign associated with that text.
248 * @GST_SUBTITLE_MULTI_ROW_ALIGN_START: Lines should be aligned at their
249 * starting edge. The edge that is considered the starting edge depends upon
250 * the direction of that text.
251 * @GST_SUBTITLE_MULTI_ROW_ALIGN_CENTER: Lines should be center-aligned.
252 * @GST_SUBTITLE_MULTI_ROW_ALIGN_END: Lines should be aligned at their trailing
253 * edge. The edge that is considered the trailing edge depends upon the
254 * direction of that text.
255 *
256 * Defines how multiple 'rows' (i.e, lines) in a block should be aligned
257 * relative to each other.
258 *
259 * This is based upon the ebutts:multiRowAlign attribute defined in the
260 * EBU-TT-D specification.
261 */
262 typedef enum {
263 GST_SUBTITLE_MULTI_ROW_ALIGN_AUTO,
264 GST_SUBTITLE_MULTI_ROW_ALIGN_START,
265 GST_SUBTITLE_MULTI_ROW_ALIGN_CENTER,
266 GST_SUBTITLE_MULTI_ROW_ALIGN_END
267 } GstSubtitleMultiRowAlign;
268
269 /**
270 * GstSubtitleStyleSet:
271 * @text_direction: Defines the direction of text that has been declared by the
272 * #GstSubtitleStyleSet:unicode_bidi attribute to be embedded or overridden.
273 * Applies to both #GstSubtitleBlocks and #GstSubtitleElements.
274 * @font_family: The name of the font family that should be used to render the
275 * text of an inline element. Applies only to #GstSubtitleElements.
276 * @font_size: The size of the font that should be used to render the text
277 * of an inline element. The size is given as a multiple of the display height,
278 * where 1.0 equals the height of the display. Applies only to
279 * #GstSubtitleElements.
280 * @line_height: The inter-baseline separation between lines generated when
281 * rendering inline text elements within a block area. The height is given as a
282 * multiple of the the overall display height, where 1.0 equals the height of
283 * the display. Applies only to #GstSubtitleBlocks.
284 * @text_align: Controls the alignent of lines of text within a block area.
285 * Note that this attribute does not control the alignment of lines relative to
286 * each other within a block area: that is determined by
287 * #GstSubtitleStyleSet:multi_row_align. Applies only to #GstSubtitleBlocks.
288 * @color: The color that should be used when rendering the text of an inline
289 * element. Applies only to #GstSubtitleElements.
290 * @background_color: The color of the rectangle that should be rendered behind
291 * the contents of a #GstSubtitleRegion, #GstSubtitleBlock or
292 * #GstSubtitleElement.
293 * @font_style: The style of the font that should be used to render the text
294 * of an inline element. Applies only to #GstSubtitleElements.
295 * @font_weight: The weight of the font that should be used to render the text
296 * of an inline element. Applies only to #GstSubtitleElements.
297 * @text_decoration: The decoration that should be applied to the text of an
298 * inline element. Applies only to #GstSubtitleElements.
299 * @unicode_bidi: Controls how unicode text within a block or inline element
300 * should be treated by the unicode bidirectional algorithm. Applies to both
301 * #GstSubtitleBlocks and #GstSubtitleElements.
302 * @wrap_option: Defines whether or not automatic line breaking should apply to
303 * the lines generated when rendering a block of text elements. Applies only to
304 * #GstSubtitleBlocks.
305 * @multi_row_align: Defines how 'rows' (i.e., lines) within a text block
306 * should be aligned relative to each other. Note that this attribute does not
307 * determine how a block of text is aligned within that block area: that is
308 * determined by @text_align. Applies only to #GstSubtitleBlocks.
309 * @line_padding: Defines how much horizontal padding should be added on the
310 * start and end of each rendered line; this allows the insertion of space
311 * between the start/end of text lines and their background rectangles for
312 * better-looking subtitles. This is based upon the ebutts:linePadding
313 * attribute defined in the EBU-TT-D specification. Applies only to
314 * #GstSubtitleBlocks.
315 * @origin_x: The horizontal origin of a region into which text blocks may be
316 * rendered. Given as a multiple of the overall display width, where 1.0 equals
317 * the width of the display. Applies only to #GstSubtitleRegions.
318 * @origin_y: The vertical origin of a region into which text blocks may be
319 * rendered. Given as a multiple of the overall display height, where 1.0
320 * equals the height of the display. Applies only to #GstSubtitleRegions.
321 * @extent_w: The horizontal extent of a region into which text blocks may be
322 * rendered. Given as a multiple of the overall display width, where 1.0 equals
323 * the width of the display. Applies only to #GstSubtitleRegions.
324 * @extent_h: The vertical extent of a region into which text blocks may be
325 * rendered. Given as a multiple of the overall display height, where 1.0
326 * equals the height of the display. Applies only to #GstSubtitleRegions.
327 * @display_align: The alignment of generated text blocks in the direction in
328 * which blocks are being stacked. For text that flows left-to-right and
329 * top-to-bottom, for example, this corresponds to the vertical alignment of
330 * text blocks. Applies only to #GstSubtitleRegions.
331 * @padding_start: The horizontal indent of text from the leading edge of a
332 * region into which blocks may be rendered. Given as a multiple of the overall
333 * display width, where 1.0 equals the width of the display. Applies only to
334 * #GstSubtitleRegions.
335 * @padding_end: The horizontal indent of text from the trailing edge of a
336 * region into which blocks may be rendered. Given as a multiple of the overall
337 * display width, where 1.0 equals the width of the display. Applies only to
338 * #GstSubtitleRegions.
339 * @padding_before: The vertical indent of text from the top edge of a region
340 * into which blocks may be rendered. Given as a multiple of the overall
341 * display height, where 1.0 equals the height of the display. Applies only to
342 * #GstSubtitleRegions.
343 * @padding_after: The vertical indent of text from the bottom edge of a
344 * region into which blocks may be rendered. Given as a multiple of the overall
345 * display height, where 1.0 equals the height of the display. Applies only to
346 * #GstSubtitleRegions.
347 * @writing_mode: Defines the direction in which both inline elements and
348 * blocks should be stacked when rendered into an on-screen region. Applies
349 * only to #GstSubtitleRegions.
350 * @show_background: Defines whether the background of a region should be
351 * displayed at all times or only when it has text rendered into it. Applies
352 * only to #GstSubtitleRegions.
353 * @overflow: Defines what should happen if text and background rectangles
354 * generated by rendering text blocks overflow the size of their containing
355 * region. Applies only to #GstSubtitleRegions.
356 * @fill_line_gap: Controls whether the rendered backgrounds of text elements
357 * in a line fill the whole space between that line and adjacent lines or
358 * extends only to the font height of the text in the individual elements (thus
359 * this field controls whether or not there are gaps between backgrounds
360 * through which the underlying video can be seen). Applies only to
361 * #GstSubtitleBlocks.
362 *
363 * Holds a set of attributes that describes the styling and layout that apply
364 * to #GstSubtitleRegion, #GstSubtitleBlock and/or #GstSubtitleElement objects.
365 *
366 * Note that, though each of the above object types have an associated
367 * #GstSubtitleStyleSet, not all attributes in a #GstSubtitleStyleSet type
368 * apply to all object types: #GstSubtitleStyleSet:overflow applies only to
369 * #GstSubtitleRegions, for example, while #GstSubtitleStyleSet:font_style
370 * applies only to #GstSubtitleElements. Some attributes apply to multiple
371 * object types: #GstSubtitleStyleSet:background_color, for example, applies to
372 * all object types. The types to which each attribute applies is given in the
373 * description of that attribute below.
374 */
375 struct _GstSubtitleStyleSet
376 {
377 GstMiniObject mini_object;
378
379 GstSubtitleTextDirection text_direction;
380 gchar *font_family;
381 gdouble font_size;
382 gdouble line_height;
383 GstSubtitleTextAlign text_align;
384 GstSubtitleColor color;
385 GstSubtitleColor background_color;
386 GstSubtitleFontStyle font_style;
387 GstSubtitleFontWeight font_weight;
388 GstSubtitleTextDecoration text_decoration;
389 GstSubtitleUnicodeBidi unicode_bidi;
390 GstSubtitleWrapping wrap_option;
391 GstSubtitleMultiRowAlign multi_row_align;
392 gdouble line_padding;
393 gdouble origin_x, origin_y;
394 gdouble extent_w, extent_h;
395 GstSubtitleDisplayAlign display_align;
396 gdouble padding_start, padding_end, padding_before, padding_after;
397 GstSubtitleWritingMode writing_mode;
398 GstSubtitleBackgroundMode show_background;
399 GstSubtitleOverflowMode overflow;
400 gboolean fill_line_gap;
401
402 /*< private >*/
403 gpointer _gst_reserved[GST_PADDING];
404 };
405
406 GType gst_subtitle_style_set_get_type (void);
407
408 GstSubtitleStyleSet * gst_subtitle_style_set_new (void);
409
410 /**
411 * gst_subtitle_style_set_ref:
412 * @style_set: A #GstSubtitleStyleSet.
413 *
414 * Increments the refcount of @style_set.
415 *
416 * Returns: (transfer full): @style_set.
417 */
418 static inline GstSubtitleStyleSet *
gst_subtitle_style_set_ref(GstSubtitleStyleSet * style_set)419 gst_subtitle_style_set_ref (GstSubtitleStyleSet * style_set)
420 {
421 return (GstSubtitleStyleSet *)
422 gst_mini_object_ref (GST_MINI_OBJECT_CAST (style_set));
423 }
424
425 /**
426 * gst_subtitle_style_set_unref:
427 * @style_set: (transfer full): A #GstSubtitleStyleSet.
428 *
429 * Decrements the refcount of @style_set. If the refcount reaches 0, @style_set
430 * will be freed.
431 */
432 static inline void
gst_subtitle_style_set_unref(GstSubtitleStyleSet * style_set)433 gst_subtitle_style_set_unref (GstSubtitleStyleSet * style_set)
434 {
435 gst_mini_object_unref (GST_MINI_OBJECT_CAST (style_set));
436 }
437
438
439 /**
440 * GstSubtitleElement:
441 * @mini_object: The parent #GstMiniObject.
442 * @style_set: Styling associated with this element.
443 * @text_index: Index into the #GstBuffer associated with this
444 * #GstSubtitleElement; the index identifies the #GstMemory within the
445 * #GstBuffer that holds the #GstSubtitleElement's text.
446 * @suppress_whitespace: Indicates whether or not a renderer should suppress
447 * whitespace in the element's text.
448 *
449 * Represents an inline text element.
450 *
451 * In TTML this would correspond to inline text resulting from a <span>
452 * element, an anonymous span (e.g., text within a <p> tag), or a
453 * <br> element.
454 */
455 struct _GstSubtitleElement
456 {
457 GstMiniObject mini_object;
458
459 GstSubtitleStyleSet *style_set;
460 guint text_index;
461 gboolean suppress_whitespace;
462
463 /*< private >*/
464 gpointer _gst_reserved[GST_PADDING];
465 };
466
467 GType gst_subtitle_element_get_type (void);
468
469 GstSubtitleElement * gst_subtitle_element_new (GstSubtitleStyleSet * style_set,
470 guint text_index, gboolean suppress_whitespace);
471
472 /**
473 * gst_subtitle_element_ref:
474 * @element: A #GstSubtitleElement.
475 *
476 * Increments the refcount of @element.
477 *
478 * Returns: (transfer full): @element.
479 */
480 static inline GstSubtitleElement *
gst_subtitle_element_ref(GstSubtitleElement * element)481 gst_subtitle_element_ref (GstSubtitleElement * element)
482 {
483 return (GstSubtitleElement *)
484 gst_mini_object_ref (GST_MINI_OBJECT_CAST (element));
485 }
486
487 /**
488 * gst_subtitle_element_unref:
489 * @element: (transfer full): A #GstSubtitleElement.
490 *
491 * Decrements the refcount of @element. If the refcount reaches 0, @element
492 * will be freed.
493 */
494 static inline void
gst_subtitle_element_unref(GstSubtitleElement * element)495 gst_subtitle_element_unref (GstSubtitleElement * element)
496 {
497 gst_mini_object_unref (GST_MINI_OBJECT_CAST (element));
498 }
499
500
501 /**
502 * GstSubtitleBlock:
503 * @mini_object: The parent #GstMiniObject.
504 * @style_set: Styling associated with this block.
505 *
506 * Represents a text block made up of one or more inline text elements (i.e.,
507 * one or more #GstSubtitleElements).
508 *
509 * In TTML this would correspond to the block of text resulting from the inline
510 * elements within a single <p>.
511 */
512 struct _GstSubtitleBlock
513 {
514 GstMiniObject mini_object;
515
516 GstSubtitleStyleSet *style_set;
517
518 /*< private >*/
519 GPtrArray *elements;
520 gpointer _gst_reserved[GST_PADDING];
521 };
522
523 GType gst_subtitle_block_get_type (void);
524
525 GstSubtitleBlock * gst_subtitle_block_new (GstSubtitleStyleSet * style_set);
526
527 void gst_subtitle_block_add_element (
528 GstSubtitleBlock * block,
529 GstSubtitleElement * element);
530
531 guint gst_subtitle_block_get_element_count (const GstSubtitleBlock * block);
532
533 GstSubtitleElement * gst_subtitle_block_get_element (
534 const GstSubtitleBlock * block, guint index);
535
536 /**
537 * gst_subtitle_block_ref:
538 * @block: A #GstSubtitleBlock.
539 *
540 * Increments the refcount of @block.
541 *
542 * Returns: (transfer full): @block.
543 */
544 static inline GstSubtitleBlock *
gst_subtitle_block_ref(GstSubtitleBlock * block)545 gst_subtitle_block_ref (GstSubtitleBlock * block)
546 {
547 return (GstSubtitleBlock *)
548 gst_mini_object_ref (GST_MINI_OBJECT_CAST (block));
549 }
550
551 /**
552 * gst_subtitle_block_unref:
553 * @block: (transfer full): A #GstSubtitleBlock.
554 *
555 * Decrements the refcount of @block. If the refcount reaches 0, @block will
556 * be freed.
557 */
558 static inline void
gst_subtitle_block_unref(GstSubtitleBlock * block)559 gst_subtitle_block_unref (GstSubtitleBlock * block)
560 {
561 gst_mini_object_unref (GST_MINI_OBJECT_CAST (block));
562 }
563
564
565 /**
566 * GstSubtitleRegion:
567 * @mini_object: The parent #GstMiniObject.
568 * @style_set: Styling associated with this region.
569 *
570 * Represents an on-screen region in which is displayed zero or more
571 * #GstSubtitleBlocks.
572 *
573 * In TTML this corresponds to a <region> into which zero or more
574 * <p>s may be rendered. A #GstSubtitleRegion allows a background
575 * rectangle to be displayed in a region area even if no text blocks are
576 * rendered into it, as per the behaviour allowed by TTML regions whose
577 * tts:showBackground style attribute is set to "always".
578 */
579 struct _GstSubtitleRegion
580 {
581 GstMiniObject mini_object;
582
583 GstSubtitleStyleSet *style_set;
584
585 /*< private >*/
586 GPtrArray *blocks;
587 gpointer _gst_reserved[GST_PADDING];
588 };
589
590 GType gst_subtitle_region_get_type (void);
591
592 GstSubtitleRegion * gst_subtitle_region_new (GstSubtitleStyleSet * style_set);
593
594 void gst_subtitle_region_add_block (
595 GstSubtitleRegion * region,
596 GstSubtitleBlock * block);
597
598 guint gst_subtitle_region_get_block_count (const GstSubtitleRegion * region);
599
600 const GstSubtitleBlock * gst_subtitle_region_get_block (
601 const GstSubtitleRegion * region, guint index);
602
603 /**
604 * gst_subtitle_region_ref:
605 * @region: A #GstSubtitleRegion.
606 *
607 * Increments the refcount of @region.
608 *
609 * Returns: (transfer full): @region.
610 */
611 static inline GstSubtitleRegion *
gst_subtitle_region_ref(GstSubtitleRegion * region)612 gst_subtitle_region_ref (GstSubtitleRegion * region)
613 {
614 return (GstSubtitleRegion *)
615 gst_mini_object_ref (GST_MINI_OBJECT_CAST (region));
616 }
617
618 /**
619 * gst_subtitle_region_unref:
620 * @region: (transfer full): A #GstSubtitleRegion.
621 *
622 * Decrements the refcount of @region. If the refcount reaches 0, @region will
623 * be freed.
624 */
625 static inline void
gst_subtitle_region_unref(GstSubtitleRegion * region)626 gst_subtitle_region_unref (GstSubtitleRegion * region)
627 {
628 gst_mini_object_unref (GST_MINI_OBJECT_CAST (region));
629 }
630
631 G_END_DECLS
632
633 #endif /* __GST_SUBTITLE_H__ */
634