Commit ca334665 authored by Laurent Aimar's avatar Laurent Aimar

* input: introduce 'position', 'time', 'length', 'state' and 'rate'

 object variables and begin to use pf_demux_control.
 * variables: new time type handling.
parent 8e8dada2
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* demux.c * demux.c
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2003 VideoLAN * Copyright (C) 1999-2003 VideoLAN
* $Id: demux.c,v 1.1 2003/08/02 16:43:59 fenrir Exp $ * $Id: demux.c,v 1.2 2003/09/07 22:51:11 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -48,3 +48,109 @@ int demux_Control ( input_thread_t *p_input, int i_query, ... ) ...@@ -48,3 +48,109 @@ int demux_Control ( input_thread_t *p_input, int i_query, ... )
return i_result; return i_result;
} }
static void SeekOffset( input_thread_t *p_input, int64_t i_pos );
int demux_vaControlDefault( input_thread_t *p_input, int i_query, va_list args )
{
int i_ret;
double f, *pf;
int64_t i64, *pi64;
vlc_mutex_lock( &p_input->stream.stream_lock );
switch( i_query )
{
case DEMUX_GET_POSITION:
pf = (double*)va_arg( args, double * );
if( p_input->stream.p_selected_area->i_size <= 0 )
{
*pf = 0.0;
}
else
{
*pf = (double)p_input->stream.p_selected_area->i_tell /
(double)p_input->stream.p_selected_area->i_size;
}
i_ret = VLC_SUCCESS;
break;
case DEMUX_SET_POSITION:
f = (double)va_arg( args, double );
if( p_input->stream.b_seekable && p_input->pf_seek != NULL && f >= 0.0 && f <= 1.0 )
{
SeekOffset( p_input, (int64_t)(f * (double)p_input->stream.p_selected_area->i_size) );
i_ret = VLC_SUCCESS;
}
else
{
i_ret = VLC_EGENERIC;
}
break;
case DEMUX_GET_TIME:
pi64 = (int64_t*)va_arg( args, int64_t * );
if( p_input->stream.i_mux_rate > 0 )
{
*pi64 = (int64_t)1000000 *
( p_input->stream.p_selected_area->i_tell / 50 ) /
p_input->stream.i_mux_rate;
i_ret = VLC_SUCCESS;
}
else
{
*pi64 = 0;
i_ret = VLC_EGENERIC;
}
break;
case DEMUX_SET_TIME:
i64 = (int64_t)va_arg( args, int64_t );
if( p_input->stream.i_mux_rate > 0 &&
p_input->stream.b_seekable && p_input->pf_seek != NULL && i64 >= 0 )
{
SeekOffset( p_input, i64 * 50 *
(int64_t)p_input->stream.i_mux_rate /
(int64_t)1000000 );
i_ret = VLC_SUCCESS;
}
else
{
i_ret = VLC_EGENERIC;
}
break;
case DEMUX_GET_LENGTH:
pi64 = (int64_t*)va_arg( args, int64_t * );
if( p_input->stream.i_mux_rate > 0 )
{
*pi64 = (int64_t)1000000 *
( p_input->stream.p_selected_area->i_size / 50 ) /
p_input->stream.i_mux_rate;
i_ret = VLC_SUCCESS;
}
else
{
*pi64 = 0;
i_ret = VLC_EGENERIC;
}
break;
default:
msg_Err( p_input, "unknown query in demux_vaControlDefault !!!" );
i_ret = VLC_EGENERIC;
break;
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
return i_ret;
}
static void SeekOffset( input_thread_t *p_input, int64_t i_pos )
{
/* Reinitialize buffer manager. */
input_AccessReinit( p_input );
vlc_mutex_unlock( &p_input->stream.stream_lock );
p_input->pf_seek( p_input, i_pos );
vlc_mutex_lock( &p_input->stream.stream_lock );
}
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_clock.c: Clock/System date convertions, stream management * input_clock.c: Clock/System date convertions, stream management
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: input_clock.c,v 1.41 2003/08/08 16:50:27 gbazin Exp $ * $Id: input_clock.c,v 1.42 2003/09/07 22:51:11 fenrir Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -147,6 +147,7 @@ void input_ClockInit( pgrm_descriptor_t * p_pgrm ) ...@@ -147,6 +147,7 @@ void input_ClockInit( pgrm_descriptor_t * p_pgrm )
int input_ClockManageControl( input_thread_t * p_input, int input_ClockManageControl( input_thread_t * p_input,
pgrm_descriptor_t * p_pgrm, mtime_t i_clock ) pgrm_descriptor_t * p_pgrm, mtime_t i_clock )
{ {
vlc_value_t val;
int i_return_value = UNDEF_S; int i_return_value = UNDEF_S;
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
...@@ -205,6 +206,12 @@ int input_ClockManageControl( input_thread_t * p_input, ...@@ -205,6 +206,12 @@ int input_ClockManageControl( input_thread_t * p_input,
input_EscapeAudioDiscontinuity( p_input ); input_EscapeAudioDiscontinuity( p_input );
} }
val.i_int = p_input->stream.control.i_rate;
var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
val.i_int = p_input->stream.control.i_status;
var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
p_input->stream.i_new_status = UNDEF_S; p_input->stream.i_new_status = UNDEF_S;
p_input->stream.i_new_rate = UNDEF_S; p_input->stream.i_new_rate = UNDEF_S;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* variables.c: routines for object variables handling * variables.c: routines for object variables handling
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: variables.c,v 1.29 2003/07/23 23:05:25 gbazin Exp $ * $Id: variables.c,v 1.30 2003/09/07 22:51:11 fenrir Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -46,10 +46,7 @@ static int CmpBool( vlc_value_t v, vlc_value_t w ) { return v.b_bool ? w.b_bool ...@@ -46,10 +46,7 @@ static int CmpBool( vlc_value_t v, vlc_value_t w ) { return v.b_bool ? w.b_bool
static int CmpInt( vlc_value_t v, vlc_value_t w ) { return v.i_int == w.i_int ? 0 : v.i_int > w.i_int ? 1 : -1; } static int CmpInt( vlc_value_t v, vlc_value_t w ) { return v.i_int == w.i_int ? 0 : v.i_int > w.i_int ? 1 : -1; }
static int CmpTime( vlc_value_t v, vlc_value_t w ) static int CmpTime( vlc_value_t v, vlc_value_t w )
{ {
mtime_t v_time,w_time; return v.i_time == w.i_time ? 0 : v.i_time > w.i_time ? 1 : -1;
v_time = ( (mtime_t)v.time.i_high << 32 ) + v.time.i_low;
w_time = ( (mtime_t)w.time.i_high << 32 ) + w.time.i_low;
return v_time == w_time ? 0 : v_time > w_time ? 1 : -1;
} }
static int CmpString( vlc_value_t v, vlc_value_t w ) { return strcmp( v.psz_string, w.psz_string ); } static int CmpString( vlc_value_t v, vlc_value_t w ) { return strcmp( v.psz_string, w.psz_string ); }
static int CmpFloat( vlc_value_t v, vlc_value_t w ) { return v.f_float == w.f_float ? 0 : v.f_float > w.f_float ? 1 : -1; } static int CmpFloat( vlc_value_t v, vlc_value_t w ) { return v.f_float == w.f_float ? 0 : v.f_float > w.f_float ? 1 : -1; }
...@@ -237,8 +234,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) ...@@ -237,8 +234,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
break; break;
case VLC_VAR_TIME: case VLC_VAR_TIME:
p_var->pf_cmp = CmpTime; p_var->pf_cmp = CmpTime;
p_var->val.time.i_low = 0; p_var->val.i_time = 0;
p_var->val.time.i_high = 0;
break; break;
case VLC_VAR_ADDRESS: case VLC_VAR_ADDRESS:
p_var->pf_cmp = CmpAddress; p_var->pf_cmp = CmpAddress;
......
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