Commit 75adef44 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Signal can_rewind for use by user interfaces.

parent f76cff41
......@@ -1044,16 +1044,24 @@ void libvlc_media_player_set_rate(
{
input_thread_t *p_input_thread;
vlc_value_t val;
bool b_can_rewind;
if( rate <= 0 )
if( rate != 0 )
RAISEVOID( "Rate value is invalid" );
val.i_int = 1000.0f/rate;
p_input_thread = libvlc_get_input_thread ( p_mi, p_e);
if ( !p_input_thread )
if( !p_input_thread )
return;
b_can_rewind = var_GetBool( p_input_thread, "can-rewind" );
if( (rate < 0) && !b_can_rewind )
{
vlc_object_release( p_input_thread );
libvlc_exception_raise( p_e, "Rate value is invalid" );
return;
}
val.i_int = 1000.0f/rate;
var_Set( p_input_thread, "rate", val );
vlc_object_release( p_input_thread );
}
......@@ -1064,12 +1072,19 @@ float libvlc_media_player_get_rate(
{
input_thread_t *p_input_thread;
vlc_value_t val;
bool b_can_rewind;
p_input_thread = libvlc_get_input_thread ( p_mi, p_e);
if ( !p_input_thread )
return -1.0;
p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
if( !p_input_thread )
return 0.0; /* rate < 0 indicates rewind */
var_Get( p_input_thread, "rate", &val );
b_can_rewind = var_GetBool( p_input_thread, "can-rewind" );
if( (val.i_int < 0) && !b_can_rewind )
{
libvlc_exception_raise( p_e, "invalid rate" );
return 0.0;
}
vlc_object_release( p_input_thread );
return (float)1000.0f/val.i_int;
......
......@@ -191,20 +191,20 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
p_input->b_eof = false;
p_input->b_can_pace_control = true;
p_input->p->i_start = 0;
p_input->i_time = 0;
p_input->i_time = 0;
p_input->p->i_stop = 0;
p_input->p->i_run = 0;
p_input->p->i_run = 0;
p_input->p->i_title = 0;
p_input->p->title = NULL;
p_input->p->title = NULL;
p_input->p->i_title_offset = p_input->p->i_seekpoint_offset = 0;
p_input->i_state = INIT_S;
p_input->p->i_rate = INPUT_RATE_DEFAULT;
p_input->p->i_rate = INPUT_RATE_DEFAULT;
p_input->p->b_recording = false;
TAB_INIT( p_input->p->i_bookmark, p_input->p->bookmark );
TAB_INIT( p_input->p->i_attachment, p_input->p->attachment );
p_input->p->p_es_out_display = NULL;
p_input->p->p_es_out = NULL;
p_input->p->p_sout = NULL;
p_input->p->p_sout = NULL;
p_input->p->b_out_pace_control = false;
p_input->i_pts_delay = 0;
......@@ -1746,6 +1746,7 @@ static bool Control( input_thread_t *p_input, int i_type,
i_error = i_test_e;
}
}
assert( i_idx >= 0 && ppi_factor[i_idx][0] != 0 );
if( i_type == INPUT_CONTROL_SET_RATE_SLOWER )
......@@ -1811,7 +1812,7 @@ static bool Control( input_thread_t *p_input, int i_type,
var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
var_SetBool( p_input, "rate-change", true );
p_input->p->i_rate = i_rate;
p_input->p->i_rate = i_rate;
/* FIXME do we need a RESET_PCR when !p_input->p->input.b_rescale_ts ? */
if( p_input->p->input.b_rescale_ts )
......@@ -2359,6 +2360,7 @@ static int InputSourceInit( input_thread_t *p_input,
&in->b_can_pause ) )
in->b_can_pause = false;
var_SetBool( p_input, "can-pause", in->b_can_pause || !in->b_can_pace_control ); /* XXX temporary because of es_out_timeshift*/
var_SetBool( p_input, "can-rewind", !in->b_rescale_ts && !in->b_can_pace_control );
int ret = demux_Control( in->p_demux, DEMUX_CAN_SEEK,
&val.b_bool );
......@@ -2443,6 +2445,8 @@ static int InputSourceInit( input_thread_t *p_input,
access_Control( in->p_access, ACCESS_CAN_PAUSE,
&in->b_can_pause );
var_SetBool( p_input, "can-pause", in->b_can_pause || !in->b_can_pace_control ); /* XXX temporary because of es_out_timeshift*/
var_SetBool( p_input, "can-rewind", !in->b_rescale_ts && !in->b_can_pace_control );
access_Control( in->p_access, ACCESS_CAN_SEEK,
&val.b_bool );
var_Set( p_input, "seekable", val );
......
......@@ -73,6 +73,7 @@ typedef struct
const char *psz_name;
vlc_callback_t callback;
} vlc_input_callback_t;
static void InputAddCallbacks( input_thread_t *, const vlc_input_callback_t * );
static void InputDelCallbacks( input_thread_t *, const vlc_input_callback_t * );
......@@ -478,6 +479,9 @@ void input_ConfigVarInit ( input_thread_t *p_input )
var_Create( p_input, "can-pause", VLC_VAR_BOOL );
var_SetBool( p_input, "can-pause", true ); /* Fixed later*/
var_Create( p_input, "can-rewind", VLC_VAR_BOOL );
var_SetBool( p_input, "can-rewind", false );
var_Create( p_input, "can-record", VLC_VAR_BOOL );
var_SetBool( p_input, "can-record", false ); /* Fixed later*/
......@@ -521,6 +525,7 @@ static void InputAddCallbacks( input_thread_t *p_input,
p_callbacks[i].psz_name,
p_callbacks[i].callback, NULL );
}
static void InputDelCallbacks( input_thread_t *p_input,
const vlc_input_callback_t *p_callbacks )
{
......@@ -530,6 +535,7 @@ static void InputDelCallbacks( input_thread_t *p_input,
p_callbacks[i].psz_name,
p_callbacks[i].callback, NULL );
}
/*****************************************************************************
* All Callbacks:
*****************************************************************************/
......@@ -568,7 +574,6 @@ static int RateCallback( vlc_object_t *p_this, char const *psz_cmd,
{
input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
}
return VLC_SUCCESS;
}
......@@ -812,6 +817,7 @@ static int RecordCallback( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS;
}
static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
void *p_data )
......
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