1 /*****************************************************************************
2 * demux.c: demux functions for dvdplay.
3 *****************************************************************************
4 * Copyright (C) 1998-2001 VideoLAN
5 * $Id: demux.c,v 1.1 2002/08/04 17:23:42 sam Exp $
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
32 #include <vlc/input.h>
39 #include <sys/types.h>
44 #ifdef STRNCASECMP_IN_STRINGS_H
48 #include "interface.h"
53 /* how many packets dvdplay_Demux will read in each loop */
54 #define dvdplay_READ_ONCE 64
56 /*****************************************************************************
58 *****************************************************************************/
59 static int Demux ( input_thread_t * );
61 /*****************************************************************************
62 * InitDVD: initializes dvdplay structures
63 *****************************************************************************/
64 int E_(InitDVD) ( vlc_object_t *p_this )
66 input_thread_t *p_input = (input_thread_t *)p_this;
68 char * psz_intf = NULL;
70 if( p_input->stream.i_method != INPUT_METHOD_DVD )
75 p_input->p_demux_data = (void*)p_input->p_access_data;
76 p_dvd = (dvd_data_t *)p_input->p_demux_data;
78 p_input->pf_demux = Demux;
79 p_input->pf_rewind = NULL;
81 psz_intf = config_GetPsz( p_input, "intf" );
82 config_PutPsz( p_input, "intf", "dvdplay" );
83 p_dvd->p_intf = intf_Create( p_input );
84 p_dvd->p_intf->b_block = VLC_FALSE;
85 intf_RunThread( p_dvd->p_intf );
87 if( psz_intf != NULL )
89 config_PutPsz( p_input, "intf", psz_intf );
95 /*****************************************************************************
96 * EndDVD: frees unused data
97 *****************************************************************************/
98 void E_(EndDVD) ( vlc_object_t *p_this )
100 input_thread_t *p_input = (input_thread_t *)p_this;
102 intf_thread_t * p_intf = NULL;
104 p_intf = vlc_object_find( p_input, VLC_OBJECT_INTF, FIND_CHILD );
107 intf_StopThread( p_intf );
108 vlc_object_detach_all( p_intf );
109 vlc_object_release( p_intf );
110 intf_Destroy( p_intf );
113 p_dvd = (dvd_data_t *)p_input->p_demux_data;
114 p_dvd->p_intf = NULL;
117 /*****************************************************************************
119 *****************************************************************************/
120 static int Demux( input_thread_t * p_input )
123 data_packet_t * p_data;
128 p_dvd = (dvd_data_t *)p_input->p_demux_data;
130 /* Read headers to compute payload length */
133 if( ( i_result = input_ReadPS( p_input, &p_data ) ) <= 0)
138 i_remains = p_input->p_last_data - p_input->p_current_data;
140 input_DemuxPS( p_input, p_data );
149 // if( p_dvd->b_still && p_dvd->b_end_of_cell && p_dvd->p_intf != NULL )
150 if( p_dvd->i_still_time && p_dvd->b_end_of_cell && p_dvd->p_intf != NULL )
152 pgrm_descriptor_t * p_pgrm;
154 /* when we receive still_time flag, we have to pause immediately */
155 input_SetStatus( p_input, INPUT_STATUS_PAUSE );
157 dvdIntfStillTime( p_dvd->p_intf, p_dvd->i_still_time );
158 p_dvd->i_still_time = 0;
160 vlc_mutex_lock( &p_input->stream.stream_lock );
162 p_pgrm = p_input->stream.p_selected_program;
163 p_pgrm->i_synchro_state = SYNCHRO_REINIT;
165 vlc_mutex_unlock( &p_input->stream.stream_lock );
167 input_ClockManageControl( p_input, p_pgrm, 0 );