1 /*****************************************************************************
2 * var.c: object variables for input thread
3 *****************************************************************************
4 * Copyright (C) 2004 VideoLAN
5 * $Id: input.c 7955 2004-06-07 22:21:33Z fenrir $
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
29 #include <vlc/input.h>
31 #include "input_internal.h"
33 /*****************************************************************************
35 *****************************************************************************/
36 void input_ControlVarInit ( input_thread_t * );
37 void input_ControlVarClean( input_thread_t * );
38 void input_ControlVarNavigation( input_thread_t * );
39 void input_ControlVarTitle( input_thread_t *p_input, int i_title );
41 void input_ConfigVarInit ( input_thread_t *p_input );
44 /*****************************************************************************
46 *****************************************************************************/
47 static int StateCallback ( vlc_object_t *p_this, char const *psz_cmd,
48 vlc_value_t oldval, vlc_value_t newval, void * );
49 static int RateCallback ( vlc_object_t *p_this, char const *psz_cmd,
50 vlc_value_t oldval, vlc_value_t newval, void * );
51 static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
52 vlc_value_t oldval, vlc_value_t newval, void * );
53 static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd,
54 vlc_value_t oldval, vlc_value_t newval, void * );
55 static int ProgramCallback ( vlc_object_t *p_this, char const *psz_cmd,
56 vlc_value_t oldval, vlc_value_t newval, void * );
57 static int TitleCallback ( vlc_object_t *p_this, char const *psz_cmd,
58 vlc_value_t oldval, vlc_value_t newval, void * );
59 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
60 vlc_value_t oldval, vlc_value_t newval, void * );
61 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
62 vlc_value_t oldval, vlc_value_t newval, void * );
63 static int ESCallback ( vlc_object_t *p_this, char const *psz_cmd,
64 vlc_value_t oldval, vlc_value_t newval, void * );
65 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
66 vlc_value_t oldval, vlc_value_t newval, void * );
68 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
69 vlc_value_t oldval, vlc_value_t newval, void * );
71 /*****************************************************************************
72 * input_ControlVarInit:
73 * Create all control object variables with their callbacks
74 *****************************************************************************/
75 void input_ControlVarInit ( input_thread_t *p_input )
77 vlc_value_t val, text;
80 var_Create( p_input, "state", VLC_VAR_INTEGER );
81 val.i_int = p_input->i_state;
82 var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
83 var_AddCallback( p_input, "state", StateCallback, NULL );
86 var_Create( p_input, "rate", VLC_VAR_INTEGER );
87 val.i_int = p_input->i_rate;
88 var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
89 var_AddCallback( p_input, "rate", RateCallback, NULL );
91 var_Create( p_input, "rate-slower", VLC_VAR_VOID );
92 var_AddCallback( p_input, "rate-slower", RateCallback, NULL );
94 var_Create( p_input, "rate-faster", VLC_VAR_VOID );
95 var_AddCallback( p_input, "rate-faster", RateCallback, NULL );
99 var_Create( p_input, "position", VLC_VAR_FLOAT );
100 var_Create( p_input, "position-offset", VLC_VAR_FLOAT );
102 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
103 var_AddCallback( p_input, "position", PositionCallback, NULL );
104 var_AddCallback( p_input, "position-offset", PositionCallback, NULL );
107 var_Create( p_input, "time", VLC_VAR_TIME );
108 var_Create( p_input, "time-offset", VLC_VAR_TIME ); /* relative */
110 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
111 var_AddCallback( p_input, "time", TimeCallback, NULL );
112 var_AddCallback( p_input, "time-offset", TimeCallback, NULL );
116 var_Create( p_input, "bookmark", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
118 val.psz_string = _("Bookmark");
119 var_Change( p_input, "bookmark", VLC_VAR_SETTEXT, &val, NULL );
120 var_AddCallback( p_input, "bookmark", BookmarkCallback, NULL );
124 var_Create( p_input, "program", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
126 var_Get( p_input, "program", &val );
128 var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
129 text.psz_string = _("Program");
130 var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL );
131 var_AddCallback( p_input, "program", ProgramCallback, NULL );
134 var_Create( p_input, "programs", VLC_VAR_LIST | VLC_VAR_DOINHERIT );
135 text.psz_string = _("Programs");
136 var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL );
139 var_Create( p_input, "title", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
140 text.psz_string = _("Title");
141 var_Change( p_input, "title", VLC_VAR_SETTEXT, &text, NULL );
142 var_AddCallback( p_input, "title", TitleCallback, NULL );
145 var_Create( p_input, "chapter", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
146 text.psz_string = _("Chapter");
147 var_Change( p_input, "chapter", VLC_VAR_SETTEXT, &text, NULL );
148 var_AddCallback( p_input, "chapter", SeekpointCallback, NULL );
150 /* Navigation The callback is added after */
151 var_Create( p_input, "navigation", VLC_VAR_VARIABLE | VLC_VAR_HASCHOICE );
152 text.psz_string = _("Navigation");
153 var_Change( p_input, "navigation", VLC_VAR_SETTEXT, &text, NULL );
156 var_Create( p_input, "audio-delay", VLC_VAR_TIME );
158 var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
159 var_AddCallback( p_input, "audio-delay", EsDelayCallback, NULL );
160 var_Create( p_input, "spu-delay", VLC_VAR_TIME );
162 var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
163 var_AddCallback( p_input, "spu-delay", EsDelayCallback, NULL );
167 var_Create( p_input, "video-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
168 text.psz_string = _("Video Track");
169 var_Change( p_input, "video-es", VLC_VAR_SETTEXT, &text, NULL );
170 var_AddCallback( p_input, "video-es", ESCallback, NULL );
173 var_Create( p_input, "audio-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
174 text.psz_string = _("Audio Track");
175 var_Change( p_input, "audio-es", VLC_VAR_SETTEXT, &text, NULL );
176 var_AddCallback( p_input, "audio-es", ESCallback, NULL );
179 var_Create( p_input, "spu-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
180 text.psz_string = _("Subtitles Track");
181 var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL );
182 var_AddCallback( p_input, "spu-es", ESCallback, NULL );
185 /* Special read only objects variables for intf */
186 var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
188 var_Create( p_input, "length", VLC_VAR_TIME );
190 var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
194 /* Special "intf-change" variable, it allows intf to set up a callback
195 * to be notified of some changes.
196 * TODO list all changes warn by this callbacks */
197 var_Create( p_input, "intf-change", VLC_VAR_BOOL );
198 var_SetBool( p_input, "intf-change", VLC_TRUE );
201 /*****************************************************************************
202 * input_ControlVarClean:
203 *****************************************************************************/
204 void input_ControlVarClean( input_thread_t *p_input )
206 var_Destroy( p_input, "state" );
207 var_Destroy( p_input, "rate" );
208 var_Destroy( p_input, "rate-slower" );
209 var_Destroy( p_input, "rate-faster" );
210 var_Destroy( p_input, "position" );
211 var_Destroy( p_input, "position-offset" );
212 var_Destroy( p_input, "time" );
213 var_Destroy( p_input, "time-offset" );
215 var_Destroy( p_input, "audio-delay" );
216 var_Destroy( p_input, "spu-delay" );
218 var_Destroy( p_input, "bookmark" );
220 var_Destroy( p_input, "program" );
221 if( p_input->i_title > 1 )
223 /* TODO Destroy sub navigation var ? */
225 var_Destroy( p_input, "next-title" );
226 var_Destroy( p_input, "prev-title" );
228 if( p_input->i_title > 0 )
230 /* FIXME title > 0 doesn't mean current title has more than 1 seekpoint */
231 var_Destroy( p_input, "next-chapter" );
232 var_Destroy( p_input, "prev-chapter" );
234 var_Destroy( p_input, "title" );
235 var_Destroy( p_input, "chapter" );
236 var_Destroy( p_input, "navigation" );
238 var_Destroy( p_input, "video-es" );
239 var_Destroy( p_input, "audio-es" );
240 var_Destroy( p_input, "spu-es" );
242 var_Destroy( p_input, "bookmarks" );
243 var_Destroy( p_input, "length" );
245 var_Destroy( p_input, "intf-change" );
248 /*****************************************************************************
249 * input_ControlVarNavigation:
250 * Create all remaining control object variables
251 *****************************************************************************/
252 void input_ControlVarNavigation( input_thread_t *p_input )
254 vlc_value_t val, text;
257 /* Create more command variables */
258 if( p_input->i_title > 1 )
260 var_Create( p_input, "next-title", VLC_VAR_VOID );
261 text.psz_string = _("Next title");
262 var_Change( p_input, "next-title", VLC_VAR_SETTEXT, &text, NULL );
263 var_AddCallback( p_input, "next-title", TitleCallback, NULL );
265 var_Create( p_input, "prev-title", VLC_VAR_VOID );
266 text.psz_string = _("Previous title");
267 var_Change( p_input, "prev-title", VLC_VAR_SETTEXT, &text, NULL );
268 var_AddCallback( p_input, "prev-title", TitleCallback, NULL );
271 /* Create title and navigation */
272 val.psz_string = malloc( sizeof("title ") + 5 );
273 for( i = 0; i < p_input->i_title; i++ )
275 vlc_value_t val2, text, text2;
278 /* Add Navigation entries */
279 sprintf( val.psz_string, "title %2i", i );
280 var_Destroy( p_input, val.psz_string );
281 var_Create( p_input, val.psz_string,
282 VLC_VAR_INTEGER|VLC_VAR_HASCHOICE|VLC_VAR_ISCOMMAND );
283 var_AddCallback( p_input, val.psz_string,
284 NavigationCallback, (void *)i );
286 if( p_input->title[i]->psz_name == NULL ||
287 *p_input->title[i]->psz_name == '\0' )
289 asprintf( &text.psz_string, _("Title %i"),
290 i + p_input->i_title_offset );
294 text.psz_string = strdup( p_input->title[i]->psz_name );
296 var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val, &text );
298 /* Add title choice */
300 var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val2, &text );
302 free( text.psz_string );
304 for( j = 0; j < p_input->title[i]->i_seekpoint; j++ )
308 if( p_input->title[i]->seekpoint[j]->psz_name == NULL ||
309 *p_input->title[i]->seekpoint[j]->psz_name == '\0' )
312 asprintf( &text2.psz_string, _("Chapter %i"),
313 j + p_input->i_seekpoint_offset );
318 strdup( p_input->title[i]->seekpoint[j]->psz_name );
321 var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE,
323 if( text2.psz_string ) free( text2.psz_string );
327 free( val.psz_string );
330 /*****************************************************************************
331 * input_ControlVarTitle:
332 * Create all variables for a title
333 *****************************************************************************/
334 void input_ControlVarTitle( input_thread_t *p_input, int i_title )
336 input_title_t *t = p_input->title[i_title];
340 /* Create/Destroy command variables */
341 if( t->i_seekpoint <= 1 )
343 var_Destroy( p_input, "next-chapter" );
344 var_Destroy( p_input, "prev-chapter" );
346 else if( var_Get( p_input, "next-chapter", &val ) != VLC_SUCCESS )
350 var_Create( p_input, "next-chapter", VLC_VAR_VOID );
351 text.psz_string = _("Next chapter");
352 var_Change( p_input, "next-chapter", VLC_VAR_SETTEXT, &text, NULL );
353 var_AddCallback( p_input, "next-chapter", SeekpointCallback, NULL );
355 var_Create( p_input, "prev-chapter", VLC_VAR_VOID );
356 text.psz_string = _("Previous chapter");
357 var_Change( p_input, "prev-chapter", VLC_VAR_SETTEXT, &text, NULL );
358 var_AddCallback( p_input, "prev-chapter", SeekpointCallback, NULL );
361 /* Build chapter list */
362 var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL );
363 for( i = 0; i < t->i_seekpoint; i++ )
368 if( t->seekpoint[i]->psz_name == NULL ||
369 *t->seekpoint[i]->psz_name == '\0' )
372 asprintf( &text.psz_string, _("Chapter %i"),
373 i + p_input->i_seekpoint_offset );
377 text.psz_string = strdup( t->seekpoint[i]->psz_name );
380 var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, &text );
381 if( text.psz_string ) free( text.psz_string );
386 /*****************************************************************************
387 * input_ConfigVarInit:
388 * Create all config object variables
389 *****************************************************************************/
390 void input_ConfigVarInit ( input_thread_t *p_input )
394 /* Create Object Variables for private use only */
395 var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
396 var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
398 var_Create( p_input, "audio-channel", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
399 var_Create( p_input, "spu-channel", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
401 var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT );
402 var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
404 var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING |
406 var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER |
409 var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
410 var_Create( p_input, "sout-all", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
411 var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
412 var_Create( p_input, "sout-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
413 var_Create( p_input, "sout-keep", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
415 var_Create( p_input, "input-repeat", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
417 var_Create( p_input, "start-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
418 var_Create( p_input, "stop-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
420 var_Create( p_input, "minimize-threads", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
422 var_Create( p_input, "demuxed-id3", VLC_VAR_BOOL ); /* FIXME beurk */
423 val.b_bool = VLC_FALSE;
424 var_Change( p_input, "demuxed-id3", VLC_VAR_SETVALUE, &val, NULL );
426 var_Create( p_input, "audio-desync", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
428 var_Create( p_input, "cr-average", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
430 var_Create( p_input, "seekable", VLC_VAR_BOOL );
431 val.b_bool = VLC_TRUE; /* Fixed later*/
432 var_Change( p_input, "seekable", VLC_VAR_SETVALUE, &val, NULL );
434 var_Create( p_input, "input-slave", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
437 var_Create( p_input, "meta-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
438 var_Create( p_input, "meta-author", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
439 var_Create( p_input, "meta-artist", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
440 var_Create( p_input, "meta-genre", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
441 var_Create( p_input, "meta-copyright", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
442 var_Create( p_input, "meta-description", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
443 var_Create( p_input, "meta-date", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
444 var_Create( p_input, "meta-url", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
447 /*****************************************************************************
449 *****************************************************************************/
450 static int StateCallback( vlc_object_t *p_this, char const *psz_cmd,
451 vlc_value_t oldval, vlc_value_t newval,
454 input_thread_t *p_input = (input_thread_t*)p_this;
457 if( newval.i_int == PLAYING_S || newval.i_int == PAUSE_S )
459 input_ControlPush( p_input, INPUT_CONTROL_SET_STATE, &newval );
465 static int RateCallback( vlc_object_t *p_this, char const *psz_cmd,
466 vlc_value_t oldval, vlc_value_t newval, void *p_data )
468 input_thread_t *p_input = (input_thread_t*)p_this;
472 /* Problem with this way: the "rate" variable is update after the input thread do the change */
473 if( !strcmp( psz_cmd, "rate-slower" ) )
475 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_SLOWER, NULL );
477 /* Fix "rate" value */
478 i_rate = var_GetInteger( p_input, "rate" ) * 2;
479 if( i_rate < INPUT_RATE_MIN ) i_rate = INPUT_RATE_MIN;
481 var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
483 else if( !strcmp( psz_cmd, "rate-faster" ) )
485 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_FASTER, NULL );
486 i_rate = var_GetInteger( p_input, "rate" ) / 2;
488 if( i_rate > INPUT_RATE_MAX ) i_rate = INPUT_RATE_MAX;
490 var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
494 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
500 static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
501 vlc_value_t oldval, vlc_value_t newval,
504 input_thread_t *p_input = (input_thread_t*)p_this;
505 vlc_value_t val, length;
507 if( !strcmp( psz_cmd, "position-offset" ) )
509 input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION_OFFSET, &newval );
511 val.f_float = var_GetFloat( p_input, "position" ) + newval.f_float;
512 if( val.f_float < 0.0 ) val.f_float = 0.0;
513 if( val.f_float > 1.0 ) val.f_float = 1.0;
514 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
518 val.f_float = newval.f_float;
519 input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &newval );
522 /* Update "position" for better intf behavour */
523 var_Get( p_input, "length", &length );
524 if( length.i_time > 0 && val.f_float >= 0.0 && val.f_float <= 1.0 )
526 val.i_time = length.i_time * val.f_float;
527 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
534 static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd,
535 vlc_value_t oldval, vlc_value_t newval, void *p_data )
537 input_thread_t *p_input = (input_thread_t*)p_this;
538 vlc_value_t val, length;
540 if( !strcmp( psz_cmd, "time-offset" ) )
542 input_ControlPush( p_input, INPUT_CONTROL_SET_TIME_OFFSET, &newval );
544 val.i_time = var_GetTime( p_input, "time" ) + newval.i_time;
545 if( val.i_time < 0 ) val.i_time = 0;
546 /* TODO maybe test against i_length ? */
547 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
551 val.i_time = newval.i_time;
552 input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval );
555 /* Update "position" for better intf behavour */
556 var_Get( p_input, "length", &length );
557 if( length.i_time > 0 && val.i_time >= 0 && val.i_time <= length.i_time )
559 val.f_float = (double)val.i_time/(double)length.i_time;
560 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
566 static int ProgramCallback( vlc_object_t *p_this, char const *psz_cmd,
567 vlc_value_t oldval, vlc_value_t newval,
570 input_thread_t *p_input = (input_thread_t*)p_this;
572 input_ControlPush( p_input, INPUT_CONTROL_SET_PROGRAM, &newval );
577 static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
578 vlc_value_t oldval, vlc_value_t newval,
581 input_thread_t *p_input = (input_thread_t*)p_this;
582 vlc_value_t val, count;
584 if( !strcmp( psz_cmd, "next-title" ) )
586 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_NEXT, NULL );
588 val.i_int = var_GetInteger( p_input, "title" ) + 1;
589 var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &count, NULL );
590 if( val.i_int < count.i_int )
591 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
593 else if( !strcmp( psz_cmd, "prev-title" ) )
595 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_PREV, NULL );
597 val.i_int = var_GetInteger( p_input, "title" ) - 1;
599 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
603 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &newval );
609 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
610 vlc_value_t oldval, vlc_value_t newval,
613 input_thread_t *p_input = (input_thread_t*)p_this;
614 vlc_value_t val, count;
616 if( !strcmp( psz_cmd, "next-chapter" ) )
618 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_NEXT, NULL );
620 val.i_int = var_GetInteger( p_input, "chapter" ) + 1;
621 var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &count, NULL );
622 if( val.i_int < count.i_int )
623 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
625 else if( !strcmp( psz_cmd, "prev-chapter" ) )
627 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_PREV, NULL );
629 val.i_int = var_GetInteger( p_input, "chapter" ) - 1;
631 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
635 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
641 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
642 vlc_value_t oldval, vlc_value_t newval,
645 input_thread_t *p_input = (input_thread_t*)p_this;
648 /* Issue a title change */
649 val.i_int = (int)p_data;
650 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &val );
652 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
654 /* And a chapter change */
655 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
657 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &newval, NULL );
662 static int ESCallback( vlc_object_t *p_this, char const *psz_cmd,
663 vlc_value_t oldval, vlc_value_t newval, void *p_data )
665 input_thread_t *p_input = (input_thread_t*)p_this;
667 if( newval.i_int < 0 )
671 if( !strcmp( psz_cmd, "audio-es" ) )
673 else if( !strcmp( psz_cmd, "video-es" ) )
675 else if( !strcmp( psz_cmd, "spu-es" ) )
680 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &v );
684 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &newval );
690 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
691 vlc_value_t oldval, vlc_value_t newval, void *p )
693 input_thread_t *p_input = (input_thread_t*)p_this;
695 if( !strcmp( psz_cmd, "audio-delay" ) )
696 input_ControlPush( p_input, INPUT_CONTROL_SET_AUDIO_DELAY, &newval );
697 else if( !strcmp( psz_cmd, "spu-delay" ) )
698 input_ControlPush( p_input, INPUT_CONTROL_SET_SPU_DELAY, &newval );
702 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
703 vlc_value_t oldval, vlc_value_t newval,
706 input_thread_t *p_input = (input_thread_t*)p_this;
708 input_ControlPush( p_input, INPUT_CONTROL_SET_BOOKMARK, &newval );