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( ...@@ -1044,16 +1044,24 @@ void libvlc_media_player_set_rate(
{ {
input_thread_t *p_input_thread; input_thread_t *p_input_thread;
vlc_value_t val; vlc_value_t val;
bool b_can_rewind;
if( rate <= 0 ) if( rate != 0 )
RAISEVOID( "Rate value is invalid" ); RAISEVOID( "Rate value is invalid" );
val.i_int = 1000.0f/rate;
p_input_thread = libvlc_get_input_thread ( p_mi, p_e); p_input_thread = libvlc_get_input_thread ( p_mi, p_e);
if ( !p_input_thread ) if( !p_input_thread )
return; 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 ); var_Set( p_input_thread, "rate", val );
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
} }
...@@ -1064,12 +1072,19 @@ float libvlc_media_player_get_rate( ...@@ -1064,12 +1072,19 @@ float libvlc_media_player_get_rate(
{ {
input_thread_t *p_input_thread; input_thread_t *p_input_thread;
vlc_value_t val; vlc_value_t val;
bool b_can_rewind;
p_input_thread = libvlc_get_input_thread ( p_mi, p_e); p_input_thread = libvlc_get_input_thread ( p_mi, p_e );
if ( !p_input_thread ) if( !p_input_thread )
return -1.0; return 0.0; /* rate < 0 indicates rewind */
var_Get( p_input_thread, "rate", &val ); 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 ); vlc_object_release( p_input_thread );
return (float)1000.0f/val.i_int; return (float)1000.0f/val.i_int;
......
...@@ -1746,6 +1746,7 @@ static bool Control( input_thread_t *p_input, int i_type, ...@@ -1746,6 +1746,7 @@ static bool Control( input_thread_t *p_input, int i_type,
i_error = i_test_e; i_error = i_test_e;
} }
} }
assert( i_idx >= 0 && ppi_factor[i_idx][0] != 0 ); assert( i_idx >= 0 && ppi_factor[i_idx][0] != 0 );
if( i_type == INPUT_CONTROL_SET_RATE_SLOWER ) if( i_type == INPUT_CONTROL_SET_RATE_SLOWER )
...@@ -2359,6 +2360,7 @@ static int InputSourceInit( input_thread_t *p_input, ...@@ -2359,6 +2360,7 @@ static int InputSourceInit( input_thread_t *p_input,
&in->b_can_pause ) ) &in->b_can_pause ) )
in->b_can_pause = false; 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-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, int ret = demux_Control( in->p_demux, DEMUX_CAN_SEEK,
&val.b_bool ); &val.b_bool );
...@@ -2443,6 +2445,8 @@ static int InputSourceInit( input_thread_t *p_input, ...@@ -2443,6 +2445,8 @@ static int InputSourceInit( input_thread_t *p_input,
access_Control( in->p_access, ACCESS_CAN_PAUSE, access_Control( in->p_access, ACCESS_CAN_PAUSE,
&in->b_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-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, access_Control( in->p_access, ACCESS_CAN_SEEK,
&val.b_bool ); &val.b_bool );
var_Set( p_input, "seekable", val ); var_Set( p_input, "seekable", val );
......
...@@ -73,6 +73,7 @@ typedef struct ...@@ -73,6 +73,7 @@ typedef struct
const char *psz_name; const char *psz_name;
vlc_callback_t callback; vlc_callback_t callback;
} vlc_input_callback_t; } vlc_input_callback_t;
static void InputAddCallbacks( input_thread_t *, const 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 * ); static void InputDelCallbacks( input_thread_t *, const vlc_input_callback_t * );
...@@ -478,6 +479,9 @@ void input_ConfigVarInit ( input_thread_t *p_input ) ...@@ -478,6 +479,9 @@ void input_ConfigVarInit ( input_thread_t *p_input )
var_Create( p_input, "can-pause", VLC_VAR_BOOL ); var_Create( p_input, "can-pause", VLC_VAR_BOOL );
var_SetBool( p_input, "can-pause", true ); /* Fixed later*/ 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_Create( p_input, "can-record", VLC_VAR_BOOL );
var_SetBool( p_input, "can-record", false ); /* Fixed later*/ var_SetBool( p_input, "can-record", false ); /* Fixed later*/
...@@ -521,6 +525,7 @@ static void InputAddCallbacks( input_thread_t *p_input, ...@@ -521,6 +525,7 @@ static void InputAddCallbacks( input_thread_t *p_input,
p_callbacks[i].psz_name, p_callbacks[i].psz_name,
p_callbacks[i].callback, NULL ); p_callbacks[i].callback, NULL );
} }
static void InputDelCallbacks( input_thread_t *p_input, static void InputDelCallbacks( input_thread_t *p_input,
const vlc_input_callback_t *p_callbacks ) const vlc_input_callback_t *p_callbacks )
{ {
...@@ -530,6 +535,7 @@ static void InputDelCallbacks( input_thread_t *p_input, ...@@ -530,6 +535,7 @@ static void InputDelCallbacks( input_thread_t *p_input,
p_callbacks[i].psz_name, p_callbacks[i].psz_name,
p_callbacks[i].callback, NULL ); p_callbacks[i].callback, NULL );
} }
/***************************************************************************** /*****************************************************************************
* All Callbacks: * All Callbacks:
*****************************************************************************/ *****************************************************************************/
...@@ -568,7 +574,6 @@ static int RateCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -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 ); input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
} }
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -812,6 +817,7 @@ static int RecordCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -812,6 +817,7 @@ static int RecordCallback( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd, static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, vlc_value_t oldval, vlc_value_t newval,
void *p_data ) 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