1 /* demux.c: DVD demux functions.
2 *****************************************************************************
3 * Copyright (C) 1998-2001 VideoLAN
4 * $Id: demux.c,v 1.2 2002/08/07 00:29:36 sam Exp $
6 * Author: Stéphane Borel <stef@via.ecp.fr>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
21 *****************************************************************************/
23 /*****************************************************************************
25 *****************************************************************************/
31 #include <vlc/input.h>
33 #include "../../demux/mpeg/system.h"
40 #include <sys/types.h>
45 #ifdef STRNCASECMP_IN_STRINGS_H
49 /* how many packets DVDDemux will read in each loop */
50 #define DVD_READ_ONCE 64
52 /*****************************************************************************
54 *****************************************************************************/
61 /*****************************************************************************
63 *****************************************************************************/
64 static int DVDDemux ( input_thread_t * );
66 void DVDLaunchDecoders( input_thread_t * );
68 /*****************************************************************************
69 * DVDInit: initialize DVD structures
70 *****************************************************************************/
71 int E_(DVDInit) ( vlc_object_t *p_this )
73 input_thread_t *p_input = (input_thread_t *)p_this;
74 demux_sys_t * p_demux;
76 if( p_input->stream.i_method != INPUT_METHOD_DVD )
81 p_demux = p_input->p_demux_data = malloc( sizeof(demux_sys_t ) );
87 p_input->p_private = (void*)&p_demux->mpeg;
88 p_demux->p_module = module_Need( p_input, "mpeg-system", NULL );
89 if( p_demux->p_module == NULL )
91 free( p_input->p_demux_data );
95 p_input->pf_demux = DVDDemux;
96 p_input->pf_rewind = NULL;
98 vlc_mutex_lock( &p_input->stream.stream_lock );
100 DVDLaunchDecoders( p_input );
102 vlc_mutex_unlock( &p_input->stream.stream_lock );
107 /*****************************************************************************
108 * DVDEnd: free DVD structures
109 *****************************************************************************/
110 void E_(DVDEnd) ( vlc_object_t *p_this )
112 input_thread_t *p_input = (input_thread_t *)p_this;
114 module_Unneed( p_input, p_input->p_demux_data->p_module );
115 free( p_input->p_demux_data );
118 /*****************************************************************************
120 *****************************************************************************/
121 static int DVDDemux( input_thread_t * p_input )
123 data_packet_t * p_data;
127 /* Read headers to compute payload length */
128 for( i = 0 ; i < DVD_READ_ONCE ; i++ )
130 i_result = p_input->p_demux_data->mpeg.pf_read_ps( p_input, &p_data );
136 else if( i_result == 0 )
141 p_input->p_demux_data->mpeg.pf_demux_ps( p_input, p_data );