/*****************************************************************************
* var.c: object variables for input thread
*****************************************************************************
- * Copyright (C) 2004-2007 the VideoLAN team
+ * Copyright (C) 2004-2007 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
#endif
#include <vlc_common.h>
+#include <assert.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
{
CALLBACK( "state", StateCallback ),
CALLBACK( "rate", RateCallback ),
- CALLBACK( "rate-slower", RateCallback ),
- CALLBACK( "rate-faster", RateCallback ),
CALLBACK( "position", PositionCallback ),
CALLBACK( "position-offset", PositionCallback ),
CALLBACK( "time", TimeCallback ),
var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
/* Rate */
- var_Create( p_input, "rate", VLC_VAR_FLOAT );
- val.f_float = (float)INPUT_RATE_DEFAULT / (float)p_input->p->i_rate;
- var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
-
- var_Create( p_input, "rate-slower", VLC_VAR_VOID );
-
- var_Create( p_input, "rate-faster", VLC_VAR_VOID );
+ var_Create( p_input, "rate", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
var_Create( p_input, "frame-next", VLC_VAR_VOID );
var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL );
/* Programs */
- var_Create( p_input, "programs", VLC_VAR_LIST | VLC_VAR_DOINHERIT );
+ var_Create( p_input, "programs", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
text.psz_string = _("Programs");
var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL );
/* Spu ES */
var_Create( p_input, "spu-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
- text.psz_string = _("Subtitles Track");
+ text.psz_string = _("Subtitle Track");
var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL );
/* Special read only objects variables for intf */
var_AddCallback( p_input, val.psz_string,
NavigationCallback, (void *)(intptr_t)i );
+ char psz_length[MSTRTIME_MAX_SIZE + sizeof(" []")] = "";
+ if( p_input->p->title[i]->i_length > 0 )
+ {
+ strcpy( psz_length, " [" );
+ secstotimestr( &psz_length[2], p_input->p->title[i]->i_length / CLOCK_FREQ );
+ strcat( psz_length, "]" );
+ }
+
if( p_input->p->title[i]->psz_name == NULL ||
*p_input->p->title[i]->psz_name == '\0' )
{
- if( asprintf( &text.psz_string, _("Title %i"),
- i + p_input->p->i_title_offset ) == -1 )
+ if( asprintf( &text.psz_string, _("Title %i%s"),
+ i + p_input->p->i_title_offset, psz_length ) == -1 )
continue;
}
else
{
- text.psz_string = strdup( p_input->p->title[i]->psz_name );
+ if( asprintf( &text.psz_string, "%s%s",
+ p_input->p->title[i]->psz_name, psz_length ) == -1 )
+ continue;
}
var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val, &text );
void input_ControlVarTitle( input_thread_t *p_input, int i_title )
{
input_title_t *t = p_input->p->title[i_title];
- vlc_value_t val, text;
+ vlc_value_t text;
int i;
/* Create/Destroy command variables */
var_Destroy( p_input, "next-chapter" );
var_Destroy( p_input, "prev-chapter" );
}
- else if( var_Get( p_input, "next-chapter", &val ) != VLC_SUCCESS )
+ else if( var_Type( p_input, "next-chapter" ) == 0 )
{
var_Create( p_input, "next-chapter", VLC_VAR_VOID );
text.psz_string = _("Next chapter");
var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL );
for( i = 0; i < t->i_seekpoint; i++ )
{
+ vlc_value_t val;
val.i_int = i;
if( t->seekpoint[i]->psz_name == NULL ||
var_Create( p_input, "sub-track-id",
VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
- var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT );
+ var_Create( p_input, "sub-file", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
VLC_VAR_DOINHERIT );
var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING |
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
input_thread_t *p_input = (input_thread_t*)p_this;
- VLC_UNUSED(oldval); VLC_UNUSED(p_data);
+ VLC_UNUSED(oldval); VLC_UNUSED(p_data); VLC_UNUSED(psz_cmd);
+
+ newval.i_int = INPUT_RATE_DEFAULT / newval.f_float;
+ input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
- /* Problem with this way: the "rate" variable is update after the input thread do the change */
- if( !strcmp( psz_cmd, "rate-slower" ) )
- {
- input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_SLOWER, NULL );
- }
- else if( !strcmp( psz_cmd, "rate-faster" ) )
- {
- input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_FASTER, NULL );
- }
- else
- {
- int i_rate = INPUT_RATE_DEFAULT / newval.f_float;
- input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
- }
return VLC_SUCCESS;
}
val.f_float = (double)newval.i_time/(double)i_length;
var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
+ /*
+ * Notify the intf that a new event has been occurred.
+ * XXX this is a bit hackish but it's the only way to do it now.
+ */
+ var_SetInteger( p_input, "intf-event", INPUT_EVENT_POSITION );
}
/* */