Commit 4f49b52c authored by Laurent Aimar's avatar Laurent Aimar

* include: removed a few deprecated functions.

 * demux, access: change the prototype of access2_New/demux2_New.
 * control: implemented all INPUT_GET/SET.
 * src/input/*.c: removed old functions, move some of them.
              
parent 275cc553
......@@ -218,20 +218,6 @@ struct stream_descriptor_t
count_t c_packets_trashed; /* trashed packets */
};
/*****************************************************************************
* stream_position_t
*****************************************************************************
* Describes the current position in the stream.
*****************************************************************************/
struct stream_position_t
{
off_t i_tell; /* actual location in the area (in arbitrary units) */
off_t i_size; /* total size of the area (in arbitrary units) */
uint32_t i_mux_rate; /* the rate we read the stream (in
* units of 50 bytes/s) ; 0 if undef */
};
#define MUTE_NO_CHANGE -1
/*****************************************************************************
......@@ -392,25 +378,9 @@ VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item
VLC_EXPORT( void, input_StopThread, ( input_thread_t * ) );
VLC_EXPORT( void, input_DestroyThread, ( input_thread_t * ) );
#define input_SetStatus(a,b) __input_SetStatus(VLC_OBJECT(a),b)
VLC_EXPORT( void, __input_SetStatus, ( vlc_object_t *, int ) );
#define input_SetRate(a,b) __input_SetRate(VLC_OBJECT(a),b)
VLC_EXPORT( void, __input_SetRate, ( vlc_object_t *, int ) );
#define input_Seek(a,b,c) __input_Seek(VLC_OBJECT(a),b,c)
VLC_EXPORT( void, __input_Seek, ( vlc_object_t *, off_t, int ) );
#define input_Tell(a,b) __input_Tell(VLC_OBJECT(a),b)
VLC_EXPORT( void, __input_Tell, ( vlc_object_t *, stream_position_t * ) );
VLC_EXPORT( void, input_DumpStream, ( input_thread_t * ) );
VLC_EXPORT( char *, input_OffsetToTime, ( input_thread_t *, char *, off_t ) );
VLC_EXPORT( int, input_ToggleES, ( input_thread_t *, es_descriptor_t *, vlc_bool_t ) );
VLC_EXPORT( int, input_ChangeArea, ( input_thread_t *, input_area_t * ) );
VLC_EXPORT( int, input_ChangeProgram, ( input_thread_t *, uint16_t ) );
int input_ToggleGrayscale( input_thread_t * );
int input_ToggleMute ( input_thread_t * );
#endif /* "input_ext-intf.h" */
......@@ -289,8 +289,8 @@ struct access_t
access_sys_t *p_sys;
};
#define access2_New( a, b ) __access2_New(VLC_OBJECT(a), b )
VLC_EXPORT( access_t *, __access2_New, ( vlc_object_t *p_obj, char *psz_mrl ) );
#define access2_New( a, b, c, d ) __access2_New(VLC_OBJECT(a), b, c, d )
VLC_EXPORT( access_t *, __access2_New, ( vlc_object_t *p_obj, char *psz_access, char *psz_demux, char *psz_path ) );
VLC_EXPORT( void, access2_Delete, ( access_t * ) );
static inline int access2_vaControl( access_t *p_access, int i_query, va_list args )
......@@ -541,8 +541,8 @@ VLC_EXPORT( int, access_vaControlDefault,( input_thread_t *, int i_query, va_lis
/* stream_t *s could be null and then it mean a access+demux in one */
#define demux2_New( a, b, c, d ) __demux2_New(VLC_OBJECT(a), b, c, d)
VLC_EXPORT( demux_t *, __demux2_New, ( vlc_object_t *p_obj, char *psz_mrl, stream_t *s, es_out_t *out ) );
#define demux2_New( a, b, c, d, e, f ) __demux2_New(VLC_OBJECT(a),b,c,d,e,f)
VLC_EXPORT( demux_t *, __demux2_New, ( vlc_object_t *p_obj, char *psz_access, char *psz_demux, char *psz_path, stream_t *s, es_out_t *out ) );
VLC_EXPORT( void, demux2_Delete, ( demux_t * ) );
VLC_EXPORT( int, demux2_vaControlHelper, ( stream_t *, int64_t i_start, int64_t i_end, int i_bitrate, int i_align, int i_query, va_list args ) );
......@@ -579,17 +579,27 @@ VLC_EXPORT( char **, subtitles_Detect, ( input_thread_t *, char* path, char *fna
*/
enum input_query_e
{
/* input variable "position" */
INPUT_GET_POSITION, /* arg1= double * res= */
INPUT_SET_POSITION, /* arg1= double res=can fail */
/* input variable "length" */
INPUT_GET_LENGTH, /* arg1= int64_t * res=can fail */
/* input variable "time" */
INPUT_GET_TIME, /* arg1= int64_t * res= */
INPUT_SET_TIME, /* arg1= int64_t res=can fail */
INPUT_GET_LENGTH, /* arg1= int64_t * res=can fail */
/* input variable "rate" (1 is DEFAULT_RATE) */
INPUT_GET_RATE, /* arg1= int * res= */
INPUT_SET_RATE, /* arg1= int res=can fail */
/* input variable "state" */
INPUT_GET_STATE, /* arg1= int * res= */
INPUT_SET_STATE, /* arg1= int res=can fail */
INPUT_GET_FPS, /* arg1= float * res=can fail */
INPUT_GET_META, /* arg1= vlc_meta_t ** res=can fail */
/* bookmarks */
INPUT_GET_BOOKMARKS, /* arg1= seekpoint_t *** arg2= int * res=can fail */
INPUT_CLEAR_BOOKMARKS, /* res=can fail */
INPUT_ADD_BOOKMARK, /* arg1= seekpoint_t * res=can fail */
......@@ -599,15 +609,15 @@ enum input_query_e
INPUT_ADD_OPTION, /* arg1= char * arg2= char * res=can fail */
/* */
INPUT_ADD_INFO, /* arg1= char * arg2= char * arg3=... res=can fail */
INPUT_GET_INFO, /* arg1= char * arg2= char * arg3= char ** res=can fail*/
INPUT_SET_NAME, /* arg1= char * res=can fail */
/* */
INPUT_GET_SUBDELAY, /* arg1 = int* res=can fail */
INPUT_SET_SUBDELAY, /* arg1 = int res=can fail */
INPUT_GET_DIVISIONS
};
VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) );
......
......@@ -307,7 +307,6 @@ typedef struct encoder_sys_t encoder_sys_t;
/* Misc */
typedef struct data_packet_t data_packet_t;
typedef struct data_buffer_t data_buffer_t;
typedef struct stream_position_t stream_position_t;
typedef struct stream_ctrl_t stream_ctrl_t;
typedef struct pes_packet_t pes_packet_t;
typedef struct network_socket_t network_socket_t;
......
......@@ -56,59 +56,23 @@ int access_vaControlDefault( input_thread_t *p_input, int i_query, va_list args
/*****************************************************************************
* access2_New:
*****************************************************************************/
access_t *__access2_New( vlc_object_t *p_obj, char *psz_mrl )
access_t *__access2_New( vlc_object_t *p_obj,
char *psz_access, char *psz_demux, char *psz_path )
{
access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );
char *psz_dup = strdup( psz_mrl ? psz_mrl : "" );
char *psz = strchr( psz_dup, ':' );
if( p_access == NULL )
{
msg_Err( p_obj, "vlc_object_create( p_obj, VLC_OBJECT_ACCESS ) had failed" );
free( psz_dup );
msg_Err( p_obj, "vlc_object_create( p_obj, VLC_OBJECT_ACCESS ) failed" );
return NULL;
}
/* Parse URL */
p_access->psz_access = NULL;
p_access->psz_path = NULL;
if( psz )
{
*psz++ = '\0';
if( psz[0] == '/' && psz[1] == '/' )
{
psz += 2;
}
p_access->psz_path = strdup( psz );
psz = strchr( psz_dup, '/' );
if( psz )
{
*psz++ = '\0';
}
p_access->psz_access = strdup( psz_dup );
}
else
{
p_access->psz_path = strdup( psz_mrl );
}
free( psz_dup );
p_access->psz_access = strdup( psz_access );
p_access->psz_path = strdup( psz_path );
p_access->psz_demux = strdup( "" );
p_access->psz_demux = strdup( "" );
if( p_access->psz_access == NULL )
{
p_access->psz_access = strdup( "" );
}
if( p_access->psz_path == NULL )
{
p_access->psz_path = strdup( "" );
}
msg_Dbg( p_obj, "access2_New: '%s' -> access='%s' path='%s'",
psz_mrl,
msg_Dbg( p_obj, "access2_New: access='%s' path='%s'",
p_access->psz_access, p_access->psz_path );
p_access->pf_read = NULL;
......
......@@ -71,10 +71,58 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
int i, *pi;
vlc_value_t val, text;
char *psz_option, *psz_value;
int i_int, *pi_int;
double f, *pf;
int64_t i_64, *pi_64;
vlc_mutex_lock( &p_input->stream.stream_lock );
switch( i_query )
{
case INPUT_GET_POSITION:
pf = (double*)va_arg( args, double * );
*pf = var_GetFloat( p_input, "position" );
i_ret = VLC_SUCCESS;
break;
case INPUT_SET_POSITION:
f = (double)va_arg( args, double );
i_ret = var_SetFloat( p_input, "position", f );
break;
case INPUT_GET_LENGTH:
pi_64 = (int64_t*)va_arg( args, int64_t * );
*pi_64 = var_GetTime( p_input, "length" );
i_ret = VLC_SUCCESS;
break;
case INPUT_GET_TIME:
pi_64 = (int64_t*)va_arg( args, int64_t * );
*pi_64 = var_GetTime( p_input, "time" );
i_ret = VLC_SUCCESS;
break;
case INPUT_SET_TIME:
i_64 = (int64_t)va_arg( args, int64_t );
i_ret = var_SetTime( p_input, "time", i_64 );
break;
case INPUT_GET_RATE:
pi_int = (int*)va_arg( args, int * );
*pi_int = var_GetInteger( p_input, "rate" );
i_ret = VLC_SUCCESS;
break;
case INPUT_SET_RATE:
i_int = (int)va_arg( args, int );
i_ret = var_SetInteger( p_input, "rate", i_int );
break;
case INPUT_GET_STATE:
pi_int = (int*)va_arg( args, int * );
*pi_int = var_GetInteger( p_input, "state" );
i_ret = VLC_SUCCESS;
break;
case INPUT_SET_STATE:
i_int = (int)va_arg( args, int );
i_ret = var_SetInteger( p_input, "state", i_int );
break;
case INPUT_ADD_OPTION:
{
psz_option = (char *)va_arg( args, char * );
......
......@@ -169,64 +169,23 @@ static void SeekOffset( input_thread_t *p_input, int64_t i_pos )
* demux2_New:
*****************************************************************************/
demux_t *__demux2_New( vlc_object_t *p_obj,
char *psz_mrl, stream_t *s, es_out_t *out )
char *psz_access, char *psz_demux, char *psz_path,
stream_t *s, es_out_t *out )
{
demux_t *p_demux = vlc_object_create( p_obj, VLC_OBJECT_DEMUX );
char *psz_dup = strdup( psz_mrl ? psz_mrl : "" );
char *psz = strchr( psz_dup, ':' );
char *psz_module;
char *psz_module;
if( p_demux == NULL )
{
free( psz_dup );
return NULL;
}
/* Parse URL */
p_demux->psz_access = NULL;
p_demux->psz_demux = NULL;
p_demux->psz_path = NULL;
if( psz )
{
*psz++ = '\0';
if( psz[0] == '/' && psz[1] == '/' )
{
psz += 2;
}
p_demux->psz_path = strdup( psz );
p_demux->psz_access = strdup( psz_access );
p_demux->psz_demux = strdup( psz_demux );
p_demux->psz_path = strdup( psz_path );
psz = strchr( psz_dup, '/' );
if( psz )
{
*psz++ = '\0';
p_demux->psz_demux = strdup( psz );
}
p_demux->psz_access = strdup( psz_dup );
}
else
{
p_demux->psz_path = strdup( psz_mrl );
}
free( psz_dup );
if( p_demux->psz_access == NULL )
{
p_demux->psz_access = strdup( "" );
}
if( p_demux->psz_demux == NULL )
{
p_demux->psz_demux = strdup( "" );
}
if( p_demux->psz_path == NULL )
{
p_demux->psz_path = strdup( "" );
}
msg_Dbg( p_obj, "demux2_New: '%s' -> access='%s' demux='%s' path='%s'",
psz_mrl,
msg_Dbg( p_obj, "demux2_New: access='%s' demux='%s' path='%s'",
p_demux->psz_access, p_demux->psz_demux, p_demux->psz_path );
p_demux->s = s;
......
......@@ -1198,7 +1198,7 @@ static void ErrorThread( input_thread_t *p_input )
*****************************************************************************/
static void EndThread( input_thread_t * p_input )
{
int i;
int i, j;
#ifdef HAVE_SYS_TIMES_H
/* Display statistics */
struct tms cpu_usage;
......@@ -1210,7 +1210,44 @@ static void EndThread( input_thread_t * p_input )
msg_Dbg( p_input, "%ld loops", p_input->c_loops );
#endif
input_DumpStream( p_input );
/* DumpStream: printf some info for debugging purpose */
#define S p_input->stream
msg_Dbg( p_input, "dumping stream ID 0x%x [OK:%ld/D:%ld]", S.i_stream_id,
S.c_packets_read, S.c_packets_trashed );
if( S.b_seekable )
{
char psz_time1[MSTRTIME_MAX_SIZE];
char psz_time2[MSTRTIME_MAX_SIZE];
msg_Dbg( p_input, "seekable stream, position: "I64Fd"/"I64Fd" (%s/%s)",
S.p_selected_area->i_tell, S.p_selected_area->i_size,
input_OffsetToTime( p_input, psz_time1,
S.p_selected_area->i_tell ),
input_OffsetToTime( p_input, psz_time2,
S.p_selected_area->i_size ) );
}
else
msg_Dbg( p_input, "pace %scontrolled", S.b_pace_control ? "" : "un-" );
#undef S
for( i = 0; i < p_input->stream.i_pgrm_number; i++ )
{
#define P p_input->stream.pp_programs[i]
msg_Dbg( p_input, "dumping program 0x%x, version %d (%s)",
P->i_number, P->i_version,
P->b_is_ok ? "complete" : "partial" );
#undef P
for( j = 0; j < p_input->stream.pp_programs[i]->i_es_number; j++ )
{
#define ES p_input->stream.pp_programs[i]->pp_es[j]
msg_Dbg( p_input, "ES 0x%x, "
"stream 0x%x, fourcc `%4.4s', %s [OK:%ld/ERR:%ld]",
ES->i_id, ES->i_stream_id, (char*)&ES->i_fourcc,
ES->p_dec != NULL ? "selected" : "not selected",
ES->c_packets, ES->c_invalid_packets );
#undef ES
}
}
/* Free demultiplexer's data */
if( p_input->p_demux ) module_Unneed( p_input, p_input->p_demux );
......@@ -1415,6 +1452,152 @@ static void ParseOption( input_thread_t *p_input, const char *psz_option )
return;
}
/*****************************************************************************
* input_SetStatus: change the reading status
*****************************************************************************/
static void input_SetStatus( input_thread_t *p_input, int i_mode )
{
vlc_mutex_lock( &p_input->stream.stream_lock );
switch( i_mode )
{
case INPUT_STATUS_END:
p_input->stream.i_new_status = PLAYING_S;
p_input->b_eof = 1;
msg_Dbg( p_input, "end of stream" );
break;
case INPUT_STATUS_PLAY:
p_input->stream.i_new_status = PLAYING_S;
msg_Dbg( p_input, "playing at normal rate" );
break;
case INPUT_STATUS_PAUSE:
/* XXX: we don't need to check i_status, because input_clock.c
* does it for us */
p_input->stream.i_new_status = PAUSE_S;
msg_Dbg( p_input, "toggling pause" );
break;
case INPUT_STATUS_FASTER:
if( p_input->stream.control.i_rate * 4 <= DEFAULT_RATE )
{
msg_Dbg( p_input, "can not play any faster" );
}
else
{
p_input->stream.i_new_status = FORWARD_S;
p_input->stream.i_new_rate =
p_input->stream.control.i_rate / 2;
if ( p_input->stream.i_new_rate < DEFAULT_RATE )
{
msg_Dbg( p_input, "playing at %i:1 fast forward",
DEFAULT_RATE / p_input->stream.i_new_rate );
}
else if ( p_input->stream.i_new_rate > DEFAULT_RATE )
{
msg_Dbg( p_input, "playing at 1:%i slow motion",
p_input->stream.i_new_rate / DEFAULT_RATE );
}
else if ( p_input->stream.i_new_rate == DEFAULT_RATE )
{
p_input->stream.i_new_status = PLAYING_S;
msg_Dbg( p_input, "playing at normal rate" );
}
}
break;
case INPUT_STATUS_SLOWER:
if( p_input->stream.control.i_rate >= 8 * DEFAULT_RATE )
{
msg_Dbg( p_input, "can not play any slower" );
}
else
{
p_input->stream.i_new_status = FORWARD_S;
p_input->stream.i_new_rate =
p_input->stream.control.i_rate * 2;
if ( p_input->stream.i_new_rate < DEFAULT_RATE )
{
msg_Dbg( p_input, "playing at %i:1 fast forward",
DEFAULT_RATE / p_input->stream.i_new_rate );
}
else if ( p_input->stream.i_new_rate > DEFAULT_RATE )
{
msg_Dbg( p_input, "playing at 1:%i slow motion",
p_input->stream.i_new_rate / DEFAULT_RATE );
}
else if ( p_input->stream.i_new_rate == DEFAULT_RATE )
{
p_input->stream.i_new_status = PLAYING_S;
msg_Dbg( p_input, "playing at normal rate" );
}
}
break;
default:
break;
}
vlc_cond_signal( &p_input->stream.stream_wait );
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
/*****************************************************************************
* input_SetRate:
*****************************************************************************/
static void input_SetRate( vlc_object_t * p_this, int i_rate )
{
input_thread_t *p_input;
p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input == NULL )
{
msg_Err( p_this, "no input found" );
return;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
if( i_rate * 8 < DEFAULT_RATE )
{
msg_Dbg( p_input, "can not play faster than 8x" );
vlc_mutex_unlock( &p_input->stream.stream_lock );
return;
}
if( i_rate > DEFAULT_RATE * 8 )
{
msg_Dbg( p_input, "can not play slower than 1/8x" );
vlc_mutex_unlock( &p_input->stream.stream_lock );
return;
}
p_input->stream.i_new_status = FORWARD_S;
p_input->stream.i_new_rate = i_rate;
if ( p_input->stream.i_new_rate < DEFAULT_RATE )
{
msg_Dbg( p_input, "playing at %i:1 fast forward",
DEFAULT_RATE / p_input->stream.i_new_rate );
}
else if ( p_input->stream.i_new_rate > DEFAULT_RATE )
{
msg_Dbg( p_input, "playing at 1:%i slow motion",
p_input->stream.i_new_rate / DEFAULT_RATE );
}
else if ( p_input->stream.i_new_rate == DEFAULT_RATE )
{
p_input->stream.i_new_status = PLAYING_S;
msg_Dbg( p_input, "playing at normal rate" );
}
vlc_cond_signal( &p_input->stream.stream_wait );
vlc_mutex_unlock( &p_input->stream.stream_lock );
vlc_object_release( p_input );
}
/*****************************************************************************
* Callbacks (position, time, state, rate )
*****************************************************************************/
......
This diff is collapsed.
......@@ -1017,7 +1017,7 @@ static int ProgramCallback( vlc_object_t *p_this, char const *psz_cmd,
{
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_ChangeProgram( p_input, (uint16_t)newval.i_int );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
var_SetInteger( p_input, "state", PLAYING_S );
vlc_mutex_lock( &p_input->stream.stream_lock );
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
......@@ -1066,7 +1066,7 @@ static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_ChangeArea( p_input, p_area );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
var_SetInteger( p_input, "state", PLAYING_S );
val.b_bool = VLC_TRUE;
var_Set( p_input, "intf-change", val );
......@@ -1111,7 +1111,7 @@ static int ChapterCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_ChangeArea( p_input, p_area );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
var_SetInteger( p_input, "state", PLAYING_S );
val.b_bool = VLC_TRUE;
var_Set( p_input, "intf-change", val );
......@@ -1144,7 +1144,7 @@ static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
p_area->i_part = newval.i_int;
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_ChangeArea( p_input, p_area );
input_SetStatus( p_input, INPUT_STATUS_PLAY );
var_SetInteger( p_input, "state", PLAYING_S );
vlc_mutex_lock( &p_input->stream.stream_lock );
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
......
......@@ -569,20 +569,14 @@ static int DStreamControl( stream_t *s, int i_query, va_list args )
static int DStreamThread ( stream_t *s )
{
d_stream_sys_t *p_sys = (d_stream_sys_t*)s->p_sys;
char *psz_mrl;
demux_t *p_demux;
/* Create the demuxer */
psz_mrl = malloc( strlen( p_sys->psz_name ) + 3 );
sprintf( psz_mrl, "/%s:", p_sys->psz_name );
if( ( p_demux = demux2_New( s, psz_mrl, s, p_sys->out ) ) == NULL )
if( ( p_demux = demux2_New( s, "", p_sys->psz_name, "", s, p_sys->out ) ) == NULL )
{
free( psz_mrl );
return VLC_EGENERIC;
}
free( psz_mrl );
vlc_mutex_lock( &p_sys->lock );
p_sys->p_demux = p_demux;
......
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