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>
28 #include "input_internal.h"
30 /*****************************************************************************
31 * access2_InternalNew:
32 *****************************************************************************/
33 static access_t *access2_InternalNew( vlc_object_t *p_obj,
34 char *psz_access, char *psz_demux, char *psz_path,
38 access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );
40 if( p_access == NULL )
42 msg_Err( p_obj, "vlc_object_create( p_obj, VLC_OBJECT_ACCESS ) failed" );
47 p_access->p_source = p_source;
50 msg_Dbg( p_obj, "creating access filter '%s'", psz_access );
51 p_access->psz_access = strdup( p_source->psz_access );
52 p_access->psz_path = strdup( p_source->psz_path );
56 msg_Dbg( p_obj, "creating access '%s' path='%s'",
57 psz_access, psz_path );
58 p_access->psz_access = b_quick ? strdup( "file" ) : strdup( psz_access );
59 p_access->psz_path = strdup( psz_path );
61 p_access->psz_demux = strdup( "" );
63 p_access->pf_read = NULL;
64 p_access->pf_block = NULL;
65 p_access->pf_seek = NULL;
66 p_access->pf_control = NULL;
67 p_access->p_sys = NULL;
68 p_access->info.i_update = 0;
69 p_access->info.i_size = 0;
70 p_access->info.i_pos = 0;
71 p_access->info.b_eof = VLC_FALSE;
72 p_access->info.i_title = 0;
73 p_access->info.i_seekpoint = 0;
76 /* Before module_Need (for var_Create...) */
77 vlc_object_attach( p_access, p_obj );
82 module_Need( p_access, "access_filter", psz_access, VLC_FALSE );
87 module_Need( p_access, "access2",p_access->psz_access,
88 b_quick ? VLC_TRUE : VLC_FALSE );
91 if( p_access->p_module == NULL )
93 vlc_object_detach( p_access );
94 free( p_access->psz_access );
95 free( p_access->psz_path );
96 free( p_access->psz_demux );
97 vlc_object_destroy( p_access );
104 /*****************************************************************************
106 *****************************************************************************/
107 access_t *__access2_New( vlc_object_t *p_obj,
108 char *psz_access, char *psz_demux, char *psz_path,
111 return access2_InternalNew( p_obj, psz_access, psz_demux, psz_path, NULL, b_quick );
114 /*****************************************************************************
116 *****************************************************************************/
117 access_t *access2_FilterNew( access_t *p_source, char *psz_access_filter )
119 return access2_InternalNew( VLC_OBJECT(p_source),
120 psz_access_filter, NULL, NULL,
121 p_source, VLC_FALSE );
124 /*****************************************************************************
126 *****************************************************************************/
127 void access2_Delete( access_t *p_access )
129 module_Unneed( p_access, p_access->p_module );
130 vlc_object_detach( p_access );
132 free( p_access->psz_access );
133 free( p_access->psz_path );
134 free( p_access->psz_demux );
136 if( p_access->p_source )
138 access2_Delete( p_access->p_source );
141 vlc_object_destroy( p_access );