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>
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
);
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
, "frame-next", VLC_VAR_VOID
);
146 var_Create( p_input
, "position", VLC_VAR_FLOAT
);
147 var_Create( p_input
, "position-offset", VLC_VAR_FLOAT
);
149 var_Change( p_input
, "position", VLC_VAR_SETVALUE
, &val
, NULL
);
152 var_Create( p_input
, "time", VLC_VAR_TIME
);
153 var_Create( p_input
, "time-offset", VLC_VAR_TIME
); /* relative */
155 var_Change( p_input
, "time", VLC_VAR_SETVALUE
, &val
, NULL
);
158 var_Create( p_input
, "bookmark", VLC_VAR_INTEGER
| VLC_VAR_HASCHOICE
|
160 val
.psz_string
= _("Bookmark");
161 var_Change( p_input
, "bookmark", VLC_VAR_SETTEXT
, &val
, NULL
);
164 var_Create( p_input
, "program", VLC_VAR_INTEGER
| VLC_VAR_HASCHOICE
|
166 var_Get( p_input
, "program", &val
);
168 var_Change( p_input
, "program", VLC_VAR_DELCHOICE
, &val
, NULL
);
169 text
.psz_string
= _("Program");
170 var_Change( p_input
, "program", VLC_VAR_SETTEXT
, &text
, NULL
);
173 var_Create( p_input
, "programs", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
174 text
.psz_string
= _("Programs");
175 var_Change( p_input
, "programs", VLC_VAR_SETTEXT
, &text
, NULL
);
178 var_Create( p_input
, "title", VLC_VAR_INTEGER
| VLC_VAR_HASCHOICE
);
179 text
.psz_string
= _("Title");
180 var_Change( p_input
, "title", VLC_VAR_SETTEXT
, &text
, NULL
);
183 var_Create( p_input
, "chapter", VLC_VAR_INTEGER
| VLC_VAR_HASCHOICE
);
184 text
.psz_string
= _("Chapter");
185 var_Change( p_input
, "chapter", VLC_VAR_SETTEXT
, &text
, NULL
);
187 /* Navigation The callback is added after */
188 var_Create( p_input
, "navigation", VLC_VAR_VARIABLE
| VLC_VAR_HASCHOICE
);
189 text
.psz_string
= _("Navigation");
190 var_Change( p_input
, "navigation", VLC_VAR_SETTEXT
, &text
, NULL
);
193 var_Create( p_input
, "audio-delay", VLC_VAR_TIME
);
194 val
.i_time
= INT64_C(1000) * var_GetInteger( p_input
, "audio-desync" );
195 var_Change( p_input
, "audio-delay", VLC_VAR_SETVALUE
, &val
, NULL
);
196 var_Create( p_input
, "spu-delay", VLC_VAR_TIME
);
198 var_Change( p_input
, "spu-delay", VLC_VAR_SETVALUE
, &val
, NULL
);
201 var_Create( p_input
, "video-es", VLC_VAR_INTEGER
| VLC_VAR_HASCHOICE
);
202 text
.psz_string
= _("Video Track");
203 var_Change( p_input
, "video-es", VLC_VAR_SETTEXT
, &text
, NULL
);
206 var_Create( p_input
, "audio-es", VLC_VAR_INTEGER
| VLC_VAR_HASCHOICE
);
207 text
.psz_string
= _("Audio Track");
208 var_Change( p_input
, "audio-es", VLC_VAR_SETTEXT
, &text
, NULL
);
211 var_Create( p_input
, "spu-es", VLC_VAR_INTEGER
| VLC_VAR_HASCHOICE
);
212 text
.psz_string
= _("Subtitles Track");
213 var_Change( p_input
, "spu-es", VLC_VAR_SETTEXT
, &text
, NULL
);
215 /* Special read only objects variables for intf */
216 var_Create( p_input
, "bookmarks", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
218 var_Create( p_input
, "length", VLC_VAR_TIME
);
220 var_Change( p_input
, "length", VLC_VAR_SETVALUE
, &val
, NULL
);
222 var_Create( p_input
, "bit-rate", VLC_VAR_INTEGER
);
223 var_Create( p_input
, "sample-rate", VLC_VAR_INTEGER
);
225 if( !p_input
->b_preparsing
)
227 /* Special "intf-event" variable. */
228 var_Create( p_input
, "intf-event", VLC_VAR_INTEGER
);
232 * XXX we put callback only in non preparsing mode. We need to create the variable
233 * unless someone want to check all var_Get/var_Change return value ... */
234 if( !p_input
->b_preparsing
)
235 InputAddCallbacks( p_input
, p_input_callbacks
);
238 /*****************************************************************************
239 * input_ControlVarStop:
240 *****************************************************************************/
241 void input_ControlVarStop( input_thread_t
*p_input
)
243 if( !p_input
->b_preparsing
)
244 InputDelCallbacks( p_input
, p_input_callbacks
);
246 if( p_input
->p
->i_title
> 0 )
248 char name
[sizeof("title ") + 5 ];
251 InputDelCallbacks( p_input
, p_input_navigation_callbacks
);
252 InputDelCallbacks( p_input
, p_input_title_callbacks
);
254 for( i
= 0; i
< p_input
->p
->i_title
; i
++ )
256 snprintf( name
, sizeof(name
), "title %2i", i
);
257 var_DelCallback( p_input
, name
, NavigationCallback
, (void *)(intptr_t)i
);
262 /*****************************************************************************
263 * input_ControlVarNavigation:
264 * Create all remaining control object variables
265 *****************************************************************************/
266 void input_ControlVarNavigation( input_thread_t
*p_input
)
268 vlc_value_t val
, text
;
271 /* Create more command variables */
272 if( p_input
->p
->i_title
> 1 )
274 var_Create( p_input
, "next-title", VLC_VAR_VOID
);
275 text
.psz_string
= _("Next title");
276 var_Change( p_input
, "next-title", VLC_VAR_SETTEXT
, &text
, NULL
);
277 var_AddCallback( p_input
, "next-title", TitleCallback
, NULL
);
279 var_Create( p_input
, "prev-title", VLC_VAR_VOID
);
280 text
.psz_string
= _("Previous title");
281 var_Change( p_input
, "prev-title", VLC_VAR_SETTEXT
, &text
, NULL
);
282 var_AddCallback( p_input
, "prev-title", TitleCallback
, NULL
);
285 /* Create title and navigation */
286 val
.psz_string
= malloc( sizeof("title ") + 5 );
287 if( !val
.psz_string
)
290 for( i
= 0; i
< p_input
->p
->i_title
; i
++ )
292 vlc_value_t val2
, text2
;
295 /* Add Navigation entries */
296 sprintf( val
.psz_string
, "title %2i", i
);
297 var_Destroy( p_input
, val
.psz_string
);
298 var_Create( p_input
, val
.psz_string
,
299 VLC_VAR_INTEGER
|VLC_VAR_HASCHOICE
|VLC_VAR_ISCOMMAND
);
300 var_AddCallback( p_input
, val
.psz_string
,
301 NavigationCallback
, (void *)(intptr_t)i
);
303 char psz_length
[MSTRTIME_MAX_SIZE
+ sizeof(" []")] = "";
304 if( p_input
->p
->title
[i
]->i_length
> 0 )
306 strcpy( psz_length
, " [" );
307 secstotimestr( &psz_length
[2], p_input
->p
->title
[i
]->i_length
/ CLOCK_FREQ
);
308 strcat( psz_length
, "]" );
311 if( p_input
->p
->title
[i
]->psz_name
== NULL
||
312 *p_input
->p
->title
[i
]->psz_name
== '\0' )
314 if( asprintf( &text
.psz_string
, _("Title %i%s"),
315 i
+ p_input
->p
->i_title_offset
, psz_length
) == -1 )
320 if( asprintf( &text
.psz_string
, "%s%s",
321 p_input
->p
->title
[i
]->psz_name
, psz_length
) == -1 )
324 var_Change( p_input
, "navigation", VLC_VAR_ADDCHOICE
, &val
, &text
);
326 /* Add title choice */
328 var_Change( p_input
, "title", VLC_VAR_ADDCHOICE
, &val2
, &text
);
330 free( text
.psz_string
);
332 for( j
= 0; j
< p_input
->p
->title
[i
]->i_seekpoint
; j
++ )
336 if( p_input
->p
->title
[i
]->seekpoint
[j
]->psz_name
== NULL
||
337 *p_input
->p
->title
[i
]->seekpoint
[j
]->psz_name
== '\0' )
340 if( asprintf( &text2
.psz_string
, _("Chapter %i"),
341 j
+ p_input
->p
->i_seekpoint_offset
) == -1 )
347 strdup( p_input
->p
->title
[i
]->seekpoint
[j
]->psz_name
);
350 var_Change( p_input
, val
.psz_string
, VLC_VAR_ADDCHOICE
,
352 free( text2
.psz_string
);
356 free( val
.psz_string
);
359 /*****************************************************************************
360 * input_ControlVarTitle:
361 * Create all variables for a title
362 *****************************************************************************/
363 void input_ControlVarTitle( input_thread_t
*p_input
, int i_title
)
365 input_title_t
*t
= p_input
->p
->title
[i_title
];
369 /* Create/Destroy command variables */
370 if( t
->i_seekpoint
<= 1 )
372 var_Destroy( p_input
, "next-chapter" );
373 var_Destroy( p_input
, "prev-chapter" );
375 else if( var_Type( p_input
, "next-chapter" ) == 0 )
377 var_Create( p_input
, "next-chapter", VLC_VAR_VOID
);
378 text
.psz_string
= _("Next chapter");
379 var_Change( p_input
, "next-chapter", VLC_VAR_SETTEXT
, &text
, NULL
);
380 var_AddCallback( p_input
, "next-chapter", SeekpointCallback
, NULL
);
382 var_Create( p_input
, "prev-chapter", VLC_VAR_VOID
);
383 text
.psz_string
= _("Previous chapter");
384 var_Change( p_input
, "prev-chapter", VLC_VAR_SETTEXT
, &text
, NULL
);
385 var_AddCallback( p_input
, "prev-chapter", SeekpointCallback
, NULL
);
388 /* Build chapter list */
389 var_Change( p_input
, "chapter", VLC_VAR_CLEARCHOICES
, NULL
, NULL
);
390 for( i
= 0; i
< t
->i_seekpoint
; i
++ )
395 if( t
->seekpoint
[i
]->psz_name
== NULL
||
396 *t
->seekpoint
[i
]->psz_name
== '\0' )
399 if( asprintf( &text
.psz_string
, _("Chapter %i"),
400 i
+ p_input
->p
->i_seekpoint_offset
) == -1 )
405 text
.psz_string
= strdup( t
->seekpoint
[i
]->psz_name
);
408 var_Change( p_input
, "chapter", VLC_VAR_ADDCHOICE
, &val
, &text
);
409 free( text
.psz_string
);
413 /*****************************************************************************
414 * input_ConfigVarInit:
415 * Create all config object variables
416 *****************************************************************************/
417 void input_ConfigVarInit ( input_thread_t
*p_input
)
419 /* Create Object Variables for private use only */
421 if( !p_input
->b_preparsing
)
423 var_Create( p_input
, "video", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
424 var_Create( p_input
, "audio", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
425 var_Create( p_input
, "spu", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
427 var_Create( p_input
, "audio-track", VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
428 var_Create( p_input
, "sub-track", VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
430 var_Create( p_input
, "audio-language",
431 VLC_VAR_STRING
|VLC_VAR_DOINHERIT
);
432 var_Create( p_input
, "sub-language",
433 VLC_VAR_STRING
|VLC_VAR_DOINHERIT
);
435 var_Create( p_input
, "audio-track-id",
436 VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
437 var_Create( p_input
, "sub-track-id",
438 VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
440 var_Create( p_input
, "sub-file", VLC_VAR_FILE
| VLC_VAR_DOINHERIT
);
441 var_Create( p_input
, "sub-autodetect-file", VLC_VAR_BOOL
|
443 var_Create( p_input
, "sub-autodetect-path", VLC_VAR_STRING
|
445 var_Create( p_input
, "sub-autodetect-fuzzy", VLC_VAR_INTEGER
|
448 var_Create( p_input
, "sout", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
449 var_Create( p_input
, "sout-all", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
450 var_Create( p_input
, "sout-audio", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
451 var_Create( p_input
, "sout-video", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
452 var_Create( p_input
, "sout-spu", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
453 var_Create( p_input
, "sout-keep", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
455 var_Create( p_input
, "input-repeat",
456 VLC_VAR_INTEGER
|VLC_VAR_DOINHERIT
);
457 var_Create( p_input
, "start-time", VLC_VAR_FLOAT
|VLC_VAR_DOINHERIT
);
458 var_Create( p_input
, "stop-time", VLC_VAR_FLOAT
|VLC_VAR_DOINHERIT
);
459 var_Create( p_input
, "run-time", VLC_VAR_FLOAT
|VLC_VAR_DOINHERIT
);
460 var_Create( p_input
, "input-fast-seek", VLC_VAR_BOOL
|VLC_VAR_DOINHERIT
);
462 var_Create( p_input
, "input-slave",
463 VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
465 var_Create( p_input
, "audio-desync",
466 VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
467 var_Create( p_input
, "cr-average",
468 VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
469 var_Create( p_input
, "clock-synchro",
470 VLC_VAR_INTEGER
| VLC_VAR_DOINHERIT
);
473 var_Create( p_input
, "can-seek", VLC_VAR_BOOL
);
474 var_SetBool( p_input
, "can-seek", true ); /* Fixed later*/
476 var_Create( p_input
, "can-pause", VLC_VAR_BOOL
);
477 var_SetBool( p_input
, "can-pause", true ); /* Fixed later*/
479 var_Create( p_input
, "can-rate", VLC_VAR_BOOL
);
480 var_SetBool( p_input
, "can-rate", false );
482 var_Create( p_input
, "can-rewind", VLC_VAR_BOOL
);
483 var_SetBool( p_input
, "can-rewind", false );
485 var_Create( p_input
, "can-record", VLC_VAR_BOOL
);
486 var_SetBool( p_input
, "can-record", false ); /* Fixed later*/
488 var_Create( p_input
, "record", VLC_VAR_BOOL
);
489 var_SetBool( p_input
, "record", false );
491 var_Create( p_input
, "teletext-es", VLC_VAR_INTEGER
);
492 var_SetInteger( p_input
, "teletext-es", -1 );
494 var_Create( p_input
, "signal-quality", VLC_VAR_FLOAT
);
495 var_SetFloat( p_input
, "signal-quality", -1 );
497 var_Create( p_input
, "signal-strength", VLC_VAR_FLOAT
);
498 var_SetFloat( p_input
, "signal-strength", -1 );
500 var_Create( p_input
, "program-scrambled", VLC_VAR_BOOL
);
501 var_SetBool( p_input
, "program-scrambled", false );
503 var_Create( p_input
, "cache", VLC_VAR_FLOAT
);
504 var_SetFloat( p_input
, "cache", 0.0 );
507 var_Create( p_input
, "input-record-native", VLC_VAR_BOOL
| VLC_VAR_DOINHERIT
);
510 var_Create( p_input
, "access", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
511 var_Create( p_input
, "demux", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
512 var_Create( p_input
, "stream-filter", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
515 var_Create( p_input
, "meta-title", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
516 var_Create( p_input
, "meta-author", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
517 var_Create( p_input
, "meta-artist", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
518 var_Create( p_input
, "meta-genre", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
519 var_Create( p_input
, "meta-copyright", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
520 var_Create( p_input
, "meta-description", VLC_VAR_STRING
|VLC_VAR_DOINHERIT
);
521 var_Create( p_input
, "meta-date", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
522 var_Create( p_input
, "meta-url", VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
525 /*****************************************************************************
526 * Callbacks managements:
527 *****************************************************************************/
528 static void InputAddCallbacks( input_thread_t
*p_input
,
529 const vlc_input_callback_t
*p_callbacks
)
532 for( i
= 0; p_callbacks
[i
].psz_name
!= NULL
; i
++ )
533 var_AddCallback( p_input
,
534 p_callbacks
[i
].psz_name
,
535 p_callbacks
[i
].callback
, NULL
);
538 static void InputDelCallbacks( input_thread_t
*p_input
,
539 const vlc_input_callback_t
*p_callbacks
)
542 for( i
= 0; p_callbacks
[i
].psz_name
!= NULL
; i
++ )
543 var_DelCallback( p_input
,
544 p_callbacks
[i
].psz_name
,
545 p_callbacks
[i
].callback
, NULL
);
548 /*****************************************************************************
550 *****************************************************************************/
551 static int StateCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
552 vlc_value_t oldval
, vlc_value_t newval
,
555 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
556 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
558 if( newval
.i_int
== PLAYING_S
|| newval
.i_int
== PAUSE_S
)
560 input_ControlPush( p_input
, INPUT_CONTROL_SET_STATE
, &newval
);
567 static int RateCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
568 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
570 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
571 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
); VLC_UNUSED(psz_cmd
);
573 newval
.i_int
= INPUT_RATE_DEFAULT
/ newval
.f_float
;
574 input_ControlPush( p_input
, INPUT_CONTROL_SET_RATE
, &newval
);
579 static int PositionCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
580 vlc_value_t oldval
, vlc_value_t newval
,
583 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
584 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
586 if( !strcmp( psz_cmd
, "position-offset" ) )
588 float f_position
= var_GetFloat( p_input
, "position" ) + newval
.f_float
;
589 if( f_position
< 0.0 )
591 else if( f_position
> 1.0 )
593 var_SetFloat( p_this
, "position", f_position
);
597 /* Update "length" for better intf behavour */
598 const mtime_t i_length
= var_GetTime( p_input
, "length" );
599 if( i_length
> 0 && newval
.f_float
>= 0.0 && newval
.f_float
<= 1.0 )
603 val
.i_time
= i_length
* newval
.f_float
;
604 var_Change( p_input
, "time", VLC_VAR_SETVALUE
, &val
, NULL
);
608 input_ControlPush( p_input
, INPUT_CONTROL_SET_POSITION
, &newval
);
613 static int TimeCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
614 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
616 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
617 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
619 if( !strcmp( psz_cmd
, "time-offset" ) )
621 mtime_t i_time
= var_GetTime( p_input
, "time" ) + newval
.i_time
;
624 var_SetTime( p_this
, "time", i_time
);
628 /* Update "position" for better intf behavour */
629 const mtime_t i_length
= var_GetTime( p_input
, "length" );
630 if( i_length
> 0 && newval
.i_time
>= 0 && newval
.i_time
<= i_length
)
634 val
.f_float
= (double)newval
.i_time
/(double)i_length
;
635 var_Change( p_input
, "position", VLC_VAR_SETVALUE
, &val
, NULL
);
639 input_ControlPush( p_input
, INPUT_CONTROL_SET_TIME
, &newval
);
644 static int ProgramCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
645 vlc_value_t oldval
, vlc_value_t newval
,
648 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
649 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
651 input_ControlPush( p_input
, INPUT_CONTROL_SET_PROGRAM
, &newval
);
656 static int TitleCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
657 vlc_value_t oldval
, vlc_value_t newval
,
660 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
661 vlc_value_t val
, count
;
662 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
664 if( !strcmp( psz_cmd
, "next-title" ) )
666 input_ControlPush( p_input
, INPUT_CONTROL_SET_TITLE_NEXT
, NULL
);
668 val
.i_int
= var_GetInteger( p_input
, "title" ) + 1;
669 var_Change( p_input
, "title", VLC_VAR_CHOICESCOUNT
, &count
, NULL
);
670 if( val
.i_int
< count
.i_int
)
671 var_Change( p_input
, "title", VLC_VAR_SETVALUE
, &val
, NULL
);
673 else if( !strcmp( psz_cmd
, "prev-title" ) )
675 input_ControlPush( p_input
, INPUT_CONTROL_SET_TITLE_PREV
, NULL
);
677 val
.i_int
= var_GetInteger( p_input
, "title" ) - 1;
679 var_Change( p_input
, "title", VLC_VAR_SETVALUE
, &val
, NULL
);
683 input_ControlPush( p_input
, INPUT_CONTROL_SET_TITLE
, &newval
);
689 static int SeekpointCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
690 vlc_value_t oldval
, vlc_value_t newval
,
693 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
694 vlc_value_t val
, count
;
695 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
697 if( !strcmp( psz_cmd
, "next-chapter" ) )
699 input_ControlPush( p_input
, INPUT_CONTROL_SET_SEEKPOINT_NEXT
, NULL
);
701 val
.i_int
= var_GetInteger( p_input
, "chapter" ) + 1;
702 var_Change( p_input
, "chapter", VLC_VAR_CHOICESCOUNT
, &count
, NULL
);
703 if( val
.i_int
< count
.i_int
)
704 var_Change( p_input
, "chapter", VLC_VAR_SETVALUE
, &val
, NULL
);
706 else if( !strcmp( psz_cmd
, "prev-chapter" ) )
708 input_ControlPush( p_input
, INPUT_CONTROL_SET_SEEKPOINT_PREV
, NULL
);
710 val
.i_int
= var_GetInteger( p_input
, "chapter" ) - 1;
712 var_Change( p_input
, "chapter", VLC_VAR_SETVALUE
, &val
, NULL
);
716 input_ControlPush( p_input
, INPUT_CONTROL_SET_SEEKPOINT
, &newval
);
722 static int NavigationCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
723 vlc_value_t oldval
, vlc_value_t newval
,
726 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
728 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
);
730 /* Issue a title change */
731 val
.i_int
= (intptr_t)p_data
;
732 input_ControlPush( p_input
, INPUT_CONTROL_SET_TITLE
, &val
);
734 var_Change( p_input
, "title", VLC_VAR_SETVALUE
, &val
, NULL
);
736 /* And a chapter change */
737 input_ControlPush( p_input
, INPUT_CONTROL_SET_SEEKPOINT
, &newval
);
739 var_Change( p_input
, "chapter", VLC_VAR_SETVALUE
, &newval
, NULL
);
744 static int ESCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
745 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
747 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
748 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
750 if( newval
.i_int
< 0 )
754 if( !strcmp( psz_cmd
, "audio-es" ) )
756 else if( !strcmp( psz_cmd
, "video-es" ) )
758 else if( !strcmp( psz_cmd
, "spu-es" ) )
763 input_ControlPush( p_input
, INPUT_CONTROL_SET_ES
, &v
);
767 input_ControlPush( p_input
, INPUT_CONTROL_SET_ES
, &newval
);
773 static int EsDelayCallback ( vlc_object_t
*p_this
, char const *psz_cmd
,
774 vlc_value_t oldval
, vlc_value_t newval
, void *p_data
)
776 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
777 VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
779 if( !strcmp( psz_cmd
, "audio-delay" ) )
781 input_ControlPush( p_input
, INPUT_CONTROL_SET_AUDIO_DELAY
, &newval
);
783 else if( !strcmp( psz_cmd
, "spu-delay" ) )
785 input_ControlPush( p_input
, INPUT_CONTROL_SET_SPU_DELAY
, &newval
);
790 static int BookmarkCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
791 vlc_value_t oldval
, vlc_value_t newval
,
794 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
795 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
797 input_ControlPush( p_input
, INPUT_CONTROL_SET_BOOKMARK
, &newval
);
802 static int RecordCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
803 vlc_value_t oldval
, vlc_value_t newval
,
806 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
807 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
809 input_ControlPush( p_input
, INPUT_CONTROL_SET_RECORD_STATE
, &newval
);
814 static int FrameNextCallback( vlc_object_t
*p_this
, char const *psz_cmd
,
815 vlc_value_t oldval
, vlc_value_t newval
,
818 input_thread_t
*p_input
= (input_thread_t
*)p_this
;
819 VLC_UNUSED(psz_cmd
); VLC_UNUSED(oldval
); VLC_UNUSED(p_data
);
822 input_ControlPush( p_input
, INPUT_CONTROL_SET_FRAME_NEXT
, NULL
);