#include "vlc_playlist.h"
#include "vlc_interface.h"
#include "vlc_interaction.h"
+#include "vlc_url.h"
#include "charset.h"
static void UpdateItemLength( input_thread_t *, int64_t i_length );
-static void DecodeUrl( char * );
static void MRLSections( input_thread_t *, char *, int *, int *, int *, int *);
static input_source_t *InputSourceNew( input_thread_t *);
static int InputSourceInit( input_thread_t *, input_source_t *,
- char *, char *psz_forced_demux );
+ char *, const char *psz_forced_demux );
static void InputSourceClean( input_thread_t *, input_source_t * );
static void SlaveDemux( input_thread_t *p_input );
return __input_CreateThread2( p_parent, p_item, NULL );
}
-
/* Gruik ! */
input_thread_t *__input_CreateThread2( vlc_object_t *p_parent,
input_item_t *p_item,
input_thread_t *p_input = NULL; /* thread descriptor */
p_input = Create( p_parent, p_item, psz_header, VLC_FALSE );
+ if( !p_input )
+ return NULL;
+
/* Now we can attach our new input */
vlc_object_attach( p_input, p_parent );
if( vlc_thread_create( p_input, "input", Run,
VLC_THREAD_PRIORITY_INPUT, VLC_TRUE ) )
{
+ input_ChangeState( p_input, ERROR_S );
msg_Err( p_input, "cannot create input thread" );
vlc_object_detach( p_input );
vlc_object_destroy( p_input );
return p_input;
}
-
/**
* Initialize an input thread and run it. This thread will clean after himself,
* you can forget about it. It can work either in blocking or non-blocking mode
input_thread_t *p_input = NULL; /* thread descriptor */
p_input = Create( p_parent, p_item, NULL, VLC_FALSE );
+ if( !p_input )
+ return VLC_EGENERIC;
+
/* Now we can attach our new input */
vlc_object_attach( p_input, p_parent );
if( vlc_thread_create( p_input, "input", RunAndClean,
VLC_THREAD_PRIORITY_INPUT, VLC_TRUE ) )
{
+ input_ChangeState( p_input, ERROR_S );
msg_Err( p_input, "cannot create input thread" );
vlc_object_detach( p_input );
vlc_object_destroy( p_input );
/* Allocate descriptor */
p_input = Create( p_parent, p_item, NULL, VLC_TRUE );
+ if( !p_input )
+ return VLC_EGENERIC;
+
p_input->i_flags |= OBJECT_FLAGS_QUIET;
p_input->i_flags |= OBJECT_FLAGS_NOINTERACT;
/* Set die for input */
p_input->b_die = VLC_TRUE;
- /* We cannot touch p_input fields directly (we can from another thread),
+ /* We cannot touch p_input fields directly (we come from another thread),
* so use the vlc_object_find way, it's perfectly safe */
/* Set die for all access */
{
/* If we failed, wait before we are killed, and exit */
p_input->b_error = VLC_TRUE;
+ playlist_Signal( pl_Get( p_input ) );
Error( p_input );
/* We have finished */
p_input->b_eof = VLC_TRUE;
+ playlist_Signal( pl_Get( p_input ) );
}
/* Wait until we are asked to die */
return 0;
}
-
/*****************************************************************************
* Main loop: Fill buffers from access, and demux
*****************************************************************************/
{
/* End of file - we do not set b_die because only the
* playlist is allowed to do so. */
+ input_ChangeState( p_input, END_S );
msg_Dbg( p_input, "EOF reached" );
p_input->input.b_eof = VLC_TRUE;
}
}
}
-
static int Init( input_thread_t * p_input )
{
char *psz;
p_input->p_sout = sout_NewInstance( p_input, psz );
if( p_input->p_sout == NULL )
{
+ input_ChangeState( p_input, ERROR_S );
msg_Err( p_input, "cannot start stream output instance, " \
"aborting" );
free( psz );
p_input->i_stop = 0;
}
-
/* Load subtitles */
/* Get fps and set it if not already set */
if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_FPS, &f_fps ) &&
var_SetTime( p_input, "spu-delay", (mtime_t)i_delay * 100000 );
}
-
/* Look for and add subtitle files */
psz_subtitle = var_GetString( p_input, "sub-file" );
if( *psz_subtitle )
char **subs = subtitles_Detect( p_input, psz_autopath,
p_input->input.p_item->psz_uri );
input_source_t *sub;
-
i = 0;
/* Try to autoselect the first autodetected subtitles file
}
/* initialization is complete */
- input_ChangeState(p_input, PLAYING_S);
+ input_ChangeState( p_input, PLAYING_S );
return VLC_SUCCESS;
error:
+ input_ChangeState( p_input, ERROR_S );
+
if( p_input->p_es_out )
input_EsOutDelete( p_input->p_es_out );
while( !p_input->b_die )
{
/* Sleep a while */
+ input_ChangeState( p_input, ERROR_S );
msleep( INPUT_IDLE_SLEEP );
}
}
msg_Dbg( p_input, "closing input" );
/* We are at the end */
- input_ChangeState(p_input, END_S);
+ input_ChangeState( p_input, END_S );
/* Clean control variables */
input_ControlVarClean( p_input );
static void ControlReduce( input_thread_t *p_input )
{
int i;
+
+ if( !p_input )
+ return;
+
for( i = 1; i < p_input->i_control; i++ )
{
const int i_lt = p_input->control[i-1].i_type;
*****************************************************************************/
static int InputSourceInit( input_thread_t *p_input,
input_source_t *in, char *psz_mrl,
- char *psz_forced_demux )
+ const char *psz_forced_demux )
{
char *psz_dup = strdup( psz_mrl );
char *psz_access;
vlc_value_t val;
if( !in ) return VLC_EGENERIC;
+ if( !p_input ) return VLC_EGENERIC;
/* Split uri */
if( !p_input->b_preparsing )
{
int64_t i_pts_delay;
- input_ChangeState( p_input, OPENING_S);
+ input_ChangeState( p_input, OPENING_S );
/* Now try a real access */
in->p_access = access2_New( p_input, psz_access, psz_demux, psz_path,
/* Access failed, URL encoded ? */
if( in->p_access == NULL && strchr( psz_path, '%' ) )
{
- DecodeUrl( psz_path );
+ decode_URI( psz_path );
msg_Dbg( p_input, "retrying with access `%s' demux `%s' path `%s'",
psz_access, psz_demux, psz_path );
var_Set( p_input, "seekable", val );
}
- input_ChangeState( p_input, BUFFERING_S);
+ input_ChangeState( p_input, BUFFERING_S );
/* Create the stream_t */
in->p_stream = stream_AccessNew( in->p_access, p_input->b_preparsing );
return VLC_SUCCESS;
error:
+ input_ChangeState( p_input, ERROR_S );
+
if( in->p_demux )
demux2_Delete( in->p_demux );
{
int64_t i_time;
int i;
-
+
if( demux2_Control( p_input->input.p_demux, DEMUX_GET_TIME, &i_time ) )
{
msg_Err( p_input, "demux doesn't like DEMUX_GET_TIME" );
int64_t i_time;
int i;
+ if( !p_input ) return;
+
if( demux2_Control( p_input->input.p_demux, DEMUX_GET_TIME, &i_time ) )
{
msg_Err( p_input, "demux doesn't like DEMUX_GET_TIME" );
}
}
}
+
/*****************************************************************************
* InputMetaUser:
*****************************************************************************/
#undef GET_META
}
-/*****************************************************************************
- * DecodeUrl: decode a given encoded url
- *****************************************************************************/
-static void DecodeUrl( char *psz )
-{
- char *dup = strdup( psz );
- char *p = dup;
-
- while( *p )
- {
- if( *p == '%' )
- {
- char val[3];
- p++;
- if( !*p )
- {
- break;
- }
-
- val[0] = *p++;
- val[1] = *p++;
- val[2] = '\0';
-
- *psz++ = strtol( val, NULL, 16 );
- }
- else if( *p == '+' )
- {
- *psz++ = ' ';
- p++;
- }
- else
- {
- *psz++ = *p++;
- }
- }
- if( psz ) *psz++ ='\0';
- if( dup ) free( dup );
-}
-
/*****************************************************************************
* MRLSplit: parse the access, demux and url part of the
* Media Resource Locator.
*****************************************************************************/
void MRLSplit( vlc_object_t *p_input, char *psz_dup,
- char **ppsz_access, char **ppsz_demux, char **ppsz_path )
+ const char **ppsz_access, const char **ppsz_demux,
+ const char **ppsz_path )
{
char *psz_access = NULL;
char *psz_demux = NULL;
return VLC_TRUE;
}
+