* Read an MPEG2 stream, demultiplex and parse it before sending it to
* decoders.
*****************************************************************************
- * Copyright (C) 1998-2001 VideoLAN
- * $Id: input.c,v 1.209 2002/07/31 20:56:52 sam Exp $
+ * Copyright (C) 1998-2002 VideoLAN
+ * $Id: input.c,v 1.220 2002/12/18 14:17:11 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Preamble
*****************************************************************************/
#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
#include <vlc/vlc.h>
#include <string.h>
-#include <errno.h>
#ifdef HAVE_SYS_TIMES_H
# include <sys/times.h>
#include "input_ext-dec.h"
#include "input_ext-plugins.h"
+#include "stream_output.h"
+
#include "interface.h"
/*****************************************************************************
*****************************************************************************
* This function creates a new input, and returns a pointer
* to its description. On error, it returns NULL.
- * If pi_status is NULL, then the function will block until the thread is ready.
- * If not, it will be updated using one of the THREAD_* constants.
*****************************************************************************/
input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
- playlist_item_t *p_item, int *pi_status )
+ playlist_item_t *p_item )
{
input_thread_t * p_input; /* thread descriptor */
input_info_category_t * p_info;
p_input->b_eof = 0;
/* Set target */
- p_input->psz_source = strdup( p_item->psz_name );
+ p_input->psz_source = strdup( p_item->psz_uri );
/* Demux */
p_input->p_demux = NULL;
/* Access */
p_input->p_access = NULL;
-
+
p_input->i_bufsize = 0;
p_input->i_mtu = 0;
+ p_input->i_pts_delay = DEFAULT_PTS_DELAY;
/* Initialize statistics */
p_input->c_loops = 0;
p_input->stream.b_new_mute = MUTE_NO_CHANGE;
p_input->stream.i_mux_rate = 0;
p_input->stream.b_seekable = 0;
+ p_input->stream.p_sout = NULL;
/* no stream, no program, no area, no es */
p_input->stream.p_new_program = NULL;
msg_Info( p_input, "playlist item `%s'", p_input->psz_source );
- p_info = input_InfoCategory( p_input, "General");
- input_AddInfo( p_info, "Playlist item", p_input->psz_source );
+ p_info = input_InfoCategory( p_input, "General" );
+ input_AddInfo( p_info, "playlist item", p_input->psz_source );
vlc_object_attach( p_input, p_parent );
/* Create thread and wait for its readiness. */
- if( vlc_thread_create( p_input, "input", RunThread, VLC_TRUE ) )
+ if( vlc_thread_create( p_input, "input", RunThread,
+ VLC_THREAD_PRIORITY_INPUT, VLC_TRUE ) )
{
- msg_Err( p_input, "cannot create input thread (%s)", strerror(errno) );
+ msg_Err( p_input, "cannot create input thread" );
free( p_input );
return NULL;
}
while( !p_input->b_die && !p_input->b_error && !p_input->b_eof )
{
- int i, i_count;
+ unsigned int i, i_count;
p_input->c_loops++;
/* Reinitialize buffer manager. */
input_AccessReinit( p_input );
-
- p_input->pf_set_program( p_input,
+
+ p_input->pf_set_program( p_input,
p_input->stream.p_new_program );
/* Escape all decoders for the stream discontinuity they
}
p_input->stream.p_new_program = NULL;
}
-
+
if( p_input->stream.p_new_area )
{
if( p_input->stream.b_seekable && p_input->pf_set_area != NULL )
{
psz_parser++;
}
-#ifdef WIN32
+#if defined( WIN32 ) || defined( UNDER_CE )
if( psz_parser - p_input->psz_source == 1 )
{
msg_Warn( p_input, "drive letter %c: found in source string",
- p_input->psz_source ) ;
+ p_input->psz_source[0] ) ;
psz_parser = "";
}
#endif
if( psz_parser[0] == '/' && psz_parser[1] == '/' )
{
psz_parser += 2 ;
- }
+ }
p_input->psz_name = psz_parser ;
return -1;
}
+ /* Initialize optional stream output. */
+ psz_parser = config_GetPsz( p_input, "sout" );
+ if ( psz_parser != NULL )
+ {
+ if ( *psz_parser &&
+ (p_input->stream.p_sout = sout_NewInstance( p_input, psz_parser ))
+ == NULL )
+ {
+ msg_Err( p_input, "cannot start stream output instance, aborting" );
+ free( psz_parser );
+ module_Unneed( p_input, p_input->p_access );
+ module_Unneed( p_input, p_input->p_demux );
+ return -1;
+ }
+
+ free( psz_parser );
+ }
+
return 0;
}
struct tms cpu_usage;
times( &cpu_usage );
- msg_Dbg( p_input, "%d loops consuming user: %d, system: %d",
+ msg_Dbg( p_input, "%ld loops consuming user: %ld, system: %ld",
p_input->c_loops, cpu_usage.tms_utime, cpu_usage.tms_stime );
#else
- msg_Dbg( p_input, "%d loops", p_input->c_loops );
+ msg_Dbg( p_input, "%ld loops", p_input->c_loops );
#endif
/* Free info structures */
msg_Dbg( p_input, "freeing info structures...");
input_DelInfo( p_input );
-
+
input_DumpStream( p_input );
/* Free all ES and destroy all decoder threads */
input_EndStream( p_input );
+ /* Close optional stream output instance */
+ if ( p_input->stream.p_sout != NULL )
+ {
+ sout_DeleteInstance( p_input->stream.p_sout );
+ }
+
/* Free demultiplexer's data */
module_Unneed( p_input, p_input->p_demux );