]> git.sesse.net Git - vlc/blob - src/input/access.c
Remove VLC_OBJECT_(ACCESS|DEMUX|STREAM) types
[vlc] / src / input / access.c
1 /*****************************************************************************
2  * access.c
3  *****************************************************************************
4  * Copyright (C) 1999-2004 the VideoLAN team
5  * $Id$
6  *
7  * Author: Laurent Aimar <fenrir@via.ecp.fr>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
27
28 #include <vlc_common.h>
29
30 #include "input_internal.h"
31
32 /*****************************************************************************
33  * access_InternalNew:
34  *****************************************************************************/
35 static access_t *access_InternalNew( vlc_object_t *p_obj, const char *psz_access,
36                                       const char *psz_demux, const char *psz_path,
37                                       access_t *p_source )
38 {
39     static const char typename[] = "access";
40     access_t *p_access = vlc_custom_create( p_obj, sizeof (*p_access),
41                                             VLC_OBJECT_GENERIC, typename );
42
43     if( p_access == NULL )
44         return NULL;
45
46     /* Parse URL */
47     p_access->p_source = p_source;
48     if( p_source )
49     {
50         msg_Dbg( p_obj, "creating access filter '%s'", psz_access );
51         p_access->psz_access = strdup( p_source->psz_access );
52     }
53     else
54     {
55         msg_Dbg( p_obj, "creating access '%s' path='%s'",
56                  psz_access, psz_path );
57         p_access->psz_path   = strdup( psz_path );
58     }
59     p_access->psz_access = strdup( psz_access );
60     p_access->psz_demux  = strdup( psz_demux );
61
62     p_access->pf_read    = NULL;
63     p_access->pf_block   = NULL;
64     p_access->pf_seek    = NULL;
65     p_access->pf_control = NULL;
66     p_access->p_sys      = NULL;
67     p_access->info.i_update = 0;
68     p_access->info.i_size   = 0;
69     p_access->info.i_pos    = 0;
70     p_access->info.b_eof    = false;
71     p_access->info.b_prebuffered = false;
72     p_access->info.i_title  = 0;
73     p_access->info.i_seekpoint = 0;
74
75
76     /* Before module_Need (for var_Create...) */
77     vlc_object_attach( p_access, p_obj );
78
79     p_access->p_module =
80          module_Need( p_access, p_source ? "access_filter" : "access",
81                       psz_access, true );
82
83     if( p_access->p_module == NULL )
84     {
85         msg_StackAdd( "could not create access" );
86         vlc_object_detach( p_access );
87         free( p_access->psz_access );
88         free( p_access->psz_path );
89         free( p_access->psz_demux );
90         vlc_object_release( p_access );
91         return NULL;
92     }
93
94     return p_access;
95 }
96
97 /*****************************************************************************
98  * access_New:
99  *****************************************************************************/
100 access_t *__access_New( vlc_object_t *p_obj, const char *psz_access,
101                          const char *psz_demux, const char *psz_path )
102 {
103     return access_InternalNew( p_obj, psz_access, psz_demux,
104                                 psz_path, NULL );
105 }
106
107 /*****************************************************************************
108  * access_FilterNew:
109  *****************************************************************************/
110 access_t *access_FilterNew( access_t *p_source, const char *psz_access_filter )
111 {
112     return access_InternalNew( VLC_OBJECT(p_source), psz_access_filter,
113                                 p_source->psz_demux, p_source->psz_path,
114                                 p_source );
115 }
116
117 /*****************************************************************************
118  * access_Delete:
119  *****************************************************************************/
120 void access_Delete( access_t *p_access )
121 {
122     module_Unneed( p_access, p_access->p_module );
123     vlc_object_detach( p_access );
124
125     free( p_access->psz_access );
126     free( p_access->psz_path );
127     free( p_access->psz_demux );
128
129     if( p_access->p_source )
130     {
131         access_Delete( p_access->p_source );
132     }
133
134     vlc_object_release( p_access );
135 }
136