1 /*****************************************************************************
2 * var.c: object variables for input thread
3 *****************************************************************************
4 * Copyright (C) 2004-2007 VLC authors and VideoLAN
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #include <vlc_common.h>
37 #include "input_internal.h"
39 /*****************************************************************************
41 *****************************************************************************/
42 static int StateCallback ( vlc_object_t *p_this, char const *psz_cmd,
43 vlc_value_t oldval, vlc_value_t newval, void * );
44 static int RateCallback ( vlc_object_t *p_this, char const *psz_cmd,
45 vlc_value_t oldval, vlc_value_t newval, void * );
46 static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
47 vlc_value_t oldval, vlc_value_t newval, void * );
48 static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd,
49 vlc_value_t oldval, vlc_value_t newval, void * );
50 static int ProgramCallback ( vlc_object_t *p_this, char const *psz_cmd,
51 vlc_value_t oldval, vlc_value_t newval, void * );
52 static int TitleCallback ( vlc_object_t *p_this, char const *psz_cmd,
53 vlc_value_t oldval, vlc_value_t newval, void * );
54 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
55 vlc_value_t oldval, vlc_value_t newval, void * );
56 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
57 vlc_value_t oldval, vlc_value_t newval, void * );
58 static int ESCallback ( vlc_object_t *p_this, char const *psz_cmd,
59 vlc_value_t oldval, vlc_value_t newval, void * );
60 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
61 vlc_value_t oldval, vlc_value_t newval, void * );
63 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
64 vlc_value_t oldval, vlc_value_t newval, void * );
66 static int RecordCallback( vlc_object_t *p_this, char const *psz_cmd,
67 vlc_value_t oldval, vlc_value_t newval,
69 static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
70 vlc_value_t oldval, vlc_value_t newval,
76 vlc_callback_t callback;
77 } vlc_input_callback_t;
79 static void InputAddCallbacks( input_thread_t *, const vlc_input_callback_t * );
80 static void InputDelCallbacks( input_thread_t *, const vlc_input_callback_t * );
82 #ifdef CALLBACK /* For windows */
83 # undef CALLBACK /* We don't care of this one here */
85 /* List all callbacks added by input */
86 #define CALLBACK(name,cb) { name, cb }
87 static const vlc_input_callback_t p_input_callbacks[] =
89 CALLBACK( "state", StateCallback ),
90 CALLBACK( "rate", 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 | VLC_VAR_DOINHERIT );
141 var_Create( p_input, "frame-next", VLC_VAR_VOID );
144 var_Create( p_input, "position", VLC_VAR_FLOAT );
145 var_Create( p_input, "position-offset", VLC_VAR_FLOAT );
147 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
150 var_Create( p_input, "time", VLC_VAR_TIME );
151 var_Create( p_input, "time-offset", VLC_VAR_TIME ); /* relative */
153 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
156 var_Create( p_input, "bookmark", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
158 val.psz_string = _("Bookmark");
159 var_Change( p_input, "bookmark", VLC_VAR_SETTEXT, &val, NULL );
162 var_Create( p_input, "program", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
164 var_Get( p_input, "program", &val );
166 var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
167 text.psz_string = _("Program");
168 var_Change( p_input, "program", VLC_VAR_SETTEXT, &text, NULL );
171 var_Create( p_input, "programs", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
172 text.psz_string = _("Programs");
173 var_Change( p_input, "programs", VLC_VAR_SETTEXT, &text, NULL );
176 var_Create( p_input, "title", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
177 text.psz_string = _("Title");
178 var_Change( p_input, "title", VLC_VAR_SETTEXT, &text, NULL );
181 var_Create( p_input, "chapter", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
182 text.psz_string = _("Chapter");
183 var_Change( p_input, "chapter", VLC_VAR_SETTEXT, &text, NULL );
185 /* Navigation The callback is added after */
186 var_Create( p_input, "navigation", VLC_VAR_VARIABLE | VLC_VAR_HASCHOICE );
187 text.psz_string = _("Navigation");
188 var_Change( p_input, "navigation", VLC_VAR_SETTEXT, &text, NULL );
191 var_Create( p_input, "audio-delay", VLC_VAR_TIME );
192 val.i_time = INT64_C(1000) * var_GetInteger( p_input, "audio-desync" );
193 var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
194 var_Create( p_input, "spu-delay", VLC_VAR_TIME );
196 var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
199 var_Create( p_input, "video-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
200 text.psz_string = _("Video Track");
201 var_Change( p_input, "video-es", VLC_VAR_SETTEXT, &text, NULL );
204 var_Create( p_input, "audio-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
205 text.psz_string = _("Audio Track");
206 var_Change( p_input, "audio-es", VLC_VAR_SETTEXT, &text, NULL );
209 var_Create( p_input, "spu-es", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
210 text.psz_string = _("Subtitle Track");
211 var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL );
213 var_Create( p_input, "spu-choice", VLC_VAR_INTEGER );
215 var_Change( p_input, "spu-choice", VLC_VAR_SETVALUE, &val, NULL );
217 /* Special read only objects variables for intf */
218 var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
220 var_Create( p_input, "length", VLC_VAR_TIME );
222 var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
224 var_Create( p_input, "bit-rate", VLC_VAR_INTEGER );
225 var_Create( p_input, "sample-rate", VLC_VAR_INTEGER );
227 if( !p_input->b_preparsing )
229 /* Special "intf-event" variable. */
230 var_Create( p_input, "intf-event", VLC_VAR_INTEGER );
234 * XXX we put callback only in non preparsing mode. We need to create the variable
235 * unless someone want to check all var_Get/var_Change return value ... */
236 if( !p_input->b_preparsing )
237 InputAddCallbacks( p_input, p_input_callbacks );
240 /*****************************************************************************
241 * input_ControlVarStop:
242 *****************************************************************************/
243 void input_ControlVarStop( input_thread_t *p_input )
245 if( !p_input->b_preparsing )
246 InputDelCallbacks( p_input, p_input_callbacks );
248 if( p_input->p->i_title > 0 )
250 char name[sizeof("title ") + 5 ];
253 InputDelCallbacks( p_input, p_input_navigation_callbacks );
254 InputDelCallbacks( p_input, p_input_title_callbacks );
256 for( i = 0; i < p_input->p->i_title; i++ )
258 snprintf( name, sizeof(name), "title %2i", i );
259 var_DelCallback( p_input, name, NavigationCallback, (void *)(intptr_t)i );
264 /*****************************************************************************
265 * input_ControlVarNavigation:
266 * Create all remaining control object variables
267 *****************************************************************************/
268 void input_ControlVarNavigation( input_thread_t *p_input )
270 vlc_value_t val, text;
273 /* Create more command variables */
274 if( p_input->p->i_title > 1 )
276 var_Create( p_input, "next-title", VLC_VAR_VOID );
277 text.psz_string = _("Next title");
278 var_Change( p_input, "next-title", VLC_VAR_SETTEXT, &text, NULL );
279 var_AddCallback( p_input, "next-title", TitleCallback, NULL );
281 var_Create( p_input, "prev-title", VLC_VAR_VOID );
282 text.psz_string = _("Previous title");
283 var_Change( p_input, "prev-title", VLC_VAR_SETTEXT, &text, NULL );
284 var_AddCallback( p_input, "prev-title", TitleCallback, NULL );
287 /* Create title and navigation */
288 val.psz_string = malloc( sizeof("title ") + 5 );
289 if( !val.psz_string )
292 var_Change( p_input, "title", VLC_VAR_CLEARCHOICES, NULL, NULL );
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 char psz_length[MSTRTIME_MAX_SIZE + sizeof(" []")] = "";
308 if( p_input->p->title[i]->i_length > 0 )
310 strcpy( psz_length, " [" );
311 secstotimestr( &psz_length[2], p_input->p->title[i]->i_length / CLOCK_FREQ );
312 strcat( psz_length, "]" );
315 if( p_input->p->title[i]->psz_name == NULL ||
316 *p_input->p->title[i]->psz_name == '\0' )
318 if( asprintf( &text.psz_string, _("Title %i%s"),
319 i + p_input->p->i_title_offset, psz_length ) == -1 )
324 if( asprintf( &text.psz_string, "%s%s",
325 p_input->p->title[i]->psz_name, psz_length ) == -1 )
328 var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val, &text );
330 /* Add title choice */
332 var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val2, &text );
334 free( text.psz_string );
336 for( j = 0; j < p_input->p->title[i]->i_seekpoint; j++ )
340 if( p_input->p->title[i]->seekpoint[j]->psz_name == NULL ||
341 *p_input->p->title[i]->seekpoint[j]->psz_name == '\0' )
344 if( asprintf( &text2.psz_string, _("Chapter %i"),
345 j + p_input->p->i_seekpoint_offset ) == -1 )
351 strdup( p_input->p->title[i]->seekpoint[j]->psz_name );
354 var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE,
356 free( text2.psz_string );
360 free( val.psz_string );
363 /*****************************************************************************
364 * input_ControlVarTitle:
365 * Create all variables for a title
366 *****************************************************************************/
367 void input_ControlVarTitle( input_thread_t *p_input, int i_title )
369 input_title_t *t = p_input->p->title[i_title];
373 /* Create/Destroy command variables */
374 if( t->i_seekpoint <= 1 )
376 var_Destroy( p_input, "next-chapter" );
377 var_Destroy( p_input, "prev-chapter" );
379 else if( var_Type( p_input, "next-chapter" ) == 0 )
381 var_Create( p_input, "next-chapter", VLC_VAR_VOID );
382 text.psz_string = _("Next chapter");
383 var_Change( p_input, "next-chapter", VLC_VAR_SETTEXT, &text, NULL );
384 var_AddCallback( p_input, "next-chapter", SeekpointCallback, NULL );
386 var_Create( p_input, "prev-chapter", VLC_VAR_VOID );
387 text.psz_string = _("Previous chapter");
388 var_Change( p_input, "prev-chapter", VLC_VAR_SETTEXT, &text, NULL );
389 var_AddCallback( p_input, "prev-chapter", SeekpointCallback, NULL );
392 /* Build chapter list */
393 var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL );
394 for( i = 0; i < t->i_seekpoint; i++ )
399 if( t->seekpoint[i]->psz_name == NULL ||
400 *t->seekpoint[i]->psz_name == '\0' )
403 if( asprintf( &text.psz_string, _("Chapter %i"),
404 i + p_input->p->i_seekpoint_offset ) == -1 )
409 text.psz_string = strdup( t->seekpoint[i]->psz_name );
412 var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, &text );
413 free( text.psz_string );
417 /*****************************************************************************
418 * input_ConfigVarInit:
419 * Create all config object variables
420 *****************************************************************************/
421 void input_ConfigVarInit ( input_thread_t *p_input )
423 /* Create Object Variables for private use only */
425 if( !p_input->b_preparsing )
427 var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
428 var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
429 var_Create( p_input, "spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
431 var_Create( p_input, "audio-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
432 var_Create( p_input, "sub-track", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
434 var_Create( p_input, "audio-language",
435 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
436 var_Create( p_input, "sub-language",
437 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
438 var_Create( p_input, "menu-language",
439 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
441 var_Create( p_input, "audio-track-id",
442 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
443 var_Create( p_input, "sub-track-id",
444 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
446 var_Create( p_input, "sub-file", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
447 var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL |
449 var_Create( p_input, "sub-autodetect-path", VLC_VAR_STRING |
451 var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER |
454 var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
455 var_Create( p_input, "sout-all", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
456 var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
457 var_Create( p_input, "sout-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
458 var_Create( p_input, "sout-spu", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
459 var_Create( p_input, "sout-keep", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
461 var_Create( p_input, "input-repeat",
462 VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
463 var_Create( p_input, "start-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
464 var_Create( p_input, "stop-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
465 var_Create( p_input, "run-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
466 var_Create( p_input, "input-fast-seek", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
468 var_Create( p_input, "input-slave",
469 VLC_VAR_STRING | VLC_VAR_DOINHERIT );
471 var_Create( p_input, "audio-desync",
472 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
473 var_Create( p_input, "cr-average",
474 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
475 var_Create( p_input, "clock-synchro",
476 VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
479 var_Create( p_input, "can-seek", VLC_VAR_BOOL );
480 var_SetBool( p_input, "can-seek", true ); /* Fixed later*/
482 var_Create( p_input, "can-pause", VLC_VAR_BOOL );
483 var_SetBool( p_input, "can-pause", true ); /* Fixed later*/
485 var_Create( p_input, "can-rate", VLC_VAR_BOOL );
486 var_SetBool( p_input, "can-rate", false );
488 var_Create( p_input, "can-rewind", VLC_VAR_BOOL );
489 var_SetBool( p_input, "can-rewind", false );
491 var_Create( p_input, "can-record", VLC_VAR_BOOL );
492 var_SetBool( p_input, "can-record", false ); /* Fixed later*/
494 var_Create( p_input, "record", VLC_VAR_BOOL );
495 var_SetBool( p_input, "record", false );
497 var_Create( p_input, "teletext-es", VLC_VAR_INTEGER );
498 var_SetInteger( p_input, "teletext-es", -1 );
500 var_Create( p_input, "signal-quality", VLC_VAR_FLOAT );
501 var_SetFloat( p_input, "signal-quality", -1 );
503 var_Create( p_input, "signal-strength", VLC_VAR_FLOAT );
504 var_SetFloat( p_input, "signal-strength", -1 );
506 var_Create( p_input, "program-scrambled", VLC_VAR_BOOL );
507 var_SetBool( p_input, "program-scrambled", false );
509 var_Create( p_input, "cache", VLC_VAR_FLOAT );
510 var_SetFloat( p_input, "cache", 0.0 );
513 var_Create( p_input, "input-record-native", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
516 var_Create( p_input, "access", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
517 var_Create( p_input, "demux", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
518 var_Create( p_input, "stream-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
521 var_Create( p_input, "meta-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
522 var_Create( p_input, "meta-author", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
523 var_Create( p_input, "meta-artist", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
524 var_Create( p_input, "meta-genre", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
525 var_Create( p_input, "meta-copyright", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
526 var_Create( p_input, "meta-description", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
527 var_Create( p_input, "meta-date", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
528 var_Create( p_input, "meta-url", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
531 /*****************************************************************************
532 * Callbacks managements:
533 *****************************************************************************/
534 static void InputAddCallbacks( input_thread_t *p_input,
535 const vlc_input_callback_t *p_callbacks )
538 for( i = 0; p_callbacks[i].psz_name != NULL; i++ )
539 var_AddCallback( p_input,
540 p_callbacks[i].psz_name,
541 p_callbacks[i].callback, NULL );
544 static void InputDelCallbacks( input_thread_t *p_input,
545 const vlc_input_callback_t *p_callbacks )
548 for( i = 0; p_callbacks[i].psz_name != NULL; i++ )
549 var_DelCallback( p_input,
550 p_callbacks[i].psz_name,
551 p_callbacks[i].callback, NULL );
554 /*****************************************************************************
556 *****************************************************************************/
557 static int StateCallback( vlc_object_t *p_this, char const *psz_cmd,
558 vlc_value_t oldval, vlc_value_t newval,
561 input_thread_t *p_input = (input_thread_t*)p_this;
562 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
564 if( newval.i_int == PLAYING_S || newval.i_int == PAUSE_S )
566 input_ControlPush( p_input, INPUT_CONTROL_SET_STATE, &newval );
573 static int RateCallback( vlc_object_t *p_this, char const *psz_cmd,
574 vlc_value_t oldval, vlc_value_t newval, void *p_data )
576 input_thread_t *p_input = (input_thread_t*)p_this;
577 VLC_UNUSED(oldval); VLC_UNUSED(p_data); VLC_UNUSED(psz_cmd);
579 newval.i_int = INPUT_RATE_DEFAULT / newval.f_float;
580 input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval );
585 static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
586 vlc_value_t oldval, vlc_value_t newval,
589 input_thread_t *p_input = (input_thread_t*)p_this;
590 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
592 if( !strcmp( psz_cmd, "position-offset" ) )
594 float f_position = var_GetFloat( p_input, "position" ) + newval.f_float;
595 if( f_position < 0.f )
597 else if( f_position > 1.f )
599 var_SetFloat( p_this, "position", f_position );
603 /* Update "length" for better intf behavour */
604 const mtime_t i_length = var_GetTime( p_input, "length" );
605 if( i_length > 0 && newval.f_float >= 0.f && newval.f_float <= 1.f )
609 val.i_time = i_length * newval.f_float;
610 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
614 input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &newval );
619 static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd,
620 vlc_value_t oldval, vlc_value_t newval, void *p_data )
622 input_thread_t *p_input = (input_thread_t*)p_this;
623 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
625 if( !strcmp( psz_cmd, "time-offset" ) )
627 mtime_t i_time = var_GetTime( p_input, "time" ) + newval.i_time;
630 var_SetTime( p_this, "time", i_time );
634 /* Update "position" for better intf behavour */
635 const mtime_t i_length = var_GetTime( p_input, "length" );
636 if( i_length > 0 && newval.i_time >= 0 && newval.i_time <= i_length )
640 val.f_float = (double)newval.i_time/(double)i_length;
641 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
643 * Notify the intf that a new event has been occurred.
644 * XXX this is a bit hackish but it's the only way to do it now.
646 var_SetInteger( p_input, "intf-event", INPUT_EVENT_POSITION );
650 input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval );
655 static int ProgramCallback( vlc_object_t *p_this, char const *psz_cmd,
656 vlc_value_t oldval, vlc_value_t newval,
659 input_thread_t *p_input = (input_thread_t*)p_this;
660 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
662 input_ControlPush( p_input, INPUT_CONTROL_SET_PROGRAM, &newval );
667 static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd,
668 vlc_value_t oldval, vlc_value_t newval,
671 input_thread_t *p_input = (input_thread_t*)p_this;
672 vlc_value_t val, count;
673 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
675 if( !strcmp( psz_cmd, "next-title" ) )
677 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_NEXT, NULL );
679 val.i_int = var_GetInteger( p_input, "title" ) + 1;
680 var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &count, NULL );
681 if( val.i_int < count.i_int )
682 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
684 else if( !strcmp( psz_cmd, "prev-title" ) )
686 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE_PREV, NULL );
688 val.i_int = var_GetInteger( p_input, "title" ) - 1;
690 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
694 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &newval );
700 static int SeekpointCallback( vlc_object_t *p_this, char const *psz_cmd,
701 vlc_value_t oldval, vlc_value_t newval,
704 input_thread_t *p_input = (input_thread_t*)p_this;
705 vlc_value_t val, count;
706 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
708 if( !strcmp( psz_cmd, "next-chapter" ) )
710 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_NEXT, NULL );
712 val.i_int = var_GetInteger( p_input, "chapter" ) + 1;
713 var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &count, NULL );
714 if( val.i_int < count.i_int )
715 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
717 else if( !strcmp( psz_cmd, "prev-chapter" ) )
719 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT_PREV, NULL );
721 val.i_int = var_GetInteger( p_input, "chapter" ) - 1;
723 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
727 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
733 static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd,
734 vlc_value_t oldval, vlc_value_t newval,
737 input_thread_t *p_input = (input_thread_t*)p_this;
739 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
741 /* Issue a title change */
742 val.i_int = (intptr_t)p_data;
743 input_ControlPush( p_input, INPUT_CONTROL_SET_TITLE, &val );
745 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
747 /* And a chapter change */
748 input_ControlPush( p_input, INPUT_CONTROL_SET_SEEKPOINT, &newval );
750 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &newval, NULL );
755 static int ESCallback( vlc_object_t *p_this, char const *psz_cmd,
756 vlc_value_t oldval, vlc_value_t newval, void *p_data )
758 input_thread_t *p_input = (input_thread_t*)p_this;
759 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
761 if( newval.i_int < 0 )
765 if( !strcmp( psz_cmd, "audio-es" ) )
767 else if( !strcmp( psz_cmd, "video-es" ) )
769 else if( !strcmp( psz_cmd, "spu-es" ) )
774 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &v );
778 input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &newval );
784 static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd,
785 vlc_value_t oldval, vlc_value_t newval, void *p_data )
787 input_thread_t *p_input = (input_thread_t*)p_this;
788 VLC_UNUSED(oldval); VLC_UNUSED(p_data);
790 if( !strcmp( psz_cmd, "audio-delay" ) )
792 input_ControlPush( p_input, INPUT_CONTROL_SET_AUDIO_DELAY, &newval );
794 else if( !strcmp( psz_cmd, "spu-delay" ) )
796 input_ControlPush( p_input, INPUT_CONTROL_SET_SPU_DELAY, &newval );
801 static int BookmarkCallback( vlc_object_t *p_this, char const *psz_cmd,
802 vlc_value_t oldval, vlc_value_t newval,
805 input_thread_t *p_input = (input_thread_t*)p_this;
806 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
808 input_ControlPush( p_input, INPUT_CONTROL_SET_BOOKMARK, &newval );
813 static int RecordCallback( vlc_object_t *p_this, char const *psz_cmd,
814 vlc_value_t oldval, vlc_value_t newval,
817 input_thread_t *p_input = (input_thread_t*)p_this;
818 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
820 input_ControlPush( p_input, INPUT_CONTROL_SET_RECORD_STATE, &newval );
825 static int FrameNextCallback( vlc_object_t *p_this, char const *psz_cmd,
826 vlc_value_t oldval, vlc_value_t newval,
829 input_thread_t *p_input = (input_thread_t*)p_this;
830 VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
833 input_ControlPush( p_input, INPUT_CONTROL_SET_FRAME_NEXT, NULL );