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 *****************************************************************************/
31 #include <vlc_common.h>
35 #include "input_internal.h"
37 /*****************************************************************************
39 *****************************************************************************/
40 static int StateCallback ( vlc_object_t *p_this, char const *psz_cmd,
41 vlc_value_t oldval, vlc_value_t newval, void * );
42 static int RateCallback ( vlc_object_t *p_this, char const *psz_cmd,
43 vlc_value_t oldval, vlc_value_t newval, void * );
44 static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
45 vlc_value_t oldval, vlc_value_t newval, void * );
46 static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd,
47 vlc_value_t oldval, vlc_value_t newval, void * );
48 static int ProgramCallback ( vlc_object_t *p_this, char const *psz_cmd,
49 vlc_value_t oldval, vlc_value_t newval, void * );
50 static int TitleCallback ( vlc_object_t *p_this, char const *psz_cmd,
51 vlc_value_t oldval, vlc_value_t newval, void * );
52 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
53 vlc_value_t oldval, vlc_value_t newval, void * );
54 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
55 vlc_value_t oldval, vlc_value_t newval, void * );
56 static int ESCallback ( vlc_object_t *p_this, char const *psz_cmd,
57 vlc_value_t oldval, vlc_value_t newval, void * );
58 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
59 vlc_value_t oldval, vlc_value_t newval, void * );
61 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
62 vlc_value_t oldval, vlc_value_t newval, void * );
64 static int RecordCallback( vlc_object_t *p_this, char const *psz_cmd,
65 vlc_value_t oldval, vlc_value_t newval,
67 static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
68 vlc_value_t oldval, vlc_value_t newval,
74 vlc_callback_t callback;
75 } vlc_input_callback_t;
77 static void InputAddCallbacks( input_thread_t *, const vlc_input_callback_t * );
78 static void InputDelCallbacks( input_thread_t *, const vlc_input_callback_t * );
80 #ifdef CALLBACK /* For windows */
81 # undef CALLBACK /* We don't care of this one here */
83 /* List all callbacks added by input */
84 #define CALLBACK(name,cb) { name, cb }
85 static const vlc_input_callback_t p_input_callbacks[] =
87 CALLBACK( "state", StateCallback ),
88 CALLBACK( "rate", RateCallback ),
89 CALLBACK( "rate-slower", RateCallback ),
90 CALLBACK( "rate-faster", RateCallback ),
91 CALLBACK( "position", PositionCallback ),
92 CALLBACK( "position-offset", PositionCallback ),
93 CALLBACK( "time", TimeCallback ),
94 CALLBACK( "time-offset", TimeCallback ),
95 CALLBACK( "bookmark", BookmarkCallback ),
96 CALLBACK( "program", ProgramCallback ),
97 CALLBACK( "title", TitleCallback ),
98 CALLBACK( "chapter", SeekpointCallback ),
99 CALLBACK( "audio-delay", EsDelayCallback ),
100 CALLBACK( "spu-delay", EsDelayCallback ),
101 CALLBACK( "video-es", ESCallback ),
102 CALLBACK( "audio-es", ESCallback ),
103 CALLBACK( "spu-es", ESCallback ),
104 CALLBACK( "record", RecordCallback ),
105 CALLBACK( "frame-next", FrameNextCallback ),
107 CALLBACK( NULL, NULL )
109 static const vlc_input_callback_t p_input_navigation_callbacks[] =
111 CALLBACK( "next-title", TitleCallback ),
112 CALLBACK( "prev-title", TitleCallback ),
114 CALLBACK( NULL, NULL )
116 static const vlc_input_callback_t p_input_title_callbacks[] =
118 CALLBACK( "next-chapter", SeekpointCallback ),
119 CALLBACK( "prev-chapter", SeekpointCallback ),
121 CALLBACK( NULL, NULL )
125 /*****************************************************************************
126 * input_ControlVarInit:
127 * Create all control object variables with their callbacks
128 *****************************************************************************/
129 void input_ControlVarInit ( input_thread_t *p_input )
131 vlc_value_t val, text;
134 var_Create( p_input, "state", VLC_VAR_INTEGER );
135 val.i_int = p_input->p->i_state;
136 var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
139 var_Create( p_input, "rate", VLC_VAR_FLOAT );
140 val.f_float = (float)INPUT_RATE_DEFAULT / (float)p_input->p->i_rate;
141 var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
143 var_Create( p_input, "rate-slower", VLC_VAR_VOID );
145 var_Create( p_input, "rate-faster", VLC_VAR_VOID );
147 var_Create( p_input, "frame-next", VLC_VAR_VOID );
150 var_Create( p_input, "position", VLC_VAR_FLOAT );
151 var_Create( p_input, "position-offset", VLC_VAR_FLOAT );
153 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
156 var_Create( p_input, "time", VLC_VAR_TIME );
157 var_Create( p_input, "time-offset", VLC_VAR_TIME ); /* relative */
159 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
162 var_Create( p_input, "bookmark", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
164 val.psz_string = _("Bookmark");
165 var_Change( p_input, "bookmark", VLC_VAR_SETTEXT, &val, NULL );
168 var_Create( p_input, "program", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
170 var_Get( p_input, "program", &val );
172 var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
173 text.psz_string = _("Program");
174 var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL );
177 var_Create( p_input, "programs", VLC_VAR_LIST | VLC_VAR_DOINHERIT );
178 text.psz_string = _("Programs");
179 var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL );
182 var_Create( p_input, "title", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
183 text.psz_string = _("Title");
184 var_Change( p_input, "title", VLC_VAR_SETTEXT, &text, NULL );
187 var_Create( p_input, "chapter", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
188 text.psz_string = _("Chapter");
189 var_Change( p_input, "chapter", VLC_VAR_SETTEXT, &text, NULL );
191 /* Navigation The callback is added after */
192 var_Create( p_input, "navigation", VLC_VAR_VARIABLE | VLC_VAR_HASCHOICE );
193 text.psz_string = _("Navigation");
194 var_Change( p_input, "navigation", VLC_VAR_SETTEXT, &text, NULL );
197 var_Create( p_input, "audio-delay", VLC_VAR_TIME );
198 val.i_time = INT64_C(1000) * var_GetInteger( p_input, "audio-desync" );
199 var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
200 var_Create( p_input, "spu-delay", VLC_VAR_TIME );
202 var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
205 var_Create( p_input, "video-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
206 text.psz_string = _("Video Track");
207 var_Change( p_input, "video-es", VLC_VAR_SETTEXT, &text, NULL );
210 var_Create( p_input, "audio-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
211 text.psz_string = _("Audio Track");
212 var_Change( p_input, "audio-es", VLC_VAR_SETTEXT, &text, NULL );
215 var_Create( p_input, "spu-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
216 text.psz_string = _("Subtitles Track");
217 var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL );
219 /* Special read only objects variables for intf */
220 var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
222 var_Create( p_input, "length", VLC_VAR_TIME );
224 var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
226 var_Create( p_input, "bit-rate", VLC_VAR_INTEGER );
227 var_Create( p_input, "sample-rate", VLC_VAR_INTEGER );
229 if( !p_input->b_preparsing )
231 /* Special "intf-event" variable. */
232 var_Create( p_input, "intf-event", VLC_VAR_INTEGER );
236 * XXX we put callback only in non preparsing mode. We need to create the variable
237 * unless someone want to check all var_Get/var_Change return value ... */
238 if( !p_input->b_preparsing )
239 InputAddCallbacks( p_input, p_input_callbacks );
242 /*****************************************************************************
243 * input_ControlVarStop:
244 *****************************************************************************/
245 void input_ControlVarStop( input_thread_t *p_input )
247 if( !p_input->b_preparsing )
248 InputDelCallbacks( p_input, p_input_callbacks );
250 if( p_input->p->i_title > 0 )
252 char name[sizeof("title ") + 5 ];
255 InputDelCallbacks( p_input, p_input_navigation_callbacks );
256 InputDelCallbacks( p_input, p_input_title_callbacks );
258 for( i = 0; i < p_input->p->i_title; i++ )
260 snprintf( name, sizeof(name), "title %2i", i );
261 var_DelCallback( p_input, name, NavigationCallback, (void *)(intptr_t)i );
266 /*****************************************************************************
267 * input_ControlVarNavigation:
268 * Create all remaining control object variables
269 *****************************************************************************/
270 void input_ControlVarNavigation( input_thread_t *p_input )
272 vlc_value_t val, text;
275 /* Create more command variables */
276 if( p_input->p->i_title > 1 )
278 var_Create( p_input, "next-title", VLC_VAR_VOID );
279 text.psz_string = _("Next title");
280 var_Change( p_input, "next-title", VLC_VAR_SETTEXT, &text, NULL );
281 var_AddCallback( p_input, "next-title", TitleCallback, NULL );
283 var_Create( p_input, "prev-title", VLC_VAR_VOID );
284 text.psz_string = _("Previous title");
285 var_Change( p_input, "prev-title", VLC_VAR_SETTEXT, &text, NULL );
286 var_AddCallback( p_input, "prev-title", TitleCallback, NULL );
289 /* Create title and navigation */
290 val.psz_string = malloc( sizeof("title ") + 5 );
291 if( !val.psz_string )
294 for( i = 0; i < p_input->p->i_title; i++ )
296 vlc_value_t val2, text2;
299 /* Add Navigation entries */
300 sprintf( val.psz_string, "title %2i", i );
301 var_Destroy( p_input, val.psz_string );
302 var_Create( p_input, val.psz_string,
303 VLC_VAR_INTEGER|VLC_VAR_HASCHOICE|VLC_VAR_ISCOMMAND );
304 var_AddCallback( p_input, val.psz_string,
305 NavigationCallback, (void *)(intptr_t)i );
307 if( p_input->p->title[i]->psz_name == NULL ||
308 *p_input->p->title[i]->psz_name == '\0' )
310 if( asprintf( &text.psz_string, _("Title %i"),
311 i + p_input->p->i_title_offset ) == -1 )
316 text.psz_string = strdup( p_input->p->title[i]->psz_name );
318 var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val, &text );
320 /* Add title choice */
322 var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val2, &text );
324 free( text.psz_string );
326 for( j = 0; j < p_input->p->title[i]->i_seekpoint; j++ )
330 if( p_input->p->title[i]->seekpoint[j]->psz_name == NULL ||
331 *p_input->p->title[i]->seekpoint[j]->psz_name == '\0' )
334 if( asprintf( &text2.psz_string, _("Chapter %i"),
335 j + p_input->p->i_seekpoint_offset ) == -1 )
341 strdup( p_input->p->title[i]->seekpoint[j]->psz_name );
344 var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE,
346 free( text2.psz_string );
350 free( val.psz_string );
353 /*****************************************************************************
354 * input_ControlVarTitle:
355 * Create all variables for a title
356 *****************************************************************************/
357 void input_ControlVarTitle( input_thread_t *p_input, int i_title )
359 input_title_t *t = p_input->p->title[i_title];
360 vlc_value_t val, text;
363 /* Create/Destroy command variables */
364 if( t->i_seekpoint <= 1 )
366 var_Destroy( p_input, "next-chapter" );
367 var_Destroy( p_input, "prev-chapter" );
369 else if( var_Get( p_input, "next-chapter", &val ) != VLC_SUCCESS )
371 var_Create( p_input, "next-chapter", VLC_VAR_VOID );
372 text.psz_string = _("Next chapter");
373 var_Change( p_input, "next-chapter", VLC_VAR_SETTEXT, &text, NULL );
374 var_AddCallback( p_input, "next-chapter", SeekpointCallback, NULL );
376 var_Create( p_input, "prev-chapter", VLC_VAR_VOID );
377 text.psz_string = _("Previous chapter");
378 var_Change( p_input, "prev-chapter", VLC_VAR_SETTEXT, &text, NULL );
379 var_AddCallback( p_input, "prev-chapter", SeekpointCallback, NULL );
382 /* Build chapter list */
383 var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL );
384 for( i = 0; i < t->i_seekpoint; i++ )
388 if( t->seekpoint[i]->psz_name == NULL ||
389 *t->seekpoint[i]->psz_name == '\0' )
392 if( asprintf( &text.psz_string, _("Chapter %i"),
393 i + p_input->p->i_seekpoint_offset ) == -1 )
398 text.psz_string = strdup( t->seekpoint[i]->psz_name );
401 var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, &text );
402 free( text.psz_string );
406 /*****************************************************************************
407 * input_ConfigVarInit:
408 * Create all config object variables
409 *****************************************************************************/
410 void input_ConfigVarInit ( input_thread_t *p_input )
412 /* Create Object Variables for private use only */
414 if( !p_input->b_preparsing )
416 var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
417 var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
418 var_Create( p_input, "spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
420 var_Create( p_input, "audio-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
421 var_Create( p_input, "sub-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
423 var_Create( p_input, "audio-language",
424 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
425 var_Create( p_input, "sub-language",
426 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
428 var_Create( p_input, "audio-track-id",
429 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
430 var_Create( p_input, "sub-track-id",
431 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
433 var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT );
434 var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
436 var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING |
438 var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER |
441 var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
442 var_Create( p_input, "sout-all", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
443 var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
444 var_Create( p_input, "sout-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
445 var_Create( p_input, "sout-spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
446 var_Create( p_input, "sout-keep", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
448 var_Create( p_input, "input-repeat",
449 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
450 var_Create( p_input, "start-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
451 var_Create( p_input, "stop-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
452 var_Create( p_input, "run-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
453 var_Create( p_input, "input-fast-seek", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
455 var_Create( p_input, "input-slave",
456 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
458 var_Create( p_input, "audio-desync",
459 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
460 var_Create( p_input, "cr-average",
461 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
462 var_Create( p_input, "clock-synchro",
463 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
466 var_Create( p_input, "can-seek", VLC_VAR_BOOL );
467 var_SetBool( p_input, "can-seek", true ); /* Fixed later*/
469 var_Create( p_input, "can-pause", VLC_VAR_BOOL );
470 var_SetBool( p_input, "can-pause", true ); /* Fixed later*/
472 var_Create( p_input, "can-rate", VLC_VAR_BOOL );
473 var_SetBool( p_input, "can-rate", false );
475 var_Create( p_input, "can-rewind", VLC_VAR_BOOL );
476 var_SetBool( p_input, "can-rewind", false );
478 var_Create( p_input, "can-record", VLC_VAR_BOOL );
479 var_SetBool( p_input, "can-record", false ); /* Fixed later*/
481 var_Create( p_input, "record", VLC_VAR_BOOL );
482 var_SetBool( p_input, "record", false );
484 var_Create( p_input, "teletext-es", VLC_VAR_INTEGER );
485 var_SetInteger( p_input, "teletext-es", -1 );
487 var_Create( p_input, "signal-quality", VLC_VAR_FLOAT );
488 var_SetFloat( p_input, "signal-quality", -1 );
490 var_Create( p_input, "signal-strength", VLC_VAR_FLOAT );
491 var_SetFloat( p_input, "signal-strength", -1 );
493 var_Create( p_input, "program-scrambled", VLC_VAR_BOOL );
494 var_SetBool( p_input, "program-scrambled", false );
496 var_Create( p_input, "cache", VLC_VAR_FLOAT );
497 var_SetFloat( p_input, "cache", 0.0 );
500 var_Create( p_input, "input-record-native", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
503 var_Create( p_input, "access", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
504 var_Create( p_input, "demux", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
505 var_Create( p_input, "stream-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
508 var_Create( p_input, "meta-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
509 var_Create( p_input, "meta-author", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
510 var_Create( p_input, "meta-artist", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
511 var_Create( p_input, "meta-genre", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
512 var_Create( p_input, "meta-copyright", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
513 var_Create( p_input, "meta-description", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
514 var_Create( p_input, "meta-date", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
515 var_Create( p_input, "meta-url", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
518 /*****************************************************************************
519 * Callbacks managements:
520 *****************************************************************************/
521 static void InputAddCallbacks( input_thread_t *p_input,
522 const vlc_input_callback_t *p_callbacks )
525 for( i = 0; p_callbacks[i].psz_name != NULL; i++ )
526 var_AddCallback( p_input,
527 p_callbacks[i].psz_name,
528 p_callbacks[i].callback, NULL );
531 static void InputDelCallbacks( input_thread_t *p_input,
532 const vlc_input_callback_t *p_callbacks )
535 for( i = 0; p_callbacks[i].psz_name != NULL; i++ )
536 var_DelCallback( p_input,
537 p_callbacks[i].psz_name,
538 p_callbacks[i].callback, NULL );
541 /*****************************************************************************
543 *****************************************************************************/
544 static int StateCallback( vlc_object_t *p_this, char const *psz_cmd,
545 vlc_value_t oldval, vlc_value_t newval,
548 input_thread_t *p_input = (input_thread_t*)p_this;
549 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
551 if( newval.i_int == PLAYING_S || newval.i_int == PAUSE_S )
553 input_ControlPush( p_input, INPUT_CONTROL_SET_STATE, &newval );
560 static int RateCallback( vlc_object_t *p_this, char const *psz_cmd,
561 vlc_value_t oldval, vlc_value_t newval, void *p_data )
563 input_thread_t *p_input = (input_thread_t*)p_this;
564 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
566 /* Problem with this way: the "rate" variable is update after the input thread do the change */
567 if( !strcmp( psz_cmd, "rate-slower" ) )
569 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_SLOWER, NULL );
571 else if( !strcmp( psz_cmd, "rate-faster" ) )
573 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_FASTER, NULL );
577 newval.i_int = INPUT_RATE_DEFAULT / newval.f_float;
578 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
583 static int PositionCallback( 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(oldval); VLC_UNUSED(p_data);
590 if( !strcmp( psz_cmd, "position-offset" ) )
592 float f_position = var_GetFloat( p_input, "position" ) + newval.f_float;
593 if( f_position < 0.0 )
595 else if( f_position > 1.0 )
597 var_SetFloat( p_this, "position", f_position );
601 /* Update "length" for better intf behavour */
602 const mtime_t i_length = var_GetTime( p_input, "length" );
603 if( i_length > 0 && newval.f_float >= 0.0 && newval.f_float <= 1.0 )
607 val.i_time = i_length * newval.f_float;
608 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
612 input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &newval );
617 static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd,
618 vlc_value_t oldval, vlc_value_t newval, void *p_data )
620 input_thread_t *p_input = (input_thread_t*)p_this;
621 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
623 if( !strcmp( psz_cmd, "time-offset" ) )
625 mtime_t i_time = var_GetTime( p_input, "time" ) + newval.i_time;
628 var_SetTime( p_this, "time", i_time );
632 /* Update "position" for better intf behavour */
633 const mtime_t i_length = var_GetTime( p_input, "length" );
634 if( i_length > 0 && newval.i_time >= 0 && newval.i_time <= i_length )
638 val.f_float = (double)newval.i_time/(double)i_length;
639 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
643 input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval );
648 static int ProgramCallback( vlc_object_t *p_this, char const *psz_cmd,
649 vlc_value_t oldval, vlc_value_t newval,
652 input_thread_t *p_input = (input_thread_t*)p_this;
653 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
655 input_ControlPush( p_input, INPUT_CONTROL_SET_PROGRAM, &newval );
660 static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
661 vlc_value_t oldval, vlc_value_t newval,
664 input_thread_t *p_input = (input_thread_t*)p_this;
665 vlc_value_t val, count;
666 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
668 if( !strcmp( psz_cmd, "next-title" ) )
670 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_NEXT, NULL );
672 val.i_int = var_GetInteger( p_input, "title" ) + 1;
673 var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &count, NULL );
674 if( val.i_int < count.i_int )
675 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
677 else if( !strcmp( psz_cmd, "prev-title" ) )
679 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_PREV, NULL );
681 val.i_int = var_GetInteger( p_input, "title" ) - 1;
683 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
687 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &newval );
693 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
694 vlc_value_t oldval, vlc_value_t newval,
697 input_thread_t *p_input = (input_thread_t*)p_this;
698 vlc_value_t val, count;
699 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
701 if( !strcmp( psz_cmd, "next-chapter" ) )
703 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_NEXT, NULL );
705 val.i_int = var_GetInteger( p_input, "chapter" ) + 1;
706 var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &count, NULL );
707 if( val.i_int < count.i_int )
708 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
710 else if( !strcmp( psz_cmd, "prev-chapter" ) )
712 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_PREV, NULL );
714 val.i_int = var_GetInteger( p_input, "chapter" ) - 1;
716 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
720 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
726 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
727 vlc_value_t oldval, vlc_value_t newval,
730 input_thread_t *p_input = (input_thread_t*)p_this;
732 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
734 /* Issue a title change */
735 val.i_int = (intptr_t)p_data;
736 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &val );
738 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
740 /* And a chapter change */
741 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
743 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &newval, NULL );
748 static int ESCallback( vlc_object_t *p_this, char const *psz_cmd,
749 vlc_value_t oldval, vlc_value_t newval, void *p_data )
751 input_thread_t *p_input = (input_thread_t*)p_this;
752 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
754 if( newval.i_int < 0 )
758 if( !strcmp( psz_cmd, "audio-es" ) )
760 else if( !strcmp( psz_cmd, "video-es" ) )
762 else if( !strcmp( psz_cmd, "spu-es" ) )
767 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &v );
771 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &newval );
777 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
778 vlc_value_t oldval, vlc_value_t newval, void *p_data )
780 input_thread_t *p_input = (input_thread_t*)p_this;
781 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
783 if( !strcmp( psz_cmd, "audio-delay" ) )
785 input_ControlPush( p_input, INPUT_CONTROL_SET_AUDIO_DELAY, &newval );
787 else if( !strcmp( psz_cmd, "spu-delay" ) )
789 input_ControlPush( p_input, INPUT_CONTROL_SET_SPU_DELAY, &newval );
794 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
795 vlc_value_t oldval, vlc_value_t newval,
798 input_thread_t *p_input = (input_thread_t*)p_this;
799 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
801 input_ControlPush( p_input, INPUT_CONTROL_SET_BOOKMARK, &newval );
806 static int RecordCallback( vlc_object_t *p_this, char const *psz_cmd,
807 vlc_value_t oldval, vlc_value_t newval,
810 input_thread_t *p_input = (input_thread_t*)p_this;
811 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
813 input_ControlPush( p_input, INPUT_CONTROL_SET_RECORD_STATE, &newval );
818 static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
819 vlc_value_t oldval, vlc_value_t newval,
822 input_thread_t *p_input = (input_thread_t*)p_this;
823 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
826 input_ControlPush( p_input, INPUT_CONTROL_SET_FRAME_NEXT, NULL );