* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_ps.c,v 1.4 2001/02/08 17:44:12 massiot Exp $
+ * $Id: input_ps.c,v 1.11 2001/03/15 01:42:20 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+#define MODULE_NAME ps
+#include "modules_inner.h"
+
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <string.h>
#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+
#include "config.h"
#include "common.h"
#include "threads.h"
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
*****************************************************************************/
-void input_getfunctions( function_list_t * p_function_list )
+void _M( input_getfunctions )( function_list_t * p_function_list )
{
#define input p_function_list->functions.input
p_function_list->pf_probe = PSProbe;
input.pf_open = input_FileOpen;
input.pf_close = input_FileClose;
input.pf_end = PSEnd;
+ input.pf_set_area = NULL;
input.pf_read = PSRead;
input.pf_demux = input_DemuxPS;
input.pf_new_packet = NewPacket;
*****************************************************************************/
static int PSProbe( probedata_t *p_data )
{
+ input_thread_t * p_input = (input_thread_t *)p_data;
+
+ char * psz_name = p_input->p_source;
+ int i_handle;
+ int i_score = 10;
+
if( TestMethod( INPUT_METHOD_VAR, "ps" ) )
{
return( 999 );
}
- return 10;
+ if( ( strlen(psz_name) > 5 ) && !strncasecmp( psz_name, "file:", 5 ) )
+ {
+ /* If the user specified "file:" then it's probably a file */
+ i_score = 100;
+ psz_name += 5;
+ }
+
+ i_handle = open( psz_name, 0 );
+ if( i_handle == -1 )
+ {
+ return( 0 );
+ }
+ close( i_handle );
+
+ return( i_score );
}
/*****************************************************************************
}
/* File too big. */
- if( p_input->stream.i_tell > INPUT_PREPARSE_LENGTH )
+ if( p_input->stream.p_selected_area->i_tell >
+ INPUT_PREPARSE_LENGTH )
{
break;
}
}
rewind( p_method->stream );
vlc_mutex_lock( &p_input->stream.stream_lock );
- p_input->stream.i_tell = 0;
+ p_input->stream.p_selected_area->i_tell = 0;
if( p_demux_data->b_has_PSM )
{
/* (The PSM decoder will care about spawning the decoders) */
case MPEG1_AUDIO_ES:
case MPEG2_AUDIO_ES:
- if( main_GetIntVariable( INPUT_DVD_CHANNEL_VAR, 0 )
+ if( main_GetIntVariable( INPUT_CHANNEL_VAR, 0 )
== (p_es->i_id & 0x1F) )
- switch( main_GetIntVariable( INPUT_DVD_AUDIO_VAR, 0 ) )
+ switch( main_GetIntVariable( INPUT_AUDIO_VAR, 0 ) )
{
case 0:
- main_PutIntVariable( INPUT_DVD_CHANNEL_VAR,
+ main_PutIntVariable( INPUT_AUDIO_VAR,
REQUESTED_MPEG );
case REQUESTED_MPEG:
input_SelectES( p_input, p_es );
break;
case AC3_AUDIO_ES:
- if( main_GetIntVariable( INPUT_DVD_CHANNEL_VAR, 0 )
+ if( main_GetIntVariable( INPUT_CHANNEL_VAR, 0 )
== ((p_es->i_id & 0xF00) >> 8) )
- switch( main_GetIntVariable( INPUT_DVD_AUDIO_VAR, 0 ) )
+ switch( main_GetIntVariable( INPUT_AUDIO_VAR, 0 ) )
{
case 0:
- main_PutIntVariable( INPUT_DVD_CHANNEL_VAR,
+ main_PutIntVariable( INPUT_AUDIO_VAR,
REQUESTED_AC3 );
case REQUESTED_AC3:
input_SelectES( p_input, p_es );
break;
case DVD_SPU_ES:
- if( main_GetIntVariable( INPUT_DVD_SUBTITLE_VAR, -1 )
+ if( main_GetIntVariable( INPUT_SUBTITLE_VAR, -1 )
== ((p_es->i_id & 0x1F00) >> 8) )
{
input_SelectES( p_input, p_es );
*****************************************************************************/
static void PSEnd( input_thread_t * p_input )
{
- free( p_input->stream.p_demux_data );
free( p_input->p_plugin_data );
}
}
}
vlc_mutex_lock( &p_input->stream.stream_lock );
- p_input->stream.i_tell += i_len;
+ p_input->stream.p_selected_area->i_tell += i_len;
vlc_mutex_unlock( &p_input->stream.stream_lock );
return( 0 );
}
/* It is common for MPEG-1 streams to pad with zeros
* (although it is forbidden by the recommendation), so
* don't bother everybody in this case. */
- intf_WarnMsg( 1, "Garbage at input (%x)", i_startcode );
+ intf_WarnMsg( 1, "Garbage at input (%.8x)", i_startcode );
}
while( (i_startcode & 0xFFFFFF00) != 0x100L )
/* A little bourrin but should work for a while --Meuuh */
fseeko( p_method->stream, i_position, SEEK_SET );
- p_input->stream.i_tell = i_position;
+ p_input->stream.p_selected_area->i_tell = i_position;
}
/*