1 /*****************************************************************************
2 * demux2 adaptation layer.
3 *****************************************************************************
4 * Copyright (C) 2004 VideoLAN
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 #include "vlc_playlist.h"
34 /*****************************************************************************
36 *****************************************************************************/
37 static int Demux2Open ( vlc_object_t * );
38 static void Demux2Close ( vlc_object_t * );
41 set_description( _("Demux2 adaptation layer" ) );
42 set_capability( "demux", 10 );
43 set_callbacks( Demux2Open, Demux2Close );
44 add_shortcut( "demux2" );
47 add_shortcut( "nsv" );
48 add_shortcut( "live" );
50 add_shortcut( "ps2" );
51 add_shortcut( "dvdnav" );
52 add_shortcut( "dvdnavsimple" );
53 add_shortcut( "ffmpeg" );
54 add_shortcut( "mp3" );
55 add_shortcut( "mpga" );
56 add_shortcut( "aac" );
57 add_shortcut( "a52" );
58 add_shortcut( "dts" );
59 add_shortcut( "mod" );
60 add_shortcut( "flac" );
61 add_shortcut( "m3u" );
62 add_shortcut( "playlist" );
63 add_shortcut( "m4v" );
64 add_shortcut( "mp4v" );
65 add_shortcut( "mpgv" );
66 add_shortcut( "rawdv" );
67 add_shortcut( "ogg" );
68 add_shortcut( "h264" );
69 add_shortcut( "avi" );
70 add_shortcut( "mjpeg" );
71 add_shortcut( "directory" );
72 add_shortcut( "wav" );
75 /*****************************************************************************
77 *****************************************************************************/
78 static int Demux2Demux ( input_thread_t * );
79 static int Demux2Control( input_thread_t *, int, va_list );
86 /*****************************************************************************
87 * Demux2Open: initializes structures
88 *****************************************************************************/
89 static int Demux2Open( vlc_object_t * p_this )
91 input_thread_t *p_input = (input_thread_t *)p_this;
92 demux2_sys_t *p_sys = malloc( sizeof( demux2_sys_t ) );
94 playlist_t *p_playlist;
98 if( input_InitStream( p_input, 0 ) )
103 psz_uri = malloc( strlen( p_input->psz_access ) + strlen( p_input->psz_demux ) + strlen( p_input->psz_name ) + 1 + 3 + 1 );
104 if( p_input->psz_demux && *p_input->psz_demux )
106 sprintf( psz_uri, "%s/%s://%s", p_input->psz_access, p_input->psz_demux, p_input->psz_name );
108 else if( p_input->psz_access && *p_input->psz_access )
110 sprintf( psz_uri, "%s://%s", p_input->psz_access, p_input->psz_name );
114 sprintf( psz_uri, "://%s", p_input->psz_name );
117 p_demux = demux2_New( p_input, psz_uri, p_input->s, p_input->p_es_out );
123 /* We should handle special access+demuxer but later */
128 /* Now retreive meta info from demuxer */
129 if( ( p_playlist = vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
134 if( !demux2_Control( p_demux, DEMUX_GET_LENGTH, &i_length ) )
136 playlist_SetDuration( p_playlist, -1, i_length );
138 vlc_object_release( p_playlist );
141 p_input->pf_demux = Demux2Demux;
142 p_input->pf_demux_control = Demux2Control;
143 p_input->p_demux_data = (demux_sys_t*)p_sys;
145 p_sys->p_demux = p_demux;
151 /*****************************************************************************
152 * Demux2Demux: reads and demuxes data packets
153 *****************************************************************************
154 * Returns -1 in case of error, 0 in case of EOF, 1 otherwise
155 *****************************************************************************/
156 static int Demux2Demux( input_thread_t * p_input )
158 demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
160 return demux2_Demux( p_sys->p_demux );
163 /*****************************************************************************
165 *****************************************************************************/
166 static int Demux2Control( input_thread_t *p_input, int i_query, va_list args )
168 demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
170 return demux2_vaControl( p_sys->p_demux, i_query, args );
173 /*****************************************************************************
174 * Demux2Close: frees unused data
175 *****************************************************************************/
176 static void Demux2Close( vlc_object_t * p_this )
178 input_thread_t *p_input = (input_thread_t*)p_this;
179 demux2_sys_t *p_sys = (demux2_sys_t*)p_input->p_demux_data;
181 demux2_Delete( p_sys->p_demux );