]> git.sesse.net Git - vlc/blob - plugins/fb/fb.c
. autod�tection des plugins
[vlc] / plugins / fb / fb.c
1 /*****************************************************************************
2  * fb.c : Linux framebuffer 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 <sys/types.h>
29 #include <sys/stat.h>
30 #include <fcntl.h>
31 #include <stdlib.h>                                      /* malloc(), free() */
32 #include <unistd.h>                                               /* close() */
33
34 #include "config.h"
35 #include "common.h"                                     /* boolean_t, byte_t */
36 #include "threads.h"
37 #include "mtime.h"
38 #include "tests.h"
39 #include "plugins.h"
40
41 #include "interface.h"
42 #include "audio_output.h"
43 #include "video.h"
44 #include "video_output.h"
45
46 #include "main.h"
47
48 /*****************************************************************************
49  * Exported prototypes
50  *****************************************************************************/
51 static void vout_GetPlugin( p_vout_thread_t p_vout );
52 static void intf_GetPlugin( p_intf_thread_t p_intf );
53
54 /* Video output */
55 int     vout_FBCreate       ( vout_thread_t *p_vout, char *psz_display,
56                               int i_root_window, void *p_data );
57 int     vout_FBInit         ( p_vout_thread_t p_vout );
58 void    vout_FBEnd          ( p_vout_thread_t p_vout );
59 void    vout_FBDestroy      ( p_vout_thread_t p_vout );
60 int     vout_FBManage       ( p_vout_thread_t p_vout );
61 void    vout_FBDisplay      ( p_vout_thread_t p_vout );
62 void    vout_FBSetPalette   ( p_vout_thread_t p_vout,
63                               u16 *red, u16 *green, u16 *blue, u16 *transp );
64
65 /* Interface */
66 int     intf_FBCreate       ( p_intf_thread_t p_intf );
67 void    intf_FBDestroy      ( p_intf_thread_t p_intf );
68 void    intf_FBManage       ( p_intf_thread_t p_intf );
69
70 /*****************************************************************************
71  * GetConfig: get the plugin structure and configuration
72  *****************************************************************************/
73 plugin_info_t * GetConfig( void )
74 {
75     int i_fd;
76     plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
77
78     p_info->psz_name    = "Linux framebuffer";
79     p_info->psz_version = VERSION;
80     p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
81
82     p_info->aout_GetPlugin = NULL;
83     p_info->vout_GetPlugin = vout_GetPlugin;
84     p_info->intf_GetPlugin = intf_GetPlugin;
85     p_info->yuv_GetPlugin  = NULL;
86
87     /* Test if the device can be opened */
88     if ( (i_fd = open( main_GetPszVariable( VOUT_FB_DEV_VAR,
89                                             VOUT_FB_DEV_DEFAULT ),
90                        O_RDWR )) < 0 )
91     {
92         p_info->i_score = 0;
93     }
94     else
95     {
96         close( i_fd );
97         p_info->i_score = 0x100;
98     }
99
100     if( TestProgram( "fbvlc" ) )
101     {
102         p_info->i_score += 0x180;
103     }
104
105     /* If this plugin was requested, score it higher */
106     if( TestMethod( VOUT_METHOD_VAR, "fb" ) )
107     {
108         p_info->i_score += 0x200;
109     }
110
111     return( p_info );
112 }
113
114 /*****************************************************************************
115  * Following functions are only called through the p_info structure
116  *****************************************************************************/
117
118 static void vout_GetPlugin( p_vout_thread_t p_vout )
119 {
120     p_vout->p_sys_create  = vout_FBCreate;
121     p_vout->p_sys_init    = vout_FBInit;
122     p_vout->p_sys_end     = vout_FBEnd;
123     p_vout->p_sys_destroy = vout_FBDestroy;
124     p_vout->p_sys_manage  = vout_FBManage;
125     p_vout->p_sys_display = vout_FBDisplay;
126     
127     /* optional functions */
128     p_vout->p_set_palette = vout_FBSetPalette;
129 }
130
131 static void intf_GetPlugin( p_intf_thread_t p_intf )
132 {
133     p_intf->p_sys_create  = intf_FBCreate;
134     p_intf->p_sys_destroy = intf_FBDestroy;
135     p_intf->p_sys_manage  = intf_FBManage;
136 }
137