]> git.sesse.net Git - vlc/commitdiff
Merged OSD functionality on the same core functions. All OSD functionality is describ...
authorJean-Paul Saman <jpsaman@videolan.org>
Sat, 27 Aug 2005 16:40:23 +0000 (16:40 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Sat, 27 Aug 2005 16:40:23 +0000 (16:40 +0000)
30 files changed:
Makefile.am
include/osd.h [deleted file]
include/vlc_osd.h
include/vlc_symbols.h
include/vlc_video.h
modules/access_filter/record.c
modules/codec/cmml/cmml.c
modules/codec/cmml/intf.c
modules/codec/subsdec.c
modules/control/corba/mediacontrol-core.c
modules/control/hotkeys.c
modules/gui/macosx/controls.m
modules/gui/macosx/playlist.m
modules/misc/freetype.c
modules/misc/svg.c
modules/misc/win32text.c
modules/stream_out/transcode.c
modules/video_filter/logo.c
modules/video_filter/marq.c
modules/video_filter/osdmenu.c
modules/video_filter/rss.c
modules/video_filter/time.c
src/control/audio_video.c
src/control/core.c
src/control/util.c
src/misc/modules.c
src/osd/osd_text.c [new file with mode: 0644]
src/osd/osd_widgets.c [new file with mode: 0644]
src/video_output/video_text.c
src/video_output/video_widgets.c

index 45d08056e44b5df6d68906d72ade02743827c792..16a4298c99abedc95317afc3303244275fd45165 100644 (file)
@@ -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 (file)
index f9c6ec6..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*****************************************************************************
- * osd.h : Constants for use with osd modules
- *****************************************************************************
- * Copyright (C) 2003 the VideoLAN team
- * $Id$
- *
- * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
- *
- * 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 ) );
index 4256bdf972aaa8d2683eb5997ef3cad9dfd07116..bf47c87f2f4ea2ebc371dd920215ae83c84152b2 100644 (file)
@@ -1,11 +1,15 @@
 /*****************************************************************************\r
- * osd.h - OSD menu definitions and function prototypes\r
+ * vlc_osd.h - OSD menu definitions and function prototypes\r
  *****************************************************************************\r
  * Copyright (C) 2004-2005 M2X\r
- * $Id: osd.h 9451 2004-12-01 01:07:08Z jpsaman $\r
+ * $Id: vlc_osd.h 9451 2004-12-01 01:07:08Z jpsaman $\r
  *\r
  * Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl>\r
  *\r
+ * Added code from include/osd.h written by:\r
+ * Copyright (C) 2003-2005 the VideoLAN team\r
+ * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>\r
+ *\r
  * This program is free software; you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
  * the Free Software Foundation; either version 2 of the License, or\r
@@ -63,7 +67,7 @@ extern "C" {
 # endif\r
 \r
 /**\r
- * The OSD Menu configuration file format.\r
+ * \brief The OSD Menu configuration file format.\r
  *\r
  * The configuration file syntax is very basic and so is its parser. See the\r
  * BNF formal representation below:\r
@@ -95,6 +99,37 @@ extern "C" {
  *\r
  */ \r
 \r
+/**\r
+ * OSD menu position and picture type defines\r
+ */\r
+\r
+#define OSD_ALIGN_LEFT 0x1\r
+#define OSD_ALIGN_RIGHT 0x2\r
+#define OSD_ALIGN_TOP 0x4\r
+#define OSD_ALIGN_BOTTOM 0x8\r
+\r
+#define OSD_HOR_SLIDER 1\r
+#define OSD_VERT_SLIDER 2\r
+\r
+#define OSD_PLAY_ICON 1\r
+#define OSD_PAUSE_ICON 2\r
+#define OSD_SPEAKER_ICON 3\r
+#define OSD_MUTE_ICON 4\r
+\r
+/**\r
+ * Text style information.\r
+ * This struct is currently ignored\r
+ */\r
+struct text_style_t\r
+{\r
+    int i_size;\r
+    uint32_t i_color;\r
+    vlc_bool_t b_italic;\r
+    vlc_bool_t b_bold;\r
+    vlc_bool_t b_underline;\r
+};\r
+static const text_style_t default_text_style = { 22, 0xffffff, VLC_FALSE, VLC_FALSE, VLC_FALSE };\r
\r
 /**\r
  * OSD menu button states\r
  *\r
@@ -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 );\r
 } \r
 \r
+/**\r
+ * Textual feedback\r
+ *\r
+ * Functions that provide the textual feedback on the OSD. They are shown on hotkey commands. The feedback\r
+ * is also part of the osd_button_t object. The types are declared in the include file\r
+ * include/vlc_osd.h\r
+ * @see vlc_osd.h \r
+ */\r
+VLC_EXPORT( int, osd_ShowTextRelative, ( spu_t *, int, char *, text_style_t *, int, int, int, mtime_t ) );\r
+VLC_EXPORT( int, osd_ShowTextAbsolute, ( spu_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t ) );\r
+VLC_EXPORT( void,osd_Message, ( spu_t *, int, char *, ... ) );\r
+\r
+/**\r
+ * Default feedback images\r
+ *\r
+ * Functions that provide the default OSD feedback images on hotkey commands. These feedback\r
+ * images are also part of the osd_button_t object. The types are declared in the include file\r
+ * include/vlc_osd.h\r
+ * @see vlc_osd.h \r
+ */\r
+VLC_EXPORT( int, osd_Slider, ( vlc_object_t *, spu_t *, int, int, int, int, short ) );\r
+VLC_EXPORT( int, osd_Icon, ( vlc_object_t *, spu_t *, int, int, int, short ) );\r
+\r
 /**\r
  * Loading and parse the OSD Configuration file\r
  *\r
index e6b1463a91a32c07e8b79da3afc9606017868a58..657b5834f1208f73035c4c7dddba56d3f849bc7a 100644 (file)
@@ -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; \
index 9245643465449c24ec0a04261ff9347b7f359022..71d7a40d24c4596efce63f20bfd49e3c1c2a02d6 100644 (file)
@@ -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 */
index 97c42362e04a571c18b7f5de0d11b9673aea8d56..f95d65ce935310ba6d08b956e5ba0671e89d3827 100644 (file)
@@ -31,7 +31,7 @@
 #include <vlc/vout.h>
 
 #include "vlc_keys.h"
