xine-lib  1.2.10
osd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2000-2018 the xine project
3  *
4  * This file is part of xine, a free video player.
5  *
6  * xine is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * xine 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19  *
20  * OSD stuff (text and graphic primitives)
21  */
22 
23 #ifndef HAVE_OSD_H
24 #define HAVE_OSD_H
25 
26 #ifdef HAVE_ICONV
27 # include <iconv.h>
28 #endif
29 
30 #include <xine/video_overlay.h>
31 
32 typedef struct osd_object_s osd_object_t;
34 typedef struct osd_font_s osd_font_t;
35 typedef struct osd_ft2context_s osd_ft2context_t;
36 
37 struct osd_object_s {
40 
41  int width, height; /* work area dimentions */
42  uint8_t *area; /* work area */
43  int area_touched; /* work area was used for painting */
44  int display_x,display_y; /* where to display it in screen */
45 
46  /* video output area within osd extent */
49 
50  /* extent of reference coordinate system */
52 
53  /* clipping box inside work area */
54  int x1, y1;
55  int x2, y2;
56 
57  uint32_t color[OVL_PALETTE_SIZE]; /* color lookup table */
58  uint8_t trans[OVL_PALETTE_SIZE]; /* mixer key table */
59 
60 #ifdef HAVE_ICONV
61  iconv_t cd; /* iconv handle of encoding */
62  char *encoding; /* name of encoding */
63 #endif
64 
67 
68 
69  /* this holds an optional ARGB overlay, which
70  * is only be used by supported video_out modules.
71  * right now this is only vdpau */
73 
74  int32_t handle;
75 };
76 
77 /* this one is public */
78 struct xine_osd_s {
80 };
81 
83 
85 
86  /*
87  * open a new osd object. this will allocated an empty (all zero) drawing
88  * area where graphic primitives may be used.
89  * It is ok to specify big width and height values. The render will keep
90  * track of the smallest changed area to not generate too big overlays.
91  * A default palette is initialized (i sugest keeping color 0 as transparent
92  * for the sake of simplicity)
93  */
94  osd_object_t* (*new_object) (osd_renderer_t *this_gen, int width, int height);
95 
96  /*
97  * free osd object
98  */
99  void (*free_object) (osd_object_t *osd_to_close);
100 
101 
102  /*
103  * send the osd to be displayed at given pts (0=now)
104  * the object is not changed. there may be subsequent drawing on it.
105  */
106  int (*show) (osd_object_t *osd, int64_t vpts );
107 
108  /*
109  * send event to hide osd at given pts (0=now)
110  * the object is not changed. there may be subsequent drawing on it.
111  */
112  int (*hide) (osd_object_t *osd, int64_t vpts );
113 
114  /*
115  * draw point.
116  */
117  void (*point) (osd_object_t *osd, int x, int y, int color);
118 
119  /*
120  * Bresenham line implementation on osd object
121  */
122  void (*line) (osd_object_t *osd,
123  int x1, int y1, int x2, int y2, int color );
124 
125  /*
126  * filled rectangle
127  */
128  void (*filled_rect) (osd_object_t *osd,
129  int x1, int y1, int x2, int y2, int color );
130 
131  /*
132  * set palette (color and transparency)
133  *
134  * NOTE: both color and trans arrays must hold OVL_PALETTE_SIZE entries !
135  */
136  void (*set_palette) (osd_object_t *osd, const uint32_t *color, const uint8_t *trans );
137 
138  /*
139  * set on existing text palette
140  * (-1 to set used specified palette)
141  *
142  * color_base specifies the first color index to use for this text
143  * palette. The OSD palette is then modified starting at this
144  * color index, up to the size of the text palette.
145  *
146  * Use OSD_TEXT1, OSD_TEXT2, ... for some preasssigned color indices.
147  */
148  void (*set_text_palette) (osd_object_t *osd, int palette_number,
149  int color_base );
150 
151  /*
152  * get palette (color and transparency)
153  */
154  void (*get_palette) (osd_object_t *osd, uint32_t *color,
155  uint8_t *trans);
156 
157  /*
158  * set position were overlay will be blended
159  */
160  void (*set_position) (osd_object_t *osd, int x, int y);
161 
162  /*
163  * set the font of osd object
164  */
165 
166  int (*set_font) (osd_object_t *osd, const char *fontname, int size);
167 
168  /*
169  * set encoding of text
170  *
171  * NULL ... no conversion (iso-8859-1)
172  * "" ... locale encoding
173  */
174  int (*set_encoding) (osd_object_t *osd, const char *encoding);
175 
176  /*
177  * render text in current encoding on x,y position
178  * no \n yet
179  *
180  * The text is assigned the colors starting at the index specified by
181  * color_base up to the size of the text palette.
182  *
183  * Use OSD_TEXT1, OSD_TEXT2, ... for some preasssigned color indices.
184  */
185  int (*render_text) (osd_object_t *osd, int x1, int y1,
186  const char *text, int color_base);
187 
188  /*
189  * get width and height of how text will be renderized
190  */
191  int (*get_text_size) (osd_object_t *osd, const char *text,
192  int *width, int *height);
193 
194  /*
195  * close osd rendering engine
196  * loaded fonts are unloaded
197  * osd objects are closed
198  */
199  void (*close) (osd_renderer_t *this_gen);
200 
201  /*
202  * clear an osd object (empty drawing area)
203  */
204  void (*clear) (osd_object_t *osd );
205 
206  /*
207  * paste a bitmap with optional palette mapping
208  */
209  void (*draw_bitmap) (osd_object_t *osd, uint8_t *bitmap,
210  int x1, int y1, int width, int height,
211  uint8_t *palette_map);
212 
213  /*
214  * send the osd to be displayed (unscaled) at given pts (0=now)
215  * the object is not changed. there may be subsequent drawing on it.
216  * overlay is blended at output (screen) resolution.
217  */
218  int (*show_unscaled) (osd_object_t *osd, int64_t vpts );
219 
220  /*
221  * see xine.h for defined XINE_OSD_CAP_ values.
222  */
223  uint32_t (*get_capabilities) (osd_object_t *osd);
224 
225  /*
226  * define extent of reference coordinate system for video
227  * resolution independent osds. both sizes must be > 0 to
228  * take effect. otherwise, video resolution will be used.
229  */
230  void (*set_extent) (osd_object_t *osd, int extent_width, int extent_height);
231 
232  /*
233  * set an argb buffer to be blended into video
234  * the buffer must exactly match the osd dimensions
235  * and stay valid while the osd is on screen. pass
236  * a NULL pointer to safely remove the buffer from
237  * the osd layer. only the dirty area will be
238  * updated on screen. for convinience the whole
239  * osd object will be considered dirty when setting
240  * a different buffer pointer.
241  * see also XINE_OSD_CAP_ARGB_LAYER
242  */
243  void (*set_argb_buffer) (osd_object_t *osd, uint32_t *argb_buffer,
244  int dirty_x, int dirty_y, int dirty_width, int dirty_height);
245 
246  /*
247  * osd video window defines an area withing osd extent where the
248  * video shall be scaled to while an osd is displayed on screen.
249  * both width and height must be > 0 to take effect.
250  */
252  int window_x, int window_y, int window_width, int window_height);
253 
254  /* private stuff */
255 
256  pthread_mutex_t osd_mutex;
258  osd_object_t *osds; /* instances of osd */
259  osd_font_t *fonts; /* loaded fonts */
260  int textpalette; /* default textpalette */
261 
262 };
263 
264 /*
265  * initialize the osd rendering engine
266  */
268 
269 
270 /*
271  * The size of a text palette
272  */
273 
274 #define TEXT_PALETTE_SIZE 11
275 
276 /*
277  * Preassigned color indices for rendering text
278  * (more can be added, not exceeding OVL_PALETTE_SIZE)
279  */
280 
281 #define OSD_TEXT1 (0 * TEXT_PALETTE_SIZE)
282 #define OSD_TEXT2 (1 * TEXT_PALETTE_SIZE)
283 #define OSD_TEXT3 (2 * TEXT_PALETTE_SIZE)
284 #define OSD_TEXT4 (3 * TEXT_PALETTE_SIZE)
285 #define OSD_TEXT5 (4 * TEXT_PALETTE_SIZE)
286 #define OSD_TEXT6 (5 * TEXT_PALETTE_SIZE)
287 #define OSD_TEXT7 (6 * TEXT_PALETTE_SIZE)
288 #define OSD_TEXT8 (7 * TEXT_PALETTE_SIZE)
289 #define OSD_TEXT9 (8 * TEXT_PALETTE_SIZE)
290 #define OSD_TEXT10 (9 * TEXT_PALETTE_SIZE)
291 
292 /*
293  * Defined palettes for rendering osd text
294  * (more can be added later)
295  */
296 
297 #define NUMBER_OF_TEXT_PALETTES 4
298 #define TEXTPALETTE_WHITE_BLACK_TRANSPARENT 0
299 #define TEXTPALETTE_WHITE_NONE_TRANSPARENT 1
300 #define TEXTPALETTE_WHITE_NONE_TRANSLUCID 2
301 #define TEXTPALETTE_YELLOW_BLACK_TRANSPARENT 3
302 
303 #endif
304 
argb_layer_s
Definition: video_out.h:463
osd_object_s::video_window_y
int video_window_y
Definition: osd.h:47
osd_ft2context_t
struct osd_ft2context_s osd_ft2context_t
Definition: osd.h:35
xine_stream_s
Definition: xine_internal.h:123
osd_object_s::x1
int x1
Definition: osd.h:54
osd_renderer_s::close
void(* close)(osd_renderer_t *this_gen)
Definition: osd.h:199
osd_renderer_s::show
int(* show)(osd_object_t *osd, int64_t vpts)
Definition: osd.h:106
osd_renderer_s::hide
int(* hide)(osd_object_t *osd, int64_t vpts)
Definition: osd.h:112
osd_renderer_s::get_palette
void(* get_palette)(osd_object_t *osd, uint32_t *color, uint8_t *trans)
Definition: osd.h:154
osd_renderer_s::set_video_window
void(* set_video_window)(osd_object_t *osd, int window_x, int window_y, int window_width, int window_height)
Definition: osd.h:251
xine_osd_s::osd
osd_object_t osd
Definition: osd.h:79
video_overlay.h
osd_renderer_s::textpalette
int textpalette
Definition: osd.h:260
osd_renderer_s::free_object
void(* free_object)(osd_object_t *osd_to_close)
Definition: osd.h:99
osd_renderer_s::draw_bitmap
void(* draw_bitmap)(osd_object_t *osd, uint8_t *bitmap, int x1, int y1, int width, int height, uint8_t *palette_map)
Definition: osd.h:209
osd_object_s::y2
int y2
Definition: osd.h:55
osd_renderer_s::fonts
osd_font_t * fonts
Definition: osd.h:259
osd_object_s
Definition: osd.h:37
osd_object_s::next
osd_object_t * next
Definition: osd.h:38
osd_renderer_s::osd_mutex
pthread_mutex_t osd_mutex
Definition: osd.h:256
osd_renderer_s::stream
xine_stream_t * stream
Definition: osd.h:84
osd_object_s::extent_width
int extent_width
Definition: osd.h:51
osd_font_s
Definition: osd.c:208
iconv_t
int iconv_t
Definition: asfheader.c:67
OVL_PALETTE_SIZE
#define OVL_PALETTE_SIZE
Definition: video_out.h:280
osd_object_s::y1
int y1
Definition: osd.h:54
osd_renderer_s::clear
void(* clear)(osd_object_t *osd)
Definition: osd.h:204
osd_object_s::area
uint8_t * area
Definition: osd.h:42
osd_renderer_s::get_capabilities
uint32_t(* get_capabilities)(osd_object_t *osd)
Definition: osd.h:223
osd_object_s::handle
int32_t handle
Definition: osd.h:74
osd_renderer_s::set_encoding
int(* set_encoding)(osd_object_t *osd, const char *encoding)
Definition: osd.h:174
osd_renderer_s::set_palette
void(* set_palette)(osd_object_t *osd, const uint32_t *color, const uint8_t *trans)
Definition: osd.h:136
_x_osd_renderer_init
osd_renderer_t * _x_osd_renderer_init(xine_stream_t *stream)
Definition: osd.c:2007
width
unsigned int width
Definition: gfontrle.c:4
osd_object_s::extent_height
int extent_height
Definition: osd.h:51
xine_osd_s
Definition: osd.h:78
osd_renderer_s::render_text
int(* render_text)(osd_object_t *osd, int x1, int y1, const char *text, int color_base)
Definition: osd.h:185
video_overlay_event_s
Definition: video_overlay.h:54
osd_object_s::display_y
int display_y
Definition: osd.h:44
osd_object_s::color
uint32_t color[OVL_PALETTE_SIZE]
Definition: osd.h:57
osd_object_s::trans
uint8_t trans[OVL_PALETTE_SIZE]
Definition: osd.h:58
osd_renderer_s::set_text_palette
void(* set_text_palette)(osd_object_t *osd, int palette_number, int color_base)
Definition: osd.h:148
osd_renderer_s::set_font
int(* set_font)(osd_object_t *osd, const char *fontname, int size)
Definition: osd.h:166
osd_renderer_s
Definition: osd.h:82
osd_object_s::display_x
int display_x
Definition: osd.h:44
osd_renderer_s::get_text_size
int(* get_text_size)(osd_object_t *osd, const char *text, int *width, int *height)
Definition: osd.h:191
osd_renderer_s::line
void(* line)(osd_object_t *osd, int x1, int y1, int x2, int y2, int color)
Definition: osd.h:122
osd_renderer_s::filled_rect
void(* filled_rect)(osd_object_t *osd, int x1, int y1, int x2, int y2, int color)
Definition: osd.h:128
osd_object_s::video_window_height
int video_window_height
Definition: osd.h:48
osd_object_s::video_window_x
int video_window_x
Definition: osd.h:47
osd_object_s::width
int width
Definition: osd.h:41
height
unsigned int height
Definition: gfontrle.c:5
osd_renderer_s::point
void(* point)(osd_object_t *osd, int x, int y, int color)
Definition: osd.h:117
osd_renderer_s::set_extent
void(* set_extent)(osd_object_t *osd, int extent_width, int extent_height)
Definition: osd.h:230
osd_object_s::renderer
osd_renderer_t * renderer
Definition: osd.h:39
osd_renderer_s::show_unscaled
int(* show_unscaled)(osd_object_t *osd, int64_t vpts)
Definition: osd.h:218
osd_object_s::height
int height
Definition: osd.h:41
osd_object_s::area_touched
int area_touched
Definition: osd.h:43
osd_renderer_s::set_position
void(* set_position)(osd_object_t *osd, int x, int y)
Definition: osd.h:160
osd_object_s::argb_layer
argb_layer_t * argb_layer
Definition: osd.h:72
osd_object_s::ft2
osd_ft2context_t * ft2
Definition: osd.h:66
osd_object_s::x2
int x2
Definition: osd.h:55
osd_object_s::font
osd_font_t * font
Definition: osd.h:65
osd_renderer_s::osds
osd_object_t * osds
Definition: osd.h:258
osd_object_s::video_window_width
int video_window_width
Definition: osd.h:48
osd_renderer_s::set_argb_buffer
void(* set_argb_buffer)(osd_object_t *osd, uint32_t *argb_buffer, int dirty_x, int dirty_y, int dirty_width, int dirty_height)
Definition: osd.h:243
osd_renderer_s::event
video_overlay_event_t event
Definition: osd.h:257