1 /* dvd_demux.c: DVD demux functions.
2 *****************************************************************************
3 * Copyright (C) 1998-2001 VideoLAN
4 * $Id: dvd_demux.c,v 1.7 2002/06/01 12:31:58 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>
38 #include <sys/types.h>
43 #ifdef STRNCASECMP_IN_STRINGS_H
47 /* how many packets DVDDemux will read in each loop */
48 #define DVD_READ_ONCE 64
50 /*****************************************************************************
52 *****************************************************************************/
54 /* called from outside */
55 static int DVDRewind ( input_thread_t * );
56 static int DVDDemux ( input_thread_t * );
57 static int DVDInit ( input_thread_t * );
58 static void DVDEnd ( input_thread_t * );
60 void DVDLaunchDecoders( input_thread_t * );
62 /*****************************************************************************
63 * Functions exported as capabilities. They are declared as static so that
64 * we don't pollute the namespace too much.
65 *****************************************************************************/
66 void _M( demux_getfunctions)( function_list_t * p_function_list )
68 #define demux p_function_list->functions.demux
69 demux.pf_init = DVDInit;
70 demux.pf_end = DVDEnd;
71 demux.pf_demux = DVDDemux;
72 demux.pf_rewind = DVDRewind;
77 * Data demux functions
80 /*****************************************************************************
81 * DVDInit: initializes DVD structures
82 *****************************************************************************/
83 static int DVDInit( input_thread_t * p_input )
85 if( p_input->stream.i_method != INPUT_METHOD_DVD )
90 vlc_mutex_lock( &p_input->stream.stream_lock );
92 DVDLaunchDecoders( p_input );
94 vlc_mutex_unlock( &p_input->stream.stream_lock );
99 /*****************************************************************************
100 * DVDEnd: frees unused data
101 *****************************************************************************/
102 static void DVDEnd( input_thread_t * p_input )
106 /*****************************************************************************
108 *****************************************************************************/
109 static int DVDDemux( input_thread_t * p_input )
111 data_packet_t * p_data;
115 /* Read headers to compute payload length */
116 for( i = 0 ; i < DVD_READ_ONCE ; i++ )
118 i_result = input_ReadPS( p_input, &p_data );
124 else if( i_result == 0 )
129 input_DemuxPS( p_input, p_data );
135 /*****************************************************************************
136 * DVDRewind : reads a stream backward
137 *****************************************************************************/
138 static int DVDRewind( input_thread_t * p_input )