]> git.sesse.net Git - vlc/blob - plugins/dummy/dummy.c
. the IDCT functions are now located in modules : the classic IDCT,
[vlc] / plugins / dummy / dummy.c
1 /*****************************************************************************
2  * dummy.c : dummy 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 #define MODULE_NAME dummy
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include "defs.h"
29
30 #include <stdlib.h>                                      /* malloc(), free() */
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 "modules.h"
45 #include "modules_inner.h"
46
47 /*****************************************************************************
48  * Build configuration tree.
49  *****************************************************************************/
50 MODULE_CONFIG_START
51 ADD_WINDOW( "Configuration for dummy module" )
52     ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
53 MODULE_CONFIG_END
54
55 /*****************************************************************************
56  * Capabilities defined in the other files.
57  *****************************************************************************/
58 extern void aout_getfunctions( function_list_t * p_function_list );
59
60 /*****************************************************************************
61  * InitModule: get the module structure and configuration.
62  *****************************************************************************
63  * We have to fill psz_name, psz_longname and psz_version. These variables
64  * will be strdup()ed later by the main application because the module can
65  * be unloaded later to save memory, and we want to be able to access this
66  * data even after the module has been unloaded.
67  *****************************************************************************/
68 int InitModule( module_t * p_module )
69 {
70     p_module->psz_name = MODULE_STRING;
71     p_module->psz_longname = "dummy functions module";
72     p_module->psz_version = VERSION;
73
74     p_module->i_capabilities = MODULE_CAPABILITY_NULL
75                                 | MODULE_CAPABILITY_AOUT;
76
77     return( 0 );
78 }
79
80 /*****************************************************************************
81  * ActivateModule: set the module to an usable state.
82  *****************************************************************************
83  * This function fills the capability functions and the configuration
84  * structure. Once ActivateModule() has been called, the i_usage can
85  * be set to 0 and calls to NeedModule() be made to increment it. To unload
86  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
87  *****************************************************************************/
88 int ActivateModule( module_t * p_module )
89 {
90     p_module->p_functions = malloc( sizeof( module_functions_t ) );
91     if( p_module->p_functions == NULL )
92     {
93         return( -1 );
94     }
95
96     aout_getfunctions( &p_module->p_functions->aout );
97
98     p_module->p_config = p_config;
99
100     return( 0 );
101 }
102
103 /*****************************************************************************
104  * DeactivateModule: make sure the module can be unloaded.
105  *****************************************************************************
106  * This function must only be called when i_usage == 0. If it successfully
107  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
108  * lock usage_lock during the whole process.
109  *****************************************************************************/
110 int DeactivateModule( module_t * p_module )
111 {
112     free( p_module->p_functions );
113
114     return( 0 );
115 }
116
117 /* OLD MODULE STRUCTURE -- soon to be removed */
118
119 /*****************************************************************************
120  * Exported prototypes
121  *****************************************************************************/
122 static void vout_GetPlugin( p_vout_thread_t p_vout );
123 static void intf_GetPlugin( p_intf_thread_t p_intf );
124
125 /* Video output */
126 int     vout_DummyCreate       ( vout_thread_t *p_vout, char *psz_display,
127                                  int i_root_window, void *p_data );
128 int     vout_DummyInit         ( p_vout_thread_t p_vout );
129 void    vout_DummyEnd          ( p_vout_thread_t p_vout );
130 void    vout_DummyDestroy      ( p_vout_thread_t p_vout );
131 int     vout_DummyManage       ( p_vout_thread_t p_vout );
132 void    vout_DummyDisplay      ( p_vout_thread_t p_vout );
133 void    vout_DummySetPalette   ( p_vout_thread_t p_vout,
134                                  u16 *red, u16 *green, u16 *blue, u16 *transp );
135
136 /* Interface */
137 int     intf_DummyCreate       ( p_intf_thread_t p_intf );
138 void    intf_DummyDestroy      ( p_intf_thread_t p_intf );
139 void    intf_DummyManage       ( p_intf_thread_t p_intf );
140
141 /*****************************************************************************
142  * GetConfig: get the plugin structure and configuration
143  *****************************************************************************/
144 plugin_info_t * GetConfig( void )
145 {
146     plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
147
148     p_info->psz_name    = "Dummy";
149     p_info->psz_version = VERSION;
150     p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
151
152     p_info->aout_GetPlugin = NULL;
153     p_info->vout_GetPlugin = vout_GetPlugin;
154     p_info->intf_GetPlugin = intf_GetPlugin;
155     p_info->yuv_GetPlugin  = NULL;
156
157     /* The dummy plugin always works, but should have low priority */
158     p_info->i_score = 0x1;
159
160     /* If this plugin was requested, score it higher */
161     if( TestMethod( VOUT_METHOD_VAR, "dummy" ) )
162     {
163         p_info->i_score += 0x200;
164     }
165
166     return( p_info );
167 }
168
169 /*****************************************************************************
170  * Following functions are only called through the p_info structure
171  *****************************************************************************/
172
173 static void vout_GetPlugin( p_vout_thread_t p_vout )
174 {
175     p_vout->p_sys_create  = vout_DummyCreate;
176     p_vout->p_sys_init    = vout_DummyInit;
177     p_vout->p_sys_end     = vout_DummyEnd;
178     p_vout->p_sys_destroy = vout_DummyDestroy;
179     p_vout->p_sys_manage  = vout_DummyManage;
180     p_vout->p_sys_display = vout_DummyDisplay;
181 }
182
183 static void intf_GetPlugin( p_intf_thread_t p_intf )
184 {
185     p_intf->p_sys_create  = intf_DummyCreate;
186     p_intf->p_sys_destroy = intf_DummyDestroy;
187     p_intf->p_sys_manage  = intf_DummyManage;
188 }
189