1 /*****************************************************************************
\r
2 * osd.h - OSD menu definitions and function prototypes
\r
3 *****************************************************************************
\r
4 * Copyright (C) 2004-2005 M2X
\r
5 * $Id: osd.h 9451 2004-12-01 01:07:08Z jpsaman $
\r
7 * Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
\r
9 * This program is free software; you can redistribute it and/or modify
\r
10 * it under the terms of the GNU General Public License as published by
\r
11 * the Free Software Foundation; either version 2 of the License, or
\r
12 * (at your option) any later version.
\r
14 * This program is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU General Public License for more details.
\r
19 * You should have received a copy of the GNU General Public License
\r
20 * along with this program; if not, write to the Free Software
\r
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
\r
22 *****************************************************************************/
\r
26 * The OSD menu core creates the OSD menu structure in memory. It parses a
\r
27 * configuration file that defines all elements that are part of the menu. The
\r
28 * core also handles all actions and menu structure updates on behalf of video
\r
29 * subpicture filters.
\r
31 * The file modules/video_filters/osdmenu.c implements a subpicture filter that
\r
32 * specifies the final information on positioning of the current state image.
\r
33 * A subpicture filter is called each time a video picture has to be rendered, it
\r
34 * also gives a start and end date to the subpicture. The subpicture can be streamed
\r
35 * if used inside a transcoding command. For example:
\r
37 * vlc dvdsimple:///dev/dvd --extraintf rc
\r
38 * --sout='#transcode{osd}:std{access=udp,mux=ts,url=dest_ipaddr}'
\r
39 * --osdmenu-file=share/osdmenu/dvd.cfg
\r
41 * Each OSD menu element, called "action", defines a hotkey action. Each action
\r
42 * can have several states (unselect, select, pressed). Each state has an image
\r
43 * that represents the state visually. The commands "menu right", "menu left",
\r
44 * "menu up" and "menu down" are used to navigate through the OSD menu structure.
\r
45 * The commands "menu on" or "menu show" and "menu off" or "menu hide" respectively
\r
46 * show and hide the OSD menu subpictures.
\r
48 * There is one special element called "range". A range is an arbritary range
\r
49 * of state images that can be browsed using "menu up" and "menu down" commands
\r
50 * on the rc interface.
\r
52 * The OSD menu configuration file uses a very simple syntax and basic parser.
\r
53 * A configuration file has the ".cfg". An example is "share/osdmenu/dvd256.cfg".
\r
57 #define _VLC_OSD_H 1
\r
59 #include "vlc_video.h"
\r
66 * The OSD Menu configuration file format.
\r
68 * The configuration file syntax is very basic and so is its parser. See the
\r
69 * BNF formal representation below:
\r
71 * The keywords FILENAME and PATHNAME represent the filename and pathname specification
\r
72 * that is valid for the Operating System VLC is compiled for.
\r
74 * The hotkey actions that are supported by VLC are documented in the file src/libvlc. The
\r
75 * file include/vlc_keys.h defines some hotkey internals.
\r
77 * CONFIG_FILE = FILENAME '.cfg'
\r
78 * WS = [ ' ' | '\t' ]+
\r
79 * OSDMEN_PATH = PATHNAME
\r
80 * DIR = 'dir' WS OSDMENU_PATH '\n'
\r
81 * STATE = [ 'unselect' | 'select' | 'pressed' ]
\r
82 * HOTKEY_ACTION = 'key-' [ 'a' .. 'z', 'A' .. 'Z', '-' ]+
\r
84 * ACTION_TYPE = 'type' 'volume' '\n'
\r
85 * ACTION_BLOCK_START = 'action' WS HOTKEY_ACTION WS '('POS','POS')' '\n'
\r
86 * ACTION_BLOCK_END = 'end' '\n'
\r
87 * ACTION_STATE = STATE WS FILENAME '\n'
\r
88 * ACTION_RANGE_START = 'range' WS HOTKEY_ACTION WS DEFAULT_INDEX '\n'
\r
89 * ACTION_RANGE_END = 'end' '\n'
\r
90 * ACTION_RANGE_STATE = FILENAME '\n'
\r
92 * ACTION_BLOCK_RANGE = ACTION_RANGE_START [WS ACTION_RANGE_STATE]+ WS ACTION_RANGE_END
\r
93 * ACTION_BLOCK = ACTION_BLOCK_START [WS ACTION_TYPE*] [ [WS ACTION_STATE]+3 | [WS ACTION_BLOCK_RANGE]+1 ] ACTION_BLOCK_END
\r
94 * CONFIG_FILE_CONTENTS = DIR [ACTION_BLOCK]+
\r
99 * OSD menu button states
\r
101 * Every button has three states, either it is unselected, selected or pressed.
\r
102 * An OSD menu skin can associate images with each state.
\r
104 * OSD_BUTTON_UNSELECT 0
\r
105 * OSD_BUTTON_SELECT 1
\r
106 * OSD_BUTTON_PRESSED 2
\r
108 #define OSD_BUTTON_UNSELECT 0
\r
109 #define OSD_BUTTON_SELECT 1
\r
110 #define OSD_BUTTON_PRESSED 2
\r
115 * The OSD state object holds the state and associated images for a particular state
\r
116 * on the screen. The picture is displayed when this state is the active state.
\r
120 osd_state_t *p_next; /*< pointer to next state */
\r
121 osd_state_t *p_prev; /*< pointer to previous state */
\r
122 picture_t *p_pic; /*< picture of state */
\r
124 char *psz_state; /*< state name */
\r
125 int i_state; /*< state index */
\r
129 * OSD Button object
\r
131 * An OSD Button has different states. Each state has an image for display.
\r
133 struct osd_button_t
\r
135 osd_button_t *p_next; /*< pointer to next button */
\r
136 osd_button_t *p_prev; /*< pointer to previous button */
\r
137 osd_button_t *p_up; /*< pointer to up button */
\r
138 osd_button_t *p_down; /*< pointer to down button */
\r
140 osd_state_t *p_current_state; /*< pointer to current state image */
\r
141 osd_state_t *p_states; /*< doubly linked list of states */
\r
142 picture_t *p_feedback; /*< feedback picture */
\r
144 char *psz_name; /*< name of button */
\r
146 /* These member should probably be a struct hotkey */
\r
147 char *psz_action; /*< hotkey action name on button*/
\r
148 char *psz_action_down; /*< hotkey action name on range buttons for command "menu down" */
\r
149 /* end of hotkey specifics */
\r
151 int i_x; /*< x-position of button visible state image */
\r
152 int i_y; /*< y-position of button visible state image */
\r
154 /* range style button */
\r
155 vlc_bool_t b_range; /*< button should be interpreted as range */
\r
156 int i_ranges; /*< number of states */
\r
160 * OSD Menu State object
\r
162 * Represents the current state as displayed.
\r
164 /* Represent the menu state */
\r
165 struct osd_menu_state_t
\r
167 int i_x; /*< x position of spu region */
\r
168 int i_y; /*< y position of spu region */
\r
169 int i_width; /*< width of spu region */
\r
170 int i_height; /*< height of spu region */
\r
172 picture_t *p_pic; /*< pointer to picture to display */
\r
173 osd_button_t *p_visible; /*< shortcut to visible button */
\r
175 vlc_bool_t b_menu_visible; /*< menu currently visible? */
\r
176 vlc_bool_t b_update; /*< update OSD Menu when VLC_TRUE */
\r
178 /* quick hack to volume state. */
\r
179 osd_button_t *p_volume; /*< pointer to volume range object. */
\r
185 * The main OSD Menu object, which holds a linked list to all buttons
\r
186 * and images that defines the menu. The p_state variable represents the
\r
187 * current state of the OSD Menu.
\r
193 int i_x; /*< x-position of OSD Menu on the video screen */
\r
194 int i_y; /*< y-position of OSD Menu on the video screen */
\r
195 int i_width; /*< width of OSD Menu on the video screen */
\r
196 int i_height; /*< height of OSD Menu on the video screen */
\r
198 char *psz_path; /*< directory where OSD menu images are stored */
\r
199 osd_button_t *p_button; /*< doubly linked list of buttons */
\r
200 osd_menu_state_t *p_state; /*< current state of OSD menu */
\r
202 /* quick link in the linked list. */
\r
203 osd_button_t *p_last_button; /*< pointer to last button in the list */
\r
207 * Initialize an osd_menu_t object
\r
209 * This functions has to be called before any call to other osd_menu_t* functions.
\r
210 * It creates the osd_menu object and holds a pointer to it during its lifetime.
\r
212 VLC_EXPORT( osd_menu_t *, __osd_MenuCreate, ( vlc_object_t *, const char * ) );
\r
215 * Delete the osd_menu_t object
\r
217 * This functions has to be called to release the associated module and memory
\r
218 * for the osdmenu. After return of this function the pointer to osd_menu_t* is invalid.
\r
220 VLC_EXPORT( void, __osd_MenuDelete, ( vlc_object_t *, osd_menu_t * ) );
\r
223 * Change state on an osd_button_t.
\r
225 * This function selects the specified state and returns a pointer to it. The
\r
226 * following states are currently supported:
\r
227 * \see OSD_BUTTON_UNSELECT
\r
228 * \see OSD_BUTTON_SELECT
\r
229 * \see OSD_BUTTON_PRESSED
\r
231 VLC_EXPORT( osd_state_t *, __osd_StateChange, ( osd_state_t *, const int ) );
\r
233 #define osd_MenuCreate(object,file) __osd_MenuCreate( VLC_OBJECT(object), file )
\r
234 #define osd_MenuDelete(object,osd) __osd_MenuDelete( VLC_OBJECT(object), osd )
\r
235 #define osd_StateChange(object,value) __osd_StateChange( object, value )
\r
238 * Show the OSD menu.
\r
240 * Show the OSD menu on the video output or mux it into the stream.
\r
241 * Every change to the OSD menu will now be visible in the output. An output
\r
242 * can be a video output window or a stream (\see stream output)
\r
244 VLC_EXPORT( void, __osd_MenuShow, ( vlc_object_t * ) );
\r
247 * Hide the OSD menu.
\r
249 * Stop showing the OSD menu on the video output or mux it into the stream.
\r
251 VLC_EXPORT( void, __osd_MenuHide, ( vlc_object_t * ) );
\r
254 * Activate the action of this OSD menu item.
\r
256 * The rc interface command "menu select" triggers the sending of an hotkey action
\r
257 * to the hotkey interface. The hotkey that belongs to the current highlighted
\r
258 * OSD menu item will be used.
\r
260 VLC_EXPORT( void, __osd_MenuActivate, ( vlc_object_t * ) );
\r
262 #define osd_MenuShow(object) __osd_MenuShow( VLC_OBJECT(object) )
\r
263 #define osd_MenuHide(object) __osd_MenuHide( VLC_OBJECT(object) )
\r
264 #define osd_MenuActivate(object) __osd_MenuActivate( VLC_OBJECT(object) )
\r
267 * Next OSD menu item
\r
269 * Select the next OSD menu item to be highlighted.
\r
270 * Note: The actual position on screen of the menu item is determined by the the
\r
271 * OSD menu configuration file.
\r
273 VLC_EXPORT( void, __osd_MenuNext, ( vlc_object_t * ) );
\r
276 * Previous OSD menu item
\r
278 * Select the previous OSD menu item to be highlighted.
\r
279 * Note: The actual position on screen of the menu item is determined by the the
\r
280 * OSD menu configuration file.
\r
282 VLC_EXPORT( void, __osd_MenuPrev, ( vlc_object_t * ) );
\r
285 * OSD menu item above
\r
287 * Select the OSD menu item above the current item to be highlighted.
\r
288 * Note: The actual position on screen of the menu item is determined by the the
\r
289 * OSD menu configuration file.
\r
291 VLC_EXPORT( void, __osd_MenuUp, ( vlc_object_t * ) );
\r
294 * OSD menu item below
\r
296 * Select the next OSD menu item below the current item to be highlighted.
\r
297 * Note: The actual position on screen of the menu item is determined by the the
\r
298 * OSD menu configuration file.
\r
300 VLC_EXPORT( void, __osd_MenuDown, ( vlc_object_t * ) );
\r
302 #define osd_MenuNext(object) __osd_MenuNext( VLC_OBJECT(object) )
\r
303 #define osd_MenuPrev(object) __osd_MenuPrev( VLC_OBJECT(object) )
\r
304 #define osd_MenuUp(object) __osd_MenuUp( VLC_OBJECT(object) )
\r
305 #define osd_MenuDown(object) __osd_MenuDown( VLC_OBJECT(object) )
\r
310 * Use the OSD menu to turn the audio volume up.
\r
312 VLC_EXPORT( void, __osd_VolumeUp, ( vlc_object_t * ) );
\r
317 * Use the OSD menu to turn the audio volume down.
\r
319 VLC_EXPORT( void, __osd_VolumeDown, ( vlc_object_t * ) );
\r
321 #define osd_VolumeUp(object) __osd_VolumeUp( VLC_OBJECT(object) )
\r
322 #define osd_VolumeDown(object) __osd_VolumeDown( VLC_OBJECT(object) )
\r
325 * Retrieve a non modifyable pointer to the OSD Menu state
\r
328 static inline const osd_menu_state_t *osd_GetMenuState( osd_menu_t *p_osd )
\r
330 return( p_osd->p_state );
\r
334 * Get the last key press received by the OSD Menu
\r
336 * Returns 0 when no key has been pressed or the value of the key pressed.
\r
338 static inline vlc_bool_t osd_GetKeyPressed( osd_menu_t *p_osd )
\r
340 return( p_osd->p_state->b_update );
\r
344 * Set the key pressed to a value.
\r
346 * Assign a new key value to the last key pressed on the OSD Menu.
\r
348 static inline void osd_SetKeyPressed( vlc_object_t *p_this, int i_value )
\r
352 val.i_int = i_value;
\r
353 var_Set( p_this, "key-pressed", val );
\r
357 * Update the OSD Menu visibility flag.
\r
359 * VLC_TRUE means OSD Menu should be shown. VLC_FALSE means OSD Menu should not be shown.
\r
361 static inline void osd_SetMenuVisible( osd_menu_t *p_osd, vlc_bool_t b_value )
\r
365 val.b_bool = p_osd->p_state->b_menu_visible = b_value;
\r
366 var_Set( p_osd, "osd-menu-visible", val );
\r
370 * Update the OSD Menu update flag
\r
372 * If the OSD Menu should be updated then set the update flag to VLC_TRUE, else to VLC_FALSE.
\r
374 static inline void osd_SetMenuUpdate( osd_menu_t *p_osd, vlc_bool_t b_value )
\r
378 val.b_bool = p_osd->p_state->b_update = b_value;
\r
379 var_Set( p_osd, "osd-menu-update", val );
\r
383 * Default feedback images
\r
385 * Functions that provide the default OSD feedback images on hotkey commands. These feedback
\r
386 * images are also part of the osd_button_t object. The types are declared in the include file
\r
390 VLC_EXPORT( picture_t *, osd_Slider, ( int i_width, int i_height, int i_position, short i_type ) );
\r
391 VLC_EXPORT( picture_t *, osd_Icon, ( int i_width, int i_height, short i_type ) );
\r
394 * Loading and parse the OSD Configuration file
\r
396 * These functions load/unload the OSD menu configuration file and create/destroy the
\r
397 * themable OSD menu structure on the OSD object.
\r
399 VLC_EXPORT( int, osd_ConfigLoader, ( vlc_object_t *, const char *, osd_menu_t ** ) );
\r
400 VLC_EXPORT( void, osd_ConfigUnload, ( vlc_object_t *, osd_menu_t ** ) );
\r
402 # ifdef __cplusplus
\r
406 #endif /* _VLC_OSD_H */
\r