Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

access.c

00001 /*****************************************************************************
00002  * access.c
00003  *****************************************************************************
00004  * Copyright (C) 1999-2004 the VideoLAN team
00005  * $Id: demux.c 7546 2004-04-29 13:53:29Z gbazin $
00006  *
00007  * Author: Laurent Aimar <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
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  * access2_InternalNew:
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     /* Parse URL */
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     /* Before module_Need (for var_Create...) */
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  * access2_New:
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  * access2_FilterNew:
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  * access2_Delete:
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 

Generated on Tue Dec 20 10:14:23 2005 for vlc-0.8.4a by  doxygen 1.4.2