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