-#include <osd.h>
+#include <vlc_osd.h>
 #include <errno.h>
 #include <time.h>
 
index 6619f1702adcfaa1eb562b6d58cca42fef72ad6a..07a90823752b38198dbcef125ccaf3798c2c5186 100644 (file)
@@ -31,7 +31,7 @@
 #include <vlc/decoder.h>
 #include <vlc/intf.h>
 
-#include <osd.h>
+#include <vlc_osd.h>
 
 #include "charset.h"
 
index 9670fc866dbb8e17e0deeab3e55b7226136adffb..8d5a7725e4b3255c535b0df4b9f4746d836ae799 100644 (file)
@@ -41,7 +41,7 @@
 #include <vlc/intf.h>
 #include <vlc/vout.h>
 
-#include <osd.h>
+#include <vlc_osd.h>
 
 #include "vlc_keys.h"
 
index aae7072cb71889294cdf9367aec35106f5155091..25b2ac0aa137080919461366bddeb077750062e6 100644 (file)
@@ -29,7 +29,7 @@
 #include <vlc/vout.h>
 #include <vlc/decoder.h>
 
-#include "osd.h"
+#include "vlc_osd.h"
 #include "vlc_filter.h"
 
 #include "charset.h"
index 2069697bb158eed3f7f836d23fb87dc046058606..7f67f5b7288b38a6713c7d4c358491de585622aa 100644 (file)
@@ -5,7 +5,7 @@
 #include <vlc/aout.h>
 #include <vlc_demux.h>
 
-#include <osd.h>
+#include <vlc_osd.h>
 
 #define HAS_SNAPSHOT 1
 
index 595cf8485dc705a7a08cdb6037e67c1ef730c6fc..b9d202ebff17207e50fc8261d2c1358dd1e648fa 100644 (file)
@@ -32,7 +32,7 @@
 #include <vlc/input.h>
 #include <vlc/vout.h>
 #include <vlc/aout.h>
-#include <osd.h>
+#include <vlc_osd.h>
 
 #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;
             }
         }
 
index bdaabfac0ce28707a7c00504a8471ac11a66e285..605abd4869d85c18e403307acaa5956749561dfc 100644 (file)
@@ -34,7 +34,7 @@
 #include "vout.h"
 #include "open.h"
 #include "controls.h"
-#include <osd.h>
+#include <vlc_osd.h>
 
 /*****************************************************************************
  * VLCControls implementation 
index ee3ac59cc306cd59cde6f5f46f795fd0d59090c8..e2fe09d9d1313bf1e37e80732566454ee8598be6 100644 (file)
@@ -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. */
 
index a15958889cabf0c17590187a906b9f2421b19a26..56abe66e0314cafca503c51b33f22edf6a33ffdb 100644 (file)
@@ -34,7 +34,7 @@
 
 #include <vlc/vlc.h>
 #include <vlc/vout.h>
-#include "osd.h"
+#include "vlc_osd.h"
 #include "vlc_block.h"
 #include "vlc_filter.h"
 
index ff1fc952359eefe042383329532a4c0f2f477dec..3d4a03fbf72b0ccd0be3a5356d0eb54e4964c179 100644 (file)
@@ -33,7 +33,7 @@
 
 #include <vlc/vlc.h>
 #include <vlc/vout.h>
-#include "osd.h"
+#include "vlc_osd.h"
 #include "vlc_block.h"
 #include "vlc_filter.h"
 
index 0ba0d5dd52e72f877d03b340d9f2a34bcfc72cf9..0a64c9cbf25fb45d4937cef97dd3b9c65cf28619 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <vlc/vlc.h>
 #include <vlc/vout.h>
-#include "osd.h"
+#include "vlc_osd.h"
 #include "vlc_block.h"
 #include "vlc_filter.h"
 
