summaryrefslogtreecommitdiff
path: root/gst/dvbsuboverlay/dvb-sub.h
blob: 7faa31f456f82db20faf1f6b0eb6f91d4b8341cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * libdvbsub - DVB subtitle decoding
 * Copyright (C) Mart Raudsepp 2009 <mart.raudsepp@artecdesign.ee>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef _DVB_SUB_H_
#define _DVB_SUB_H_

#include <glib.h>

G_BEGIN_DECLS

typedef struct _DvbSub DvbSub;

/**
 * DVBSubtitlePicture:
 * @data: the data in the form of palette indices, each byte represents one pixel
 *   as an index into the @palette.
 * @palette: the palette used for this subtitle rectangle, up to 256 items depending
 *   on the depth of the subpicture; each palette item is in ARGB form, 8-bits per channel.
 * @palette_bits_count: the amount of bits used in indeces into @palette in @data.
 * @rowstride: the number of bytes between the start of a row and the start of the next row.
 *
 * A structure representing the contents of a subtitle rectangle.
 *
 * FIXME: Expose the depth of the palette, and perhaps also the height in this struct.
 */
typedef struct DVBSubtitlePicture {
	guint8 *data;
	guint32 *palette;
	guint8 palette_bits_count;
	int rowstride;
} DVBSubtitlePicture;

/**
 * DVBSubtitleRect:
 * @x: x coordinate of top left corner
 * @y: y coordinate of top left corner
 * @w: the width of this subpicture rectangle
 * @h: the height of this subpicture rectangle
 * @pict: the content of this subpicture rectangle
 *
 * A structure representing one subtitle objects position, dimension and content.
 */
typedef struct DVBSubtitleRect {
	int x;
	int y;
	int w;
	int h;

	DVBSubtitlePicture pict;
} DVBSubtitleRect;

/**
 * DVBSubtitleWindow
 * @version: version 
 * @display_window_flag: window_* are valid
 * @display_width: assumed width of display
 * @display_height: assumed height of display
 * @window_x: x coordinate of top left corner of the subtitle window
 * @window_y: y coordinate of top left corner of the subtitle window
 * @window_width: width of the subtitle window
 * @window_height: height of the subtitle window
 *
 * A structure presenting display and window information
 * display definition segment from ETSI EN 300 743 V1.3.1
 */
typedef struct DVBSubtitleWindow {
    gint version;
    gint window_flag;

    gint display_width;
    gint display_height;

    gint window_x;
    gint window_y;
    gint window_width;
    gint window_height;
} DVBSubtitleWindow;

/**
 * DVBSubtitles:
 * @num_rects: the number of #DVBSubtitleRect in @rects
 * @rects: dynamic array of #DVBSubtitleRect
 *
 * A structure representing a set of subtitle objects.
 */
typedef struct DVBSubtitles {
	guint64 pts;
	guint8 page_time_out;
	guint num_rects;
	DVBSubtitleRect *rects;
	DVBSubtitleWindow display_def;
} DVBSubtitles;

/**
 * DvbSubCallbacks:
 * @new_data: called when new subpicture data is available for display. @dvb_sub
 *    is the #DvbSub instance this callback originates from; @subs is the set of
 *    subtitle objects that should be display for no more than @page_time_out
 *    seconds at @pts; @user_data is the same user_data as was passed through
 *    dvb_sub_set_callbacks(); The callback handler is responsible for eventually
 *    cleaning up the subpicture data @subs with a call to dvb_subtitles_free()
 *
 * A set of callbacks that can be installed on the #DvbSub with
 * dvb_sub_set_callbacks().
 */
typedef struct {
	void     (*new_data) (DvbSub *dvb_sub, DVBSubtitles * subs, gpointer user_data);
	/*< private >*/
	gpointer _dvb_sub_reserved[3];
} DvbSubCallbacks;

DvbSub  *dvb_sub_new           (void);
void     dvb_sub_free          (DvbSub * sub);

gint     dvb_sub_feed_with_pts (DvbSub *dvb_sub, guint64 pts, guint8 *data, gint len);
void     dvb_sub_set_callbacks (DvbSub *dvb_sub, DvbSubCallbacks *callbacks, gpointer user_data);
void     dvb_subtitles_free    (DVBSubtitles *sub);

G_END_DECLS

#endif /* _DVB_SUB_H_ */