1 /*****************************************************************************
2 * xvideo.c : Xvideo plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 1998-2001 VideoLAN
5 * $Id: xvideo.c,v 1.17 2002/07/31 20:56:52 sam Exp $
7 * Authors: Shane Harper <shanegh@optusnet.com.au>
8 * Vincent Seguin <seguin@via.ecp.fr>
9 * Samuel Hocevar <sam@zoy.org>
10 * David Kennedy <dkennedy@tinytoad.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
30 #include <stdlib.h> /* malloc(), free() */
31 #include <string.h> /* strerror() */
35 /*****************************************************************************
37 *****************************************************************************/
38 extern int E_(Activate) ( vlc_object_t * );
39 extern void E_(Deactivate) ( vlc_object_t * );
41 /*****************************************************************************
43 *****************************************************************************/
44 #define ADAPTOR_TEXT N_("XVideo adaptor number")
45 #define ADAPTOR_LONGTEXT N_( \
46 "If you graphics card provides several adaptors, this option allows you " \
47 "to choose which one will be used (you shouldn't have to change this).")
49 #define ALT_FS_TEXT N_("alternate fullscreen method")
50 #define ALT_FS_LONGTEXT N_( \
51 "There are two ways to make a fullscreen window, unfortunately each one " \
52 "has its drawbacks.\n" \
53 "1) Let the window manager handle your fullscreen window (default). But " \
54 "things like taskbars will likely show on top of the video.\n" \
55 "2) Completly bypass the window manager, but then nothing will be able " \
56 "to show on top of the video.")
58 #define DISPLAY_TEXT N_("X11 display name")
59 #define DISPLAY_LONGTEXT N_( \
60 "Specify the X11 hardware display you want to use. By default vlc will " \
61 "use the value of the DISPLAY environment variable.")
63 #define CHROMA_TEXT N_("XVimage chroma format")
64 #define CHROMA_LONGTEXT N_( \
65 "Force the XVideo renderer to use a specific chroma format instead of " \
66 "trying to improve performances by using the most efficient one.")
68 #define DRAWABLE_TEXT N_("X11 drawable")
69 #define DRAWABLE_LONGTEXT N_( \
70 "Specify a X11 drawable to use instead of opening a new window. This " \
71 "option is DANGEROUS, use with care.")
73 #define SHM_TEXT N_("use shared memory")
74 #define SHM_LONGTEXT N_( \
75 "Use shared memory to communicate between vlc and the X server.")
78 add_category_hint( N_("Miscellaneous"), NULL );
79 add_string( "xvideo-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT );
80 add_integer( "xvideo-adaptor", -1, NULL, ADAPTOR_TEXT, ADAPTOR_LONGTEXT );
81 add_bool( "xvideo-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT );
82 add_string( "xvideo-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT );
83 add_integer( "xvideo-drawable", -1, NULL, DRAWABLE_TEXT, DRAWABLE_LONGTEXT );
85 add_bool( "xvideo-shm", 1, NULL, SHM_TEXT, SHM_LONGTEXT );
87 set_description( _("XVideo extension module") );
88 set_capability( "video output", 150 );
89 set_callbacks( E_(Activate), E_(Deactivate) );
92 /* following functions are local */
95 /*****************************************************************************
97 *****************************************************************************
98 * This function can be used to set attributes, e.g. XV_BRIGHTNESS and
99 * XV_CONTRAST. "f_value" should be in the range of 0 to 1.
100 *****************************************************************************/
101 static void XVideoSetAttribute( vout_thread_t *p_vout,
102 char *attr_name, float f_value )
105 XvAttribute *p_attrib;
106 Display *p_display = p_vout->p_sys->p_display;
107 int i_xvport = p_vout->p_sys->i_xvport;
109 p_attrib = XvQueryPortAttributes( p_display, i_xvport, &i_attrib );
115 if( i_attrib >= 0 && !strcmp( p_attrib[ i_attrib ].name, attr_name ) )
117 int i_sv = f_value * ( p_attrib[ i_attrib ].max_value
118 - p_attrib[ i_attrib ].min_value + 1 )
119 + p_attrib[ i_attrib ].min_value;
121 XvSetPortAttribute( p_display, i_xvport,
122 XInternAtom( p_display, attr_name, False ), i_sv );
126 } while( i_attrib > 0 );