1 /*****************************************************************************
2 * demux.c: demux functions for dvdplay.
3 *****************************************************************************
4 * Copyright (C) 1998-2001 the VideoLAN team
7 * Author: Stéphane Borel <stef@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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
30 #include <vlc_input.h>
31 #include <vlc_access.h>
32 #include <vlc_interface.h>
39 #include <sys/types.h>
43 #ifdef STRNCASECMP_IN_STRINGS_H
48 #include "vcdplayer.h"
51 /* how many packets vcdx_Demux will read in each loop */
52 /* #define vcdplay_READ_ONCE 64 */
54 /*****************************************************************************
56 *****************************************************************************/
57 static int Demux ( input_thread_t * );
59 /*****************************************************************************
61 *****************************************************************************/
70 /*****************************************************************************
71 * VCDInit: initializes structures
72 *****************************************************************************/
73 int E_(VCDInit) ( vlc_object_t *p_this )
75 input_thread_t *p_input = (input_thread_t *)p_this;
76 vcd_data_t * p_vcd = (vcd_data_t *)p_input->p_sys;
77 demux_sys_t * p_demux;
79 printf("++++ VCDInit CALLED\n");
82 if( p_input->stream.i_method != INPUT_METHOD_VCD )
87 p_demux = p_input->p_demux_data = malloc( sizeof(demux_sys_t ) );
93 p_input->p_private = (void*)&p_demux->mpeg;
94 p_demux->p_module = module_Need( p_input, "mpeg-system", NULL, 0 );
95 if( p_demux->p_module == NULL )
97 free( p_input->p_demux_data );
101 p_input->p_demux_data->p_vcd = p_vcd;
103 p_input->pf_demux = Demux;
104 p_input->pf_demux_control = demux_vaControlDefault;
105 p_input->pf_rewind = NULL;
107 p_vcd->p_intf = NULL;
108 p_vcd->i_still_time = 0;
113 /*****************************************************************************
114 * VCDEnd: frees unused data
115 *****************************************************************************/
116 void E_(VCDEnd) ( vlc_object_t *p_this )
118 input_thread_t *p_input = (input_thread_t *)p_this;
119 vcd_data_t * p_vcd = p_input->p_demux_data->p_vcd;
120 intf_thread_t * p_intf = NULL;
122 p_intf = vlc_object_find( p_input, VLC_OBJECT_INTF, FIND_CHILD );
125 intf_StopThread( p_intf );
126 vlc_object_detach( p_intf );
127 vlc_object_release( p_intf );
128 intf_Destroy( p_intf );
131 p_vcd->p_intf = NULL;
133 module_Unneed( p_input, p_input->p_demux_data->p_module );
134 free( p_input->p_demux_data );
137 /*****************************************************************************
139 *****************************************************************************/
140 static int Demux( input_thread_t * p_input )
143 data_packet_t * p_data;
148 p_vcd = p_input->p_demux_data->p_vcd;
150 /* Read headers to compute payload length */
153 i_result = p_input->p_demux_data->mpeg.pf_read_ps( p_input, &p_data );
160 i_remains = p_input->p_last_data - p_input->p_current_data;
162 p_input->p_demux_data->mpeg.pf_demux_ps( p_input, p_data );
171 // if( p_vcd->b_still && p_vcd->b_end_of_cell && p_vcd->p_intf != NULL )
172 if( p_vcd->i_still_time && p_vcd->b_end_of_cell && p_vcd->p_intf != NULL )
174 pgrm_descriptor_t * p_pgrm;
176 /* when we receive still_time flag, we have to pause immediately */
177 var_SetInteger( p_input, "state", PAUSE_S );
179 vcdIntfStillTime( p_vcd->p_intf, p_vcd->i_still_time );
180 p_vcd->i_still_time = 0;
182 vlc_mutex_lock( &p_input->stream.stream_lock );
184 p_pgrm = p_input->stream.p_selected_program;
185 p_pgrm->i_synchro_state = SYNCHRO_REINIT;
187 vlc_mutex_unlock( &p_input->stream.stream_lock );
189 input_ClockManageControl( p_input, p_pgrm, 0 );