00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <stdlib.h>
00025 #include <vlc/vlc.h>
00026 #include <vlc/input.h>
00027
00028 #include "input_internal.h"
00029
00030
00031
00032
00033 static access_t *access2_InternalNew( vlc_object_t *p_obj, char *psz_access,
00034 char *psz_demux, char *psz_path,
00035 access_t *p_source, vlc_bool_t b_quick )
00036 {
00037 access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );
00038
00039 if( p_access == NULL )
00040 {
00041 msg_Err( p_obj, "vlc_object_create() failed" );
00042 return NULL;
00043 }
00044
00045
00046 p_access->p_source = p_source;
00047 if( p_source )
00048 {
00049 msg_Dbg( p_obj, "creating access filter '%s'", psz_access );
00050 p_access->psz_access = strdup( p_source->psz_access );
00051 p_access->psz_path = strdup( p_source->psz_path );
00052 p_access->psz_demux = strdup( p_source->psz_demux );
00053 }
00054 else
00055 {
00056 p_access->psz_path = strdup( psz_path );
00057 p_access->psz_access =
00058 b_quick ? strdup( "file" ) : strdup( psz_access );
00059 p_access->psz_demux = strdup( psz_demux );
00060
00061 if( !b_quick )
00062 msg_Dbg( p_obj, "creating access '%s' path='%s'",
00063 psz_access, psz_path );
00064 }
00065
00066 p_access->pf_read = NULL;
00067 p_access->pf_block = NULL;
00068 p_access->pf_seek = NULL;
00069 p_access->pf_control = NULL;
00070 p_access->p_sys = NULL;
00071 p_access->info.i_update = 0;
00072 p_access->info.i_size = 0;
00073 p_access->info.i_pos = 0;
00074 p_access->info.b_eof = VLC_FALSE;
00075 p_access->info.b_prebuffered = VLC_FALSE;
00076 p_access->info.i_title = 0;
00077 p_access->info.i_seekpoint = 0;
00078
00079
00080
00081 vlc_object_attach( p_access, p_obj );
00082
00083 if( p_source )
00084 {
00085 p_access->p_module =
00086 module_Need( p_access, "access_filter", psz_access, VLC_FALSE );
00087 }
00088 else
00089 {
00090 p_access->p_module =
00091 module_Need( p_access, "access2", p_access->psz_access,
00092 b_quick ? VLC_TRUE : VLC_FALSE );
00093 }
00094
00095 if( p_access->p_module == NULL )
00096 {
00097 vlc_object_detach( p_access );
00098 free( p_access->psz_access );
00099 free( p_access->psz_path );
00100 free( p_access->psz_demux );
00101 vlc_object_destroy( p_access );
00102 return NULL;
00103 }
00104
00105 return p_access;
00106 }
00107
00108
00109
00110
00111 access_t *__access2_New( vlc_object_t *p_obj, char *psz_access,
00112 char *psz_demux, char *psz_path, vlc_bool_t b_quick )
00113 {
00114 return access2_InternalNew( p_obj, psz_access, psz_demux,
00115 psz_path, NULL, b_quick );
00116 }
00117
00118
00119
00120
00121 access_t *access2_FilterNew( access_t *p_source, char *psz_access_filter )
00122 {
00123 return access2_InternalNew( VLC_OBJECT(p_source), psz_access_filter,
00124 NULL, NULL, p_source, VLC_FALSE );
00125 }
00126
00127
00128
00129
00130 void access2_Delete( access_t *p_access )
00131 {
00132 module_Unneed( p_access, p_access->p_module );
00133 vlc_object_detach( p_access );
00134
00135 free( p_access->psz_access );
00136 free( p_access->psz_path );
00137 free( p_access->psz_demux );
00138
00139 if( p_access->p_source )
00140 {
00141 access2_Delete( p_access->p_source );
00142 }
00143
00144 vlc_object_destroy( p_access );
00145 }
00146