1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ 2 /* 3 * libdvbsub - DVB subtitle decoding 4 * Copyright (C) Mart Raudsepp 2009 <mart.raudsepp@artecdesign.ee> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef _DVB_SUB_H_ 22 #define _DVB_SUB_H_ 23 24 #include <glib.h> 25 26 G_BEGIN_DECLS 27 28 typedef struct _DvbSub DvbSub; 29 30 /** 31 * DVBSubtitlePicture: 32 * @data: the data in the form of palette indices, each byte represents one pixel 33 * as an index into the @palette. 34 * @palette: the palette used for this subtitle rectangle, up to 256 items depending 35 * on the depth of the subpicture; each palette item is in ARGB form, 8-bits per channel. 36 * @palette_bits_count: the amount of bits used in indices into @palette in @data. 37 * @rowstride: the number of bytes between the start of a row and the start of the next row. 38 * 39 * A structure representing the contents of a subtitle rectangle. 40 * 41 * FIXME: Expose the depth of the palette, and perhaps also the height in this struct. 42 */ 43 typedef struct DVBSubtitlePicture { 44 guint8 *data; 45 guint32 *palette; 46 guint8 palette_bits_count; 47 int rowstride; 48 } DVBSubtitlePicture; 49 50 /** 51 * DVBSubtitleRect: 52 * @x: x coordinate of top left corner 53 * @y: y coordinate of top left corner 54 * @w: the width of this subpicture rectangle 55 * @h: the height of this subpicture rectangle 56 * @pict: the content of this subpicture rectangle 57 * 58 * A structure representing one subtitle objects position, dimension and content. 59 */ 60 typedef struct DVBSubtitleRect { 61 int x; 62 int y; 63 int w; 64 int h; 65 66 DVBSubtitlePicture pict; 67 } DVBSubtitleRect; 68 69 /** 70 * DVBSubtitleWindow 71 * @version: version 72 * @display_window_flag: window_* are valid 73 * @display_width: assumed width of display 74 * @display_height: assumed height of display 75 * @window_x: x coordinate of top left corner of the subtitle window 76 * @window_y: y coordinate of top left corner of the subtitle window 77 * @window_width: width of the subtitle window 78 * @window_height: height of the subtitle window 79 * 80 * A structure presenting display and window information 81 * display definition segment from ETSI EN 300 743 V1.3.1 82 */ 83 typedef struct DVBSubtitleWindow { 84 gint version; 85 gint window_flag; 86 87 gint display_width; 88 gint display_height; 89 90 gint window_x; 91 gint window_y; 92 gint window_width; 93 gint window_height; 94 } DVBSubtitleWindow; 95 96 /** 97 * DVBSubtitles: 98 * @num_rects: the number of #DVBSubtitleRect in @rects 99 * @rects: dynamic array of #DVBSubtitleRect 100 * 101 * A structure representing a set of subtitle objects. 102 */ 103 typedef struct DVBSubtitles { 104 guint64 pts; 105 guint8 page_time_out; 106 guint num_rects; 107 DVBSubtitleRect *rects; 108 DVBSubtitleWindow display_def; 109 } DVBSubtitles; 110 111 /** 112 * DvbSubCallbacks: 113 * @new_data: called when new subpicture data is available for display. @dvb_sub 114 * is the #DvbSub instance this callback originates from; @subs is the set of 115 * subtitle objects that should be display for no more than @page_time_out 116 * seconds at @pts; @user_data is the same user_data as was passed through 117 * dvb_sub_set_callbacks(); The callback handler is responsible for eventually 118 * cleaning up the subpicture data @subs with a call to dvb_subtitles_free() 119 * 120 * A set of callbacks that can be installed on the #DvbSub with 121 * dvb_sub_set_callbacks(). 122 */ 123 typedef struct { 124 void (*new_data) (DvbSub *dvb_sub, DVBSubtitles * subs, gpointer user_data); 125 /*< private >*/ 126 gpointer _dvb_sub_reserved[3]; 127 } DvbSubCallbacks; 128 129 DvbSub *dvb_sub_new (void); 130 void dvb_sub_free (DvbSub * sub); 131 132 gint dvb_sub_feed_with_pts (DvbSub *dvb_sub, guint64 pts, guint8 *data, gint len); 133 void dvb_sub_set_callbacks (DvbSub *dvb_sub, DvbSubCallbacks *callbacks, gpointer user_data); 134 void dvb_subtitles_free (DVBSubtitles *sub); 135 136 G_END_DECLS 137 138 #endif /* _DVB_SUB_H_ */ 139