Commit 50f7bdc9 authored by Laurent Aimar's avatar Laurent Aimar

* input: added position-offset and time-offset for relative seeking.

 (Untested)
parent 47d57d6d
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.241 2003/09/15 18:05:13 fenrir Exp $ * $Id: input.c,v 1.242 2003/09/20 13:50:14 fenrir Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -119,13 +119,15 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, ...@@ -119,13 +119,15 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
/* play status */ /* play status */
/* position variable */ /* position variable */
var_Create( p_input, "position", VLC_VAR_FLOAT ); /* position 0.0 -> 1.0 */ var_Create( p_input, "position", VLC_VAR_FLOAT ); /* position 0.0->1.0 */
var_Create( p_input, "position-offset", VLC_VAR_FLOAT ); /* relative */
val.f_float = 0.0; val.f_float = 0.0;
var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
var_AddCallback( p_input, "position", PositionCallback, NULL ); var_AddCallback( p_input, "position", PositionCallback, NULL );
/* time variable */ /* time variable */
var_Create( p_input, "time", VLC_VAR_TIME ); var_Create( p_input, "time", VLC_VAR_TIME );
var_Create( p_input, "time-offset", VLC_VAR_TIME ); /* relative */
val.i_time = 0; val.i_time = 0;
var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
var_AddCallback( p_input, "time", TimeCallback, NULL ); var_AddCallback( p_input, "time", TimeCallback, NULL );
...@@ -1189,14 +1191,27 @@ static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1189,14 +1191,27 @@ static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
input_thread_t *p_input = (input_thread_t *)p_this; input_thread_t *p_input = (input_thread_t *)p_this;
int64_t i_offset;
msg_Warn( p_input, "cmd=%s old=%f new=%f", msg_Warn( p_input, "cmd=%s old=%f new=%f",
psz_cmd, psz_cmd,
oldval.f_float, newval.f_float ); oldval.f_float, newval.f_float );
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.p_selected_area->i_seek = i_offset = (int64_t)( newval.f_float *
(int64_t)( newval.f_float * (double)p_input->stream.p_selected_area->i_size ); (double)p_input->stream.p_selected_area->i_size );
if( !strcmp( psz_cmd, "position-offset" ) )
{
p_input->stream.p_selected_area->i_seek += i_offset;
}
else
{
p_input->stream.p_selected_area->i_seek = i_offset;
}
if( p_input->stream.p_selected_area->i_seek < 0 )
{
p_input->stream.p_selected_area->i_seek = 0;
}
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -1206,15 +1221,28 @@ static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1206,15 +1221,28 @@ static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
input_thread_t *p_input = (input_thread_t *)p_this; input_thread_t *p_input = (input_thread_t *)p_this;
int64_t i_offset;
/* FIXME TODO FIXME */ /* FIXME TODO FIXME */
msg_Warn( p_input, "cmd=%s old=%lld new=%lld", msg_Warn( p_input, "cmd=%s old=%lld new=%lld",
psz_cmd, psz_cmd,
oldval.i_time, newval.i_time ); oldval.i_time, newval.i_time );
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.p_selected_area->i_seek = i_offset = newval.i_time / 1000000 * 50 * p_input->stream.i_mux_rate;
newval.i_time / 1000000 * 50 * p_input->stream.i_mux_rate; if( !strcmp( psz_cmd, "time-offset" ) )
{
p_input->stream.p_selected_area->i_seek += i_offset;
}
else
{
p_input->stream.p_selected_area->i_seek = i_offset;
}
if( p_input->stream.p_selected_area->i_seek < 0 )
{
p_input->stream.p_selected_area->i_seek = 0;
}
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
return VLC_SUCCESS; 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