]> git.sesse.net Git - vlc/blob - src/control/vlm.c
Add const to char * in vlm
[vlc] / src / control / vlm.c
1 /*****************************************************************************
2  * vlm.c: libvlc new API VLM handling functions
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@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 "libvlc_internal.h"
25
26 #include <vlc/libvlc.h>
27 #include <vlc_es.h>
28 #include <vlc_input.h>
29 #include <vlc_vlm.h>
30
31 #if 0
32 /* local function to be used in libvlc_vlm_show_media only */
33 static char* recurse_answer( char* psz_prefix, vlm_message_t *p_answer ) {
34     char* psz_childprefix;
35     char* psz_response="";
36     char* response_tmp;
37     int i;
38     vlm_message_t *aw_child, **paw_child;
39
40     asprintf( &psz_childprefix, "%s%s.", psz_prefix, p_answer->psz_name );
41
42     if ( p_answer->i_child )
43     {
44         paw_child = p_answer->child;
45         aw_child = *( paw_child );
46         for( i = 0; i < p_answer->i_child; i++ )
47         {
48             asprintf( &response_tmp, "%s%s%s:%s\n",
49                       psz_response, psz_prefix, aw_child->psz_name,
50                       aw_child->psz_value );
51             free( psz_response );
52             psz_response = response_tmp;
53             if ( aw_child->i_child )
54             {
55                 asprintf(&response_tmp, "%s%s", psz_response,
56                          recurse_answer(psz_childprefix, aw_child));
57                 free( psz_response );
58                 psz_response = response_tmp;
59             }
60             paw_child++;
61             aw_child = *( paw_child );
62         }
63     }
64     free( psz_childprefix );
65     return psz_response;
66 }
67
68 char* libvlc_vlm_show_media( libvlc_instance_t *p_instance, char *psz_name,
69                              libvlc_exception_t *p_exception )
70 {
71     char *psz_message;
72     vlm_message_t *answer;
73     char *psz_response;
74
75     CHECK_VLM;
76 #ifdef ENABLE_VLM
77     asprintf( &psz_message, "show %s", psz_name );
78     asprintf( &psz_response, "", psz_name );
79     vlm_ExecuteCommand( p_instance->p_vlm, psz_message, &answer );
80     if( answer->psz_value )
81     {
82         libvlc_exception_raise( p_exception, "Unable to call show %s: %s",
83                                 psz_name, answer->psz_value );
84     }
85     else
86     {
87         if ( answer->child )
88         {
89             psz_response = recurse_answer( "", answer );
90         }
91     }
92     free( psz_message );
93     return(psz_response );
94 #else
95     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
96     return NULL;
97 #endif
98 }
99 #else
100
101 char* libvlc_vlm_show_media( libvlc_instance_t *p_instance,
102                              const char *psz_name,
103                              libvlc_exception_t *p_exception )
104 {
105 #ifdef ENABLE_VLM
106     (void)p_instance;
107     /* FIXME is it needed ? */
108     libvlc_exception_raise( p_exception, "Unable to call show %s", psz_name );
109     return NULL;
110 #else
111     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
112     return VLC_EGENERIC;
113 #endif
114 }
115
116 #endif /* 0 */
117
118 static int libvlc_vlm_init( libvlc_instance_t *p_instance,
119                             libvlc_exception_t *p_exception )
120 {
121 #ifdef ENABLE_VLM
122     if( !p_instance->p_vlm )
123         p_instance->p_vlm = vlm_New( p_instance->p_libvlc_int );
124 #else
125     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
126     return VLC_EGENERIC;
127 #endif
128
129     if( !p_instance->p_vlm )
130     {
131         libvlc_exception_raise( p_exception,
132                                 "Unable to create VLM." );
133         return VLC_EGENERIC;
134     }
135     return VLC_SUCCESS;
136 }
137 #define VLM_RET(p,ret) do {                                     \
138     if( libvlc_vlm_init( p_instance, p_exception ) ) return ret;\
139     (p) = p_instance->p_vlm;                                    \
140   } while(0)
141 #define VLM(p) VLM_RET(p,)
142
143 static vlm_media_instance_t *libvlc_vlm_get_media_instance( libvlc_instance_t *p_instance,
144                                                             const char *psz_name,
145                                                             int i_minstance_idx,
146                                                             libvlc_exception_t *p_exception )
147 {
148 #ifdef ENABLE_VLM
149     vlm_t *p_vlm;
150     vlm_media_instance_t **pp_minstance;
151     vlm_media_instance_t *p_minstance;
152     int i_minstance;
153     int64_t id;
154
155     VLM_RET(p_vlm, NULL);
156
157     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
158         vlm_Control( p_vlm, VLM_GET_MEDIA_INSTANCES, id, &pp_minstance, &i_minstance ) )
159     {
160         libvlc_exception_raise( p_exception, "Unable to get %s instances", psz_name );
161         return NULL;
162     }
163     p_minstance = NULL;
164     if( i_minstance_idx >= 0 && i_minstance_idx < i_minstance )
165     {
166         p_minstance = pp_minstance[i_minstance_idx];
167         TAB_REMOVE( i_minstance, pp_minstance, p_minstance );
168     }
169     while( i_minstance > 0 )
170         vlm_media_instance_Delete( pp_minstance[--i_minstance] );
171     TAB_CLEAN( i_minstance, pp_minstance );
172     return p_minstance;
173 #else
174     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
175     return VLC_EGENERIC;
176 #endif
177 }
178
179
180 void libvlc_vlm_release( libvlc_instance_t *p_instance, libvlc_exception_t *p_exception)
181 {
182 #ifdef ENABLE_VLM
183     vlm_t *p_vlm;
184
185     VLM(p_vlm);
186
187     vlm_Delete( p_vlm );
188 #else
189     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
190     return VLC_EGENERIC;
191 #endif
192 }
193
194 void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance,
195                                const char *psz_name,
196                                const char *psz_input,
197                                const char *psz_output, int i_options,
198                                const char * const *ppsz_options,
199                                int b_enabled, int b_loop,
200                                libvlc_exception_t *p_exception )
201 {
202 #ifdef ENABLE_VLM
203     vlm_t *p_vlm;
204     vlm_media_t m;
205     int n;
206
207     VLM(p_vlm);
208
209     vlm_media_Init( &m );
210     m.psz_name = strdup( psz_name );
211     m.b_enabled = b_enabled;
212     m.b_vod = false;
213     m.broadcast.b_loop = b_loop;
214     if( psz_input )
215         TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
216     if( psz_output )
217         m.psz_output = strdup( psz_output );
218     for( n = 0; n < i_options; n++ )
219         TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );
220
221     n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
222     vlm_media_Clean( &m );
223     if( n )
224         libvlc_exception_raise( p_exception, "Media %s creation failed", psz_name );
225 #else
226     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
227     return VLC_EGENERIC;
228 #endif
229 }
230
231 void libvlc_vlm_add_vod( libvlc_instance_t *p_instance, const char *psz_name,
232                          const char *psz_input, int i_options,
233                          const char * const *ppsz_options, int b_enabled,
234                          const char *psz_mux, libvlc_exception_t *p_exception )
235 {
236 #ifdef ENABLE_VLM
237     vlm_t *p_vlm;
238     vlm_media_t m;
239     int n;
240
241     VLM(p_vlm);
242
243     vlm_media_Init( &m );
244     m.psz_name = strdup( psz_name );
245     m.b_enabled = b_enabled;
246     m.b_vod = true;
247     m.vod.psz_mux = psz_mux ? strdup( psz_mux ) : NULL;
248     if( psz_input )
249         TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
250     for( n = 0; n < i_options; n++ )
251         TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );
252
253     n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
254     vlm_media_Clean( &m );
255     if( n )
256         libvlc_exception_raise( p_exception, "Media %s creation failed", psz_name );
257 #else
258     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
259     return VLC_EGENERIC;
260 #endif
261 }
262
263 void libvlc_vlm_del_media( libvlc_instance_t *p_instance, const char *psz_name,
264                            libvlc_exception_t *p_exception )
265 {
266 #ifdef ENABLE_VLM
267     vlm_t *p_vlm;
268     int64_t id;
269
270     VLM(p_vlm);
271
272     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
273         vlm_Control( p_vlm, VLM_DEL_MEDIA, id ) )
274     {
275         libvlc_exception_raise( p_exception, "Unable to delete %s", psz_name );
276     }
277 #else
278     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
279     return VLC_EGENERIC;
280 #endif
281 }
282
283 #define VLM_CHANGE(psz_error, code ) do {   \
284     vlm_media_t *p_media;   \
285     vlm_t *p_vlm;           \
286     int64_t id;             \
287     VLM(p_vlm);             \
288     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||    \
289         vlm_Control( p_vlm, VLM_GET_MEDIA, id, &p_media ) ) {       \
290         libvlc_exception_raise( p_exception, psz_error, psz_name ); \
291         return;             \
292     }                       \
293     if( !p_media ) goto error;                                      \
294                             \
295     code;                   \
296                             \
297     if( vlm_Control( p_vlm, VLM_CHANGE_MEDIA, p_media ) ) {         \
298         vlm_media_Delete( p_media );                                \
299         goto error;         \
300     }                       \
301     vlm_media_Delete( p_media );                                    \
302     return;                 \
303   error:                    \
304     libvlc_exception_raise( p_exception, psz_error, psz_name );\
305   } while(0)
306
307 void libvlc_vlm_set_enabled( libvlc_instance_t *p_instance,
308                              const char *psz_name, int b_enabled,
309                              libvlc_exception_t *p_exception )
310 {
311 #ifdef ENABLE_VLM
312 #define VLM_CHANGE_CODE { p_media->b_enabled = b_enabled; }
313     VLM_CHANGE( "Unable to delete %s", VLM_CHANGE_CODE );
314 #undef VLM_CHANGE_CODE
315 #else
316     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
317     return VLC_EGENERIC;
318 #endif
319 }
320
321 void libvlc_vlm_set_loop( libvlc_instance_t *p_instance, const char *psz_name,
322                           int b_loop, libvlc_exception_t *p_exception )
323 {
324 #ifdef ENABLE_VLM
325 #define VLM_CHANGE_CODE { p_media->broadcast.b_loop = b_loop; }
326     VLM_CHANGE( "Unable to change %s loop property", VLM_CHANGE_CODE );
327 #undef VLM_CHANGE_CODE
328 #else
329     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
330     return VLC_EGENERIC;
331 #endif
332 }
333
334 void libvlc_vlm_set_mux( libvlc_instance_t *p_instance, const char *psz_name,
335                          const char *psz_mux, libvlc_exception_t *p_exception )
336 {
337 #ifdef ENABLE_VLM
338 #define VLM_CHANGE_CODE { if( p_media->b_vod ) { \
339                             free( p_media->vod.psz_mux ); \
340                             p_media->vod.psz_mux = psz_mux ? strdup( psz_mux ) : NULL; \
341                           } }
342     VLM_CHANGE( "Unable to change %s mux property", VLM_CHANGE_CODE );
343 #undef VLM_CHANGE_CODE
344 #else
345     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
346     return VLC_EGENERIC;
347 #endif
348 }
349
350 void libvlc_vlm_set_output( libvlc_instance_t *p_instance,
351                             const char *psz_name, const char *psz_output,
352                             libvlc_exception_t *p_exception )
353 {
354 #ifdef ENABLE_VLM
355 #define VLM_CHANGE_CODE { free( p_media->psz_output ); \
356                           p_media->psz_output = strdup( psz_output ); }
357     VLM_CHANGE( "Unable to change %s output property", VLM_CHANGE_CODE );
358 #undef VLM_CHANGE_CODE
359 #else
360     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
361     return VLC_EGENERIC;
362 #endif
363 }
364
365 void libvlc_vlm_set_input( libvlc_instance_t *p_instance,
366                            const char *psz_name, const char *psz_input,
367                            libvlc_exception_t *p_exception )
368 {
369 #ifdef ENABLE_VLM
370 #define VLM_CHANGE_CODE { while( p_media->i_input > 0 ) \
371                             free( p_media->ppsz_input[--p_media->i_input] );\
372                           TAB_APPEND( p_media->i_input, p_media->ppsz_input, strdup(psz_input) ); }
373     VLM_CHANGE( "Unable to change %s input property", VLM_CHANGE_CODE );
374 #undef VLM_CHANGE_CODE
375 #else
376     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
377     return VLC_EGENERIC;
378 #endif
379 }
380
381 void libvlc_vlm_add_input( libvlc_instance_t *p_instance,
382                            const char *psz_name, const char *psz_input,
383                            libvlc_exception_t *p_exception )
384 {
385 #ifdef ENABLE_VLM
386 #define VLM_CHANGE_CODE { TAB_APPEND( p_media->i_input, p_media->ppsz_input, strdup(psz_input) ); }
387     VLM_CHANGE( "Unable to change %s input property", VLM_CHANGE_CODE );
388 #undef VLM_CHANGE_CODE
389 #else
390     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
391     return VLC_EGENERIC;
392 #endif
393 }
394
395 void libvlc_vlm_change_media( libvlc_instance_t *p_instance,
396                               const char *psz_name, const char *psz_input,
397                               const char *psz_output, int i_options,
398                               const char * const *ppsz_options, int b_enabled,
399                               int b_loop, libvlc_exception_t *p_exception )
400 {
401 #ifdef ENABLE_VLM
402 #define VLM_CHANGE_CODE { int n;        \
403     p_media->b_enabled = b_enabled;     \
404     p_media->broadcast.b_loop = b_loop; \
405     while( p_media->i_input > 0 )       \
406         free( p_media->ppsz_input[--p_media->i_input] );    \
407     if( psz_input )                     \
408         TAB_APPEND( p_media->i_input, p_media->ppsz_input, strdup(psz_input) ); \
409     free( p_media->psz_output );        \
410     p_media->psz_output = psz_output ? strdup( psz_output ) : NULL; \
411     while( p_media->i_option > 0 )     \
412         free( p_media->ppsz_option[--p_media->i_option] );        \
413     for( n = 0; n < i_options; n++ )    \
414         TAB_APPEND( p_media->i_option, p_media->ppsz_option, strdup(ppsz_options[n]) );   \
415   }
416     VLM_CHANGE( "Unable to change %s properties", VLM_CHANGE_CODE );
417 #undef VLM_CHANGE_CODE
418 #else
419     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
420     return VLC_EGENERIC;
421 #endif
422 }
423
424 void libvlc_vlm_play_media( libvlc_instance_t *p_instance,
425                             const char *psz_name,
426                             libvlc_exception_t *p_exception )
427 {
428 #ifdef ENABLE_VLM
429     vlm_t *p_vlm;
430     int64_t id;
431
432     VLM(p_vlm);
433
434     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
435         vlm_Control( p_vlm, VLM_START_MEDIA_BROADCAST_INSTANCE, id, NULL, 0 ) )
436     {
437         libvlc_exception_raise( p_exception, "Unable to play %s", psz_name );
438     }
439 #else
440     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
441     return VLC_EGENERIC;
442 #endif
443 }
444
445 void libvlc_vlm_stop_media( libvlc_instance_t *p_instance,
446                             const char *psz_name,
447                             libvlc_exception_t *p_exception )
448 {
449 #ifdef ENABLE_VLM
450     vlm_t *p_vlm;
451     int64_t id;
452
453     VLM(p_vlm);
454
455     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
456         vlm_Control( p_vlm, VLM_STOP_MEDIA_INSTANCE, id, NULL ) )
457     {
458         libvlc_exception_raise( p_exception, "Unable to stop %s", psz_name );
459     }
460 #else
461     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
462     return VLC_EGENERIC;
463 #endif
464 }
465
466 void libvlc_vlm_pause_media( libvlc_instance_t *p_instance,
467                              const char *psz_name,
468                              libvlc_exception_t *p_exception )
469 {
470 #ifdef ENABLE_VLM
471     vlm_t *p_vlm;
472     int64_t id;
473
474     VLM(p_vlm);
475
476     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
477         vlm_Control( p_vlm, VLM_PAUSE_MEDIA_INSTANCE, id, NULL ) )
478     {
479         libvlc_exception_raise( p_exception, "Unable to pause %s", psz_name );
480     }
481 #else
482     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
483     return VLC_EGENERIC;
484 #endif
485 }
486
487 void libvlc_vlm_seek_media( libvlc_instance_t *p_instance,
488                             const char *psz_name, float f_percentage,
489                             libvlc_exception_t *p_exception )
490 {
491 #ifdef ENABLE_VLM
492     vlm_t *p_vlm;
493     int64_t id;
494
495     VLM(p_vlm);
496
497     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
498         vlm_Control( p_vlm, VLM_SET_MEDIA_INSTANCE_POSITION, id, NULL, f_percentage ) )
499     {
500         libvlc_exception_raise( p_exception, "Unable to seek %s to %f", psz_name, f_percentage );
501     }
502 #else
503     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
504     return VLC_EGENERIC;
505 #endif
506 }
507
508 float libvlc_vlm_get_media_instance_position( libvlc_instance_t *p_instance,
509                                               const char *psz_name,
510                                               int i_instance,
511                                               libvlc_exception_t *p_exception )
512 {
513 #ifdef ENABLE_VLM
514     float result = -1;
515     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
516                                         i_instance, p_exception );
517     if( p_mi )
518     {
519         result = p_mi->d_position;
520         vlm_media_instance_Delete( p_mi );
521         return result;
522     }
523     libvlc_exception_raise( p_exception, "Unable to get position attribute" );
524     return result;
525 #else
526     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
527     return VLC_EGENERIC;
528 #endif
529 }
530
531 int libvlc_vlm_get_media_instance_time( libvlc_instance_t *p_instance,
532                                         const char *psz_name, int i_instance,
533                                         libvlc_exception_t *p_exception )
534 {
535 #ifdef ENABLE_VLM
536     int result = -1;
537     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
538                                         i_instance, p_exception );
539     if( p_mi )
540     {
541         result = p_mi->i_time;
542         vlm_media_instance_Delete( p_mi );
543         return result;
544     }
545     libvlc_exception_raise( p_exception, "Unable to get time attribute" );
546     return result;
547 #else
548     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
549     return VLC_EGENERIC;
550 #endif
551 }
552
553 int libvlc_vlm_get_media_instance_length( libvlc_instance_t *p_instance,
554                                           const char *psz_name,
555                                           int i_instance,
556                                           libvlc_exception_t *p_exception )
557 {
558 #ifdef ENABLE_VLM
559     int result = -1;
560     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
561                                         i_instance, p_exception );
562     if( p_mi )
563     {
564         result = p_mi->i_length;
565         vlm_media_instance_Delete( p_mi );
566         return result;
567     }
568     libvlc_exception_raise( p_exception, "Unable to get length attribute" );
569     return result;
570 #else
571     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
572     return VLC_EGENERIC;
573 #endif
574 }
575
576 int libvlc_vlm_get_media_instance_rate( libvlc_instance_t *p_instance,
577                                         const char *psz_name, int i_instance,
578                                         libvlc_exception_t *p_exception )
579 {
580 #ifdef ENABLE_VLM
581     int result = -1;
582     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
583                                         i_instance, p_exception );
584     if( p_mi )
585     {
586         result = p_mi->i_rate;
587         vlm_media_instance_Delete( p_mi );
588         return result;
589     }
590     libvlc_exception_raise( p_exception, "Unable to get rate attribute" );
591     return result;
592 #else
593     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
594     return VLC_EGENERIC;
595 #endif
596 }
597
598 int libvlc_vlm_get_media_instance_title( libvlc_instance_t *p_instance,
599                                          const char *psz_name, int i_instance,
600                                          libvlc_exception_t *p_exception )
601 {
602 #ifdef ENABLE_VLM
603     int result = 0;
604     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
605                                         i_instance, p_exception );
606     if( p_mi )
607     {
608         vlm_media_instance_Delete( p_mi );
609         return result;
610     }
611     libvlc_exception_raise( p_exception, "Unable to get title attribute" );
612     return result;
613 #else
614     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
615     return VLC_EGENERIC;
616 #endif
617 }
618
619 int libvlc_vlm_get_media_instance_chapter( libvlc_instance_t *p_instance,
620                                            const char *psz_name,
621                                            int i_instance,
622                                            libvlc_exception_t *p_exception )
623 {
624 #ifdef ENABLE_VLM
625     int result = 0;
626     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
627                                         i_instance, p_exception );
628     if( p_mi )
629     {
630         vlm_media_instance_Delete( p_mi );
631         return result;
632     }
633     libvlc_exception_raise( p_exception, "Unable to get chapter attribute" );
634     return result;
635 #else
636     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
637     return VLC_EGENERIC;
638 #endif
639 }
640
641 int libvlc_vlm_get_media_instance_seekable( libvlc_instance_t *p_instance,
642                                             const char *psz_name,
643                                             int i_instance,
644                                             libvlc_exception_t *p_exception )
645 {
646 #ifdef ENABLE_VLM
647     bool result = 0;
648     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
649                                         i_instance, p_exception );
650     if( p_mi )
651     {
652         vlm_media_instance_Delete( p_mi );
653         return result;
654     }
655     libvlc_exception_raise( p_exception, "Unable to get seekable attribute" );
656     return result;
657 #else
658     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
659     return VLC_EGENERIC;
660 #endif
661 }