]> git.sesse.net Git - vlc/blob - plugins/x11/xvideo.c
* ./src/misc/modules.c: added the --plugin-path option to give vlc an
[vlc] / plugins / x11 / xvideo.c
1 /*****************************************************************************
2  * xvideo.c : Xvideo plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 1998-2001 VideoLAN
5  * $Id: xvideo.c,v 1.15 2002/06/27 19:01:28 sam Exp $
6  *
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>
11  *      
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.
16  * 
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.
21  *
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  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include <stdlib.h>                                      /* malloc(), free() */
31 #include <string.h>                                            /* strerror() */
32
33 #include <vlc/vlc.h>
34
35 #include "xcommon.h"
36
37 /*****************************************************************************
38  * Building configuration tree
39  *****************************************************************************/
40 #define ADAPTOR_TEXT N_("XVideo adaptor number")
41 #define ADAPTOR_LONGTEXT N_( \
42     "If you graphics card provides several adaptors, this option allows you " \
43     "to choose which one will be used (you shouldn't have to change this).")
44
45 #define ALT_FS_TEXT N_("alternate fullscreen method")
46 #define ALT_FS_LONGTEXT N_( \
47     "There are two ways to make a fullscreen window, unfortunately each one " \
48     "has its drawbacks.\n" \
49     "1) Let the window manager handle your fullscreen window (default). But " \
50     "things like taskbars will likely show on top of the video.\n" \
51     "2) Completly bypass the window manager, but then nothing will be able " \
52     "to show on top of the video.")
53
54 #define DISPLAY_TEXT N_("X11 display name")
55 #define DISPLAY_LONGTEXT N_( \
56     "Specify the X11 hardware display you want to use. By default vlc will " \
57     "use the value of the DISPLAY environment variable.")
58
59 #define CHROMA_TEXT N_("XVimage chroma format")
60 #define CHROMA_LONGTEXT N_( \
61     "Force the XVideo renderer to use a specific chroma format instead of " \
62     "trying to improve performances by using the most efficient one.")
63
64 #define DRAWABLE_TEXT N_("X11 drawable")
65 #define DRAWABLE_LONGTEXT N_( \
66     "Specify a X11 drawable to use instead of opening a new window. This " \
67     "option is DANGEROUS, use with care.")
68
69 MODULE_CONFIG_START
70 ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
71 ADD_STRING  ( "xvideo-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT )
72 ADD_INTEGER ( "xvideo-adaptor", -1, NULL, ADAPTOR_TEXT, ADAPTOR_LONGTEXT )
73 ADD_BOOL    ( "xvideo-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
74 ADD_STRING  ( "xvideo-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT )
75 ADD_INTEGER ( "xvideo-drawable", -1, NULL, DRAWABLE_TEXT, DRAWABLE_LONGTEXT )
76 MODULE_CONFIG_STOP
77
78 MODULE_INIT_START
79     SET_DESCRIPTION( _("XVideo extension module") )
80     ADD_CAPABILITY( VOUT, 150 )
81 MODULE_INIT_STOP
82
83 MODULE_ACTIVATE_START
84     _M( vout_getfunctions )( &p_module->p_functions->vout );
85 MODULE_ACTIVATE_STOP
86
87 MODULE_DEACTIVATE_START
88 MODULE_DEACTIVATE_STOP
89
90 /* following functions are local */
91
92 #if 0
93 /*****************************************************************************
94  * XVideoSetAttribute
95  *****************************************************************************
96  * This function can be used to set attributes, e.g. XV_BRIGHTNESS and
97  * XV_CONTRAST. "f_value" should be in the range of 0 to 1.
98  *****************************************************************************/
99 static void XVideoSetAttribute( vout_thread_t *p_vout,
100                                 char *attr_name, float f_value )
101 {
102     int             i_attrib;
103     XvAttribute    *p_attrib;
104     Display        *p_display = p_vout->p_sys->p_display;
105     int             i_xvport  = p_vout->p_sys->i_xvport;
106
107     p_attrib = XvQueryPortAttributes( p_display, i_xvport, &i_attrib );
108
109     do
110     {
111         i_attrib--;
112
113         if( i_attrib >= 0 && !strcmp( p_attrib[ i_attrib ].name, attr_name ) )
114         {
115             int i_sv = f_value * ( p_attrib[ i_attrib ].max_value
116                                     - p_attrib[ i_attrib ].min_value + 1 )
117                         + p_attrib[ i_attrib ].min_value;
118
119             XvSetPortAttribute( p_display, i_xvport,
120                             XInternAtom( p_display, attr_name, False ), i_sv );
121             break;
122         }
123
124     } while( i_attrib > 0 );
125
126     if( p_attrib )
127         XFree( p_attrib );
128 }
129 #endif
130