]> git.sesse.net Git - vlc/blob - plugins/x11/x11.c
. autod�tection des plugins
[vlc] / plugins / x11 / x11.c
1 /*****************************************************************************
2  * x11.c : X11 plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000 VideoLAN
5  *
6  * Authors:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26 #include "defs.h"
27
28 #include <stdlib.h>                                      /* malloc(), free() */
29
30 #include <X11/Xlib.h>
31
32 #include "config.h"
33 #include "common.h"                                     /* boolean_t, byte_t */
34 #include "threads.h"
35 #include "mtime.h"
36 #include "tests.h"
37 #include "plugins.h"
38
39 #include "interface.h"
40 #include "audio_output.h"
41 #include "video.h"
42 #include "video_output.h"
43
44 #include "main.h"
45
46 /*****************************************************************************
47  * Exported prototypes
48  *****************************************************************************/
49 static void vout_GetPlugin( p_vout_thread_t p_vout );
50 static void intf_GetPlugin( p_intf_thread_t p_intf );
51
52 /* Video output */
53 int     vout_X11Create       ( vout_thread_t *p_vout, char *psz_display,
54                                int i_root_window, void *p_data );
55 int     vout_X11Init         ( p_vout_thread_t p_vout );
56 void    vout_X11End          ( p_vout_thread_t p_vout );
57 void    vout_X11Destroy      ( p_vout_thread_t p_vout );
58 int     vout_X11Manage       ( p_vout_thread_t p_vout );
59 void    vout_X11Display      ( p_vout_thread_t p_vout );
60 void    vout_X11SetPalette   ( p_vout_thread_t p_vout,
61                                u16 *red, u16 *green, u16 *blue, u16 *transp );
62
63 /* Interface */
64 int     intf_X11Create       ( p_intf_thread_t p_intf );
65 void    intf_X11Destroy      ( p_intf_thread_t p_intf );
66 void    intf_X11Manage       ( p_intf_thread_t p_intf );
67
68 /*****************************************************************************
69  * GetConfig: get the plugin structure and configuration
70  *****************************************************************************/
71 plugin_info_t * GetConfig( void )
72 {
73     Display *p_display;
74     plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
75
76     p_info->psz_name    = "X Window System";
77     p_info->psz_version = VERSION;
78     p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
79
80     p_info->aout_GetPlugin = NULL;
81     p_info->vout_GetPlugin = vout_GetPlugin;
82     p_info->intf_GetPlugin = intf_GetPlugin;
83     p_info->yuv_GetPlugin  = NULL;
84
85     /* check that we can open the X display */
86     if( (p_display = XOpenDisplay( XDisplayName(
87                          main_GetPszVariable( VOUT_DISPLAY_VAR, NULL ) ) ))
88         == NULL )
89     {
90         p_info->i_score = 0x0;
91     }
92     else
93     {
94         XCloseDisplay( p_display );
95         p_info->i_score = 0x200;
96     }
97
98     if( TestProgram( "xvlc" ) )
99     {
100         p_info->i_score += 0x180;
101     }
102
103     /* If this plugin was requested, score it higher */
104     if( TestMethod( VOUT_METHOD_VAR, "x11" ) )
105     {
106         p_info->i_score += 0x200;
107     }
108
109     return( p_info );
110 }
111
112 /*****************************************************************************
113  * Following functions are only called through the p_info structure
114  *****************************************************************************/
115
116 static void vout_GetPlugin( p_vout_thread_t p_vout )
117 {
118     p_vout->p_sys_create  = vout_X11Create;
119     p_vout->p_sys_init    = vout_X11Init;
120     p_vout->p_sys_end     = vout_X11End;
121     p_vout->p_sys_destroy = vout_X11Destroy;
122     p_vout->p_sys_manage  = vout_X11Manage;
123     p_vout->p_sys_display = vout_X11Display;
124
125     /* optional functions */
126     p_vout->p_set_palette = vout_X11SetPalette;
127 }
128
129 static void intf_GetPlugin( p_intf_thread_t p_intf )
130 {
131     p_intf->p_sys_create  = intf_X11Create;
132     p_intf->p_sys_destroy = intf_X11Destroy;
133     p_intf->p_sys_manage  = intf_X11Manage;
134 }
135