Commit 61a2101b authored by Jean-Paul Saman's avatar Jean-Paul Saman

Signal can_rewind for use by user interfaces.

(cherry picked from commit: 3a632c159fd106e8150aef6dc6b6b41903009989)
Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent 76cfaf8a
......@@ -47,11 +47,11 @@ get_next_path( libvlc_media_list_player_t * p_mlp )
return NULL;
return libvlc_media_list_path_with_root_index(0);
}
p_sublist_of_playing_item = libvlc_media_list_sublist_at_path(
p_mlp->p_mlist,
p_mlp->current_playing_item_path );
/* If item just gained a sublist just play it */
if( p_sublist_of_playing_item )
{
......@@ -229,7 +229,7 @@ set_current_playing_item( libvlc_media_list_player_t * p_mlp,
{
p_mlp->p_mi = libvlc_media_player_new_from_media(p_md, p_e);
}
if( p_md->p_subitems && libvlc_media_list_count( p_md->p_subitems, NULL ) > 0 )
{
libvlc_media_t * p_submd;
......@@ -334,7 +334,7 @@ void libvlc_media_list_player_set_media_list(
}
libvlc_media_list_retain( p_mlist );
p_mlp->p_mlist = p_mlist;
install_playlist_observer( p_mlp );
vlc_mutex_unlock( &p_mlp->object_lock );
......
......@@ -922,16 +922,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 );
}
......@@ -942,12 +950,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;
......
......@@ -180,18 +180,18 @@ 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;
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 = 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;
......@@ -1628,6 +1628,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 )
......@@ -1692,7 +1693,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 )
......@@ -2179,6 +2180,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 );
var_SetBool( p_input, "can-rewind", !in->b_rescale_ts );
int ret = demux_Control( in->p_demux, DEMUX_CAN_SEEK,
&val.b_bool );
......@@ -2263,7 +2265,10 @@ 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 );
var_SetBool( p_input, "can-rewind", !in->b_rescale_ts );
access_Control( in->p_access, ACCESS_CAN_SEEK,
&val.b_bool );
var_Set( p_input, "seekable", val );
......
......@@ -66,6 +66,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 * );
......@@ -471,6 +472,11 @@ void input_ConfigVarInit ( input_thread_t *p_input )
var_Create( p_input, "can-pause", VLC_VAR_BOOL );
val.b_bool = true; /* Fixed later*/
var_Change( p_input, "can-pause", VLC_VAR_SETVALUE, &val, NULL );
var_Create( p_input, "can-rewind", VLC_VAR_BOOL );
val.b_bool = false;
var_Change( p_input, "can-rewind", VLC_VAR_SETVALUE, &val, NULL );
var_Create( p_input, "teletext-es", VLC_VAR_INTEGER );
var_SetInteger( p_input, "teletext-es", -1 );
......@@ -502,6 +508,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 )
{
......@@ -511,6 +518,7 @@ static void InputDelCallbacks( input_thread_t *p_input,
p_callbacks[i].psz_name,
p_callbacks[i].callback, NULL );
}
/*****************************************************************************
* All Callbacks:
*****************************************************************************/
......@@ -549,7 +557,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;
}
......
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