1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 1999-2004 VideoLAN
5 * $Id: demux.c 7546 2004-04-29 13:53:29Z gbazin $
7 * Author: Laurent Aimar <fenrir@via.ecp.fr>
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.
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.
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 *****************************************************************************/
26 #include <vlc/input.h>
30 int access_vaControl( input_thread_t *p_input, int i_query, va_list args )
32 if( p_input->pf_access_control )
34 return p_input->pf_access_control( p_input, i_query, args );
39 int access_Control( input_thread_t *p_input, int i_query, ... )
44 va_start( args, i_query );
45 i_result = access_vaControl( p_input, i_query, args );
51 int access_vaControlDefault( input_thread_t *p_input, int i_query, va_list args )
56 /*****************************************************************************
58 *****************************************************************************/
59 access_t *__access2_New( vlc_object_t *p_obj,
60 char *psz_mrl, stream_t *s, es_out_t *out )
62 msg_Err( p_obj, "access2_New not yet implemented" );
65 access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );
67 char *psz_dup = strdup( psz_mrl ? psz_mrl : "" );
68 char *psz = strchr( psz_dup, ':' );
78 p_demux->psz_access = NULL;
79 p_demux->psz_demux = NULL;
80 p_demux->psz_path = NULL;
86 if( psz[0] == '/' && psz[1] == '/' )
90 p_demux->psz_path = strdup( psz );
92 psz = strchr( psz_dup, '/' );
96 p_demux->psz_access = strdup( psz_dup );
97 p_demux->psz_demux = strdup( psz );
102 p_demux->psz_path = strdup( psz_mrl );
107 if( p_demux->psz_access == NULL )
109 p_demux->psz_access = strdup( "" );
111 if( p_demux->psz_demux == NULL )
113 p_demux->psz_demux = strdup( "" );
115 if( p_demux->psz_path == NULL )
117 p_demux->psz_path = strdup( "" );
119 msg_Dbg( p_obj, "demux2_New: '%s' -> access='%s' demux='%s' path='%s'",
121 p_demux->psz_access, p_demux->psz_demux, p_demux->psz_path );
126 p_demux->pf_demux = NULL;
127 p_demux->pf_control = NULL;
128 p_demux->p_sys = NULL;
130 psz_module = p_demux->psz_demux;
131 if( *psz_module == '\0' && strrchr( p_demux->psz_path, '.' ) )
133 /* XXX: add only file without any problem here and with strong detection.
134 * - no .mp3, .a52, ... (aac is added as it works only by file ext anyway
135 * - wav can't be added 'cause of a52 and dts in them as raw audio
137 static struct { char *ext; char *demux; } exttodemux[] =
141 { "asf", "asf" }, { "wmv", "asf" }, { "wma", "asf" },
147 { "mkv", "mkv" }, { "mka", "mkv" }, { "mks", "mkv" },
148 { "mp4", "mp4" }, { "m4a", "mp4" }, { "mov", "mp4" }, { "moov", "mp4" },
149 { "mod", "mod" }, { "xm", "mod" },
151 { "ogg", "ogg" }, { "ogm", "ogg" },
157 char *psz_ext = strrchr( p_demux->psz_path, '.' ) + 1;
160 for( i = 0; exttodemux[i].ext != NULL; i++ )
162 if( !strcasecmp( psz_ext, exttodemux[i].ext ) )
164 psz_module = exttodemux[i].demux;
170 /* Before module_Need (for var_Create...) */
171 vlc_object_attach( p_demux, p_obj );
174 module_Need( p_demux, "demux2", psz_module,
175 !strcmp( psz_module, p_demux->psz_demux ) ? VLC_TRUE : VLC_FALSE );
177 if( p_demux->p_module == NULL )
179 vlc_object_detach( p_demux );
180 free( p_demux->psz_path );
181 free( p_demux->psz_demux );
182 free( p_demux->psz_access );
183 vlc_object_destroy( p_demux );
191 /*****************************************************************************
193 *****************************************************************************/
194 void access2_Delete( access_t *p_access )
196 module_Unneed( p_access, p_access->p_module );
197 vlc_object_detach( p_access );
199 free( p_access->psz_access );
200 free( p_access->psz_path );
201 free( p_access->psz_demux );
203 vlc_object_destroy( p_access );