1 /*****************************************************************************
2 * var.c: object variables for input thread
3 *****************************************************************************
4 * Copyright (C) 2004-2007 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 *****************************************************************************/
35 #include "input_internal.h"
37 /*****************************************************************************
39 *****************************************************************************/
40 void input_ControlVarInit ( input_thread_t * );
41 void input_ControlVarClean( input_thread_t * );
42 void input_ControlVarNavigation( input_thread_t * );
43 void input_ControlVarTitle( input_thread_t *p_input, int i_title );
45 void input_ConfigVarInit ( input_thread_t *p_input );
47 /*****************************************************************************
49 *****************************************************************************/
50 static int StateCallback ( vlc_object_t *p_this, char const *psz_cmd,
51 vlc_value_t oldval, vlc_value_t newval, void * );
52 static int RateCallback ( vlc_object_t *p_this, char const *psz_cmd,
53 vlc_value_t oldval, vlc_value_t newval, void * );
54 static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
55 vlc_value_t oldval, vlc_value_t newval, void * );
56 static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd,
57 vlc_value_t oldval, vlc_value_t newval, void * );
58 static int ProgramCallback ( vlc_object_t *p_this, char const *psz_cmd,
59 vlc_value_t oldval, vlc_value_t newval, void * );
60 static int TitleCallback ( vlc_object_t *p_this, char const *psz_cmd,
61 vlc_value_t oldval, vlc_value_t newval, void * );
62 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
63 vlc_value_t oldval, vlc_value_t newval, void * );
64 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
65 vlc_value_t oldval, vlc_value_t newval, void * );
66 static int ESCallback ( vlc_object_t *p_this, char const *psz_cmd,
67 vlc_value_t oldval, vlc_value_t newval, void * );
68 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
69 vlc_value_t oldval, vlc_value_t newval, void * );
71 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
72 vlc_value_t oldval, vlc_value_t newval, void * );
74 /*****************************************************************************
75 * input_ControlVarInit:
76 * Create all control object variables with their callbacks
77 *****************************************************************************/
78 void input_ControlVarInit ( input_thread_t *p_input )
80 vlc_value_t val, text;
82 /* XXX we put callback only in non preparsing mode. We need to create the variable
83 * unless someone want to check all var_Get/var_Change return value ... */
84 #define ADD_CALLBACK( name, callback ) do { if( !p_input->b_preparsing ) { var_AddCallback( p_input, name, callback, NULL ); } } while(0)
86 var_Create( p_input, "state", VLC_VAR_INTEGER );
87 val.i_int = p_input->i_state;
88 var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
89 ADD_CALLBACK( "state", StateCallback );
92 var_Create( p_input, "rate", VLC_VAR_INTEGER );
93 val.i_int = p_input->p->i_rate;
94 var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
95 ADD_CALLBACK( "rate", RateCallback );
97 var_Create( p_input, "rate-slower", VLC_VAR_VOID );
98 ADD_CALLBACK( "rate-slower", RateCallback );
100 var_Create( p_input, "rate-faster", VLC_VAR_VOID );
101 ADD_CALLBACK( "rate-faster", RateCallback );
104 var_Create( p_input, "position", VLC_VAR_FLOAT );
105 var_Create( p_input, "position-offset", VLC_VAR_FLOAT );
107 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
108 ADD_CALLBACK( "position", PositionCallback );
109 ADD_CALLBACK( "position-offset", PositionCallback );
112 var_Create( p_input, "time", VLC_VAR_TIME );
113 var_Create( p_input, "time-offset", VLC_VAR_TIME ); /* relative */
115 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
116 ADD_CALLBACK( "time", TimeCallback );
117 ADD_CALLBACK( "time-offset", TimeCallback );
120 var_Create( p_input, "bookmark", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
122 val.psz_string = _("Bookmark");
123 var_Change( p_input, "bookmark", VLC_VAR_SETTEXT, &val, NULL );
124 ADD_CALLBACK( "bookmark", BookmarkCallback );
127 var_Create( p_input, "program", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
129 var_Get( p_input, "program", &val );
131 var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
132 text.psz_string = _("Program");
133 var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL );
134 ADD_CALLBACK( "program", ProgramCallback );
137 var_Create( p_input, "programs", VLC_VAR_LIST | VLC_VAR_DOINHERIT );
138 text.psz_string = _("Programs");
139 var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL );
142 var_Create( p_input, "title", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
143 text.psz_string = _("Title");
144 var_Change( p_input, "title", VLC_VAR_SETTEXT, &text, NULL );
145 ADD_CALLBACK( "title", TitleCallback );
148 var_Create( p_input, "chapter", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
149 text.psz_string = _("Chapter");
150 var_Change( p_input, "chapter", VLC_VAR_SETTEXT, &text, NULL );
151 ADD_CALLBACK( "chapter", SeekpointCallback );
153 /* Navigation The callback is added after */
154 var_Create( p_input, "navigation", VLC_VAR_VARIABLE | VLC_VAR_HASCHOICE );
155 text.psz_string = _("Navigation");
156 var_Change( p_input, "navigation", VLC_VAR_SETTEXT, &text, NULL );
159 var_Create( p_input, "audio-delay", VLC_VAR_TIME );
161 var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
162 ADD_CALLBACK( "audio-delay", EsDelayCallback );
163 var_Create( p_input, "spu-delay", VLC_VAR_TIME );
165 var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
166 ADD_CALLBACK( "spu-delay", EsDelayCallback );
169 var_Create( p_input, "video-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
170 text.psz_string = _("Video Track");
171 var_Change( p_input, "video-es", VLC_VAR_SETTEXT, &text, NULL );
172 ADD_CALLBACK( "video-es", ESCallback );
175 var_Create( p_input, "audio-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
176 text.psz_string = _("Audio Track");
177 var_Change( p_input, "audio-es", VLC_VAR_SETTEXT, &text, NULL );
178 ADD_CALLBACK( "audio-es", ESCallback );
181 var_Create( p_input, "spu-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
182 text.psz_string = _("Subtitles Track");
183 var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL );
184 ADD_CALLBACK( "spu-es", ESCallback );
186 /* Special read only objects variables for intf */
187 var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
189 var_Create( p_input, "length", VLC_VAR_TIME );
191 var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
193 if( !p_input->b_preparsing )
195 /* Special "intf-change" variable, it allows intf to set up a callback
196 * to be notified of some changes.
197 * TODO list all changes warn by this callbacks */
198 var_Create( p_input, "intf-change", VLC_VAR_BOOL );
199 var_SetBool( p_input, "intf-change", VLC_TRUE );
204 /*****************************************************************************
205 * input_ControlVarClean:
206 *****************************************************************************/
207 void input_ControlVarClean( input_thread_t *p_input )
209 var_Destroy( p_input, "state" );
210 var_Destroy( p_input, "rate" );
211 var_Destroy( p_input, "rate-slower" );
212 var_Destroy( p_input, "rate-faster" );
213 var_Destroy( p_input, "position" );
214 var_Destroy( p_input, "position-offset" );
215 var_Destroy( p_input, "time" );
216 var_Destroy( p_input, "time-offset" );
218 var_Destroy( p_input, "audio-delay" );
219 var_Destroy( p_input, "spu-delay" );
221 var_Destroy( p_input, "bookmark" );
223 var_Destroy( p_input, "program" );
224 if( p_input->p->i_title > 1 )
226 /* TODO Destroy sub navigation var ? */
228 var_Destroy( p_input, "next-title" );
229 var_Destroy( p_input, "prev-title" );
231 if( p_input->p->i_title > 0 )
233 /* FIXME title > 0 doesn't mean current title has more than 1 seekpoint */
234 var_Destroy( p_input, "next-chapter" );
235 var_Destroy( p_input, "prev-chapter" );
237 var_Destroy( p_input, "title" );
238 var_Destroy( p_input, "chapter" );
239 var_Destroy( p_input, "navigation" );
241 var_Destroy( p_input, "video-es" );
242 var_Destroy( p_input, "audio-es" );
243 var_Destroy( p_input, "spu-es" );
245 var_Destroy( p_input, "bookmarks" );
246 var_Destroy( p_input, "length" );
248 var_Destroy( p_input, "intf-change" );
251 /*****************************************************************************
252 * input_ControlVarNavigation:
253 * Create all remaining control object variables
254 *****************************************************************************/
255 void input_ControlVarNavigation( input_thread_t *p_input )
257 vlc_value_t val, text;
260 /* Create more command variables */
261 if( p_input->p->i_title > 1 )
263 var_Create( p_input, "next-title", VLC_VAR_VOID );
264 text.psz_string = _("Next title");
265 var_Change( p_input, "next-title", VLC_VAR_SETTEXT, &text, NULL );
266 var_AddCallback( p_input, "next-title", TitleCallback, NULL );
268 var_Create( p_input, "prev-title", VLC_VAR_VOID );
269 text.psz_string = _("Previous title");
270 var_Change( p_input, "prev-title", VLC_VAR_SETTEXT, &text, NULL );
271 var_AddCallback( p_input, "prev-title", TitleCallback, NULL );
274 /* Create title and navigation */
275 val.psz_string = malloc( sizeof("title ") + 5 );
276 for( i = 0; i < p_input->p->i_title; i++ )
278 vlc_value_t val2, text, text2;
281 /* Add Navigation entries */
282 sprintf( val.psz_string, "title %2i", i );
283 var_Destroy( p_input, val.psz_string );
284 var_Create( p_input, val.psz_string,
285 VLC_VAR_INTEGER|VLC_VAR_HASCHOICE|VLC_VAR_ISCOMMAND );
286 var_AddCallback( p_input, val.psz_string,
287 NavigationCallback, (void *)(intptr_t)i );
289 if( p_input->p->title[i]->psz_name == NULL ||
290 *p_input->p->title[i]->psz_name == '\0' )
292 asprintf( &text.psz_string, _("Title %i"),
293 i + p_input->p->i_title_offset );
297 text.psz_string = strdup( p_input->p->title[i]->psz_name );
299 var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val, &text );
301 /* Add title choice */
303 var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val2, &text );
305 free( text.psz_string );
307 for( j = 0; j < p_input->p->title[i]->i_seekpoint; j++ )
311 if( p_input->p->title[i]->seekpoint[j]->psz_name == NULL ||
312 *p_input->p->title[i]->seekpoint[j]->psz_name == '\0' )
315 asprintf( &text2.psz_string, _("Chapter %i"),
316 j + p_input->p->i_seekpoint_offset );
321 strdup( p_input->p->title[i]->seekpoint[j]->psz_name );
324 var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE,
326 if( text2.psz_string ) free( text2.psz_string );
330 free( val.psz_string );
333 /*****************************************************************************
334 * input_ControlVarTitle:
335 * Create all variables for a title
336 *****************************************************************************/
337 void input_ControlVarTitle( input_thread_t *p_input, int i_title )
339 input_title_t *t = p_input->p->title[i_title];
343 /* Create/Destroy command variables */
344 if( t->i_seekpoint <= 1 )
346 var_Destroy( p_input, "next-chapter" );
347 var_Destroy( p_input, "prev-chapter" );
349 else if( var_Get( p_input, "next-chapter", &val ) != VLC_SUCCESS )
353 var_Create( p_input, "next-chapter", VLC_VAR_VOID );
354 text.psz_string = _("Next chapter");
355 var_Change( p_input, "next-chapter", VLC_VAR_SETTEXT, &text, NULL );
356 var_AddCallback( p_input, "next-chapter", SeekpointCallback, NULL );
358 var_Create( p_input, "prev-chapter", VLC_VAR_VOID );
359 text.psz_string = _("Previous chapter");
360 var_Change( p_input, "prev-chapter", VLC_VAR_SETTEXT, &text, NULL );
361 var_AddCallback( p_input, "prev-chapter", SeekpointCallback, NULL );
364 /* Build chapter list */
365 var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL );
366 for( i = 0; i < t->i_seekpoint; i++ )
371 if( t->seekpoint[i]->psz_name == NULL ||
372 *t->seekpoint[i]->psz_name == '\0' )
375 asprintf( &text.psz_string, _("Chapter %i"),
376 i + p_input->p->i_seekpoint_offset );
380 text.psz_string = strdup( t->seekpoint[i]->psz_name );
383 var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, &text );
384 if( text.psz_string ) free( text.psz_string );
388 /*****************************************************************************
389 * input_ConfigVarInit:
390 * Create all config object variables
391 *****************************************************************************/
392 void input_ConfigVarInit ( input_thread_t *p_input )
396 /* Create Object Variables for private use only */
398 if( !p_input->b_preparsing )
400 var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
401 var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
402 var_Create( p_input, "spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
404 var_Create( p_input, "audio-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
405 var_Create( p_input, "sub-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
407 var_Create( p_input, "audio-language",
408 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
409 var_Create( p_input, "sub-language",
410 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
412 var_Create( p_input, "audio-track-id",
413 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
414 var_Create( p_input, "sub-track-id",
415 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
417 var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT );
418 var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
420 var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING |
422 var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER |
425 var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
426 var_Create( p_input, "sout-all", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
427 var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
428 var_Create( p_input, "sout-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
429 var_Create( p_input, "sout-spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
430 var_Create( p_input, "sout-keep", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
432 var_Create( p_input, "input-repeat",
433 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
434 var_Create( p_input, "start-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
435 var_Create( p_input, "stop-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
436 var_Create( p_input, "run-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
438 var_Create( p_input, "input-slave",
439 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
441 var_Create( p_input, "minimize-threads",
442 VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
444 var_Create( p_input, "audio-desync",
445 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
446 var_Create( p_input, "cr-average",
447 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
448 var_Create( p_input, "clock-synchro",
449 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
452 var_Create( p_input, "seekable", VLC_VAR_BOOL );
453 val.b_bool = VLC_TRUE; /* Fixed later*/
454 var_Change( p_input, "seekable", VLC_VAR_SETVALUE, &val, NULL );
455 var_Create( p_input, "can-pause", VLC_VAR_BOOL );
456 val.b_bool = VLC_TRUE; /* Fixed later*/
457 var_Change( p_input, "can-pause", VLC_VAR_SETVALUE, &val, NULL );
460 var_Create( p_input, "access-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
461 var_Create( p_input, "access", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
462 var_Create( p_input, "demux", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
465 var_Create( p_input, "meta-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
466 var_Create( p_input, "meta-author", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
467 var_Create( p_input, "meta-artist", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
468 var_Create( p_input, "meta-genre", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
469 var_Create( p_input, "meta-copyright", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
470 var_Create( p_input, "meta-description", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
471 var_Create( p_input, "meta-date", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
472 var_Create( p_input, "meta-url", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
475 /*****************************************************************************
477 *****************************************************************************/
478 static int StateCallback( vlc_object_t *p_this, char const *psz_cmd,
479 vlc_value_t oldval, vlc_value_t newval,
482 input_thread_t *p_input = (input_thread_t*)p_this;
483 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
485 if( newval.i_int == PLAYING_S || newval.i_int == PAUSE_S )
487 input_ControlPush( p_input, INPUT_CONTROL_SET_STATE, &newval );
494 static int RateCallback( vlc_object_t *p_this, char const *psz_cmd,
495 vlc_value_t oldval, vlc_value_t newval, void *p_data )
497 input_thread_t *p_input = (input_thread_t*)p_this;
498 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
500 /* Problem with this way: the "rate" variable is update after the input thread do the change */
501 if( !strcmp( psz_cmd, "rate-slower" ) )
503 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_SLOWER, NULL );
505 else if( !strcmp( psz_cmd, "rate-faster" ) )
507 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_FASTER, NULL );
511 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
517 static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
518 vlc_value_t oldval, vlc_value_t newval,
521 input_thread_t *p_input = (input_thread_t*)p_this;
522 vlc_value_t val, length;
523 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
525 if( !strcmp( psz_cmd, "position-offset" ) )
527 input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION_OFFSET, &newval );
529 val.f_float = var_GetFloat( p_input, "position" ) + newval.f_float;
530 if( val.f_float < 0.0 ) val.f_float = 0.0;
531 if( val.f_float > 1.0 ) val.f_float = 1.0;
532 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
536 val.f_float = newval.f_float;
537 input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &newval );
540 /* Update "position" for better intf behavour */
541 var_Get( p_input, "length", &length );
542 if( length.i_time > 0 && val.f_float >= 0.0 && val.f_float <= 1.0 )
544 val.i_time = length.i_time * val.f_float;
545 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
551 static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd,
552 vlc_value_t oldval, vlc_value_t newval, void *p_data )
554 input_thread_t *p_input = (input_thread_t*)p_this;
555 vlc_value_t val, length;
556 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
558 if( !strcmp( psz_cmd, "time-offset" ) )
560 input_ControlPush( p_input, INPUT_CONTROL_SET_TIME_OFFSET, &newval );
561 val.i_time = var_GetTime( p_input, "time" ) + newval.i_time;
562 if( val.i_time < 0 ) val.i_time = 0;
563 /* TODO maybe test against i_length ? */
564 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
568 val.i_time = newval.i_time;
569 input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval );
572 /* Update "position" for better intf behavour */
573 var_Get( p_input, "length", &length );
574 if( length.i_time > 0 && val.i_time >= 0 && val.i_time <= length.i_time )
576 val.f_float = (double)val.i_time/(double)length.i_time;
577 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
583 static int ProgramCallback( vlc_object_t *p_this, char const *psz_cmd,
584 vlc_value_t oldval, vlc_value_t newval,
587 input_thread_t *p_input = (input_thread_t*)p_this;
588 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
590 input_ControlPush( p_input, INPUT_CONTROL_SET_PROGRAM, &newval );
595 static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
596 vlc_value_t oldval, vlc_value_t newval,
599 input_thread_t *p_input = (input_thread_t*)p_this;
600 vlc_value_t val, count;
601 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
603 if( !strcmp( psz_cmd, "next-title" ) )
605 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_NEXT, NULL );
607 val.i_int = var_GetInteger( p_input, "title" ) + 1;
608 var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &count, NULL );
609 if( val.i_int < count.i_int )
610 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
612 else if( !strcmp( psz_cmd, "prev-title" ) )
614 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_PREV, NULL );
616 val.i_int = var_GetInteger( p_input, "title" ) - 1;
618 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
622 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &newval );
628 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
629 vlc_value_t oldval, vlc_value_t newval,
632 input_thread_t *p_input = (input_thread_t*)p_this;
633 vlc_value_t val, count;
634 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
636 if( !strcmp( psz_cmd, "next-chapter" ) )
638 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_NEXT, NULL );
640 val.i_int = var_GetInteger( p_input, "chapter" ) + 1;
641 var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &count, NULL );
642 if( val.i_int < count.i_int )
643 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
645 else if( !strcmp( psz_cmd, "prev-chapter" ) )
647 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_PREV, NULL );
649 val.i_int = var_GetInteger( p_input, "chapter" ) - 1;
651 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
655 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
661 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
662 vlc_value_t oldval, vlc_value_t newval,
665 input_thread_t *p_input = (input_thread_t*)p_this;
667 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
669 /* Issue a title change */
670 val.i_int = (intptr_t)p_data;
671 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &val );
673 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
675 /* And a chapter change */
676 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
678 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &newval, NULL );
683 static int ESCallback( vlc_object_t *p_this, char const *psz_cmd,
684 vlc_value_t oldval, vlc_value_t newval, void *p_data )
686 input_thread_t *p_input = (input_thread_t*)p_this;
687 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
689 if( newval.i_int < 0 )
693 if( !strcmp( psz_cmd, "audio-es" ) )
695 else if( !strcmp( psz_cmd, "video-es" ) )
697 else if( !strcmp( psz_cmd, "spu-es" ) )
702 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &v );
706 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &newval );
712 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
713 vlc_value_t oldval, vlc_value_t newval, void *p_data )
715 input_thread_t *p_input = (input_thread_t*)p_this;
716 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
718 if( !strcmp( psz_cmd, "audio-delay" ) )
720 /*Change i_pts_delay to make sure es are decoded in time*/
721 if (newval.i_int < 0 || oldval.i_int < 0 )
723 p_input->i_pts_delay -= newval.i_int - oldval.i_int;
725 input_ControlPush( p_input, INPUT_CONTROL_SET_AUDIO_DELAY, &newval );
727 else if( !strcmp( psz_cmd, "spu-delay" ) )
728 input_ControlPush( p_input, INPUT_CONTROL_SET_SPU_DELAY, &newval );
732 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
733 vlc_value_t oldval, vlc_value_t newval,
736 input_thread_t *p_input = (input_thread_t*)p_this;
737 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
739 input_ControlPush( p_input, INPUT_CONTROL_SET_BOOKMARK, &newval );