1 /*****************************************************************************
2 * var.c: object variables for input thread
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
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 );
43 /*****************************************************************************
45 *****************************************************************************/
46 static int StateCallback ( vlc_object_t *p_this, char const *psz_cmd,
47 vlc_value_t oldval, vlc_value_t newval, void * );
48 static int RateCallback ( vlc_object_t *p_this, char const *psz_cmd,
49 vlc_value_t oldval, vlc_value_t newval, void * );
50 static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
51 vlc_value_t oldval, vlc_value_t newval, void * );
52 static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd,
53 vlc_value_t oldval, vlc_value_t newval, void * );
54 static int ProgramCallback ( vlc_object_t *p_this, char const *psz_cmd,
55 vlc_value_t oldval, vlc_value_t newval, void * );
56 static int TitleCallback ( vlc_object_t *p_this, char const *psz_cmd,
57 vlc_value_t oldval, vlc_value_t newval, void * );
58 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
59 vlc_value_t oldval, vlc_value_t newval, void * );
60 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
61 vlc_value_t oldval, vlc_value_t newval, void * );
62 static int ESCallback ( vlc_object_t *p_this, char const *psz_cmd,
63 vlc_value_t oldval, vlc_value_t newval, void * );
64 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
65 vlc_value_t oldval, vlc_value_t newval, void * );
67 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
68 vlc_value_t oldval, vlc_value_t newval, void * );
70 /*****************************************************************************
71 * input_ControlVarInit:
72 * Create all control object variables with their callbacks
73 *****************************************************************************/
74 void input_ControlVarInit ( input_thread_t *p_input )
76 vlc_value_t val, text;
78 /* XXX we put callback only in non preparsing mode. We need to create the variable
79 * unless someone want to check all var_Get/var_Change return value ... */
80 #define ADD_CALLBACK( name, callback ) do { if( !p_input->b_preparsing ) { var_AddCallback( p_input, name, callback, NULL ); } } while(0)
82 var_Create( p_input, "state", VLC_VAR_INTEGER );
83 val.i_int = p_input->i_state;
84 var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
85 ADD_CALLBACK( "state", StateCallback );
88 var_Create( p_input, "rate", VLC_VAR_INTEGER );
89 val.i_int = p_input->p->i_rate;
90 var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
91 ADD_CALLBACK( "rate", RateCallback );
93 var_Create( p_input, "rate-slower", VLC_VAR_VOID );
94 ADD_CALLBACK( "rate-slower", RateCallback );
96 var_Create( p_input, "rate-faster", VLC_VAR_VOID );
97 ADD_CALLBACK( "rate-faster", RateCallback );
100 var_Create( p_input, "position", VLC_VAR_FLOAT );
101 var_Create( p_input, "position-offset", VLC_VAR_FLOAT );
103 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
104 ADD_CALLBACK( "position", PositionCallback );
105 ADD_CALLBACK( "position-offset", PositionCallback );
108 var_Create( p_input, "time", VLC_VAR_TIME );
109 var_Create( p_input, "time-offset", VLC_VAR_TIME ); /* relative */
111 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
112 ADD_CALLBACK( "time", TimeCallback );
113 ADD_CALLBACK( "time-offset", TimeCallback );
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 ADD_CALLBACK( "bookmark", BookmarkCallback );
123 var_Create( p_input, "program", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
125 var_Get( p_input, "program", &val );
127 var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
128 text.psz_string = _("Program");
129 var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL );
130 ADD_CALLBACK( "program", ProgramCallback );
133 var_Create( p_input, "programs", VLC_VAR_LIST | VLC_VAR_DOINHERIT );
134 text.psz_string = _("Programs");
135 var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL );
138 var_Create( p_input, "title", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
139 text.psz_string = _("Title");
140 var_Change( p_input, "title", VLC_VAR_SETTEXT, &text, NULL );
141 ADD_CALLBACK( "title", TitleCallback );
144 var_Create( p_input, "chapter", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
145 text.psz_string = _("Chapter");
146 var_Change( p_input, "chapter", VLC_VAR_SETTEXT, &text, NULL );
147 ADD_CALLBACK( "chapter", SeekpointCallback );
149 /* Navigation The callback is added after */
150 var_Create( p_input, "navigation", VLC_VAR_VARIABLE | VLC_VAR_HASCHOICE );
151 text.psz_string = _("Navigation");
152 var_Change( p_input, "navigation", VLC_VAR_SETTEXT, &text, NULL );
155 var_Create( p_input, "audio-delay", VLC_VAR_TIME );
157 var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
158 ADD_CALLBACK( "audio-delay", EsDelayCallback );
159 var_Create( p_input, "spu-delay", VLC_VAR_TIME );
161 var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
162 ADD_CALLBACK( "spu-delay", EsDelayCallback );
165 var_Create( p_input, "video-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
166 text.psz_string = _("Video Track");
167 var_Change( p_input, "video-es", VLC_VAR_SETTEXT, &text, NULL );
168 ADD_CALLBACK( "video-es", ESCallback );
171 var_Create( p_input, "audio-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
172 text.psz_string = _("Audio Track");
173 var_Change( p_input, "audio-es", VLC_VAR_SETTEXT, &text, NULL );
174 ADD_CALLBACK( "audio-es", ESCallback );
177 var_Create( p_input, "spu-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
178 text.psz_string = _("Subtitles Track");
179 var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL );
180 ADD_CALLBACK( "spu-es", ESCallback );
182 /* Special read only objects variables for intf */
183 var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
185 var_Create( p_input, "length", VLC_VAR_TIME );
187 var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
189 if( !p_input->b_preparsing )
191 /* Special "intf-change" variable, it allows intf to set up a callback
192 * to be notified of some changes.
193 * TODO list all changes warn by this callbacks */
194 var_Create( p_input, "intf-change", VLC_VAR_BOOL );
195 var_SetBool( p_input, "intf-change", VLC_TRUE );
197 /* item-change variable */
198 var_Create( p_input, "item-change", VLC_VAR_INTEGER );
203 /*****************************************************************************
204 * input_ControlVarClean:
205 *****************************************************************************/
206 void input_ControlVarClean( input_thread_t *p_input )
208 var_Destroy( p_input, "state" );
209 var_Destroy( p_input, "rate" );
210 var_Destroy( p_input, "rate-slower" );
211 var_Destroy( p_input, "rate-faster" );
212 var_Destroy( p_input, "position" );
213 var_Destroy( p_input, "position-offset" );
214 var_Destroy( p_input, "time" );
215 var_Destroy( p_input, "time-offset" );
217 var_Destroy( p_input, "audio-delay" );
218 var_Destroy( p_input, "spu-delay" );
220 var_Destroy( p_input, "bookmark" );
222 var_Destroy( p_input, "program" );
223 if( p_input->p->i_title > 1 )
225 /* TODO Destroy sub navigation var ? */
227 var_Destroy( p_input, "next-title" );
228 var_Destroy( p_input, "prev-title" );
230 if( p_input->p->i_title > 0 )
232 /* FIXME title > 0 doesn't mean current title has more than 1 seekpoint */
233 var_Destroy( p_input, "next-chapter" );
234 var_Destroy( p_input, "prev-chapter" );
236 var_Destroy( p_input, "title" );
237 var_Destroy( p_input, "chapter" );
238 var_Destroy( p_input, "navigation" );
240 var_Destroy( p_input, "video-es" );
241 var_Destroy( p_input, "audio-es" );
242 var_Destroy( p_input, "spu-es" );
244 var_Destroy( p_input, "bookmarks" );
245 var_Destroy( p_input, "length" );
247 var_Destroy( p_input, "intf-change" );
250 /*****************************************************************************
251 * input_ControlVarNavigation:
252 * Create all remaining control object variables
253 *****************************************************************************/
254 void input_ControlVarNavigation( input_thread_t *p_input )
256 vlc_value_t val, text;
259 /* Create more command variables */
260 if( p_input->p->i_title > 1 )
262 var_Create( p_input, "next-title", VLC_VAR_VOID );
263 text.psz_string = _("Next title");
264 var_Change( p_input, "next-title", VLC_VAR_SETTEXT, &text, NULL );
265 var_AddCallback( p_input, "next-title", TitleCallback, NULL );
267 var_Create( p_input, "prev-title", VLC_VAR_VOID );
268 text.psz_string = _("Previous title");
269 var_Change( p_input, "prev-title", VLC_VAR_SETTEXT, &text, NULL );
270 var_AddCallback( p_input, "prev-title", TitleCallback, NULL );
273 /* Create title and navigation */
274 val.psz_string = malloc( sizeof("title ") + 5 );
275 for( i = 0; i < p_input->p->i_title; i++ )
277 vlc_value_t val2, text, text2;
280 /* Add Navigation entries */
281 sprintf( val.psz_string, "title %2i", i );
282 var_Destroy( p_input, val.psz_string );
283 var_Create( p_input, val.psz_string,
284 VLC_VAR_INTEGER|VLC_VAR_HASCHOICE|VLC_VAR_ISCOMMAND );
285 var_AddCallback( p_input, val.psz_string,
286 NavigationCallback, (void *)i );
288 if( p_input->p->title[i]->psz_name == NULL ||
289 *p_input->p->title[i]->psz_name == '\0' )
291 asprintf( &text.psz_string, _("Title %i"),
292 i + p_input->p->i_title_offset );
296 text.psz_string = strdup( p_input->p->title[i]->psz_name );
298 var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val, &text );
300 /* Add title choice */
302 var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val2, &text );
304 free( text.psz_string );
306 for( j = 0; j < p_input->p->title[i]->i_seekpoint; j++ )
310 if( p_input->p->title[i]->seekpoint[j]->psz_name == NULL ||
311 *p_input->p->title[i]->seekpoint[j]->psz_name == '\0' )
314 asprintf( &text2.psz_string, _("Chapter %i"),
315 j + p_input->p->i_seekpoint_offset );
320 strdup( p_input->p->title[i]->seekpoint[j]->psz_name );
323 var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE,
325 if( text2.psz_string ) free( text2.psz_string );
329 free( val.psz_string );
332 /*****************************************************************************
333 * input_ControlVarTitle:
334 * Create all variables for a title
335 *****************************************************************************/
336 void input_ControlVarTitle( input_thread_t *p_input, int i_title )
338 input_title_t *t = p_input->p->title[i_title];
342 /* Create/Destroy command variables */
343 if( t->i_seekpoint <= 1 )
345 var_Destroy( p_input, "next-chapter" );
346 var_Destroy( p_input, "prev-chapter" );
348 else if( var_Get( p_input, "next-chapter", &val ) != VLC_SUCCESS )
352 var_Create( p_input, "next-chapter", VLC_VAR_VOID );
353 text.psz_string = _("Next chapter");
354 var_Change( p_input, "next-chapter", VLC_VAR_SETTEXT, &text, NULL );
355 var_AddCallback( p_input, "next-chapter", SeekpointCallback, NULL );
357 var_Create( p_input, "prev-chapter", VLC_VAR_VOID );
358 text.psz_string = _("Previous chapter");
359 var_Change( p_input, "prev-chapter", VLC_VAR_SETTEXT, &text, NULL );
360 var_AddCallback( p_input, "prev-chapter", SeekpointCallback, NULL );
363 /* Build chapter list */
364 var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL );
365 for( i = 0; i < t->i_seekpoint; i++ )
370 if( t->seekpoint[i]->psz_name == NULL ||
371 *t->seekpoint[i]->psz_name == '\0' )
374 asprintf( &text.psz_string, _("Chapter %i"),
375 i + p_input->p->i_seekpoint_offset );
379 text.psz_string = strdup( t->seekpoint[i]->psz_name );
382 var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, &text );
383 if( text.psz_string ) free( text.psz_string );
387 /*****************************************************************************
388 * input_ConfigVarInit:
389 * Create all config object variables
390 *****************************************************************************/
391 void input_ConfigVarInit ( input_thread_t *p_input )
395 /* Create Object Variables for private use only */
397 if( !p_input->b_preparsing )
399 var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
400 var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
401 var_Create( p_input, "spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
403 var_Create( p_input, "audio-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
404 var_Create( p_input, "sub-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
406 var_Create( p_input, "audio-language",
407 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
408 var_Create( p_input, "sub-language",
409 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
411 var_Create( p_input, "audio-track-id",
412 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
413 var_Create( p_input, "sub-track-id",
414 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
416 var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT );
417 var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
419 var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING |
421 var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER |
424 var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
425 var_Create( p_input, "sout-all", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
426 var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
427 var_Create( p_input, "sout-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
428 var_Create( p_input, "sout-spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
429 var_Create( p_input, "sout-keep", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
431 var_Create( p_input, "input-repeat",
432 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
433 var_Create( p_input, "start-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
434 var_Create( p_input, "stop-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
436 var_Create( p_input, "input-slave",
437 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
439 var_Create( p_input, "minimize-threads",
440 VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
442 var_Create( p_input, "audio-desync",
443 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
444 var_Create( p_input, "cr-average",
445 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
446 var_Create( p_input, "clock-synchro",
447 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
450 var_Create( p_input, "demuxed-id3", VLC_VAR_BOOL ); /* FIXME beurk */
451 val.b_bool = VLC_FALSE;
452 var_Change( p_input, "demuxed-id3", VLC_VAR_SETVALUE, &val, NULL );
454 var_Create( p_input, "seekable", VLC_VAR_BOOL );
455 val.b_bool = VLC_TRUE; /* Fixed later*/
456 var_Change( p_input, "seekable", VLC_VAR_SETVALUE, &val, NULL );
459 var_Create( p_input, "access-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
460 var_Create( p_input, "access", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
461 var_Create( p_input, "demux", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
464 var_Create( p_input, "meta-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
465 var_Create( p_input, "meta-author", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
466 var_Create( p_input, "meta-artist", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
467 var_Create( p_input, "meta-genre", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
468 var_Create( p_input, "meta-copyright", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
469 var_Create( p_input, "meta-description", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
470 var_Create( p_input, "meta-date", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
471 var_Create( p_input, "meta-url", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
474 /*****************************************************************************
476 *****************************************************************************/
477 static int StateCallback( vlc_object_t *p_this, char const *psz_cmd,
478 vlc_value_t oldval, vlc_value_t newval,
481 input_thread_t *p_input = (input_thread_t*)p_this;
484 if( newval.i_int == PLAYING_S || newval.i_int == PAUSE_S )
486 input_ControlPush( p_input, INPUT_CONTROL_SET_STATE, &newval );
493 static int RateCallback( vlc_object_t *p_this, char const *psz_cmd,
494 vlc_value_t oldval, vlc_value_t newval, void *p_data )
496 input_thread_t *p_input = (input_thread_t*)p_this;
498 /* Problem with this way: the "rate" variable is update after the input thread do the change */
499 if( !strcmp( psz_cmd, "rate-slower" ) )
501 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_SLOWER, NULL );
503 else if( !strcmp( psz_cmd, "rate-faster" ) )
505 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_FASTER, NULL );
509 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
515 static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
516 vlc_value_t oldval, vlc_value_t newval,
519 input_thread_t *p_input = (input_thread_t*)p_this;
520 vlc_value_t val, length;
522 if( !strcmp( psz_cmd, "position-offset" ) )
524 input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION_OFFSET, &newval );
526 val.f_float = var_GetFloat( p_input, "position" ) + newval.f_float;
527 if( val.f_float < 0.0 ) val.f_float = 0.0;
528 if( val.f_float > 1.0 ) val.f_float = 1.0;
529 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
533 val.f_float = newval.f_float;
534 input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &newval );
537 /* Update "position" for better intf behavour */
538 var_Get( p_input, "length", &length );
539 if( length.i_time > 0 && val.f_float >= 0.0 && val.f_float <= 1.0 )
541 val.i_time = length.i_time * val.f_float;
542 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
548 static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd,
549 vlc_value_t oldval, vlc_value_t newval, void *p_data )
551 input_thread_t *p_input = (input_thread_t*)p_this;
552 vlc_value_t val, length;
554 if( !strcmp( psz_cmd, "time-offset" ) )
556 input_ControlPush( p_input, INPUT_CONTROL_SET_TIME_OFFSET, &newval );
557 val.i_time = var_GetTime( p_input, "time" ) + newval.i_time;
558 if( val.i_time < 0 ) val.i_time = 0;
559 /* TODO maybe test against i_length ? */
560 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
564 val.i_time = newval.i_time;
565 input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval );
568 /* Update "position" for better intf behavour */
569 var_Get( p_input, "length", &length );
570 if( length.i_time > 0 && val.i_time >= 0 && val.i_time <= length.i_time )
572 val.f_float = (double)val.i_time/(double)length.i_time;
573 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
579 static int ProgramCallback( vlc_object_t *p_this, char const *psz_cmd,
580 vlc_value_t oldval, vlc_value_t newval,
583 input_thread_t *p_input = (input_thread_t*)p_this;
585 input_ControlPush( p_input, INPUT_CONTROL_SET_PROGRAM, &newval );
590 static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
591 vlc_value_t oldval, vlc_value_t newval,
594 input_thread_t *p_input = (input_thread_t*)p_this;
595 vlc_value_t val, count;
597 if( !strcmp( psz_cmd, "next-title" ) )
599 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_NEXT, NULL );
601 val.i_int = var_GetInteger( p_input, "title" ) + 1;
602 var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &count, NULL );
603 if( val.i_int < count.i_int )
604 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
606 else if( !strcmp( psz_cmd, "prev-title" ) )
608 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_PREV, NULL );
610 val.i_int = var_GetInteger( p_input, "title" ) - 1;
612 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
616 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &newval );
622 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
623 vlc_value_t oldval, vlc_value_t newval,
626 input_thread_t *p_input = (input_thread_t*)p_this;
627 vlc_value_t val, count;
629 if( !strcmp( psz_cmd, "next-chapter" ) )
631 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_NEXT, NULL );
633 val.i_int = var_GetInteger( p_input, "chapter" ) + 1;
634 var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &count, NULL );
635 if( val.i_int < count.i_int )
636 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
638 else if( !strcmp( psz_cmd, "prev-chapter" ) )
640 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_PREV, NULL );
642 val.i_int = var_GetInteger( p_input, "chapter" ) - 1;
644 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
648 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
654 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
655 vlc_value_t oldval, vlc_value_t newval,
658 input_thread_t *p_input = (input_thread_t*)p_this;
661 /* Issue a title change */
662 val.i_int = (int)p_data;
663 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &val );
665 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
667 /* And a chapter change */
668 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
670 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &newval, NULL );
675 static int ESCallback( vlc_object_t *p_this, char const *psz_cmd,
676 vlc_value_t oldval, vlc_value_t newval, void *p_data )
678 input_thread_t *p_input = (input_thread_t*)p_this;
680 if( newval.i_int < 0 )
684 if( !strcmp( psz_cmd, "audio-es" ) )
686 else if( !strcmp( psz_cmd, "video-es" ) )
688 else if( !strcmp( psz_cmd, "spu-es" ) )
693 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &v );
697 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &newval );
703 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
704 vlc_value_t oldval, vlc_value_t newval, void *p )
706 input_thread_t *p_input = (input_thread_t*)p_this;
709 if( !strcmp( psz_cmd, "audio-delay" ) )
711 /*Change i_pts_delay to make sure es are decoded in time*/
712 if (newval.i_int < 0 || oldval.i_int < 0 )
714 p_input->i_pts_delay -= newval.i_int - oldval.i_int;
716 input_ControlPush( p_input, INPUT_CONTROL_SET_AUDIO_DELAY, &newval );
718 else if( !strcmp( psz_cmd, "spu-delay" ) )
719 input_ControlPush( p_input, INPUT_CONTROL_SET_SPU_DELAY, &newval );
723 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
724 vlc_value_t oldval, vlc_value_t newval,
727 input_thread_t *p_input = (input_thread_t*)p_this;
729 input_ControlPush( p_input, INPUT_CONTROL_SET_BOOKMARK, &newval );