]> git.sesse.net Git - vlc/blob - src/input/access.c
* ninput, access: compilation fix.
[vlc] / src / input / access.c
1 /*****************************************************************************
2  * access.c
3  *****************************************************************************
4  * Copyright (C) 1999-2004 VideoLAN
5  * $Id: demux.c 7546 2004-04-29 13:53:29Z gbazin $
6  *
7  * Author: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #include <stdlib.h>
25 #include <vlc/vlc.h>
26 #include <vlc/input.h>
27
28 #include "ninput.h"
29
30 int access_vaControl( input_thread_t *p_input, int i_query, va_list args )
31 {
32     if( p_input->pf_access_control )
33     {
34         return p_input->pf_access_control( p_input, i_query, args );
35     }
36     return VLC_EGENERIC;
37 }
38
39 int access_Control( input_thread_t *p_input, int i_query, ...  )
40 {
41     va_list args;
42     int     i_result;
43
44     va_start( args, i_query );
45     i_result = access_vaControl( p_input, i_query, args );
46     va_end( args );
47
48     return i_result;
49 }
50
51 int access_vaControlDefault( input_thread_t *p_input, int i_query, va_list args )
52 {
53     return VLC_EGENERIC;
54 }
55
56 /*****************************************************************************
57  * access2_New:
58  *****************************************************************************/
59 access_t *__access2_New( vlc_object_t *p_obj, char *psz_mrl )
60 {
61     msg_Err( p_obj, "access2_New not yet implemented" );
62     return NULL;
63 #if 0
64     access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );
65
66     char    *psz_dup = strdup( psz_mrl ? psz_mrl : "" );
67     char    *psz = strchr( psz_dup, ':' );
68     char    *psz_module;
69
70     if( p_demux == NULL )
71     {
72         free( psz_dup );
73         return NULL;
74     }
75
76     /* Parse URL */
77     p_demux->psz_access = NULL;
78     p_demux->psz_demux  = NULL;
79     p_demux->psz_path   = NULL;
80
81     if( psz )
82     {
83         *psz++ = '\0';
84
85         if( psz[0] == '/' && psz[1] == '/' )
86         {
87             psz += 2;
88         }
89         p_demux->psz_path = strdup( psz );
90
91         psz = strchr( psz_dup, '/' );
92         if( psz )
93         {
94             *psz++ = '\0';
95             p_demux->psz_access = strdup( psz_dup );
96             p_demux->psz_demux  = strdup( psz );
97         }
98     }
99     else
100     {
101         p_demux->psz_path = strdup( psz_mrl );
102     }
103     free( psz_dup );
104
105
106     if( p_demux->psz_access == NULL )
107     {
108         p_demux->psz_access = strdup( "" );
109     }
110     if( p_demux->psz_demux == NULL )
111     {
112         p_demux->psz_demux = strdup( "" );
113     }
114     if( p_demux->psz_path == NULL )
115     {
116         p_demux->psz_path = strdup( "" );
117     }
118     msg_Dbg( p_obj, "demux2_New: '%s' -> access='%s' demux='%s' path='%s'",
119              psz_mrl,
120              p_demux->psz_access, p_demux->psz_demux, p_demux->psz_path );
121
122     p_demux->s          = s;
123     p_demux->out        = out;
124
125     p_demux->pf_demux   = NULL;
126     p_demux->pf_control = NULL;
127     p_demux->p_sys      = NULL;
128
129     psz_module = p_demux->psz_demux;
130     if( *psz_module == '\0' && strrchr( p_demux->psz_path, '.' ) )
131     {
132         /* XXX: add only file without any problem here and with strong detection.
133          *  - no .mp3, .a52, ... (aac is added as it works only by file ext anyway
134          *  - wav can't be added 'cause of a52 and dts in them as raw audio
135          */
136         static struct { char *ext; char *demux; } exttodemux[] =
137         {
138             { "aac",  "aac" },
139             { "aiff", "aiff" },
140             { "asf",  "asf" }, { "wmv",  "asf" }, { "wma",  "asf" },
141             { "avi",  "avi" },
142             { "au",   "au" },
143             { "flac", "flac" },
144             { "dv",   "dv" },
145             { "m3u",  "m3u" },
146             { "mkv",  "mkv" }, { "mka",  "mkv" }, { "mks",  "mkv" },
147             { "mp4",  "mp4" }, { "m4a",  "mp4" }, { "mov",  "mp4" }, { "moov", "mp4" },
148             { "mod",  "mod" }, { "xm",   "mod" },
149             { "nsv",  "nsv" },
150             { "ogg",  "ogg" }, { "ogm",  "ogg" },
151             { "pva",  "pva" },
152             { "rm",   "rm" },
153             { "",  "" },
154         };
155
156         char *psz_ext = strrchr( p_demux->psz_path, '.' ) + 1;
157         int  i;
158
159         for( i = 0; exttodemux[i].ext != NULL; i++ )
160         {
161             if( !strcasecmp( psz_ext, exttodemux[i].ext ) )
162             {
163                 psz_module = exttodemux[i].demux;
164                 break;
165             }
166         }
167     }
168
169     /* Before module_Need (for var_Create...) */
170     vlc_object_attach( p_demux, p_obj );
171
172     p_demux->p_module =
173         module_Need( p_demux, "demux2", psz_module,
174                      !strcmp( psz_module, p_demux->psz_demux ) ? VLC_TRUE : VLC_FALSE );
175
176     if( p_demux->p_module == NULL )
177     {
178         vlc_object_detach( p_demux );
179         free( p_demux->psz_path );
180         free( p_demux->psz_demux );
181         free( p_demux->psz_access );
182         vlc_object_destroy( p_demux );
183         return NULL;
184     }
185
186     return p_demux;
187 #endif
188 }
189
190 /*****************************************************************************
191  * demux2_Delete:
192  *****************************************************************************/
193 void access2_Delete( access_t *p_access )
194 {
195     module_Unneed( p_access, p_access->p_module );
196     vlc_object_detach( p_access );
197
198     free( p_access->psz_access );
199     free( p_access->psz_path );
200     free( p_access->psz_demux );
201
202     vlc_object_destroy( p_access );
203 }