1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 1999-2004 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
30 #include "input_internal.h"
32 /*****************************************************************************
33 * access2_InternalNew:
34 *****************************************************************************/
35 static access_t *access2_InternalNew( vlc_object_t *p_obj, const char *psz_access,
36 const char *psz_demux, const char *psz_path,
39 access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );
41 if( p_access == NULL )
45 p_access->p_source = p_source;
48 msg_Dbg( p_obj, "creating access filter '%s'", psz_access );
49 p_access->psz_access = strdup( p_source->psz_access );
53 msg_Dbg( p_obj, "creating access '%s' path='%s'",
54 psz_access, psz_path );
55 p_access->psz_path = strdup( psz_path );
57 p_access->psz_access = strdup( psz_access );
58 p_access->psz_demux = strdup( psz_demux );
60 p_access->pf_read = NULL;
61 p_access->pf_block = NULL;
62 p_access->pf_seek = NULL;
63 p_access->pf_control = NULL;
64 p_access->p_sys = NULL;
65 p_access->info.i_update = 0;
66 p_access->info.i_size = 0;
67 p_access->info.i_pos = 0;
68 p_access->info.b_eof = VLC_FALSE;
69 p_access->info.b_prebuffered = VLC_FALSE;
70 p_access->info.i_title = 0;
71 p_access->info.i_seekpoint = 0;
74 /* Before module_Need (for var_Create...) */
75 vlc_object_attach( p_access, p_obj );
78 module_Need( p_access, p_source ? "access_filter" : "access2",
79 psz_access, VLC_TRUE );
81 if( p_access->p_module == NULL )
83 msg_StackAdd( "could not create access" );
84 vlc_object_detach( p_access );
85 free( p_access->psz_access );
86 free( p_access->psz_path );
87 free( p_access->psz_demux );
88 vlc_object_release( p_access );
95 /*****************************************************************************
97 *****************************************************************************/
98 access_t *__access2_New( vlc_object_t *p_obj, const char *psz_access,
99 const char *psz_demux, const char *psz_path )
101 return access2_InternalNew( p_obj, psz_access, psz_demux,
105 /*****************************************************************************
107 *****************************************************************************/
108 access_t *access2_FilterNew( access_t *p_source, const char *psz_access_filter )
110 return access2_InternalNew( VLC_OBJECT(p_source), psz_access_filter,
111 p_source->psz_demux, p_source->psz_path,
115 /*****************************************************************************
117 *****************************************************************************/
118 void access2_Delete( access_t *p_access )
120 module_Unneed( p_access, p_access->p_module );
121 vlc_object_detach( p_access );
123 free( p_access->psz_access );
124 free( p_access->psz_path );
125 free( p_access->psz_demux );
127 if( p_access->p_source )
129 access2_Delete( p_access->p_source );
132 vlc_object_release( p_access );