From: Jean-Paul Saman Date: Sat, 27 Aug 2005 16:40:23 +0000 (+0000) Subject: Merged OSD functionality on the same core functions. All OSD functionality is describ... X-Git-Tag: 0.8.4~639 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a92603f2093140f93c34f301a22eb5763abc4232;p=vlc Merged OSD functionality on the same core functions. All OSD functionality is described in include/vlc_osd.h now, which entirely replace include/osd.h. The file src/video_output/video_widgets.c uses functionality from src/osd/osd_widgets.c now. --- diff --git a/Makefile.am b/Makefile.am index 45d08056e4..16a4298c99 100644 --- a/Makefile.am +++ b/Makefile.am @@ -86,7 +86,6 @@ HEADERS_include = \ include/modules_inner.h \ include/mtime.h \ include/network.h \ - include/osd.h \ include/os_specific.h \ include/snapshot.h \ include/stream_output.h \ @@ -430,6 +429,8 @@ SOURCES_libvlc_common = \ src/stream_output/acl.c \ src/osd/osd.c \ src/osd/osd_parser.c \ + src/osd/osd_text.c \ + src/osd/osd_widgets.c \ src/misc/charset.c \ src/misc/httpd.c \ src/misc/tls.c \ diff --git a/include/osd.h b/include/osd.h deleted file mode 100644 index f9c6ec6e9c..0000000000 --- a/include/osd.h +++ /dev/null @@ -1,68 +0,0 @@ -/***************************************************************************** - * osd.h : Constants for use with osd modules - ***************************************************************************** - * Copyright (C) 2003 the VideoLAN team - * $Id$ - * - * Authors: Sigmund Augdal - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/** - * \file - * Stucts and function prototypes to place text on the video - */ - -#define OSD_ALIGN_LEFT 0x1 -#define OSD_ALIGN_RIGHT 0x2 -#define OSD_ALIGN_TOP 0x4 -#define OSD_ALIGN_BOTTOM 0x8 - -#define OSD_HOR_SLIDER 1 -#define OSD_VERT_SLIDER 2 - -#define OSD_PLAY_ICON 1 -#define OSD_PAUSE_ICON 2 -#define OSD_SPEAKER_ICON 3 -#define OSD_MUTE_ICON 4 - -/** - * Text style information. - * This struct is currently ignored - */ -struct text_style_t -{ - int i_size; - uint32_t i_color; - vlc_bool_t b_italic; - vlc_bool_t b_bold; - vlc_bool_t b_underline; -}; -static const text_style_t default_text_style = { 22, 0xffffff, VLC_FALSE, VLC_FALSE, VLC_FALSE }; - -VLC_EXPORT( int, vout_ShowTextRelative, ( vout_thread_t *, int, char *, text_style_t *, int, int, int, mtime_t ) ); -VLC_EXPORT( int, vout_ShowTextAbsolute, ( vout_thread_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t ) ); -VLC_EXPORT( void, __vout_OSDMessage, ( vlc_object_t *, int, char *, ... ) ); -/** - * Same as __vlc_OSDMessage() but with automatic casting - */ -#if defined(HAVE_VARIADIC_MACROS) -# define vout_OSDMessage( obj, chan, fmt, args...) __vout_OSDMessage( VLC_OBJECT(obj), chan, fmt, ## args ) -#else -# define vout_OSDMessage __vout_OSDMessage -#endif -VLC_EXPORT( void, vout_OSDSlider, ( vlc_object_t *, int, int , short ) ); -VLC_EXPORT( void, vout_OSDIcon, ( vlc_object_t *, int, short ) ); diff --git a/include/vlc_osd.h b/include/vlc_osd.h index 4256bdf972..bf47c87f2f 100644 --- a/include/vlc_osd.h +++ b/include/vlc_osd.h @@ -1,11 +1,15 @@ /***************************************************************************** - * osd.h - OSD menu definitions and function prototypes + * vlc_osd.h - OSD menu definitions and function prototypes ***************************************************************************** * Copyright (C) 2004-2005 M2X - * $Id: osd.h 9451 2004-12-01 01:07:08Z jpsaman $ + * $Id: vlc_osd.h 9451 2004-12-01 01:07:08Z jpsaman $ * * Authors: Jean-Paul Saman * + * Added code from include/osd.h written by: + * Copyright (C) 2003-2005 the VideoLAN team + * Authors: Sigmund Augdal + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -63,7 +67,7 @@ extern "C" { # endif /** - * The OSD Menu configuration file format. + * \brief The OSD Menu configuration file format. * * The configuration file syntax is very basic and so is its parser. See the * BNF formal representation below: @@ -95,6 +99,37 @@ extern "C" { * */ +/** + * OSD menu position and picture type defines + */ + +#define OSD_ALIGN_LEFT 0x1 +#define OSD_ALIGN_RIGHT 0x2 +#define OSD_ALIGN_TOP 0x4 +#define OSD_ALIGN_BOTTOM 0x8 + +#define OSD_HOR_SLIDER 1 +#define OSD_VERT_SLIDER 2 + +#define OSD_PLAY_ICON 1 +#define OSD_PAUSE_ICON 2 +#define OSD_SPEAKER_ICON 3 +#define OSD_MUTE_ICON 4 + +/** + * Text style information. + * This struct is currently ignored + */ +struct text_style_t +{ + int i_size; + uint32_t i_color; + vlc_bool_t b_italic; + vlc_bool_t b_bold; + vlc_bool_t b_underline; +}; +static const text_style_t default_text_style = { 22, 0xffffff, VLC_FALSE, VLC_FALSE, VLC_FALSE }; + /** * OSD menu button states * @@ -372,6 +407,29 @@ static inline void osd_SetMenuUpdate( osd_menu_t *p_osd, vlc_bool_t b_value ) var_Set( p_osd, "osd-menu-update", val ); } +/** + * Textual feedback + * + * Functions that provide the textual feedback on the OSD. They are shown on hotkey commands. The feedback + * is also part of the osd_button_t object. The types are declared in the include file + * include/vlc_osd.h + * @see vlc_osd.h + */ +VLC_EXPORT( int, osd_ShowTextRelative, ( spu_t *, int, char *, text_style_t *, int, int, int, mtime_t ) ); +VLC_EXPORT( int, osd_ShowTextAbsolute, ( spu_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t ) ); +VLC_EXPORT( void,osd_Message, ( spu_t *, int, char *, ... ) ); + +/** + * Default feedback images + * + * Functions that provide the default OSD feedback images on hotkey commands. These feedback + * images are also part of the osd_button_t object. The types are declared in the include file + * include/vlc_osd.h + * @see vlc_osd.h + */ +VLC_EXPORT( int, osd_Slider, ( vlc_object_t *, spu_t *, int, int, int, int, short ) ); +VLC_EXPORT( int, osd_Icon, ( vlc_object_t *, spu_t *, int, int, int, short ) ); + /** * Loading and parse the OSD Configuration file * diff --git a/include/vlc_symbols.h b/include/vlc_symbols.h index e6b1463a91..657b5834f1 100644 --- a/include/vlc_symbols.h +++ b/include/vlc_symbols.h @@ -22,6 +22,7 @@ int playlist_ItemDelete (playlist_item_t *); osd_state_t * __osd_StateChange (osd_state_t *, const int); int vlm_ScheduleSetup (vlm_schedule_t *, char *, char *); vlc_acl_t * __ACL_Duplicate (vlc_object_t *p_this, const vlc_acl_t *p_acl); +int osd_Slider (vlc_object_t *, spu_t *, int, int, int, int, short); int playlist_ServicesDiscoveryRemove (playlist_t *, const char *); int playlist_NodeDelete (playlist_t *, playlist_item_t *, vlc_bool_t , vlc_bool_t); void vlm_MediaDelete (vlm_t *, vlm_media_t *, char *); @@ -52,6 +53,7 @@ int __vout_AllocatePicture (vlc_object_t *p_this, picture_t *p_pic, uint32_t i_c playlist_item_t * playlist_NodeCreate (playlist_t *,int,char *, playlist_item_t * p_parent); void * vlc_readdir (void *); int sout_AnnounceRegister (sout_instance_t *,session_descriptor_t*, announce_method_t*); +int osd_ShowTextRelative (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t); void * __vlc_object_get (vlc_object_t *, int); void vout_SynchroTrash (vout_synchro_t *); picture_t * vout_CreatePicture (vout_thread_t *, vlc_bool_t, vlc_bool_t, unsigned int); @@ -65,6 +67,7 @@ void __sout_CfgParse (vlc_object_t *, char *psz_prefix, const char **ppsz_option vlm_media_t * vlm_MediaNew (vlm_t *, char *, int); int playlist_LockItemToNode (playlist_t *,playlist_item_t *); void spu_Destroy (spu_t *); +int osd_Icon (vlc_object_t *, spu_t *, int, int, int, short); char* httpd_ServerIP (httpd_client_t *cl, char *psz_ip); int spu_Init (spu_t *); void httpd_HostDelete (httpd_host_t *); @@ -157,8 +160,8 @@ void EndMD5 (struct md5_s *); tls_server_t * tls_ServerCreate (vlc_object_t *, const char *, const char *); int vlm_MediaSetup (vlm_t *, vlm_media_t *, char *, char *); void sout_StreamDelete (sout_stream_t *); -void __osd_MenuDelete (vlc_object_t *, osd_menu_t *); int vout_ShowTextAbsolute (vout_thread_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t); +void __osd_MenuDelete (vlc_object_t *, osd_menu_t *); int sout_AnnounceUnRegister (sout_instance_t *,session_descriptor_t*); vlc_bool_t vlc_ureduce (unsigned *, unsigned *, uint64_t, uint64_t, uint64_t); httpd_host_t * httpd_HostNew (vlc_object_t *, const char *psz_host, int i_port); @@ -176,8 +179,8 @@ int playlist_Enable (playlist_t *, playlist_item_t *); playlist_item_t* __playlist_ItemCopy (vlc_object_t *,playlist_item_t*); char * vlc_strdup (const char *s); playlist_item_t* __playlist_ItemNew (vlc_object_t *,const char *,const char *); -int __var_Get (vlc_object_t *, const char *, vlc_value_t *); int __net_OpenTCP (vlc_object_t *p_this, const char *psz_host, int i_port); +int __var_Get (vlc_object_t *, const char *, vlc_value_t *); void tls_ServerDelete (tls_server_t *); unsigned int aout_FormatNbChannels (const audio_sample_format_t * p_format); int __vlc_mutex_destroy (char *, int, vlc_mutex_t *); @@ -245,8 +248,8 @@ const char * aout_FormatPrintChannels (const audio_sample_format_t *); char * __config_GetPsz (vlc_object_t *, const char *); void httpd_StreamDelete (httpd_stream_t *); image_handler_t * __image_HandlerCreate (vlc_object_t *); -aout_buffer_t * aout_DecNewBuffer (aout_instance_t *, aout_input_t *, size_t); void vout_OSDSlider (vlc_object_t *, int, int , short); +aout_buffer_t * aout_DecNewBuffer (aout_instance_t *, aout_input_t *, size_t); int vout_ChromaCmp (uint32_t, uint32_t); int sout_InputDelete (sout_packetizer_input_t *); int playlist_Import (playlist_t *, const char *); @@ -280,6 +283,7 @@ int playlist_LockReplace (playlist_t *,playlist_item_t *, input_item_t*); int __intf_Eject (vlc_object_t *, const char *); int input_Control (input_thread_t *, int i_query, ...); int __aout_VolumeUp (vlc_object_t *, int, audio_volume_t *); +void osd_Message (spu_t *, int, char *, ...); vout_thread_t * __vout_Request (vlc_object_t *, vout_thread_t *, video_format_t *); void __osd_MenuUp (vlc_object_t *); int __aout_VolumeDown (vlc_object_t *, int, audio_volume_t *); @@ -372,6 +376,7 @@ int playlist_NodeGroup (playlist_t *, int,playlist_item_t *,playlist_item_t **,i playlist_item_t* playlist_ItemNewWithType (vlc_object_t *,const char *,const char *, int); void __config_PutPsz (vlc_object_t *, const char *, const char *); vlm_schedule_t * vlm_ScheduleNew (vlm_t *, char *); +int osd_ShowTextAbsolute (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t); void net_Close (int fd); int __vlc_threads_init (vlc_object_t *); void __vout_CopyPicture (vlc_object_t *p_this, picture_t *p_dst, picture_t *p_src); @@ -808,10 +813,10 @@ struct module_symbols_t int (*vlc_scandir_inner) (const char *name, struct dirent ***namelist, int (*filter) ( const struct dirent * ), int (*compar) ( const struct dirent **, const struct dirent ** )); int (*vlc_alphasort_inner) (const struct dirent **a, const struct dirent **b); osd_state_t * (*__osd_StateChange_inner) (osd_state_t *, const int); - void *osd_Slider_deprecated; + int (*osd_Slider_inner) (vlc_object_t *, spu_t *, int, int, int, int, short); void (*osd_ConfigUnload_inner) (vlc_object_t *, osd_menu_t **); void (*__osd_MenuShow_inner) (vlc_object_t *); - void *osd_Icon_deprecated; + int (*osd_Icon_inner) (vlc_object_t *, spu_t *, int, int, int, short); void *__osd_VolumeDown_deprecated; void (*__osd_MenuNext_inner) (vlc_object_t *); void (*__osd_MenuDelete_inner) (vlc_object_t *, osd_menu_t *); @@ -839,6 +844,9 @@ struct module_symbols_t void (*httpd_HandlerDelete_inner) (httpd_handler_t *); int (*__vlc_execve_inner) (vlc_object_t *p_object, int i_argc, char **pp_argv, char **pp_env, char *psz_cwd, char *p_in, int i_in, char **pp_data, int *pi_data); httpd_handler_t * (*httpd_HandlerNew_inner) (httpd_host_t *, const char *psz_url, const char *psz_user, const char *psz_password, const vlc_acl_t *p_acl, httpd_handler_callback_t pf_fill, httpd_handler_sys_t *); + int (*osd_ShowTextRelative_inner) (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t); + void (*osd_Message_inner) (spu_t *, int, char *, ...); + int (*osd_ShowTextAbsolute_inner) (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t); }; # if defined (__PLUGIN__) # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner @@ -1215,8 +1223,10 @@ struct module_symbols_t # define vlc_scandir (p_symbols)->vlc_scandir_inner # define vlc_alphasort (p_symbols)->vlc_alphasort_inner # define __osd_StateChange (p_symbols)->__osd_StateChange_inner +# define osd_Slider (p_symbols)->osd_Slider_inner # define osd_ConfigUnload (p_symbols)->osd_ConfigUnload_inner # define __osd_MenuShow (p_symbols)->__osd_MenuShow_inner +# define osd_Icon (p_symbols)->osd_Icon_inner # define __osd_MenuNext (p_symbols)->__osd_MenuNext_inner # define __osd_MenuDelete (p_symbols)->__osd_MenuDelete_inner # define __osd_MenuHide (p_symbols)->__osd_MenuHide_inner @@ -1241,6 +1251,9 @@ struct module_symbols_t # define httpd_HandlerDelete (p_symbols)->httpd_HandlerDelete_inner # define __vlc_execve (p_symbols)->__vlc_execve_inner # define httpd_HandlerNew (p_symbols)->httpd_HandlerNew_inner +# define osd_ShowTextRelative (p_symbols)->osd_ShowTextRelative_inner +# define osd_Message (p_symbols)->osd_Message_inner +# define osd_ShowTextAbsolute (p_symbols)->osd_ShowTextAbsolute_inner # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) /****************************************************************** * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access. @@ -1620,8 +1633,10 @@ struct module_symbols_t ((p_symbols)->vlc_scandir_inner) = vlc_scandir; \ ((p_symbols)->vlc_alphasort_inner) = vlc_alphasort; \ ((p_symbols)->__osd_StateChange_inner) = __osd_StateChange; \ + ((p_symbols)->osd_Slider_inner) = osd_Slider; \ ((p_symbols)->osd_ConfigUnload_inner) = osd_ConfigUnload; \ ((p_symbols)->__osd_MenuShow_inner) = __osd_MenuShow; \ + ((p_symbols)->osd_Icon_inner) = osd_Icon; \ ((p_symbols)->__osd_MenuNext_inner) = __osd_MenuNext; \ ((p_symbols)->__osd_MenuDelete_inner) = __osd_MenuDelete; \ ((p_symbols)->__osd_MenuHide_inner) = __osd_MenuHide; \ @@ -1646,10 +1661,11 @@ struct module_symbols_t ((p_symbols)->httpd_HandlerDelete_inner) = httpd_HandlerDelete; \ ((p_symbols)->__vlc_execve_inner) = __vlc_execve; \ ((p_symbols)->httpd_HandlerNew_inner) = httpd_HandlerNew; \ + ((p_symbols)->osd_ShowTextRelative_inner) = osd_ShowTextRelative; \ + ((p_symbols)->osd_Message_inner) = osd_Message; \ + ((p_symbols)->osd_ShowTextAbsolute_inner) = osd_ShowTextAbsolute; \ (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ (p_symbols)->vlc_fix_readdir_charset_deprecated = NULL; \ - (p_symbols)->osd_Slider_deprecated = NULL; \ - (p_symbols)->osd_Icon_deprecated = NULL; \ (p_symbols)->__osd_VolumeDown_deprecated = NULL; \ (p_symbols)->__osd_VolumeUp_deprecated = NULL; \ (p_symbols)->VLC_CompileTime_deprecated = NULL; \ diff --git a/include/vlc_video.h b/include/vlc_video.h index 9245643465..71d7a40d24 100644 --- a/include/vlc_video.h +++ b/include/vlc_video.h @@ -347,6 +347,82 @@ VLC_EXPORT( int, __vout_InitPicture, ( vlc_object_t *p_this, picture_t *p_pic, u __vout_AllocatePicture(VLC_OBJECT(a),b,c,d,e,f) VLC_EXPORT( int, __vout_AllocatePicture,( vlc_object_t *p_this, picture_t *p_pic, uint32_t i_chroma, int i_width, int i_height, int i_aspect ) ); +/** + * vout_ShowTextRelative + * + * Show text on the video for some time + * \param p_vout pointer to the vout the text is to be showed on + * \param i_channel Subpicture channel + * \param psz_string The text to be shown + * \param p_style Pointer to a struct with text style info + * \param i_flags flags for alignment and such + * \param i_hmargin horizontal margin in pixels + * \param i_vmargin vertical margin in pixels + * \param i_duration Amount of time the text is to be shown. + */ +VLC_EXPORT( int, vout_ShowTextRelative, ( vout_thread_t *, int, char *, text_style_t *, int, int, int, mtime_t ) ); + +/** + * vout_ShowTextAbsolute + * + * Show text on the video from a given start date to a given end date + * \param p_vout pointer to the vout the text is to be showed on + * \param i_channel Subpicture channel + * \param psz_string The text to be shown + * \param p_style Pointer to a struct with text style info + * \param i_flags flags for alignment and such + * \param i_hmargin horizontal margin in pixels + * \param i_vmargin vertical margin in pixels + * \param i_start the time when this string is to appear on the video + * \param i_stop the time when this string should stop to be displayed + * if this is 0 the string will be shown untill the next string + * is about to be shown + */ +VLC_EXPORT( int, vout_ShowTextAbsolute, ( vout_thread_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t ) ); + +/** + * vout_OSDMessage + * + * Write an informative message at the default location, + * for the default duration and only if the OSD option is enabled. + * \param p_caller The object that called the function. + * \param i_channel Subpicture channel + * \param psz_format printf style formatting + **/ +VLC_EXPORT( void, __vout_OSDMessage, ( vlc_object_t *, int, char *, ... ) ); + +/** + * Same as __vlc_OSDMessage() but with automatic casting + */ +#if defined(HAVE_VARIADIC_MACROS) +# define vout_OSDMessage( obj, chan, fmt, args...) __vout_OSDMessage( VLC_OBJECT(obj), chan, fmt, ## args ) +#else +# define vout_OSDMessage __vout_OSDMessage +#endif + +/** + * vout_OSDSlider + * + * Display a slider on the video output. + * \param p_this The object that called the function. + * \param i_channel Subpicture channel + * \param i_postion Current position in the slider + * \param i_type Types are: OSD_HOR_SLIDER and OSD_VERT_SLIDER. + * @see vlc_osd.h + */ +VLC_EXPORT( void, vout_OSDSlider, ( vlc_object_t *, int, int , short ) ); + +/** + * vout_OSDIcon + * + * Display an Icon on the video output. + * \param p_this The object that called the function. + * \param i_channel Subpicture channel + * \param i_type Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON, OSD_SPEAKER_ICON, OSD_MUTE_ICON + * @see vlc_osd.h + */ +VLC_EXPORT( void, vout_OSDIcon, ( vlc_object_t *, int, short ) ); + /**@}*/ #endif /* _VLC_VIDEO_H */ diff --git a/modules/access_filter/record.c b/modules/access_filter/record.c index 97c42362e0..f95d65ce93 100644 --- a/modules/access_filter/record.c +++ b/modules/access_filter/record.c @@ -31,7 +31,7 @@ #include #include "vlc_keys.h" -#include +#include #include #include diff --git a/modules/codec/cmml/cmml.c b/modules/codec/cmml/cmml.c index 6619f1702a..07a9082375 100644 --- a/modules/codec/cmml/cmml.c +++ b/modules/codec/cmml/cmml.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include "charset.h" diff --git a/modules/codec/cmml/intf.c b/modules/codec/cmml/intf.c index 9670fc866d..8d5a7725e4 100644 --- a/modules/codec/cmml/intf.c +++ b/modules/codec/cmml/intf.c @@ -41,7 +41,7 @@ #include #include -#include +#include #include "vlc_keys.h" diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c index aae7072cb7..25b2ac0aa1 100644 --- a/modules/codec/subsdec.c +++ b/modules/codec/subsdec.c @@ -29,7 +29,7 @@ #include #include -#include "osd.h" +#include "vlc_osd.h" #include "vlc_filter.h" #include "charset.h" diff --git a/modules/control/corba/mediacontrol-core.c b/modules/control/corba/mediacontrol-core.c index 2069697bb1..7f67f5b728 100644 --- a/modules/control/corba/mediacontrol-core.c +++ b/modules/control/corba/mediacontrol-core.c @@ -5,7 +5,7 @@ #include #include -#include +#include #define HAS_SNAPSHOT 1 diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c index 595cf8485d..b9d202ebff 100644 --- a/modules/control/hotkeys.c +++ b/modules/control/hotkeys.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include "vlc_keys.h" @@ -243,9 +243,9 @@ static void Run( intf_thread_t *p_intf ) { if( p_hotkeys[i].i_key == i_key ) { - i_action = p_hotkeys[i].i_action; - i_times = p_hotkeys[i].i_times; /* times key pressed within max. delta time */ - p_hotkeys[i].i_times = 0; + i_action = p_hotkeys[i].i_action; + i_times = p_hotkeys[i].i_times; /* times key pressed within max. delta time */ + p_hotkeys[i].i_times = 0; } } diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m index bdaabfac0c..605abd4869 100644 --- a/modules/gui/macosx/controls.m +++ b/modules/gui/macosx/controls.m @@ -34,7 +34,7 @@ #include "vout.h" #include "open.h" #include "controls.h" -#include +#include /***************************************************************************** * VLCControls implementation diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m index ee3ac59cc3..e2fe09d9d1 100644 --- a/modules/gui/macosx/playlist.m +++ b/modules/gui/macosx/playlist.m @@ -49,7 +49,7 @@ #import "bookmarks.h" #include "playlist.h" #include "controls.h" -#include "osd.h" +#include "vlc_osd.h" #include "misc.h" /***************************************************************************** @@ -1607,7 +1607,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ } #endif /* We add the "VLCPlaylistItemPboardType" type to be able to recognize - a Drop operation comçing from the playlist. + a Drop operation com�ng from the playlist. We need to add NSFilenamesPboardType otherwise the outlineview refuses to the drop. */ diff --git a/modules/misc/freetype.c b/modules/misc/freetype.c index a15958889c..56abe66e03 100644 --- a/modules/misc/freetype.c +++ b/modules/misc/freetype.c @@ -34,7 +34,7 @@ #include #include -#include "osd.h" +#include "vlc_osd.h" #include "vlc_block.h" #include "vlc_filter.h" diff --git a/modules/misc/svg.c b/modules/misc/svg.c index ff1fc95235..3d4a03fbf7 100644 --- a/modules/misc/svg.c +++ b/modules/misc/svg.c @@ -33,7 +33,7 @@ #include #include -#include "osd.h" +#include "vlc_osd.h" #include "vlc_block.h" #include "vlc_filter.h" diff --git a/modules/misc/win32text.c b/modules/misc/win32text.c index 0ba0d5dd52..0a64c9cbf2 100644 --- a/modules/misc/win32text.c +++ b/modules/misc/win32text.c @@ -29,7 +29,7 @@ #include #include -#include "osd.h" +#include "vlc_osd.h" #include "vlc_block.h" #include "vlc_filter.h" diff --git a/modules/stream_out/transcode.c b/modules/stream_out/transcode.c index a91ccb660c..e7ee6e53c3 100644 --- a/modules/stream_out/transcode.c +++ b/modules/stream_out/transcode.c @@ -36,7 +36,7 @@ #include #include #include "vlc_filter.h" -#include "osd.h" +#include "vlc_osd.h" #define MASTER_SYNC_MAX_DRIFT 100000 diff --git a/modules/video_filter/logo.c b/modules/video_filter/logo.c index 5d3befb44b..4fb910d47d 100644 --- a/modules/video_filter/logo.c +++ b/modules/video_filter/logo.c @@ -34,7 +34,7 @@ #include "vlc_filter.h" #include "filter_common.h" #include "vlc_image.h" -#include "osd.h" +#include "vlc_osd.h" #ifdef LoadImage # undef LoadImage diff --git a/modules/video_filter/marq.c b/modules/video_filter/marq.c index 034528013e..5af4f7bf1d 100644 --- a/modules/video_filter/marq.c +++ b/modules/video_filter/marq.c @@ -32,7 +32,7 @@ #include "vlc_filter.h" #include "vlc_block.h" -#include "osd.h" +#include "vlc_osd.h" /***************************************************************************** * Local prototypes diff --git a/modules/video_filter/osdmenu.c b/modules/video_filter/osdmenu.c index 07f5ec4e6a..1d3ecce506 100644 --- a/modules/video_filter/osdmenu.c +++ b/modules/video_filter/osdmenu.c @@ -32,7 +32,6 @@ #include #include -#include #include /***************************************************************************** diff --git a/modules/video_filter/rss.c b/modules/video_filter/rss.c index 4a3efb3da3..1722072146 100644 --- a/modules/video_filter/rss.c +++ b/modules/video_filter/rss.c @@ -32,7 +32,7 @@ #include "vlc_filter.h" #include "vlc_block.h" -#include "osd.h" +#include "vlc_osd.h" #include "vlc_block.h" #include "vlc_stream.h" diff --git a/modules/video_filter/time.c b/modules/video_filter/time.c index ed32e298b5..1ca639f0b7 100644 --- a/modules/video_filter/time.c +++ b/modules/video_filter/time.c @@ -34,7 +34,7 @@ #include "vlc_filter.h" #include "vlc_block.h" -#include "osd.h" +#include "vlc_osd.h" /***************************************************************************** * Local prototypes diff --git a/src/control/audio_video.c b/src/control/audio_video.c index 2b097d96ca..bf87b1283e 100644 --- a/src/control/audio_video.c +++ b/src/control/audio_video.c @@ -28,7 +28,7 @@ #include #include -#include +#include #define HAS_SNAPSHOT 1 diff --git a/src/control/core.c b/src/control/core.c index 98287f8f7b..3abb0a52e3 100644 --- a/src/control/core.c +++ b/src/control/core.c @@ -28,7 +28,7 @@ #include #include -#include +#include #define HAS_SNAPSHOT 1 diff --git a/src/control/util.c b/src/control/util.c index e6100176f4..8fed487330 100644 --- a/src/control/util.c +++ b/src/control/util.c @@ -28,7 +28,7 @@ #include #include -#include +#include #define HAS_SNAPSHOT 1 diff --git a/src/misc/modules.c b/src/misc/modules.c index 539049fb26..b3ea3b5510 100644 --- a/src/misc/modules.c +++ b/src/misc/modules.c @@ -92,7 +92,6 @@ #include "aout_internal.h" #include "stream_output.h" -#include "osd.h" #include "vlc_httpd.h" #include "vlc_acl.h" #include "vlc_tls.h" diff --git a/src/osd/osd_text.c b/src/osd/osd_text.c new file mode 100644 index 0000000000..330e20258a --- /dev/null +++ b/src/osd/osd_text.c @@ -0,0 +1,134 @@ +/***************************************************************************** + * osd_text.c : text manipulation functions + ***************************************************************************** + * Copyright (C) 1999-2005 the VideoLAN team + * $Id$ + * + * Author: Sigmund Augdal + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include +#include +#include +#include + +/** + * \brief Show text on the video for some time + * \param p_spu pointer to the subpicture queue the text is to be showed on + * \param i_channel Subpicture channel + * \param psz_string The text to be shown + * \param p_style Pointer to a struct with text style info + * \param i_flags flags for alignment and such + * \param i_hmargin horizontal margin in pixels + * \param i_vmargin vertical margin in pixels + * \param i_duration Amount of time the text is to be shown. + */ +int osd_ShowTextRelative( spu_t *p_spu, int i_channel, + char *psz_string, text_style_t *p_style, + int i_flags, int i_hmargin, int i_vmargin, + mtime_t i_duration ) +{ + mtime_t i_now = mdate(); + + return osd_ShowTextAbsolute( p_spu, i_channel, psz_string, + p_style, i_flags, i_hmargin, i_vmargin, + i_now, i_now + i_duration ); +} + +/** + * \brief Show text on the video from a given start date to a given end date + * \param p_spu pointer to the subpicture queue the text is to be showed on + * \param i_channel Subpicture channel + * \param psz_string The text to be shown + * \param p_style Pointer to a struct with text style info + * \param i_flags flags for alignment and such + * \param i_hmargin horizontal margin in pixels + * \param i_vmargin vertical margin in pixels + * \param i_start the time when this string is to appear on the video + * \param i_stop the time when this string should stop to be displayed + * if this is 0 the string will be shown untill the next string + * is about to be shown + */ +int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel, + char *psz_string, text_style_t *p_style, + int i_flags, int i_hmargin, int i_vmargin, + mtime_t i_start, mtime_t i_stop ) +{ + subpicture_t *p_spu; + video_format_t fmt; + + if( !psz_string ) return VLC_EGENERIC; + + p_spu = spu_CreateSubpicture( p_spu_channel ); + if( !p_spu ) return VLC_EGENERIC; + + /* Create a new subpicture region */ + memset( &fmt, 0, sizeof(video_format_t) ); + fmt.i_chroma = VLC_FOURCC('T','E','X','T'); + fmt.i_aspect = 0; + fmt.i_width = fmt.i_height = 0; + fmt.i_x_offset = fmt.i_y_offset = 0; + p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_spu_channel), &fmt ); + if( !p_spu->p_region ) + { + msg_Err( p_spu_channel, "cannot allocate SPU region" ); + spu_DestroySubpicture( p_spu_channel, p_spu ); + return VLC_EGENERIC; + } + + p_spu->p_region->psz_text = strdup( psz_string ); + p_spu->i_start = i_start; + p_spu->i_stop = i_stop; + p_spu->b_ephemer = VLC_TRUE; + p_spu->b_absolute = VLC_FALSE; + + p_spu->i_x = i_hmargin; + p_spu->i_y = i_vmargin; + p_spu->i_flags = i_flags; + p_spu->i_channel = i_channel; + + spu_DisplaySubpicture( p_spu_channel, p_spu ); + + return VLC_SUCCESS; +} + + +/** + * \brief Write an informative message at the default location, + * for the default duration and only if the OSD option is enabled. + * \param p_caller The object that called the function. + * \param i_channel Subpicture channel + * \param psz_format printf style formatting + **/ +void osd_Message( spu_t *p_spu, int i_channel, + char *psz_format, ... ) +{ + char *psz_string; + va_list args; + + if( p_spu ) + { + va_start( args, psz_format ); + vasprintf( &psz_string, psz_format, args ); + + osd_ShowTextRelative( p_spu, i_channel, psz_string, NULL, + OSD_ALIGN_TOP|OSD_ALIGN_RIGHT, 30,20,1000000 ); + + free( psz_string ); + va_end( args ); + } +} diff --git a/src/osd/osd_widgets.c b/src/osd/osd_widgets.c new file mode 100644 index 0000000000..8631a49ab0 --- /dev/null +++ b/src/osd/osd_widgets.c @@ -0,0 +1,336 @@ +/***************************************************************************** + * osd_widgets.c : OSD widgets manipulation functions + ***************************************************************************** + * Copyright (C) 2004-2005 the VideoLAN team + * $Id$ + * + * Author: Yoann Peronneau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include /* free() */ +#include +#include + +#include +#include + +#define STYLE_EMPTY 0 +#define STYLE_FILLED 1 + +/***************************************************************************** + * Local prototypes + *****************************************************************************/ +static void DrawRect( subpicture_t *, int, int, int, int, short ); +static void DrawTriangle( subpicture_t *, int, int, int, int, short ); +static int CreatePicture( spu_t *, subpicture_t *, int, int, int, int ); +static subpicture_t *osd_CreateWidget( spu_t *, int ); + +/***************************************************************************** + * Draws a rectangle at the given position in the subpic. + * It may be filled (fill == STYLE_FILLED) or empty (fill == STYLE_EMPTY). + *****************************************************************************/ +static void DrawRect( subpicture_t *p_subpic, int i_x1, int i_y1, + int i_x2, int i_y2, short fill ) +{ + int x, y; + uint8_t *p_a = p_subpic->p_region->picture.A_PIXELS; + int i_pitch = p_subpic->p_region->picture.Y_PITCH; + + if( fill == STYLE_FILLED ) + { + for( y = i_y1; y <= i_y2; y++ ) + { + for( x = i_x1; x <= i_x2; x++ ) + { + p_a[ x + i_pitch * y ] = 0xff; + } + } + } + else + { + for( y = i_y1; y <= i_y2; y++ ) + { + p_a[ i_x1 + i_pitch * y ] = 0xff; + p_a[ i_x2 + i_pitch * y ] = 0xff; + } + for( x = i_x1; x <= i_x2; x++ ) + { + p_a[ x + i_pitch * i_y1 ] = 0xff; + p_a[ x + i_pitch * i_y2 ] = 0xff; + } + } +} + +/***************************************************************************** + * Draws a triangle at the given position in the subpic. + * It may be filled (fill == STYLE_FILLED) or empty (fill == STYLE_EMPTY). + *****************************************************************************/ +static void DrawTriangle( subpicture_t *p_subpic, int i_x1, int i_y1, + int i_x2, int i_y2, short fill ) +{ + int x, y, i_mid, h; + uint8_t *p_a = p_subpic->p_region->picture.A_PIXELS; + int i_pitch = p_subpic->p_region->picture.Y_PITCH; + + i_mid = i_y1 + ( ( i_y2 - i_y1 ) >> 1 ); + + if( i_x2 >= i_x1 ) + { + if( fill == STYLE_FILLED ) + { + for( y = i_y1; y <= i_mid; y++ ) + { + h = y - i_y1; + for( x = i_x1; x <= i_x1 + h && x <= i_x2; x++ ) + { + p_a[ x + i_pitch * y ] = 0xff; + p_a[ x + i_pitch * ( i_y2 - h ) ] = 0xff; + } + } + } + else + { + for( y = i_y1; y <= i_mid; y++ ) + { + h = y - i_y1; + p_a[ i_x1 + i_pitch * y ] = 0xff; + p_a[ i_x1 + h + i_pitch * y ] = 0xff; + p_a[ i_x1 + i_pitch * ( i_y2 - h ) ] = 0xff; + p_a[ i_x1 + h + i_pitch * ( i_y2 - h ) ] = 0xff; + } + } + } + else + { + if( fill == STYLE_FILLED ) + { + for( y = i_y1; y <= i_mid; y++ ) + { + h = y - i_y1; + for( x = i_x1; x >= i_x1 - h && x >= i_x2; x-- ) + { + p_a[ x + i_pitch * y ] = 0xff; + p_a[ x + i_pitch * ( i_y2 - h ) ] = 0xff; + } + } + } + else + { + for( y = i_y1; y <= i_mid; y++ ) + { + h = y - i_y1; + p_a[ i_x1 + i_pitch * y ] = 0xff; + p_a[ i_x1 - h + i_pitch * y ] = 0xff; + p_a[ i_x1 + i_pitch * ( i_y2 - h ) ] = 0xff; + p_a[ i_x1 - h + i_pitch * ( i_y2 - h ) ] = 0xff; + } + } + } +} + +/***************************************************************************** + * Create Picture: creates subpicture region and picture + *****************************************************************************/ +static int CreatePicture( spu_t *p_spu, subpicture_t *p_subpic, + int i_x, int i_y, int i_width, int i_height ) +{ + uint8_t *p_y, *p_u, *p_v, *p_a; + video_format_t fmt; + int i_pitch; + + /* Create a new subpicture region */ + memset( &fmt, 0, sizeof(video_format_t) ); + fmt.i_chroma = VLC_FOURCC('Y','U','V','A'); + fmt.i_aspect = 0; + fmt.i_width = fmt.i_visible_width = i_width; + fmt.i_height = fmt.i_visible_height = i_height; + fmt.i_x_offset = fmt.i_y_offset = 0; + p_subpic->p_region = p_subpic->pf_create_region( VLC_OBJECT(p_spu), &fmt ); + if( !p_subpic->p_region ) + { + msg_Err( p_spu, "cannot allocate SPU region" ); + return VLC_EGENERIC; + } + + p_subpic->p_region->i_x = i_x; + p_subpic->p_region->i_y = i_y; + p_y = p_subpic->p_region->picture.Y_PIXELS; + p_u = p_subpic->p_region->picture.U_PIXELS; + p_v = p_subpic->p_region->picture.V_PIXELS; + p_a = p_subpic->p_region->picture.A_PIXELS; + i_pitch = p_subpic->p_region->picture.Y_PITCH; + + /* Initialize the region pixels (only the alpha will be changed later) */ + memset( p_y, 0xff, i_pitch * p_subpic->p_region->fmt.i_height ); + memset( p_u, 0x80, i_pitch * p_subpic->p_region->fmt.i_height ); + memset( p_v, 0x80, i_pitch * p_subpic->p_region->fmt.i_height ); + memset( p_a, 0x00, i_pitch * p_subpic->p_region->fmt.i_height ); + + return VLC_SUCCESS; +} + +/***************************************************************************** + * Creates and initializes an OSD widget. + *****************************************************************************/ +subpicture_t *osd_CreateWidget( spu_t *p_spu, int i_channel ) +{ + subpicture_t *p_subpic; + mtime_t i_now = mdate(); + + /* Create and initialize a subpicture */ + p_subpic = spu_CreateSubpicture( p_spu ); + if( p_subpic == NULL ) return NULL; + + p_subpic->i_channel = i_channel; + p_subpic->i_start = i_now; + p_subpic->i_stop = i_now + 1200000; + p_subpic->b_ephemer = VLC_TRUE; + p_subpic->b_fade = VLC_TRUE; + + return p_subpic; +} + +/***************************************************************************** + * Displays an OSD slider. + * Types are: OSD_HOR_SLIDER and OSD_VERT_SLIDER. + *****************************************************************************/ +int osd_Slider( vlc_object_t *p_this, spu_t *p_spu, + int i_render_width, int i_render_height, + int i_channel, int i_position, short i_type ) +{ + subpicture_t *p_subpic; + int i_x_margin, i_y_margin, i_x, i_y, i_width, i_height; + + p_subpic = osd_CreateWidget( p_spu, i_channel ); + if( p_subpic == NULL ) + { + return VLC_EGENERIC; + } + + i_y_margin = i_render_height / 10; + i_x_margin = i_y_margin; + if( i_type == OSD_HOR_SLIDER ) + { + i_width = i_render_width - 2 * i_x_margin; + i_height = i_render_height / 20; + i_x = i_x_margin; + i_y = i_render_height - i_y_margin - i_height; + } + else + { + i_width = i_render_width / 40; + i_height = i_render_height - 2 * i_y_margin; + i_x = i_render_width - i_x_margin - i_width; + i_y = i_y_margin; + } + + /* Create subpicture region and picture */ + CreatePicture( p_spu, p_subpic, i_x, i_y, i_width, i_height ); + + if( i_type == OSD_HOR_SLIDER ) + { + int i_x_pos = ( i_width - 2 ) * i_position / 100; + DrawRect( p_subpic, i_x_pos - 1, 2, i_x_pos + 1, + i_height - 3, STYLE_FILLED ); + DrawRect( p_subpic, 0, 0, i_width - 1, i_height - 1, STYLE_EMPTY ); + } + else if( i_type == OSD_VERT_SLIDER ) + { + int i_y_pos = i_height / 2; + DrawRect( p_subpic, 2, i_height - ( i_height - 2 ) * i_position / 100, + i_width - 3, i_height - 3, STYLE_FILLED ); + DrawRect( p_subpic, 1, i_y_pos, 1, i_y_pos, STYLE_FILLED ); + DrawRect( p_subpic, i_width - 2, i_y_pos, + i_width - 2, i_y_pos, STYLE_FILLED ); + DrawRect( p_subpic, 0, 0, i_width - 1, i_height - 1, STYLE_EMPTY ); + } + + spu_DisplaySubpicture( p_spu, p_subpic ); + + return VLC_SUCCESS; +} + +/***************************************************************************** + * Displays an OSD icon. + * Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON, OSD_SPEAKER_ICON, OSD_MUTE_ICON + *****************************************************************************/ +int osd_Icon( vlc_object_t *p_this, spu_t *p_spu, + int i_render_width, int i_render_height, int i_channel, short i_type ) +{ + subpicture_t *p_subpic; + int i_x_margin, i_y_margin, i_x, i_y, i_width, i_height; + + p_subpic = osd_CreateWidget( p_spu, i_channel ); + if( p_subpic == NULL ) + { + return VLC_EGENERIC; + } + + i_y_margin = i_render_height / 15; + i_x_margin = i_y_margin; + i_width = i_render_width / 20; + i_height = i_width; + i_x = i_render_width - i_x_margin - i_width; + i_y = i_y_margin; + + /* Create subpicture region and picture */ + CreatePicture( p_spu, p_subpic, i_x, i_y, i_width, i_height ); + + if( i_type == OSD_PAUSE_ICON ) + { + int i_bar_width = i_width / 3; + DrawRect( p_subpic, 0, 0, i_bar_width - 1, i_height -1, STYLE_FILLED ); + DrawRect( p_subpic, i_width - i_bar_width, 0, + i_width - 1, i_height - 1, STYLE_FILLED ); + } + else if( i_type == OSD_PLAY_ICON ) + { + int i_mid = i_height >> 1; + int i_delta = ( i_width - i_mid ) >> 1; + int i_y2 = ( ( i_height - 1 ) >> 1 ) * 2; + DrawTriangle( p_subpic, i_delta, 0, i_width - i_delta, i_y2, + STYLE_FILLED ); + } + else if( i_type == OSD_SPEAKER_ICON || i_type == OSD_MUTE_ICON ) + { + int i_mid = i_height >> 1; + int i_delta = ( i_width - i_mid ) >> 1; + int i_y2 = ( ( i_height - 1 ) >> 1 ) * 2; + DrawRect( p_subpic, i_delta, i_mid / 2, i_width - i_delta, + i_height - 1 - i_mid / 2, STYLE_FILLED ); + DrawTriangle( p_subpic, i_width - i_delta, 0, i_delta, i_y2, + STYLE_FILLED ); + if( i_type == OSD_MUTE_ICON ) + { + uint8_t *p_a = p_subpic->p_region->picture.A_PIXELS; + int i_pitch = p_subpic->p_region->picture.Y_PITCH; + int i; + for( i = 1; i < i_pitch; i++ ) + { + int k = i + ( i_height - i - 1 ) * i_pitch; + p_a[ k ] = 0xff - p_a[ k ]; + } + } + } + + spu_DisplaySubpicture( p_spu, p_subpic ); + + return VLC_SUCCESS; +} diff --git a/src/video_output/video_text.c b/src/video_output/video_text.c index b877af0647..ecb4b22bdb 100644 --- a/src/video_output/video_text.c +++ b/src/video_output/video_text.c @@ -21,9 +21,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ #include -#include "vlc_block.h" -#include "vlc_filter.h" -#include "osd.h" +#include +#include +#include /** * \brief Show text on the video for some time @@ -123,7 +123,6 @@ void __vout_OSDMessage( vlc_object_t *p_caller, int i_channel, if( !config_GetInt( p_caller, "osd" ) ) return; p_vout = vlc_object_find( p_caller, VLC_OBJECT_VOUT, FIND_ANYWHERE ); - if( p_vout ) { va_start( args, psz_format ); diff --git a/src/video_output/video_widgets.c b/src/video_output/video_widgets.c index a77c695098..0b7798c123 100644 --- a/src/video_output/video_widgets.c +++ b/src/video_output/video_widgets.c @@ -1,7 +1,7 @@ /***************************************************************************** * video_widgets.c : OSD widgets manipulation functions ***************************************************************************** - * Copyright (C) 2004 the VideoLAN team + * Copyright (C) 2004-2005 the VideoLAN team * $Id$ * * Author: Yoann Peronneau @@ -26,185 +26,11 @@ *****************************************************************************/ #include /* free() */ #include -#include +#include #include "vlc_video.h" #include "vlc_filter.h" -#define STYLE_EMPTY 0 -#define STYLE_FILLED 1 - -/***************************************************************************** - * Local prototypes - *****************************************************************************/ -static void DrawRect( subpicture_t *, int, int, int, int, short ); -static void DrawTriangle( subpicture_t *, int, int, int, int, short ); -static void CreatePicture( spu_t *, subpicture_t *, int, int, int, int ); -static subpicture_t *vout_CreateWidget( spu_t *, int ); - -/***************************************************************************** - * Draws a rectangle at the given position in the subpic. - * It may be filled (fill == STYLE_FILLED) or empty (fill == STYLE_EMPTY). - *****************************************************************************/ -static void DrawRect( subpicture_t *p_subpic, int i_x1, int i_y1, - int i_x2, int i_y2, short fill ) -{ - int x, y; - uint8_t *p_a = p_subpic->p_region->picture.A_PIXELS; - int i_pitch = p_subpic->p_region->picture.Y_PITCH; - - if( fill == STYLE_FILLED ) - { - for( y = i_y1; y <= i_y2; y++ ) - { - for( x = i_x1; x <= i_x2; x++ ) - { - p_a[ x + i_pitch * y ] = 0xff; - } - } - } - else - { - for( y = i_y1; y <= i_y2; y++ ) - { - p_a[ i_x1 + i_pitch * y ] = 0xff; - p_a[ i_x2 + i_pitch * y ] = 0xff; - } - for( x = i_x1; x <= i_x2; x++ ) - { - p_a[ x + i_pitch * i_y1 ] = 0xff; - p_a[ x + i_pitch * i_y2 ] = 0xff; - } - } -} - -/***************************************************************************** - * Draws a triangle at the given position in the subpic. - * It may be filled (fill == STYLE_FILLED) or empty (fill == STYLE_EMPTY). - *****************************************************************************/ -static void DrawTriangle( subpicture_t *p_subpic, int i_x1, int i_y1, - int i_x2, int i_y2, short fill ) -{ - int x, y, i_mid, h; - uint8_t *p_a = p_subpic->p_region->picture.A_PIXELS; - int i_pitch = p_subpic->p_region->picture.Y_PITCH; - - i_mid = i_y1 + ( ( i_y2 - i_y1 ) >> 1 ); - - if( i_x2 >= i_x1 ) - { - if( fill == STYLE_FILLED ) - { - for( y = i_y1; y <= i_mid; y++ ) - { - h = y - i_y1; - for( x = i_x1; x <= i_x1 + h && x <= i_x2; x++ ) - { - p_a[ x + i_pitch * y ] = 0xff; - p_a[ x + i_pitch * ( i_y2 - h ) ] = 0xff; - } - } - } - else - { - for( y = i_y1; y <= i_mid; y++ ) - { - h = y - i_y1; - p_a[ i_x1 + i_pitch * y ] = 0xff; - p_a[ i_x1 + h + i_pitch * y ] = 0xff; - p_a[ i_x1 + i_pitch * ( i_y2 - h ) ] = 0xff; - p_a[ i_x1 + h + i_pitch * ( i_y2 - h ) ] = 0xff; - } - } - } - else - { - if( fill == STYLE_FILLED ) - { - for( y = i_y1; y <= i_mid; y++ ) - { - h = y - i_y1; - for( x = i_x1; x >= i_x1 - h && x >= i_x2; x-- ) - { - p_a[ x + i_pitch * y ] = 0xff; - p_a[ x + i_pitch * ( i_y2 - h ) ] = 0xff; - } - } - } - else - { - for( y = i_y1; y <= i_mid; y++ ) - { - h = y - i_y1; - p_a[ i_x1 + i_pitch * y ] = 0xff; - p_a[ i_x1 - h + i_pitch * y ] = 0xff; - p_a[ i_x1 + i_pitch * ( i_y2 - h ) ] = 0xff; - p_a[ i_x1 - h + i_pitch * ( i_y2 - h ) ] = 0xff; - } - } - } -} - -/***************************************************************************** - * Create Picture: creates subpicture region and picture - *****************************************************************************/ -static void CreatePicture( spu_t *p_spu, subpicture_t *p_subpic, - int i_x, int i_y, int i_width, int i_height ) -{ - uint8_t *p_y, *p_u, *p_v, *p_a; - video_format_t fmt; - int i_pitch; - - /* Create a new subpicture region */ - memset( &fmt, 0, sizeof(video_format_t) ); - fmt.i_chroma = VLC_FOURCC('Y','U','V','A'); - fmt.i_aspect = 0; - fmt.i_width = fmt.i_visible_width = i_width; - fmt.i_height = fmt.i_visible_height = i_height; - fmt.i_x_offset = fmt.i_y_offset = 0; - p_subpic->p_region = p_subpic->pf_create_region( VLC_OBJECT(p_spu), &fmt ); - if( !p_subpic->p_region ) - { - msg_Err( p_spu, "cannot allocate SPU region" ); - return; - } - - p_subpic->p_region->i_x = i_x; - p_subpic->p_region->i_y = i_y; - p_y = p_subpic->p_region->picture.Y_PIXELS; - p_u = p_subpic->p_region->picture.U_PIXELS; - p_v = p_subpic->p_region->picture.V_PIXELS; - p_a = p_subpic->p_region->picture.A_PIXELS; - i_pitch = p_subpic->p_region->picture.Y_PITCH; - - /* Initialize the region pixels (only the alpha will be changed later) */ - memset( p_y, 0xff, i_pitch * p_subpic->p_region->fmt.i_height ); - memset( p_u, 0x80, i_pitch * p_subpic->p_region->fmt.i_height ); - memset( p_v, 0x80, i_pitch * p_subpic->p_region->fmt.i_height ); - memset( p_a, 0x00, i_pitch * p_subpic->p_region->fmt.i_height ); -} - -/***************************************************************************** - * Creates and initializes an OSD widget. - *****************************************************************************/ -subpicture_t *vout_CreateWidget( spu_t *p_spu, int i_channel ) -{ - subpicture_t *p_subpic; - mtime_t i_now = mdate(); - - /* Create and initialize a subpicture */ - p_subpic = spu_CreateSubpicture( p_spu ); - if( p_subpic == NULL ) return NULL; - - p_subpic->i_channel = i_channel; - p_subpic->i_start = i_now; - p_subpic->i_stop = i_now + 1200000; - p_subpic->b_ephemer = VLC_TRUE; - p_subpic->b_fade = VLC_TRUE; - - return p_subpic; -} - /***************************************************************************** * Displays an OSD slider. * Types are: OSD_HOR_SLIDER and OSD_VERT_SLIDER. @@ -214,66 +40,12 @@ void vout_OSDSlider( vlc_object_t *p_caller, int i_channel, int i_position, { vout_thread_t *p_vout = vlc_object_find( p_caller, VLC_OBJECT_VOUT, FIND_ANYWHERE ); - subpicture_t *p_subpic; - int i_x_margin, i_y_margin, i_x, i_y, i_width, i_height; - - if( p_vout == NULL ) - { - return; - } - if( !config_GetInt( p_caller, "osd" ) || i_position < 0 ) - { - vlc_object_release( p_vout ); - return; - } - p_subpic = vout_CreateWidget( p_vout->p_spu, i_channel ); - if( p_subpic == NULL ) - { - return; - } - - i_y_margin = p_vout->render.i_height / 10; - i_x_margin = i_y_margin; - if( i_type == OSD_HOR_SLIDER ) - { - i_width = p_vout->render.i_width - 2 * i_x_margin; - i_height = p_vout->render.i_height / 20; - i_x = i_x_margin; - i_y = p_vout->render.i_height - i_y_margin - i_height; - } - else - { - i_width = p_vout->render.i_width / 40; - i_height = p_vout->render.i_height - 2 * i_y_margin; - i_x = p_vout->render.i_width - i_x_margin - i_width; - i_y = i_y_margin; - } - - /* Create subpicture region and picture */ - CreatePicture( p_vout->p_spu, p_subpic, i_x, i_y, i_width, i_height ); - - if( i_type == OSD_HOR_SLIDER ) + if( p_vout && ( config_GetInt( p_caller, "osd" ) || ( i_position >= 0 ) ) ) { - int i_x_pos = ( i_width - 2 ) * i_position / 100; - DrawRect( p_subpic, i_x_pos - 1, 2, i_x_pos + 1, - i_height - 3, STYLE_FILLED ); - DrawRect( p_subpic, 0, 0, i_width - 1, i_height - 1, STYLE_EMPTY ); + osd_Slider( p_caller, p_vout->p_spu, p_vout->render.i_width, + p_vout->render.i_height, i_channel, i_position, i_type ); } - else if( i_type == OSD_VERT_SLIDER ) - { - int i_y_pos = i_height / 2; - DrawRect( p_subpic, 2, i_height - ( i_height - 2 ) * i_position / 100, - i_width - 3, i_height - 3, STYLE_FILLED ); - DrawRect( p_subpic, 1, i_y_pos, 1, i_y_pos, STYLE_FILLED ); - DrawRect( p_subpic, i_width - 2, i_y_pos, - i_width - 2, i_y_pos, STYLE_FILLED ); - DrawRect( p_subpic, 0, 0, i_width - 1, i_height - 1, STYLE_EMPTY ); - } - - spu_DisplaySubpicture( p_vout->p_spu, p_subpic ); - vlc_object_release( p_vout ); - return; } /***************************************************************************** @@ -284,69 +56,10 @@ void vout_OSDIcon( vlc_object_t *p_caller, int i_channel, short i_type ) { vout_thread_t *p_vout = vlc_object_find( p_caller, VLC_OBJECT_VOUT, FIND_ANYWHERE ); - subpicture_t *p_subpic; - int i_x_margin, i_y_margin, i_x, i_y, i_width, i_height; - - if( p_vout == NULL || !config_GetInt( p_caller, "osd" ) ) + if( p_vout && config_GetInt( p_caller, "osd" ) ) { - return; + osd_Icon( p_caller, p_vout->p_spu, p_vout->render.i_width, + p_vout->render.i_height, i_channel, i_type ); } - - p_subpic = vout_CreateWidget( p_vout->p_spu, i_channel ); - if( p_subpic == NULL ) - { - return; - } - - i_y_margin = p_vout->render.i_height / 15; - i_x_margin = i_y_margin; - i_width = p_vout->render.i_width / 20; - i_height = i_width; - i_x = p_vout->render.i_width - i_x_margin - i_width; - i_y = i_y_margin; - - /* Create subpicture region and picture */ - CreatePicture( p_vout->p_spu, p_subpic, i_x, i_y, i_width, i_height ); - - if( i_type == OSD_PAUSE_ICON ) - { - int i_bar_width = i_width / 3; - DrawRect( p_subpic, 0, 0, i_bar_width - 1, i_height -1, STYLE_FILLED ); - DrawRect( p_subpic, i_width - i_bar_width, 0, - i_width - 1, i_height - 1, STYLE_FILLED ); - } - else if( i_type == OSD_PLAY_ICON ) - { - int i_mid = i_height >> 1; - int i_delta = ( i_width - i_mid ) >> 1; - int i_y2 = ( ( i_height - 1 ) >> 1 ) * 2; - DrawTriangle( p_subpic, i_delta, 0, i_width - i_delta, i_y2, - STYLE_FILLED ); - } - else if( i_type == OSD_SPEAKER_ICON || i_type == OSD_MUTE_ICON ) - { - int i_mid = i_height >> 1; - int i_delta = ( i_width - i_mid ) >> 1; - int i_y2 = ( ( i_height - 1 ) >> 1 ) * 2; - DrawRect( p_subpic, i_delta, i_mid / 2, i_width - i_delta, - i_height - 1 - i_mid / 2, STYLE_FILLED ); - DrawTriangle( p_subpic, i_width - i_delta, 0, i_delta, i_y2, - STYLE_FILLED ); - if( i_type == OSD_MUTE_ICON ) - { - uint8_t *p_a = p_subpic->p_region->picture.A_PIXELS; - int i_pitch = p_subpic->p_region->picture.Y_PITCH; - int i; - for( i = 1; i < i_pitch; i++ ) - { - int k = i + ( i_height - i - 1 ) * i_pitch; - p_a[ k ] = 0xff - p_a[ k ]; - } - } - } - - spu_DisplaySubpicture( p_vout->p_spu, p_subpic ); - vlc_object_release( p_vout ); - return; }