1 /*****************************************************************************
2 * demux2 adaptation layer.
3 *****************************************************************************
4 * Copyright (C) 2004 VideoLAN
5 * $Id: demux2.c,v 1.3 2004/01/07 14:59:37 fenrir Exp $
7 * Authors: 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
30 #include <vlc/input.h>
32 /*****************************************************************************
34 *****************************************************************************/
35 static int Demux2Open ( vlc_object_t * );
36 static void Demux2Close ( vlc_object_t * );
39 set_description( _("demux2 adaptation layer" ) );
40 set_capability( "demux", 2 );
41 set_callbacks( Demux2Open, Demux2Close );
42 add_shortcut( "demux2" );
45 add_shortcut( "nsv" );
46 add_shortcut( "real" );
50 /*****************************************************************************
52 *****************************************************************************/
53 static int Demux2Demux ( input_thread_t * );
54 static int Demux2Control( input_thread_t *, int, va_list );
61 /*****************************************************************************
62 * Demux2Open: initializes structures
63 *****************************************************************************/
64 static int Demux2Open( vlc_object_t * p_this )
66 input_thread_t *p_input = (input_thread_t *)p_this;
67 demux2_sys_t *p_sys = malloc( sizeof( demux2_sys_t ) );
72 if( input_InitStream( p_input, 0 ) )
77 psz_uri = malloc( strlen( p_input->psz_access ) + strlen( p_input->psz_demux ) + strlen( p_input->psz_name ) + 1 + 3 + 1 );
78 if( p_input->psz_demux && *p_input->psz_demux )
80 sprintf( psz_uri, "%s/%s://%s", p_input->psz_access, p_input->psz_demux, p_input->psz_name );
82 else if( p_input->psz_access && *p_input->psz_access )
84 sprintf( psz_uri, "%s://%s", p_input->psz_access, p_input->psz_name );
88 sprintf( psz_uri, "%s", p_input->psz_name );
91 p_demux = demux2_New( p_input, psz_uri, p_input->s, p_input->p_es_out );
97 /* We should handle special access+demuxer but later */
102 p_input->pf_demux = Demux2Demux;
103 p_input->pf_demux_control = Demux2Control;
104 p_input->p_demux_data = (demux_sys_t*)p_sys;
106 p_sys->p_demux = p_demux;
112 /*****************************************************************************
113 * Demux2Demux: reads and demuxes data packets
114 *****************************************************************************
115 * Returns -1 in case of error, 0 in case of EOF, 1 otherwise
116 *****************************************************************************/
117 static int Demux2Demux( input_thread_t * p_input )
119 demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
121 return demux2_Demux( p_sys->p_demux );
124 /*****************************************************************************
126 *****************************************************************************/
127 static int Demux2Control( input_thread_t *p_input, int i_query, va_list args )
129 demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
131 return demux2_vaControl( p_sys->p_demux, i_query, args );
134 /*****************************************************************************
135 * Demux2Close: frees unused data
136 *****************************************************************************/
137 static void Demux2Close( vlc_object_t * p_this )
139 input_thread_t *p_input = (input_thread_t*)p_this;
140 demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
142 demux2_Delete( p_sys->p_demux );