index a91ccb660c536b4efe4cba3dec7a17184bb21e17..e7ee6e53c369749742875eac84f4f42f98935f6d 100644 (file)
@@ -36,7 +36,7 @@
 #include <vlc/vout.h>
 #include <vlc/decoder.h>
 #include "vlc_filter.h"
-#include "osd.h"
+#include "vlc_osd.h"
 
 #define MASTER_SYNC_MAX_DRIFT 100000
 
index 5d3befb44bb25b09c55a04d6d12dd26e6bca42cb..4fb910d47da5e7b7c1e2f1f47868f66cd946110c 100644 (file)
@@ -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
index 034528013ec9627ffae7d6c5859971ccb9846278..5af4f7bf1d0c1acd0037a3c45cdfd7cbadc8f8b3 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "vlc_filter.h"
 #include "vlc_block.h"
-#include "osd.h"
+#include "vlc_osd.h"
 
 /*****************************************************************************
  * Local prototypes
index 07f5ec4e6aa7b53b6b74e98c2c0cd960be46c528..1d3ecce5061a120382b64f51c992a24b8ef96933 100644 (file)
@@ -32,7 +32,6 @@
 #include <vlc_filter.h>
 #include <vlc_video.h>
 
-#include <osd.h>
 #include <vlc_osd.h>
 
 /*****************************************************************************
index 4a3efb3da39844f97fdcc3987b4b3289b37dc5cd..1722072146a4e07049d0e2072b8daec69139b533 100644 (file)
@@ -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"
index ed32e298b5b14f085422a75bfeb38a8c0e8d0877..1ca639f0b7d0e78d85f8bbe52427986e53259934 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "vlc_filter.h"
 #include "vlc_block.h"
-#include "osd.h"
+#include "vlc_osd.h"
 
 /*****************************************************************************
  * Local prototypes
index 2b097d96cabf544759cb8500cfe0919d6c3646b8..bf87b1283ea6bae06c9bf8630c318014ccab6f42 100644 (file)
@@ -28,7 +28,7 @@
 #include <vlc/aout.h>
 #include <vlc_demux.h>
 
-#include <osd.h>
+#include <vlc_osd.h>
 
 #define HAS_SNAPSHOT 1
 
index 98287f8f7b5d80829a57301a1f16aefe01d994e7..3abb0a52e3b1c6629daf88a0ab38e56387d149b1 100644 (file)
@@ -28,7 +28,7 @@
 #include <vlc/aout.h>
 #include <vlc_demux.h>
 
-#include <osd.h>
+#include <vlc_osd.h>
 
 #define HAS_SNAPSHOT 1
 
index e6100176f46e208785344aa025fec518e95710b8..8fed487330663e82f66123cce1f65ccc01d74fb5 100644 (file)
@@ -28,7 +28,7 @@
 #include <vlc/aout.h>
 #include <vlc_demux.h>
 
-#include <osd.h>
+#include <vlc_osd.h>
 
 #define HAS_SNAPSHOT 1
 
index 539049fb26796df7bb9c7ec73b23251424c20982..b3ea3b55106f5d127190c363e7768cb78501ad91 100644 (file)
@@ -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 (file)
index 0000000..330e202
--- /dev/null
@@ -0,0 +1,134 @@
+/*****************************************************************************
+ * osd_text.c : text manipulation functions
+ *****************************************************************************
+ * Copyright (C) 1999-2005 the VideoLAN team
+ * $Id$
+ *
+ * Author: Sigmund Augdal <sigmunau@idi.ntnu.no>
+ *
+ * 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 <vlc/vout.h>
+#include <vlc_block.h>
+#include <vlc_filter.h>
+#include <vlc_osd.h>
+
+/**
+ * \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 (file)
index 0000000..8631a49
--- /dev/null
@@ -0,0 +1,336 @@
+/*****************************************************************************
+ * osd_widgets.c : OSD widgets manipulation functions
+ *****************************************************************************
+ * Copyright (C) 2004-2005 the VideoLAN team
+ * $Id$
+ *
+ * Author: Yoann Peronneau <yoann@videolan.org>
+ *
+ * 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 <stdlib.h>                                                /* free() */
+#include <vlc/vout.h>
+#include <vlc_osd.h>
+
+#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 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;
+}
index b877af064748ae7d877cd119da6942003b4c5793..ecb4b22bdb37b41c663492343da058c10769e477 100644 (file)
@@ -21,9 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 #include <vlc/vout.h>
-#include "vlc_block.h"
-#include "vlc_filter.h"
-#include "osd.h"
+#include <vlc_block.h>
+#include <vlc_filter.h>
+#include <vlc_osd.h>
 
 /**
  * \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 );
index a77c695098858d3a1233b9dd90d7ac35bb9051da..0b7798c12313af25069c24adc4e43eb87644ad66 100644 (file)
@@ -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 <yoann@videolan.org>
  *****************************************************************************/
 #include <stdlib.h>                                                /* free() */
 #include <vlc/vout.h>
-#include <osd.h>
+#include <vlc_osd.h>
 
 #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;
 }