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, char *psz_mrl )
61 msg_Err( p_obj, "access2_New not yet implemented" );
64 access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );
66 char *psz_dup = strdup( psz_mrl ? psz_mrl : "" );
67 char *psz = strchr( psz_dup, ':' );
77 p_demux->psz_access = NULL;
78 p_demux->psz_demux = NULL;
79 p_demux->psz_path = NULL;
85 if( psz[0] == '/' && psz[1] == '/' )
89 p_demux->psz_path = strdup( psz );
91 psz = strchr( psz_dup, '/' );
95 p_demux->psz_access = strdup( psz_dup );
96 p_demux->psz_demux = strdup( psz );
101 p_demux->psz_path = strdup( psz_mrl );
106 if( p_demux->psz_access == NULL )
108 p_demux->psz_access = strdup( "" );
110 if( p_demux->psz_demux == NULL )
112 p_demux->psz_demux = strdup( "" );
114 if( p_demux->psz_path == NULL )
116 p_demux->psz_path = strdup( "" );
118 msg_Dbg( p_obj, "demux2_New: '%s' -> access='%s' demux='%s' path='%s'",
120 p_demux->psz_access, p_demux->psz_demux, p_demux->psz_path );
125 p_demux->pf_demux = NULL;
126 p_demux->pf_control = NULL;
127 p_demux->p_sys = NULL;
129 psz_module = p_demux->psz_demux;
130 if( *psz_module == '\0' && strrchr( p_demux->psz_path, '.' ) )
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
136 static struct { char *ext; char *demux; } exttodemux[] =
140 { "asf", "asf" }, { "wmv", "asf" }, { "wma", "asf" },
146 { "mkv", "mkv" }, { "mka", "mkv" }, { "mks", "mkv" },
147 { "mp4", "mp4" }, { "m4a", "mp4" }, { "mov", "mp4" }, { "moov", "mp4" },
148 { "mod", "mod" }, { "xm", "mod" },
150 { "ogg", "ogg" }, { "ogm", "ogg" },
156 char *psz_ext = strrchr( p_demux->psz_path, '.' ) + 1;
159 for( i = 0; exttodemux[i].ext != NULL; i++ )
161 if( !strcasecmp( psz_ext, exttodemux[i].ext ) )
163 psz_module = exttodemux[i].demux;
169 /* Before module_Need (for var_Create...) */
170 vlc_object_attach( p_demux, p_obj );
173 module_Need( p_demux, "demux2", psz_module,
174 !strcmp( psz_module, p_demux->psz_demux ) ? VLC_TRUE : VLC_FALSE );
176 if( p_demux->p_module == NULL )
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 );
190 /*****************************************************************************
192 *****************************************************************************/
193 void access2_Delete( access_t *p_access )
195 module_Unneed( p_access, p_access->p_module );
196 vlc_object_detach( p_access );
198 free( p_access->psz_access );
199 free( p_access->psz_path );
200 free( p_access->psz_demux );
202 vlc_object_destroy( p_access );