access.c 4.5 KB
Newer Older
1
2
3
/*****************************************************************************
 * access.c
 *****************************************************************************
4
 * Copyright (C) 1999-2004 the VideoLAN team
dionoea's avatar
dionoea committed
5
 * $Id$
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 *
 * Author: Laurent Aimar <fenrir@via.ecp.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
dionoea's avatar
dionoea committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22
23
 *****************************************************************************/

24
25
26
27
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

28
29
#include <vlc/vlc.h>

Laurent Aimar's avatar
Laurent Aimar committed
30
#include "input_internal.h"
31
32

/*****************************************************************************
33
 * access2_InternalNew:
34
 *****************************************************************************/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
35
36
static access_t *access2_InternalNew( vlc_object_t *p_obj, const char *psz_access,
                                      const char *psz_demux, const char *psz_path,
37
                                      access_t *p_source )
38
39
40
{
    access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );

41
    if( p_access == NULL )
42
43
44
        return NULL;

    /* Parse URL */
45
46
47
48
49
50
    p_access->p_source = p_source;
    if( p_source )
    {
        msg_Dbg( p_obj, "creating access filter '%s'", psz_access );
        p_access->psz_access = strdup( p_source->psz_access );
    }
51
    else
52
    {
53
54
        msg_Dbg( p_obj, "creating access '%s' path='%s'",
                 psz_access, psz_path );
55
        p_access->psz_path   = strdup( psz_path );
56
    }
57
58
    p_access->psz_access = strdup( psz_access );
    p_access->psz_demux  = strdup( psz_demux );
59

60
61
62
63
64
    p_access->pf_read    = NULL;
    p_access->pf_block   = NULL;
    p_access->pf_seek    = NULL;
    p_access->pf_control = NULL;
    p_access->p_sys      = NULL;
Laurent Aimar's avatar
Laurent Aimar committed
65
66
67
68
    p_access->info.i_update = 0;
    p_access->info.i_size   = 0;
    p_access->info.i_pos    = 0;
    p_access->info.b_eof    = VLC_FALSE;
69
    p_access->info.b_prebuffered = VLC_FALSE;
Laurent Aimar's avatar
Laurent Aimar committed
70
71
72
    p_access->info.i_title  = 0;
    p_access->info.i_seekpoint = 0;

73
74

    /* Before module_Need (for var_Create...) */
75
    vlc_object_attach( p_access, p_obj );
76

77
78
79
    p_access->p_module =
         module_Need( p_access, p_source ? "access_filter" : "access2",
                      psz_access, VLC_TRUE );
80

81
    if( p_access->p_module == NULL )
82
    {
83
        msg_StackAdd( "could not create access" );
84
85
86
87
        vlc_object_detach( p_access );
        free( p_access->psz_access );
        free( p_access->psz_path );
        free( p_access->psz_demux );
88
        vlc_object_release( p_access );
89
90
91
        return NULL;
    }

92
    return p_access;
93
94
95
}

/*****************************************************************************
96
97
 * access2_New:
 *****************************************************************************/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
98
access_t *__access2_New( vlc_object_t *p_obj, const char *psz_access,
99
                         const char *psz_demux, const char *psz_path )
100
{
101
    return access2_InternalNew( p_obj, psz_access, psz_demux,
102
                                psz_path, NULL );
103
104
105
106
107
}

/*****************************************************************************
 * access2_FilterNew:
 *****************************************************************************/
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
108
access_t *access2_FilterNew( access_t *p_source, const char *psz_access_filter )
109
{
110
    return access2_InternalNew( VLC_OBJECT(p_source), psz_access_filter,
111
112
                                p_source->psz_demux, p_source->psz_path,
                                p_source );
113
114
115
116
}

/*****************************************************************************
 * access2_Delete:
117
118
119
120
121
122
123
124
125
126
 *****************************************************************************/
void access2_Delete( access_t *p_access )
{
    module_Unneed( p_access, p_access->p_module );
    vlc_object_detach( p_access );

    free( p_access->psz_access );
    free( p_access->psz_path );
    free( p_access->psz_demux );

127
128
129
130
131
    if( p_access->p_source )
    {
        access2_Delete( p_access->p_source );
    }

132
    vlc_object_release( p_access );
133
}
134