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 /* Special read only objects variables for intf */
214 var_Create( p_input
, "bookmarks", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
216 var_Create( p_input
, "length", VLC_VAR_TIME
);
218 var_Change( p_input
, "length", VLC_VAR_SETVALUE
, &val
, NULL
);
220 var_Create( p_input
, "bit-rate", VLC_VAR_INTEGER
);
221 var_Create( p_input
, "sample-rate", VLC_VAR_INTEGER
);
223 if( !p_input
->b_preparsing
)
225 /* Special "intf-event" variable. */
226 var_Create( p_input
, "intf-event", VLC_VAR_INTEGER
);
230 * XXX we put callback only in non preparsing mode. We need to create the variable
231 * unless someone want to check all var_Get/var_Change return value ... */
232 if( !p_input
->b_preparsing
)
233 InputAddCallbacks( p_input
, p_input_callbacks
);
236 /*****************************************************************************
237 * input_ControlVarStop:
238 *****************************************************************************/
239 void input_ControlVarStop( input_thread_t
*p_input
)
241 if( !p_input
->b_preparsing
)
242 InputDelCallbacks( p_input
, p_input_callbacks
);
244 if( p_input
->p
->i_title
> 0 )
246 char name
[sizeof("title ") + 5 ];
249 InputDelCallbacks( p_input
, p_input_navigation_callbacks
);
250 InputDelCallbacks( p_input
, p_input_title_callbacks
);
252 for( i
= 0; i
< p_input
->p
->i_title
; i
++ )
254 snprintf( name
, sizeof(name
), "title %2i", i
);
255 var_DelCallback( p_input
, name
, NavigationCallback
, (void *)(intptr_t)i
);
260 /*****************************************************************************
261 * input_ControlVarNavigation:
262 * Create all remaining control object variables
263 *****************************************************************************/
264 void input_ControlVarNavigation( input_thread_t
*p_input
)
266 vlc_value_t val
, text
;
269 /* Create more command variables */
270 if( p_input
->p
->i_title
> 1 )
272 var_Create( p_input
, "next-title", VLC_VAR_VOID
);
273 text
.psz_string
= _("Next title");
274 var_Change( p_input
, "next-title", VLC_VAR_SETTEXT
, &text
, NULL
);
275 var_AddCallback( p_input
, "next-title", TitleCallback
, NULL
);
277 var_Create( p_input
, "prev-title", VLC_VAR_VOID
);
278 text
.psz_string
= _("Previous title");
279 var_Change( p_input
, "prev-title", VLC_VAR_SETTEXT
, &text
, NULL
);
280 var_AddCallback( p_input
, "prev-title", TitleCallback
, NULL
);
283 /* Create title and navigation */
284 val
.psz_string
= malloc( sizeof("title ") + 5 );
285 if( !val
.psz_string
)
288 for( i
= 0; i
< p_input
->p
->i_title
; i
++ )
290 vlc_value_t val2
, text2
;
293 /* Add Navigation entries */
294 sprintf( val
.psz_string
, "title %2i", i
);
295 var_Destroy( p_input
, val
.psz_string
);
296 var_Create( p_input
, val
.psz_string
,
297 VLC_VAR_INTEGER
|VLC_VAR_HASCHOICE
|VLC_VAR_ISCOMMAND
);
298 var_AddCallback( p_input
, val
.psz_string
,
299 NavigationCallback
, (void *)(intptr_t)i
);
301 char psz_length
[MSTRTIME_MAX_SIZE
+ sizeof(" []")] = "";
302 if( p_input
->p
->title
[i
]->i_length
> 0 )
304 strcpy( psz_length
, " [" );
305 secstotimestr( &psz_length
[2], p_input
->p
->title
[i
]->i_length
/ CLOCK_FREQ
);
306 strcat( psz_length
, "]" );
309 if( p_input
->p
->title
[i
]->psz_name
== NULL
||
310 *p_input
->p
->title
[i
]->psz_name
== '\0' )
312 if( asprintf( &text
.psz_string
, _("Title %i%s"),
313 i
+ p_input
->p
->i_title_offset
, psz_length
) == -1 )
318 if( asprintf( &text
.psz_string
, "%s%s",
319 p_input
->p
->title
[i
]->psz_name
, psz_length
) == -1 )
322 var_Change( p_input
, "navigation", VLC_VAR_ADDCHOICE
, &val
, &text
);
324 /* Add title choice */
326 var_Change( p_input
, "title", VLC_VAR_ADDCHOICE
, &val2
, &text
);
328 free( text
.psz_string
);
330 for( j
= 0; j
< p_input
->p
->title
[i
]->i_seekpoint
; j
++ )
334 if( p_input
->p
->title
[i
]->seekpoint
[j
]->psz_name
== NULL
||
335 *p_input
->p
->title
[i
]->seekpoint
[j
]->psz_name
== '\0' )
338 if( asprintf( &text2
.psz_string
, _("Chapter %i"),
339 j
+ p_input
->p
->i_seekpoint_offset
) == -1 )
345 strdup( p_input
->p
->title
[i
]->seekpoint
[j
]->psz_name
);
348 var_Change( p_input
, val
.psz_string
, VLC_VAR_ADDCHOICE
,
350 free( text2
.psz_string
);
354 free( val
.psz_string
);
357 /*****************************************************************************
358 * input_ControlVarTitle:
359 * Create all variables for a title
360 *****************************************************************************/
361 void input_ControlVarTitle( input_thread_t
*p_input
, int i_title
)
363 input_title_t
*t
= p_input
->p
->title
[i_title
];
367 /* Create/Destroy command variables */
368 if( t
->i_seekpoint
<= 1 )
370 var_Destroy( p_input
, "next-chapter" );
371 var_Destroy( p_input
, "prev-chapter" );
373 else if( var_Type( p_input
, "next-chapter" ) == 0 )
375 var_Create( p_input
, "next-chapter", VLC_VAR_VOID
);
376 text
.psz_string
= _("Next chapter");
377 var_Change( p_input
, "next-chapter", VLC_VAR_SETTEXT
, &text
, NULL
);
378 var_AddCallback( p_input
, "next-chapter", SeekpointCallback
, NULL
);
380 var_Create( p_input
, "prev-chapter", VLC_VAR_VOID
);
381 text
.psz_string
= _("Previous chapter");
382 var_Change( p_input
, "prev-chapter", VLC_VAR_SETTEXT
, &text
, NULL
);
383 var_AddCallback( p_input
, "prev-chapter", SeekpointCallback
, NULL
);
386 /* Build chapter list */
387 var_Change( p_input
, "chapter", VLC_VAR_CLEARCHOICES
, NULL
, NULL
);
388 for( i
= 0; i
< t
->i_seekpoint
; i
++ )
393 if( t
->seekpoint
[i
]->psz_name
== NULL
||
394 *t
->seekpoint
[i
]->psz_name
== '\0' )
397 if( asprintf( &text
.psz_string
, _("Chapter %i"),
398 i
+ p_input
->p
->i_seekpoint_offset
) == -1 )
403 text
.psz_string
= strdup( t
->seekpoint
[i
]->psz_name
);
406 var_Change( p_input
, "chapter", VLC_VAR_ADDCHOICE
, &val
, &text
);
407 free( text
.psz_string
);
411 /*****************************************************************************
412 * input_ConfigVarInit:
413 * Create all config object variables
414 *****************************************************************************/
415 void input_ConfigVarInit ( input_thread_t
*p_input
)
417 /* Create Object Variables for private use only */
419 if( !p_input
->b_preparsing
)
421 var_Create( p_input
, "video", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
422 var_Create( p_input
, "audio", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
423 var_Create( p_input
, "spu", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
425 var_Create( p_input
, "audio-track", VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
426 var_Create( p_input
, "sub-track", VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
428 var_Create( p_input
, "audio-language",
429 VLC_VAR_STRING
|VLC_VAR_DOINHERIT
);
430 var_Create( p_input
, "sub-language",
431 VLC_VAR_STRING
|VLC_VAR_DOINHERIT
);
433 var_Create( p_input
, "audio-track-id",
434 VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
435 var_Create( p_input
, "sub-track-id",
436 VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
438 var_Create( p_input
, "sub-file", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
439 var_Create( p_input
, "sub-autodetect-file", VLC_VAR_BOOL
|
441 var_Create( p_input
, "sub-autodetect-path", VLC_VAR_STRING
|
443 var_Create( p_input
, "sub-autodetect-fuzzy", VLC_VAR_INTEGER
|
446 var_Create( p_input
, "sout", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
447 var_Create( p_input
, "sout-all", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
448 var_Create( p_input
, "sout-audio", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
449 var_Create( p_input
, "sout-video", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
450 var_Create( p_input
, "sout-spu", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
451 var_Create( p_input
, "sout-keep", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
453 var_Create( p_input
, "input-repeat",
454 VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
455 var_Create( p_input
, "start-time", VLC_VAR_FLOAT
|VLC_VAR_DOINHERIT
);
456 var_Create( p_input
, "stop-time", VLC_VAR_FLOAT
|VLC_VAR_DOINHERIT
);
457 var_Create( p_input
, "run-time", VLC_VAR_FLOAT
|VLC_VAR_DOINHERIT
);
458 var_Create( p_input
, "input-fast-seek", VLC_VAR_BOOL
|VLC_VAR_DOINHERIT
);
460 var_Create( p_input
, "input-slave",
461 VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
463 var_Create( p_input
, "audio-desync",
464 VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
465 var_Create( p_input
, "cr-average",
466 VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
467 var_Create( p_input
, "clock-synchro",
468 VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
471 var_Create( p_input
, "can-seek", VLC_VAR_BOOL
);
472 var_SetBool( p_input
, "can-seek", true ); /* Fixed later*/
474 var_Create( p_input
, "can-pause", VLC_VAR_BOOL
);
475 var_SetBool( p_input
, "can-pause", true ); /* Fixed later*/
477 var_Create( p_input
, "can-rate", VLC_VAR_BOOL
);
478 var_SetBool( p_input
, "can-rate", false );
480 var_Create( p_input
, "can-rewind", VLC_VAR_BOOL
);
481 var_SetBool( p_input
, "can-rewind", false );
483 var_Create( p_input
, "can-record", VLC_VAR_BOOL
);
484 var_SetBool( p_input
, "can-record", false ); /* Fixed later*/
486 var_Create( p_input
, "record", VLC_VAR_BOOL
);
487 var_SetBool( p_input
, "record", false );
489 var_Create( p_input
, "teletext-es", VLC_VAR_INTEGER
);
490 var_SetInteger( p_input
, "teletext-es", -1 );
492 var_Create( p_input
, "signal-quality", VLC_VAR_FLOAT
);
493 var_SetFloat( p_input
, "signal-quality", -1 );
495 var_Create( p_input
, "signal-strength", VLC_VAR_FLOAT
);
496 var_SetFloat( p_input
, "signal-strength", -1 );
498 var_Create( p_input
, "program-scrambled", VLC_VAR_BOOL
);
499 var_SetBool( p_input
, "program-scrambled", false );
501 var_Create( p_input
, "cache", VLC_VAR_FLOAT
);
502 var_SetFloat( p_input
, "cache", 0.0 );
505 var_Create( p_input
, "input-record-native", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
508 var_Create( p_input
, "access", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
509 var_Create( p_input
, "demux", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
510 var_Create( p_input
, "stream-filter", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
513 var_Create( p_input
, "meta-title", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
514 var_Create( p_input
, "meta-author", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
515 var_Create( p_input
, "meta-artist", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
516 var_Create( p_input
, "meta-genre", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
517 var_Create( p_input
, "meta-copyright", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
518 var_Create( p_input
, "meta-description", VLC_VAR_STRING
|VLC_VAR_DOINHERIT
);
519 var_Create( p_input
, "meta-date", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
520 var_Create( p_input
, "meta-url", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
523 /*****************************************************************************
524 * Callbacks managements:
525 *****************************************************************************/
526 static void InputAddCallbacks( input_thread_t
*p_input
,
527 const vlc_input_callback_t
*p_callbacks
)
530 for( i
= 0; p_callbacks
[i
].psz_name
!= NULL
; i
++ )
531 var_AddCallback( p_input
,
532 p_callbacks
[i
].psz_name
,
533 p_callbacks
[i
].callback
, NULL
);
536 static void InputDelCallbacks( input_thread_t
*p_input
,
537 const vlc_input_callback_t
*p_callbacks
)
540 for( i
= 0; p_callbacks
[i
].psz_name
!= NULL
; i
++ )
541 var_DelCallback( p_input
,
542 p_callbacks
[i
].psz_name
,
543 p_callbacks
[i
].callback
, NULL
);
546 /*****************************************************************************
548 *****************************************************************************/
549 static int StateCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
550 vlc_value_t oldval
, vlc_value_t newval
,
553 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
554 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
556 if( newval
.i_int
== PLAYING_S
|| newval
.i_int
== PAUSE_S
)
558 input_ControlPush( p_input
, INPUT_CONTROL_SET_STATE
, &newval
);
565 static int RateCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
566 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
568 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
569 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
); VLC_UNUSED(psz_cmd
);
571 newval
.i_int
= INPUT_RATE_DEFAULT
/ newval
.f_float
;
572 input_ControlPush( p_input
, INPUT_CONTROL_SET_RATE
, &newval
);
577 static int PositionCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
578 vlc_value_t oldval
, vlc_value_t newval
,
581 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
582 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
584 if( !strcmp( psz_cmd
, "position-offset" ) )
586 float f_position
= var_GetFloat( p_input
, "position" ) + newval
.f_float
;
587 if( f_position
< 0.0 )
589 else if( f_position
> 1.0 )
591 var_SetFloat( p_this
, "position", f_position
);
595 /* Update "length" for better intf behavour */
596 const mtime_t i_length
= var_GetTime( p_input
, "length" );
597 if( i_length
> 0 && newval
.f_float
>= 0.0 && newval
.f_float
<= 1.0 )
601 val
.i_time
= i_length
* newval
.f_float
;
602 var_Change( p_input
, "time", VLC_VAR_SETVALUE
, &val
, NULL
);
606 input_ControlPush( p_input
, INPUT_CONTROL_SET_POSITION
, &newval
);
611 static int TimeCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
612 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
614 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
615 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
617 if( !strcmp( psz_cmd
, "time-offset" ) )
619 mtime_t i_time
= var_GetTime( p_input
, "time" ) + newval
.i_time
;
622 var_SetTime( p_this
, "time", i_time
);
626 /* Update "position" for better intf behavour */
627 const mtime_t i_length
= var_GetTime( p_input
, "length" );
628 if( i_length
> 0 && newval
.i_time
>= 0 && newval
.i_time
<= i_length
)
632 val
.f_float
= (double)newval
.i_time
/(double)i_length
;
633 var_Change( p_input
, "position", VLC_VAR_SETVALUE
, &val
, NULL
);
635 * Notify the intf that a new event has been occurred.
636 * XXX this is a bit hackish but it's the only way to do it now.
638 var_SetInteger( p_input
, "intf-event", INPUT_EVENT_POSITION
);
642 input_ControlPush( p_input
, INPUT_CONTROL_SET_TIME
, &newval
);
647 static int ProgramCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
648 vlc_value_t oldval
, vlc_value_t newval
,
651 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
652 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
654 input_ControlPush( p_input
, INPUT_CONTROL_SET_PROGRAM
, &newval
);
659 static int TitleCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
660 vlc_value_t oldval
, vlc_value_t newval
,
663 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
664 vlc_value_t val
, count
;
665 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
667 if( !strcmp( psz_cmd
, "next-title" ) )
669 input_ControlPush( p_input
, INPUT_CONTROL_SET_TITLE_NEXT
, NULL
);
671 val
.i_int
= var_GetInteger( p_input
, "title" ) + 1;
672 var_Change( p_input
, "title", VLC_VAR_CHOICESCOUNT
, &count
, NULL
);
673 if( val
.i_int
< count
.i_int
)
674 var_Change( p_input
, "title", VLC_VAR_SETVALUE
, &val
, NULL
);
676 else if( !strcmp( psz_cmd
, "prev-title" ) )
678 input_ControlPush( p_input
, INPUT_CONTROL_SET_TITLE_PREV
, NULL
);
680 val
.i_int
= var_GetInteger( p_input
, "title" ) - 1;
682 var_Change( p_input
, "title", VLC_VAR_SETVALUE
, &val
, NULL
);
686 input_ControlPush( p_input
, INPUT_CONTROL_SET_TITLE
, &newval
);
692 static int SeekpointCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
693 vlc_value_t oldval
, vlc_value_t newval
,
696 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
697 vlc_value_t val
, count
;
698 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
700 if( !strcmp( psz_cmd
, "next-chapter" ) )
702 input_ControlPush( p_input
, INPUT_CONTROL_SET_SEEKPOINT_NEXT
, NULL
);
704 val
.i_int
= var_GetInteger( p_input
, "chapter" ) + 1;
705 var_Change( p_input
, "chapter", VLC_VAR_CHOICESCOUNT
, &count
, NULL
);
706 if( val
.i_int
< count
.i_int
)
707 var_Change( p_input
, "chapter", VLC_VAR_SETVALUE
, &val
, NULL
);
709 else if( !strcmp( psz_cmd
, "prev-chapter" ) )
711 input_ControlPush( p_input
, INPUT_CONTROL_SET_SEEKPOINT_PREV
, NULL
);
713 val
.i_int
= var_GetInteger( p_input
, "chapter" ) - 1;
715 var_Change( p_input
, "chapter", VLC_VAR_SETVALUE
, &val
, NULL
);
719 input_ControlPush( p_input
, INPUT_CONTROL_SET_SEEKPOINT
, &newval
);
725 static int NavigationCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
726 vlc_value_t oldval
, vlc_value_t newval
,
729 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
731 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
);
733 /* Issue a title change */
734 val
.i_int
= (intptr_t)p_data
;
735 input_ControlPush( p_input
, INPUT_CONTROL_SET_TITLE
, &val
);
737 var_Change( p_input
, "title", VLC_VAR_SETVALUE
, &val
, NULL
);
739 /* And a chapter change */
740 input_ControlPush( p_input
, INPUT_CONTROL_SET_SEEKPOINT
, &newval
);
742 var_Change( p_input
, "chapter", VLC_VAR_SETVALUE
, &newval
, NULL
);
747 static int ESCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
748 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
750 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
751 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
753 if( newval
.i_int
< 0 )
757 if( !strcmp( psz_cmd
, "audio-es" ) )
759 else if( !strcmp( psz_cmd
, "video-es" ) )
761 else if( !strcmp( psz_cmd
, "spu-es" ) )
766 input_ControlPush( p_input
, INPUT_CONTROL_SET_ES
, &v
);
770 input_ControlPush( p_input
, INPUT_CONTROL_SET_ES
, &newval
);
776 static int EsDelayCallback ( vlc_object_t
*p_this
, char const *psz_cmd
,
777 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
779 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
780 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
782 if( !strcmp( psz_cmd
, "audio-delay" ) )
784 input_ControlPush( p_input
, INPUT_CONTROL_SET_AUDIO_DELAY
, &newval
);
786 else if( !strcmp( psz_cmd
, "spu-delay" ) )
788 input_ControlPush( p_input
, INPUT_CONTROL_SET_SPU_DELAY
, &newval
);
793 static int BookmarkCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
794 vlc_value_t oldval
, vlc_value_t newval
,
797 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
798 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
800 input_ControlPush( p_input
, INPUT_CONTROL_SET_BOOKMARK
, &newval
);
805 static int RecordCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
806 vlc_value_t oldval
, vlc_value_t newval
,
809 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
810 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
812 input_ControlPush( p_input
, INPUT_CONTROL_SET_RECORD_STATE
, &newval
);
817 static int FrameNextCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
818 vlc_value_t oldval
, vlc_value_t newval
,
821 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
822 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
825 input_ControlPush( p_input
, INPUT_CONTROL_SET_FRAME_NEXT
, NULL
);