Commit ce0e4dd1 authored by Christophe Massiot's avatar Christophe Massiot

* Cleaned up sam's mess with input's pf_open and pf_close (not completely) ;

* With -vvv modules now show up their scores ;

This afternoon I have been a little bored, so the feature of the day is :
* HTTP input support.

You can test it with :
./vlc http://mysite.com:80/mystream.mpg
It doesn't implement any kind of buffering, so make sure you have enough
bandwidth, otherwise you'll just get nothing.

It is compatible with HTTP proxy, just set http_proxy :
export http_proxy="http://proxy.mycompany.com:3128/"

Enjoy !
parent 62ba06e0
......@@ -4,7 +4,7 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.43 2001/10/01 16:18:48 massiot Exp $
* $Id: input_ext-intf.h,v 1.44 2001/10/02 16:46:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -284,17 +284,10 @@ typedef struct input_thread_s
* backwards (it's gonna be fun) */
void (* pf_seek)( struct input_thread_s *, off_t );
/* Special callback functions */
void (* pf_file_open ) ( struct input_thread_s * );
void (* pf_file_close ) ( struct input_thread_s * );
#if !defined( SYS_BEOS ) && !defined( SYS_NTO )
void (* pf_network_open ) ( struct input_thread_s * );
void (* pf_network_close ) ( struct input_thread_s * );
#endif
char * p_source;
int i_handle; /* socket or file descriptor */
FILE * p_stream; /* if applicable */
int i_read_once; /* number of packet read by
* pf_read once */
void * p_method_data; /* data of the packet manager */
......
......@@ -10,7 +10,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.86 2001/09/30 01:26:44 stef Exp $
* $Id: input_dvd.c,v 1.87 2001/10/02 16:46:59 massiot Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -239,9 +239,6 @@ static void DVDInit( input_thread_t * p_input )
/* Initialize ES structures */
input_InitStream( p_input, sizeof( stream_ps_data_t ) );
/* disc input method */
p_input->stream.i_method = INPUT_METHOD_DVD;
#define title_inf p_dvd->p_ifo->vmg.title_inf
intf_WarnMsg( 2, "dvd info: number of titles: %d", title_inf.i_title_nb );
......
......@@ -2,7 +2,7 @@
* input_es.c: Elementary Stream demux and packet management
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_es.c,v 1.9 2001/07/30 00:53:05 sam Exp $
* $Id: input_es.c,v 1.10 2001/10/02 16:46:59 massiot Exp $
*
* Author: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -100,7 +100,7 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
#define input p_function_list->functions.input
p_function_list->pf_probe = ESProbe;
input.pf_init = ESInit;
input.pf_open = NULL; /* Set in ESInit */
input.pf_open = NULL;
input.pf_close = NULL;
input.pf_end = ESEnd;
input.pf_init_bit_stream = ESInitBitstream;
......@@ -127,8 +127,6 @@ static int ESProbe( 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 = 5;
if( TestMethod( INPUT_METHOD_VAR, "es" ) )
......@@ -136,13 +134,6 @@ static int ESProbe( probedata_t *p_data )
return( 999 );
}
i_handle = open( psz_name, 0 );
if( i_handle == -1 )
{
return( 0 );
}
close( i_handle );
return( i_score );
}
......@@ -163,9 +154,6 @@ static void ESInit( input_thread_t * p_input )
return;
}
p_input->pf_open = p_input->pf_file_open;
p_input->pf_close = p_input->pf_file_close;
/* FIXME : detect if InitStream failed */
input_InitStream( p_input, 0 );
input_AddProgram( p_input, 0, 0 );
......@@ -175,7 +163,6 @@ static void ESInit( input_thread_t * p_input )
p_es->i_type = MPEG1_VIDEO_ES;
p_es->i_cat = VIDEO_ES;
input_SelectES( p_input, p_es );
p_input->stream.i_method = INPUT_METHOD_FILE;
p_input->stream.p_selected_area->i_tell = 0;
p_input->stream.pp_programs[0]->b_is_ok = 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
......
......@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_ps.c,v 1.35 2001/10/01 16:18:48 massiot Exp $
* $Id: input_ps.c,v 1.36 2001/10/02 16:46:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -108,7 +108,7 @@ 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_init = PSInit;
input.pf_open = NULL; /* Set in PSInit */
input.pf_open = NULL;
input.pf_close = NULL;
input.pf_end = PSEnd;
input.pf_init_bit_stream = InitBitstream;
......@@ -136,7 +136,6 @@ 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" ) )
......@@ -144,20 +143,15 @@ static int PSProbe( probedata_t *p_data )
return( 999 );
}
if( ( strlen(psz_name) > 5 ) && !strncasecmp( psz_name, "file:", 5 ) )
if( ( strlen(psz_name) > 5 ) && (!strncasecmp( psz_name, "file:", 5 )
|| !strncasecmp( psz_name, "http:", 5 )) )
{
/* If the user specified "file:" then it's probably a file */
/* If the user specified "file:" or "http:" then it's probably a
* PS 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 );
}
......@@ -166,18 +160,8 @@ static int PSProbe( probedata_t *p_data )
*****************************************************************************/
static void PSInit( input_thread_t * p_input )
{
thread_ps_data_t * p_method;
packet_cache_t * p_packet_cache;
p_method = (thread_ps_data_t *)malloc( sizeof(thread_ps_data_t) );
if( p_method == NULL )
{
intf_ErrMsg( "Out of memory" );
p_input->b_error = 1;
return;
}
p_input->p_plugin_data = (void *)p_method;
/* creates the packet cache structure */
p_packet_cache = malloc( sizeof(packet_cache_t) );
if ( p_packet_cache == NULL )
......@@ -188,10 +172,6 @@ static void PSInit( input_thread_t * p_input )
}
p_input->p_method_data = (void *)p_packet_cache;
/* Set callback */
p_input->pf_open = p_input->pf_file_open;
p_input->pf_close = p_input->pf_file_close;
/* Initialize packet cache mutex */
vlc_mutex_init( &p_packet_cache->lock );
......@@ -239,16 +219,18 @@ static void PSInit( input_thread_t * p_input )
}
p_packet_cache->largebuffer.l_index = 0;
if( p_input->p_stream == NULL )
{
/* Re-open the socket as a buffered FILE stream */
p_method->stream = fdopen( p_input->i_handle, "r" );
p_input->p_stream = fdopen( p_input->i_handle, "r" );
if( p_method->stream == NULL )
if( p_input->p_stream == NULL )
{
intf_ErrMsg( "Cannot open file (%s)", strerror(errno) );
p_input->b_error = 1;
return;
}
rewind( p_method->stream );
}
/* FIXME : detect if InitStream failed */
input_InitStream( p_input, sizeof( stream_ps_data_t ) );
......@@ -259,6 +241,8 @@ static void PSInit( input_thread_t * p_input )
stream_ps_data_t * p_demux_data =
(stream_ps_data_t *)p_input->stream.pp_programs[0]->p_demux_data;
rewind( p_input->p_stream );
/* Pre-parse the stream to gather stream_descriptor_t. */
p_input->stream.pp_programs[0]->b_is_ok = 0;
p_demux_data->i_PSM_version = EMPTY_PSM_VERSION;
......@@ -298,10 +282,9 @@ static void PSInit( input_thread_t * p_input )
break;
}
}
rewind( p_method->stream );
rewind( p_input->p_stream );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.i_method = INPUT_METHOD_FILE;
p_input->stream.p_selected_area->i_tell = 0;
if( p_demux_data->b_has_PSM )
......@@ -427,18 +410,16 @@ static void PSEnd( input_thread_t * p_input )
static __inline__ int SafeRead( input_thread_t * p_input, byte_t * p_buffer,
size_t i_len )
{
thread_ps_data_t * p_method;
int i_error;
p_method = (thread_ps_data_t *)p_input->p_plugin_data;
while( fread( p_buffer, i_len, 1, p_method->stream ) != 1 )
while( fread( p_buffer, i_len, 1, p_input->p_stream ) != 1 )
{
if( feof( p_method->stream ) )
if( feof( p_input->p_stream ) )
{
return( 1 );
}
if( (i_error = ferror( p_method->stream )) )
if( (i_error = ferror( p_input->p_stream )) )
{
intf_ErrMsg( "Read failed (%s)", strerror(i_error) );
return( -1 );
......@@ -463,9 +444,6 @@ static int PSRead( input_thread_t * p_input,
data_packet_t * p_data;
size_t i_packet_size;
int i_packet, i_error;
thread_ps_data_t * p_method;
p_method = (thread_ps_data_t *)p_input->p_plugin_data;
memset( pp_packets, 0, INPUT_READ_ONCE * sizeof(data_packet_t *) );
for( i_packet = 0; i_packet < INPUT_READ_ONCE; i_packet++ )
......@@ -494,7 +472,7 @@ static int PSRead( input_thread_t * p_input,
while( (i_startcode & 0xFFFFFF00) != 0x100L )
{
i_startcode <<= 8;
if( (i_dummy = getc( p_method->stream )) != EOF )
if( (i_dummy = getc( p_input->p_stream )) != EOF )
{
i_startcode |= i_dummy;
}
......@@ -600,15 +578,11 @@ static int PSRead( input_thread_t * p_input,
*****************************************************************************/
static void PSSeek( input_thread_t * p_input, off_t i_position )
{
thread_ps_data_t * p_method;
p_method = (thread_ps_data_t *)p_input->p_plugin_data;
/* A little bourrin but should work for a while --Meuuh */
#if defined( WIN32 ) || defined( SYS_GNU0_2 )
fseek( p_method->stream, (long)i_position, SEEK_SET );
fseek( p_input->p_stream, (long)i_position, SEEK_SET );
#else
fseeko( p_method->stream, i_position, SEEK_SET );
fseeko( p_input->p_stream, i_position, SEEK_SET );
#endif
p_input->stream.p_selected_area->i_tell = i_position;
......
......@@ -2,7 +2,7 @@
* input_ps.h: thread structure of the PS plugin
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ps.h,v 1.8 2001/05/31 03:12:49 sam Exp $
* $Id: input_ps.h,v 1.9 2001/10/02 16:46:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -22,16 +22,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* thread_ps_data_t: extension of input_thread_t
*****************************************************************************/
typedef struct thread_ps_data_s
{
/* We're necessarily reading a file. */
FILE * stream;
} thread_ps_data_t;
#define DATA_CACHE_SIZE 150
#define PES_CACHE_SIZE 150
#define SMALL_CACHE_SIZE 150
......
......@@ -2,7 +2,7 @@
* input_ts.c: TS demux and netlist management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_ts.c,v 1.33 2001/09/06 18:21:02 henri Exp $
* $Id: input_ts.c,v 1.34 2001/10/02 16:46:59 massiot Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
*
......@@ -89,7 +89,6 @@
*****************************************************************************/
static int TSProbe ( probedata_t * );
static void TSInit ( struct input_thread_s * );
static void TSFakeOpen ( struct input_thread_s * );
static void TSEnd ( struct input_thread_s * );
static int TSRead ( struct input_thread_s *,
data_packet_t * p_packets[INPUT_READ_ONCE] );
......@@ -103,8 +102,8 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
#define input p_function_list->functions.input
p_function_list->pf_probe = TSProbe;
input.pf_init = TSInit;
input.pf_open = TSFakeOpen;
input.pf_close = NULL; /* Will be set by pf_open */
input.pf_open = NULL;
input.pf_close = NULL;
input.pf_end = TSEnd;
input.pf_init_bit_stream = InitBitstream;
input.pf_set_area = NULL;
......@@ -127,8 +126,7 @@ static int TSProbe( 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 = 1;
int i_score = 2;
if( TestMethod( INPUT_METHOD_VAR, "ts" ) )
{
......@@ -154,13 +152,6 @@ static int TSProbe( probedata_t * p_data )
return( 900 );
}
i_handle = open( psz_name, 0 );
if( i_handle == -1 )
{
return( 0 );
}
close( i_handle );
return( i_score );
}
......@@ -204,9 +195,6 @@ static void TSInit( input_thread_t * p_input )
/* Initialize the stream */
input_InitStream( p_input, sizeof( stream_ts_data_t ) );
/* input method type */
/* FIXME: should test if you have network or file here */
p_input->stream.i_method = INPUT_METHOD_NETWORK;
p_input->stream.p_selected_area->i_tell = 0;
/* Init */
......@@ -226,30 +214,6 @@ static void TSInit( input_thread_t * p_input )
}
/*****************************************************************************
* TSFakeOpen: open the stream and set pf_close
*****************************************************************************/
void TSFakeOpen( input_thread_t * p_input )
{
#if !defined( SYS_BEOS ) && !defined( SYS_NTO )
char *psz_name = p_input->p_source;
if( ( strlen(psz_name) > 3 ) && !strncasecmp( psz_name, "ts:", 3 ) )
{
/* If the user specified "ts:" he wants a network stream */
p_input->pf_open = p_input->pf_network_open;
p_input->pf_close = p_input->pf_network_close;
}
else
#endif
{
p_input->pf_open = p_input->pf_file_open;
p_input->pf_close = p_input->pf_file_close;
}
p_input->pf_open( p_input );
}
/*****************************************************************************
* TSEnd: frees unused data
*****************************************************************************/
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* input_programs.c: es_descriptor_t, pgrm_descriptor_t management
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_programs.c,v 1.61 2001/08/09 20:16:17 jlj Exp $
* $Id: input_programs.c,v 1.62 2001/10/02 16:46:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -56,7 +56,6 @@
int input_InitStream( input_thread_t * p_input, size_t i_data_len )
{
p_input->stream.i_method = INPUT_METHOD_NONE;
p_input->stream.i_stream_id = 0;
/* initialized to 0 since we don't give the signal to the interface
......
......@@ -2,7 +2,7 @@
* modules.c : Built-in and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.c,v 1.40 2001/07/17 09:48:08 massiot Exp $
* $Id: modules.c,v 1.41 2001/10/02 16:46:59 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
......@@ -365,6 +365,8 @@ module_t * module_Need( int i_capabilities, void *p_data )
}
}
}
intf_WarnMsg( 3, "module: %s has score %d",
p_module->psz_name, i_totalscore );
/* If the high score was broken, we have a new champion */
if( i_totalscore > i_bestscore )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment