]> git.sesse.net Git - vlc/blob - modules/video_output/x11/xvideo.c
c38193852aaef1396257a31a652af240b2a795f2
[vlc] / modules / video_output / x11 / xvideo.c
1 /*****************************************************************************
2  * xvideo.c : Xvideo plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 1998-2001 the VideoLAN team
5  * $Id$
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <vlc_common.h>
36 #include <vlc_plugin.h>
37
38 /*****************************************************************************
39  * Exported prototypes
40  *****************************************************************************/
41 extern int  Activate   ( vlc_object_t * );
42 extern void Deactivate ( vlc_object_t * );
43
44 /*****************************************************************************
45  * Module descriptor
46  *****************************************************************************/
47 #define ADAPTOR_TEXT N_("XVideo adaptor number")
48 #define ADAPTOR_LONGTEXT N_( \
49     "If your graphics card provides several adaptors, you need to choose " \
50     "which one will be used (you shouldn't have to change this).")
51
52 #define DISPLAY_TEXT N_("X11 display")
53 #define DISPLAY_LONGTEXT N_( \
54     "X11 hardware display to use. By default VLC will " \
55     "use the value of the DISPLAY environment variable.")
56
57 #define CHROMA_TEXT N_("XVimage chroma format")
58 #define CHROMA_LONGTEXT N_( \
59     "Force the XVideo renderer to use a specific chroma format instead of " \
60     "trying to improve performances by using the most efficient one.")
61
62 #define SHM_TEXT N_("Use shared memory")
63 #define SHM_LONGTEXT N_( \
64     "Use shared memory to communicate between VLC and the X server.")
65
66 vlc_module_begin ()
67     set_shortname( "XVideo" )
68     set_category( CAT_VIDEO )
69     set_subcategory( SUBCAT_VIDEO_VOUT )
70     add_string( "xvideo-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, true )
71     add_integer( "xvideo-adaptor", -1, NULL, ADAPTOR_TEXT, ADAPTOR_LONGTEXT, true )
72     add_string( "xvideo-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true )
73 #ifdef HAVE_SYS_SHM_H
74     add_bool( "xvideo-shm", 1, NULL, SHM_TEXT, SHM_LONGTEXT, true )
75 #endif
76
77     set_description( N_("XVideo extension video output") )
78     set_capability( "video output", 150 )
79     set_callbacks( Activate, Deactivate )
80 vlc_module_end ()
81
82 /* following functions are local */
83
84 #if 0
85 /*****************************************************************************
86  * XVideoSetAttribute
87  *****************************************************************************
88  * This function can be used to set attributes, e.g. XV_BRIGHTNESS and
89  * XV_CONTRAST. "f_value" should be in the range of 0 to 1.
90  *****************************************************************************/
91 static void XVideoSetAttribute( vout_thread_t *p_vout,
92                                 char *attr_name, float f_value )
93 {
94     int             i_attrib;
95     XvAttribute    *p_attrib;
96     Display        *p_display = p_vout->p_sys->p_display;
97     int             i_xvport  = p_vout->p_sys->i_xvport;
98
99     p_attrib = XvQueryPortAttributes( p_display, i_xvport, &i_attrib );
100
101     do
102     {
103         i_attrib--;
104
105         if( i_attrib >= 0 && !strcmp( p_attrib[ i_attrib ].name, attr_name ) )
106         {
107             int i_sv = f_value * ( p_attrib[ i_attrib ].max_value
108                                     - p_attrib[ i_attrib ].min_value + 1 )
109                         + p_attrib[ i_attrib ].min_value;
110
111             XvSetPortAttribute( p_display, i_xvport,
112                             XInternAtom( p_display, attr_name, False ), i_sv );
113             break;
114         }
115
116     } while( i_attrib > 0 );
117
118     if( p_attrib )
119         XFree( p_attrib );
120 }
121 #endif
122