* decoder.c: AAC decoder using libfaad2
*****************************************************************************
* Copyright (C) 2001, 2003 VideoLAN
- * $Id: faad.c,v 1.1 2003/11/03 22:30:15 fenrir Exp $
+ * $Id: faad.c,v 1.2 2003/11/04 02:23:11 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
-
-
-
-
-
-
-
-
-
-
-
-
* hotkeys.c: Hotkey handling for vlc
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: hotkeys.c,v 1.7 2003/10/31 18:18:46 gbazin Exp $
+ * $Id: hotkeys.c,v 1.8 2003/11/04 02:23:11 fenrir Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
-#include <string.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
}
else if( i_action == ACTIONID_PLAY_PAUSE )
{
- if( p_input &&
- p_input->stream.control.i_status != PAUSE_S )
+ val.i_int = PLAYING_S;
+ if( p_input )
+ {
+ var_Get( p_input, "state", &val );
+ }
+ if( p_input && val.i_int != PAUSE_S )
{
vout_OSDMessage( VLC_OBJECT(p_intf), _( "Pause" ) );
- input_SetStatus( p_input, INPUT_STATUS_PAUSE );
+ val.i_int = PAUSE_S;
+ var_Set( p_input, "state", val );
}
else
{
}
else if( p_input )
{
- uint64_t i_time;
-
if( i_action == ACTIONID_PAUSE )
{
vout_OSDMessage( VLC_OBJECT(p_intf), _( "Pause" ) );
- input_SetStatus( p_input, INPUT_STATUS_PAUSE );
+ val.i_int = PAUSE_S;
+ var_Set( p_input, "state", val );
}
else if( i_action == ACTIONID_JUMP_BACKWARD_10SEC )
{
vout_OSDMessage( VLC_OBJECT(p_intf), _( "Jump -10 seconds" ) );
- demux_Control( p_input, DEMUX_GET_TIME, &i_time );
- demux_Control( p_input, DEMUX_SET_TIME, i_time - 10000000 );
+ val.i_time = -10000000LL;
+ var_Set( p_input, "time-offset", val );
}
else if( i_action == ACTIONID_JUMP_FORWARD_10SEC )
{
vout_OSDMessage( VLC_OBJECT(p_intf), _( "Jump +10 seconds" ) );
- demux_Control( p_input, DEMUX_GET_TIME, &i_time );
- demux_Control( p_input, DEMUX_SET_TIME, i_time + 10000000 );
+ val.i_time = 10000000LL;
+ var_Set( p_input, "time-offset", val );
}
else if( i_action == ACTIONID_JUMP_BACKWARD_1MIN )
{
vout_OSDMessage( VLC_OBJECT(p_intf), _( "Jump -1 minute" ) );
- demux_Control( p_input, DEMUX_GET_TIME, &i_time );
- demux_Control( p_input, DEMUX_SET_TIME, i_time - 60000000 );
+ val.i_time = -60000000LL;
+ var_Set( p_input, "time-offset", val );
}
else if( i_action == ACTIONID_JUMP_FORWARD_1MIN )
{
vout_OSDMessage( VLC_OBJECT(p_intf), _( "Jump +1 minute" ) );
- demux_Control( p_input, DEMUX_GET_TIME, &i_time );
- demux_Control( p_input, DEMUX_SET_TIME, i_time + 60000000 );
+ val.i_time = 60000000LL;
+ var_Set( p_input, "time-offset", val );
}
else if( i_action == ACTIONID_JUMP_BACKWARD_5MIN )
{
vout_OSDMessage( VLC_OBJECT(p_intf), _( "Jump -5 minutes" ) );
- demux_Control( p_input, DEMUX_GET_TIME, &i_time );
- demux_Control( p_input, DEMUX_SET_TIME, i_time - 300000000 );
+ val.i_time = -300000000LL;
+ var_Set( p_input, "time-offset", val );
}
else if( i_action == ACTIONID_JUMP_FORWARD_5MIN )
{
vout_OSDMessage( VLC_OBJECT(p_intf), _( "Jump +5 minutes" ) );
- demux_Control( p_input, DEMUX_GET_TIME, &i_time );
- demux_Control( p_input, DEMUX_SET_TIME, i_time + 300000000 );
+ val.i_time = 300000000LL;
+ var_Set( p_input, "time-offset", val );
}
else if( i_action == ACTIONID_NEXT )
{
* avi.c : AVI file Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: avi.c,v 1.63 2003/10/19 13:39:11 hartman Exp $
+ * $Id: avi.c,v 1.64 2003/11/04 02:23:11 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
if( p_avi->b_seekable )
{
- if( !p_avi->i_length || p_avi->b_interleaved )
+ if( !p_avi->i_length ) //|| p_avi->b_interleaved )
{
avi_stream_t *p_stream;
int64_t i_pos;
*****************************************************************************
*
*****************************************************************************/
+static double ControlGetPosition( input_thread_t *p_input )
+{
+ demux_sys_t *p_sys = p_input->p_demux_data;
+
+ if( p_sys->i_length > 0 )
+ {
+ return (double)p_sys->i_time / (double)( p_sys->i_length * (mtime_t)1000000 );
+ }
+ else if( stream_Size( p_input->s ) > 0 )
+ {
+ unsigned int i;
+ int64_t i_tmp;
+ int64_t i64 = 0;
+
+ /* search the more advanced selected es */
+ for( i = 0; i < p_sys->i_streams; i++ )
+ {
+ avi_stream_t *tk = p_sys->pp_info[i];
+ if( tk->b_activated && tk->i_idxposc < tk->i_idxnb )
+ {
+ i_tmp = tk->p_index[tk->i_idxposc].i_pos +
+ tk->p_index[tk->i_idxposc].i_length + 8;
+ if( i_tmp > i64 )
+ {
+ i64 = i_tmp;
+ }
+ }
+ }
+ return (double)i64 / (double)stream_Size( p_input->s );
+ }
+ return 0.0;
+}
+
static int Control( input_thread_t *p_input, int i_query, va_list args )
{
demux_sys_t *p_sys = p_input->p_demux_data;
{
case DEMUX_GET_POSITION:
pf = (double*)va_arg( args, double * );
- if( p_sys->i_length > 0 )
- {
- *pf = (double)p_sys->i_time / (double)( p_sys->i_length * (mtime_t)1000000 );
- return VLC_SUCCESS;
- }
- else if( stream_Size( p_input->s ) > 0 )
- {
- unsigned int i;
- int64_t i_tmp;
-
- i64 = 0;
- /* search the more advanced selected es */
- for( i = 0; i < p_sys->i_streams; i++ )
- {
-#define tk p_sys->pp_info[i]
- if( tk->b_activated && tk->i_idxposc < tk->i_idxnb )
- {
- i_tmp = tk->p_index[tk->i_idxposc].i_pos +
- tk->p_index[tk->i_idxposc].i_length + 8;
- if( i_tmp > i64 )
- {
- i64 = i_tmp;
- }
- }
-#undef tk
- }
- *pf = (double)i64 / (double)stream_Size( p_input->s );
- return VLC_SUCCESS;
- }
- else
- {
- *pf = 0.0;
- return VLC_SUCCESS;
- }
+ *pf = ControlGetPosition( p_input );
+ return VLC_SUCCESS;
case DEMUX_SET_POSITION:
if( p_sys->b_seekable )
{
- int i_ret;
-
f = (double)va_arg( args, double );
i64 = (mtime_t)(1000000.0 * p_sys->i_length * f );
- i_ret = Seek( p_input, i64, (int)(f * 100) );
- return i_ret;
- }
- else
- {
- return demux_vaControlDefault( p_input, i_query, args );
+ return Seek( p_input, i64, (int)(f * 100) );
}
+ return demux_vaControlDefault( p_input, i_query, args );
+
case DEMUX_GET_TIME:
pi64 = (int64_t*)va_arg( args, int64_t * );
*pi64 = p_sys->i_time;
return VLC_SUCCESS;
case DEMUX_SET_TIME:
- msg_Err( p_input, "FIXME DEMUX_SET_TIME to be implemented" );
- return VLC_EGENERIC;
- /* return demux_vaControlDefault( p_input, i_query, args ); */
+ {
+ int i_percent = 0;
+ i64 = (int64_t)va_arg( args, int64_t );
+ if( p_sys->i_length > 0 )
+ {
+ i_percent = 100 * i64 / (p_sys->i_length*1000000ULL);
+ }
+ else if( p_sys->i_time > 0 )
+ {
+ i_percent = (int)( 100.0 * ControlGetPosition( p_input ) *
+ (double)i64 / (double)p_sys->i_time );
+ }
+ return Seek( p_input, i64, i_percent );
+ }
case DEMUX_GET_LENGTH:
pi64 = (int64_t*)va_arg( args, int64_t * );
*pi64 = p_sys->i_length * (mtime_t)1000000;
*pf = 0.0;
for( i = 0; i < (int)p_sys->i_streams; i++ )
{
-#define tk p_sys->pp_info[i]
+ avi_stream_t *tk = p_sys->pp_info[i];
if( tk->i_cat == VIDEO_ES && tk->i_scale > 0)
{
*pf = (float)tk->i_rate / (float)tk->i_scale;
break;
}
-#undef tk
}
return VLC_SUCCESS;
* decoders.
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: input.c,v 1.250 2003/10/29 01:33:26 gbazin Exp $
+ * $Id: input.c,v 1.251 2003/11/04 02:23:11 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
val.f_float = 0.0;
var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
var_AddCallback( p_input, "position", PositionCallback, NULL );
+ var_AddCallback( p_input, "position-offset", PositionCallback, NULL );
/* time variable */
var_Create( p_input, "time", VLC_VAR_TIME );
val.i_time = 0;
var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
var_AddCallback( p_input, "time", TimeCallback, NULL );
+ var_AddCallback( p_input, "time-offset", TimeCallback, NULL );
/* length variable */
var_Create( p_input, "length", VLC_VAR_TIME );
void *p_data )
{
input_thread_t *p_input = (input_thread_t *)p_this;
- int64_t i_offset;
msg_Dbg( p_input, "cmd=%s old=%f new=%f", psz_cmd,
oldval.f_float, newval.f_float );
- vlc_mutex_lock( &p_input->stream.stream_lock );
- i_offset = (int64_t)( newval.f_float *
- (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;
+ vlc_value_t val;
+ var_Get( p_input, "position", &val );
+
+ newval.f_float += val.f_float;
}
+
+ vlc_mutex_lock( &p_input->stream.stream_lock );
+ p_input->stream.p_selected_area->i_seek =
+ (int64_t)( newval.f_float *
+ (double)p_input->stream.p_selected_area->i_size );
+
if( p_input->stream.p_selected_area->i_seek < 0 )
{
p_input->stream.p_selected_area->i_seek = 0;
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
input_thread_t *p_input = (input_thread_t *)p_this;
- int64_t i_offset;
+ vlc_value_t val;
/* FIXME TODO FIXME */
msg_Dbg( p_input, "cmd=%s old=%lld new=%lld", psz_cmd,
oldval.i_time, newval.i_time );
-
- vlc_mutex_lock( &p_input->stream.stream_lock );
- i_offset = newval.i_time / 1000000 * 50 * p_input->stream.i_mux_rate;
- if( !strcmp( psz_cmd, "time-offset" ) )
+ var_Get( p_input, "length", &val );
+ if( val.i_time > 0 )
{
- p_input->stream.p_selected_area->i_seek += i_offset;
+ val.f_float = (double)newval.i_time / (double)val.i_time;
+ if( !strcmp( psz_cmd, "time-offset" ) )
+ {
+ var_Set( p_input, "position-offset", val );
+ }
+ else
+ {
+ var_Set( p_input, "position", val );
+ }
}
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;
+ msg_Warn( p_input, "TimeCallback: length <= 0 -> can't seek" );
}
- vlc_mutex_unlock( &p_input->stream.stream_lock );
-
return VLC_SUCCESS;
}