]> git.sesse.net Git - vlc/blob - src/input/control.c
Added a INPUT_GET_VIDEO_FPS (get the fps of the main video, should works with
[vlc] / src / input / control.c
1 /*****************************************************************************
2  * control.c
3  *****************************************************************************
4  * Copyright (C) 1999-2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #include <vlc/vlc.h>
25
26 #include <stdio.h>
27 #include <stdlib.h>
28
29 #include "input_internal.h"
30 #include "vlc_playlist.h"
31
32
33 static void UpdateBookmarksOption( input_thread_t * );
34 static void NotifyPlaylist( input_thread_t * );
35
36 /****************************************************************************
37  * input_Control
38  ****************************************************************************/
39 /**
40  * Control function for inputs.
41  * \param p_input input handle
42  * \param i_query query type
43  * \return VLC_SUCCESS if ok
44  */
45 int input_Control( input_thread_t *p_input, int i_query, ...  )
46 {
47     va_list args;
48     int     i_result;
49
50     va_start( args, i_query );
51     i_result = input_vaControl( p_input, i_query, args );
52     va_end( args );
53
54     return i_result;
55 }
56
57 int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
58 {
59     seekpoint_t *p_bkmk, ***ppp_bkmk;
60     int i_bkmk = 0;
61     int *pi_bkmk;
62
63     int i_int, *pi_int;
64     double f, *pf;
65     int64_t i_64, *pi_64;
66
67     char *psz;
68     vlc_value_t val;
69
70     switch( i_query )
71     {
72         case INPUT_GET_POSITION:
73             pf = (double*)va_arg( args, double * );
74             *pf = var_GetFloat( p_input, "position" );
75             return VLC_SUCCESS;
76
77         case INPUT_SET_POSITION:
78             f = (double)va_arg( args, double );
79             return var_SetFloat( p_input, "position", f );
80
81         case INPUT_GET_LENGTH:
82             pi_64 = (int64_t*)va_arg( args, int64_t * );
83             *pi_64 = var_GetTime( p_input, "length" );
84             return VLC_SUCCESS;
85
86         case INPUT_GET_TIME:
87             pi_64 = (int64_t*)va_arg( args, int64_t * );
88             *pi_64 = var_GetTime( p_input, "time" );
89             return VLC_SUCCESS;
90
91         case INPUT_SET_TIME:
92             i_64 = (int64_t)va_arg( args, int64_t );
93             return var_SetTime( p_input, "time", i_64 );
94
95         case INPUT_GET_RATE:
96             pi_int = (int*)va_arg( args, int * );
97             *pi_int = var_GetInteger( p_input, "rate" );
98             return VLC_SUCCESS;
99
100         case INPUT_SET_RATE:
101             i_int = (int)va_arg( args, int );
102             return var_SetInteger( p_input, "rate", i_int );
103
104         case INPUT_GET_STATE:
105             pi_int = (int*)va_arg( args, int * );
106             *pi_int = var_GetInteger( p_input, "state" );
107             return VLC_SUCCESS;
108
109         case INPUT_SET_STATE:
110             i_int = (int)va_arg( args, int );
111             return var_SetInteger( p_input, "state", i_int );
112
113         case INPUT_GET_AUDIO_DELAY:
114             pi_64 = (int64_t*)va_arg( args, int64_t * );
115             *pi_64 = var_GetTime( p_input, "audio-delay" );
116             return VLC_SUCCESS;
117
118         case INPUT_GET_SPU_DELAY:
119             pi_64 = (int64_t*)va_arg( args, int64_t * );
120             *pi_64 = var_GetTime( p_input, "spu-delay" );
121             return VLC_SUCCESS;
122
123         case INPUT_SET_AUDIO_DELAY:
124             i_64 = (int64_t)va_arg( args, int64_t );
125             return var_SetTime( p_input, "audio-delay", i_64 );
126
127         case INPUT_SET_SPU_DELAY:
128             i_64 = (int64_t)va_arg( args, int64_t );
129             return var_SetTime( p_input, "spu-delay", i_64 );
130
131         case INPUT_ADD_INFO:
132         {
133             /* FIXME : Impossible to use input_ItemAddInfo because of
134              * the ... problem ? */
135             char *psz_cat = (char *)va_arg( args, char * );
136             char *psz_name = (char *)va_arg( args, char * );
137             char *psz_format = (char *)va_arg( args, char * );
138
139             info_category_t *p_cat;
140             info_t *p_info;
141             int i;
142
143             vlc_mutex_lock( &p_input->p->input.p_item->lock );
144             for( i = 0; i < p_input->p->input.p_item->i_categories; i++ )
145             {
146                 if( !strcmp( p_input->p->input.p_item->pp_categories[i]->psz_name,
147                              psz_cat ) ) break;
148             }
149
150             if( i == p_input->p->input.p_item->i_categories )
151             {
152                 p_cat = malloc( sizeof( info_category_t ) );
153                 if( !p_cat )
154                 {
155                     vlc_mutex_unlock( &p_input->p->input.p_item->lock );
156                     return VLC_EGENERIC;
157                 }
158                 p_cat->psz_name = strdup( psz_cat );
159                 p_cat->i_infos = 0;
160                 p_cat->pp_infos = NULL;
161                 INSERT_ELEM( p_input->p->input.p_item->pp_categories,
162                              p_input->p->input.p_item->i_categories,
163                              p_input->p->input.p_item->i_categories, p_cat );
164             }
165
166             p_cat = p_input->p->input.p_item->pp_categories[i];
167
168             for( i = 0; i < p_cat->i_infos; i++ )
169             {
170                 if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )
171                 {
172                     if( p_cat->pp_infos[i]->psz_value )
173                         free( p_cat->pp_infos[i]->psz_value );
174                     break;
175                 }
176             }
177
178             if( i == p_cat->i_infos )
179             {
180                 p_info = malloc( sizeof( info_t ) );
181                 if( !p_info )
182                 {
183                     vlc_mutex_unlock( &p_input->p->input.p_item->lock );
184                     return VLC_EGENERIC;
185                 }
186
187                 INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos,
188                              p_cat->i_infos, p_info );
189                 p_info->psz_name = strdup( psz_name );
190             }
191
192             p_info = p_cat->pp_infos[i];
193             if( vasprintf( &p_info->psz_value, psz_format, args ) == -1 )
194                 p_info->psz_value = NULL;
195
196             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
197
198             if( !p_input->b_preparsing )
199                 NotifyPlaylist( p_input );
200         }
201         return VLC_SUCCESS;
202
203         case INPUT_DEL_INFO:
204         {
205             char *psz_cat = (char *)va_arg( args, char * );
206             char *psz_name = (char *)va_arg( args, char * );
207
208             info_category_t *p_cat = NULL;
209             int i_cat;
210             int i;
211
212             vlc_mutex_lock( &p_input->p->input.p_item->lock );
213             for( i_cat = 0; i_cat < p_input->p->input.p_item->i_categories; i_cat++ )
214             {
215                 if( !strcmp( p_input->p->input.p_item->pp_categories[i_cat]->psz_name,
216                              psz_cat ) )
217                 {
218                     p_cat = p_input->p->input.p_item->pp_categories[i_cat];
219                     break;
220                 }
221             }
222             if( p_cat == NULL )
223             {
224                 vlc_mutex_unlock( &p_input->p->input.p_item->lock );
225                 return VLC_EGENERIC;
226             }
227
228             if( psz_name )
229             {
230                 /* Remove a specific info */
231                 for( i = 0; i < p_cat->i_infos; i++ )
232                 {
233                     if( !strcmp( p_cat->pp_infos[i]->psz_name, psz_name ) )
234                     {
235                         free( p_cat->pp_infos[i]->psz_name );
236                         if( p_cat->pp_infos[i]->psz_value )
237                             free( p_cat->pp_infos[i]->psz_value );
238                         free( p_cat->pp_infos[i] );
239                         REMOVE_ELEM( p_cat->pp_infos, p_cat->i_infos, i );
240                         break;
241                     }
242                 }
243                 if( i >= p_cat->i_infos )
244                 {
245                     vlc_mutex_unlock( &p_input->p->input.p_item->lock );
246                     return VLC_EGENERIC;
247                 }
248             }
249             else
250             {
251                 /* Remove the complete categorie */
252                 for( i = 0; i < p_cat->i_infos; i++ )
253                 {
254                     free( p_cat->pp_infos[i]->psz_name );
255                     if( p_cat->pp_infos[i]->psz_value )
256                         free( p_cat->pp_infos[i]->psz_value );
257                     free( p_cat->pp_infos[i] );
258                 }
259                 if( p_cat->pp_infos )
260                     free( p_cat->pp_infos );
261                 REMOVE_ELEM( p_input->p->input.p_item->pp_categories, p_input->p->input.p_item->i_categories, i_cat );
262             }
263             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
264
265             if( !p_input->b_preparsing )
266                 NotifyPlaylist( p_input );
267
268             return VLC_SUCCESS;
269         }
270
271
272         case INPUT_GET_INFO:
273         {
274             char *psz_cat = (char *)va_arg( args, char * );
275             char *psz_name = (char *)va_arg( args, char * );
276             char **ppsz_value = (char **)va_arg( args, char ** );
277             int i_ret = VLC_EGENERIC;
278             *ppsz_value = NULL;
279
280             *ppsz_value = input_ItemGetInfo( p_input->p->input.p_item,
281                                                   psz_cat, psz_name );
282             return i_ret;
283         }
284
285         case INPUT_SET_NAME:
286         {
287             char *psz_name = (char *)va_arg( args, char * );
288
289             if( !psz_name ) return VLC_EGENERIC;
290
291             vlc_mutex_lock( &p_input->p->input.p_item->lock );
292             if( p_input->p->input.p_item->psz_name )
293                 free( p_input->p->input.p_item->psz_name );
294             p_input->p->input.p_item->psz_name = strdup( psz_name );
295             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
296
297             if( !p_input->b_preparsing )
298                 NotifyPlaylist( p_input );
299
300             return VLC_SUCCESS;
301         }
302
303         case INPUT_ADD_BOOKMARK:
304             p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * );
305             p_bkmk = vlc_seekpoint_Duplicate( p_bkmk );
306
307             vlc_mutex_lock( &p_input->p->input.p_item->lock );
308             if( !p_bkmk->psz_name )
309             {
310                  if( asprintf( &p_bkmk->psz_name, _("Bookmark %i"),
311                                p_input->p->i_bookmark ) == -1 )
312                      p_bkmk->psz_name = NULL;
313             }
314
315             TAB_APPEND( p_input->p->i_bookmark, p_input->p->bookmark, p_bkmk );
316
317             /* Reflect the changes on the object var */
318             var_Change( p_input, "bookmark", VLC_VAR_CLEARCHOICES, 0, 0 );
319             {
320                 vlc_value_t val, text;
321                 int i;
322
323                 for( i = 0; i < p_input->p->i_bookmark; i++ )
324                 {
325                     val.i_int = i;
326                     text.psz_string = p_input->p->bookmark[i]->psz_name;
327                     var_Change( p_input, "bookmark", VLC_VAR_ADDCHOICE,
328                                 &val, &text );
329                 }
330             }
331             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
332
333             UpdateBookmarksOption( p_input );
334
335             return VLC_SUCCESS;
336
337         case INPUT_CHANGE_BOOKMARK:
338             p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * );
339             i_bkmk = (int)va_arg( args, int );
340
341             vlc_mutex_lock( &p_input->p->input.p_item->lock );
342             if( i_bkmk < p_input->p->i_bookmark )
343             {
344                 vlc_value_t val, text;
345                 int i;
346
347                 p_input->p->bookmark[i_bkmk] = p_bkmk;
348
349                 /* Reflect the changes on the object var */
350                 var_Change( p_input, "bookmark", VLC_VAR_CLEARCHOICES, 0, 0 );
351                 for( i = 0; i < p_input->p->i_bookmark; i++ )
352                 {
353                     val.i_int = i;
354                     text.psz_string = p_input->p->bookmark[i]->psz_name;
355                     var_Change( p_input, "bookmark", VLC_VAR_ADDCHOICE,
356                                 &val, &text );
357                 }
358             }
359             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
360
361             UpdateBookmarksOption( p_input );
362
363             return VLC_SUCCESS;
364
365         case INPUT_DEL_BOOKMARK:
366             i_bkmk = (int)va_arg( args, int );
367
368             vlc_mutex_lock( &p_input->p->input.p_item->lock );
369             if( i_bkmk < p_input->p->i_bookmark )
370             {
371                 vlc_value_t val, text;
372                 int i;
373
374                 p_bkmk = p_input->p->bookmark[i_bkmk];
375                 TAB_REMOVE( p_input->p->i_bookmark, p_input->p->bookmark,
376                             p_bkmk );
377                 vlc_seekpoint_Delete( p_bkmk );
378
379                 /* Reflect the changes on the object var */
380                 var_Change( p_input, "bookmark", VLC_VAR_CLEARCHOICES, 0, 0 );
381                 for( i = 0; i < p_input->p->i_bookmark; i++ )
382                 {
383                     val.i_int = i;
384                     text.psz_string = p_input->p->bookmark[i]->psz_name;
385                     var_Change( p_input, "bookmark", VLC_VAR_ADDCHOICE,
386                                 &val, &text );
387                 }
388                 vlc_mutex_unlock( &p_input->p->input.p_item->lock );
389
390                 UpdateBookmarksOption( p_input );
391
392                 return VLC_SUCCESS;
393             }
394             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
395
396             return VLC_EGENERIC;
397
398         case INPUT_GET_BOOKMARKS:
399             ppp_bkmk = (seekpoint_t ***)va_arg( args, seekpoint_t *** );
400             pi_bkmk = (int *)va_arg( args, int * );
401
402             vlc_mutex_lock( &p_input->p->input.p_item->lock );
403             if( p_input->p->i_bookmark )
404             {
405                 int i;
406
407                 *pi_bkmk = p_input->p->i_bookmark;
408                 *ppp_bkmk = malloc( sizeof(seekpoint_t *) *
409                                     p_input->p->i_bookmark );
410                 for( i = 0; i < p_input->p->i_bookmark; i++ )
411                 {
412                     (*ppp_bkmk)[i] =
413                         vlc_seekpoint_Duplicate(p_input->p->bookmark[i]);
414                 }
415
416                 vlc_mutex_unlock( &p_input->p->input.p_item->lock );
417                 return VLC_SUCCESS;
418             }
419             else
420             {
421                 *ppp_bkmk = NULL;
422                 *pi_bkmk = 0;
423
424                 vlc_mutex_unlock( &p_input->p->input.p_item->lock );
425                 return VLC_EGENERIC;
426             }
427             break;
428
429         case INPUT_CLEAR_BOOKMARKS:
430
431             vlc_mutex_lock( &p_input->p->input.p_item->lock );
432             if( p_input->p->i_bookmark )
433             {
434                 int i;
435
436                 for( i = p_input->p->i_bookmark - 1; i >= 0; i-- )
437                 {
438                     p_bkmk = p_input->p->bookmark[i];
439                     TAB_REMOVE( p_input->p->i_bookmark, p_input->p->bookmark,
440                                 p_bkmk );
441                     vlc_seekpoint_Delete( p_bkmk );
442                 }
443                 var_Change( p_input, "bookmark", VLC_VAR_CLEARCHOICES, 0, 0 );
444             }
445             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
446
447             UpdateBookmarksOption( p_input );
448
449             return VLC_SUCCESS;
450
451         case INPUT_SET_BOOKMARK:
452             i_bkmk = (int)va_arg( args, int );
453
454             vlc_mutex_lock( &p_input->p->input.p_item->lock );
455             if( i_bkmk >= 0 && i_bkmk < p_input->p->i_bookmark )
456             {
457                 vlc_value_t pos;
458                 int i_ret;
459
460                 if( p_input->p->bookmark[i_bkmk]->i_time_offset != -1 )
461                 {
462                     pos.i_time = p_input->p->bookmark[i_bkmk]->i_time_offset;
463                     i_ret = var_Set( p_input, "time", pos );
464                 }
465                 else if( p_input->p->bookmark[i_bkmk]->i_byte_offset != -1 )
466                 {
467                     // don't crash on bookmarks in live streams
468                     if( stream_Size( p_input->p->input.p_stream ) == 0 )
469                     {
470                         vlc_mutex_unlock( &p_input->p->input.p_item->lock );
471                         return VLC_EGENERIC;
472                     }
473                     pos.f_float = !p_input->p->input.p_stream ? 0 :
474                         p_input->p->bookmark[i_bkmk]->i_byte_offset /
475                         stream_Size( p_input->p->input.p_stream );
476                     i_ret = var_Set( p_input, "position", pos );
477                 }
478                 else
479                 {
480                     pos.f_float = 0;
481                     i_ret = var_Set( p_input, "position", pos );
482                 }
483
484                 vlc_mutex_unlock( &p_input->p->input.p_item->lock );
485                 return i_ret;
486             }
487             else
488             {
489                 vlc_mutex_unlock( &p_input->p->input.p_item->lock );
490                 return VLC_EGENERIC;
491             }
492
493             break;
494
495         case INPUT_ADD_OPTION:
496         {
497             char *psz_option = (char *)va_arg( args, char * );
498             char *psz_value = (char *)va_arg( args, char * );
499             int i;
500
501             vlc_mutex_lock( &p_input->p->input.p_item->lock );
502             /* Check if option already exists */
503             for( i = 0; i < p_input->p->input.p_item->i_options; i++ )
504             {
505                 if( !strncmp( p_input->p->input.p_item->ppsz_options[i],
506                               psz_option, strlen( psz_option ) ) &&
507                     p_input->p->input.p_item->ppsz_options[i][strlen(psz_option)]
508                       == '=' )
509                 {
510                     free( p_input->p->input.p_item->ppsz_options[i] );
511                     break;
512                 }
513             }
514             if( i == p_input->p->input.p_item->i_options )
515             {
516                 p_input->p->input.p_item->i_options++;
517                 p_input->p->input.p_item->ppsz_options =
518                     realloc( p_input->p->input.p_item->ppsz_options,
519                              p_input->p->input.p_item->i_options *
520                              sizeof(char **) );
521             }
522
523             if( asprintf( &p_input->p->input.p_item->ppsz_options[i],
524                           "%s=%s", psz_option, psz_value ) == -1 )
525                 p_input->p->input.p_item->ppsz_options[i] = NULL;
526             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
527
528             return VLC_SUCCESS;
529         }
530
531         case INPUT_GET_BYTE_POSITION:
532             pi_64 = (int64_t*)va_arg( args, int64_t * );
533             *pi_64 = !p_input->p->input.p_stream ? 0 :
534                 stream_Tell( p_input->p->input.p_stream );
535             return VLC_SUCCESS;
536
537         case INPUT_SET_BYTE_SIZE:
538             pi_64 = (int64_t*)va_arg( args, int64_t * );
539             *pi_64 = !p_input->p->input.p_stream ? 0 :
540                 stream_Size( p_input->p->input.p_stream );
541             return VLC_SUCCESS;
542
543         case INPUT_GET_VIDEO_FPS:
544         {
545             int i;
546             pf = (double*)va_arg( args, double * );
547             vlc_mutex_lock( &p_input->p->input.p_item->lock );
548             *pf = p_input->p->input.f_fps;
549             for( i = 0; i < p_input->p->i_slave && *pf <= 0.001; i++ )
550                 *pf = p_input->p->slave[i]->f_fps;
551             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
552             return VLC_SUCCESS;
553         }
554
555         case INPUT_ADD_SLAVE:
556             psz = (char*)va_arg( args, char * );
557             if( psz && *psz )
558             {
559                 val.psz_string = strdup( psz );
560                 input_ControlPush( p_input, INPUT_CONTROL_ADD_SLAVE, &val );
561             }
562             return VLC_SUCCESS;
563
564         case INPUT_GET_ATTACHMENTS: /* arg1=input_attachment_t***, arg2=int*  res=can fail */
565         {
566             input_attachment_t ***ppp_attachment = (input_attachment_t***)va_arg( args, input_attachment_t *** );
567             int *pi_attachment = (int*)va_arg( args, int * );
568             int i;
569
570             vlc_mutex_lock( &p_input->p->input.p_item->lock );
571             if( p_input->p->i_attachment <= 0 )
572             {
573                 vlc_mutex_unlock( &p_input->p->input.p_item->lock );
574                 *ppp_attachment = NULL;
575                 *pi_attachment = 0;
576                 return VLC_EGENERIC;
577             }
578             *pi_attachment = p_input->p->i_attachment;
579             *ppp_attachment = malloc( sizeof(input_attachment_t**) * p_input->p->i_attachment );
580             for( i = 0; i < p_input->p->i_attachment; i++ )
581                 (*ppp_attachment)[i] = vlc_input_attachment_Duplicate( p_input->p->attachment[i] );
582
583             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
584             return VLC_SUCCESS;
585         }
586
587         case INPUT_GET_ATTACHMENT:  /* arg1=input_attachment_t**, arg2=char*  res=can fail */
588         {
589             input_attachment_t **pp_attachment = (input_attachment_t**)va_arg( args, input_attachment_t ** );
590             const char *psz_name = (const char*)va_arg( args, const char * );
591             int i;
592
593             vlc_mutex_lock( &p_input->p->input.p_item->lock );
594             for( i = 0; i < p_input->p->i_attachment; i++ )
595             {
596                 if( !strcmp( p_input->p->attachment[i]->psz_name, psz_name ) )
597                 {
598                     *pp_attachment = vlc_input_attachment_Duplicate( p_input->p->attachment[i] );
599                     vlc_mutex_unlock( &p_input->p->input.p_item->lock );
600                     return VLC_SUCCESS;
601                 }
602             }
603             *pp_attachment = NULL;
604             vlc_mutex_unlock( &p_input->p->input.p_item->lock );
605             return VLC_EGENERIC;
606         }
607
608
609         default:
610             msg_Err( p_input, "unknown query in input_vaControl" );
611             return VLC_EGENERIC;
612     }
613 }
614
615 static void NotifyPlaylist( input_thread_t *p_input )
616 {
617     playlist_t *p_playlist = pl_Yield( p_input );
618     var_SetInteger( p_playlist, "item-change",
619                     p_input->p->input.p_item->i_id );
620     pl_Release( p_input );
621 }
622
623 static void UpdateBookmarksOption( input_thread_t *p_input )
624 {
625     int i, i_len = 0;
626     char *psz_value = NULL, *psz_next = NULL;
627
628     vlc_mutex_lock( &p_input->p->input.p_item->lock );
629     for( i = 0; i < p_input->p->i_bookmark; i++ )
630     {
631         i_len += snprintf( NULL, 0, "{name=%s,bytes="I64Fd",time="I64Fd"}",
632                            p_input->p->bookmark[i]->psz_name,
633                            p_input->p->bookmark[i]->i_byte_offset,
634                            p_input->p->bookmark[i]->i_time_offset/1000000 );
635     }
636     for( i = 0; i < p_input->p->i_bookmark; i++ )
637     {
638         if( !i ) psz_value = psz_next = malloc( i_len + p_input->p->i_bookmark );
639
640         sprintf( psz_next, "{name=%s,bytes="I64Fd",time="I64Fd"}",
641                  p_input->p->bookmark[i]->psz_name,
642                  p_input->p->bookmark[i]->i_byte_offset,
643                  p_input->p->bookmark[i]->i_time_offset/1000000 );
644
645         psz_next += strlen( psz_next );
646         if( i < p_input->p->i_bookmark - 1)
647         {
648             *psz_next = ','; psz_next++;
649         }
650     }
651     vlc_mutex_unlock( &p_input->p->input.p_item->lock );
652
653     input_Control( p_input, INPUT_ADD_OPTION, "bookmarks",
654                    psz_value ? psz_value : "" );
655 }