]> git.sesse.net Git - vlc/blob - src/control/vlm.c
Document more VLM API's and expand define.
[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, char *psz_name,
102                              libvlc_exception_t *p_exception )
103 {
104 #ifdef ENABLE_VLM
105     (void)p_instance;
106     /* FIXME is it needed ? */
107     libvlc_exception_raise( p_exception, "Unable to call show %s", psz_name );
108     return NULL;
109 #else
110     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
111     return VLC_EGENERIC;
112 #endif
113 }
114
115 #endif /* 0 */
116
117 static int libvlc_vlm_init( libvlc_instance_t *p_instance,
118                             libvlc_exception_t *p_exception )
119 {
120 #ifdef ENABLE_VLM
121     if( !p_instance->p_vlm )
122         p_instance->p_vlm = vlm_New( p_instance->p_libvlc_int );
123 #else
124     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
125     return VLC_EGENERIC;
126 #endif
127
128     if( !p_instance->p_vlm )
129     {
130         libvlc_exception_raise( p_exception,
131                                 "Unable to create VLM." );
132         return VLC_EGENERIC;
133     }
134     return VLC_SUCCESS;
135 }
136 #define VLM_RET(p,ret) do {                                     \
137     if( libvlc_vlm_init( p_instance, p_exception ) ) return ret;\
138     (p) = p_instance->p_vlm;                                    \
139   } while(0)
140 #define VLM(p) VLM_RET(p,)
141
142 static vlm_media_instance_t *libvlc_vlm_get_media_instance( libvlc_instance_t *p_instance,
143                                                             char *psz_name, int i_minstance_idx,
144                                                             libvlc_exception_t *p_exception )
145 {
146 #ifdef ENABLE_VLM
147     vlm_t *p_vlm;
148     vlm_media_instance_t **pp_minstance;
149     vlm_media_instance_t *p_minstance;
150     int i_minstance;
151     int64_t id;
152
153     VLM_RET(p_vlm, NULL);
154
155     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
156         vlm_Control( p_vlm, VLM_GET_MEDIA_INSTANCES, id, &pp_minstance, &i_minstance ) )
157     {
158         libvlc_exception_raise( p_exception, "Unable to get %s instances", psz_name );
159         return NULL;
160     }
161     p_minstance = NULL;
162     if( i_minstance_idx >= 0 && i_minstance_idx < i_minstance )
163     {
164         p_minstance = pp_minstance[i_minstance_idx];
165         TAB_REMOVE( i_minstance, pp_minstance, p_minstance );
166     }
167     while( i_minstance > 0 )
168         vlm_media_instance_Delete( pp_minstance[--i_minstance] );
169     TAB_CLEAN( i_minstance, pp_minstance );
170     return p_minstance;
171 #else
172     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
173     return VLC_EGENERIC;
174 #endif
175 }
176
177
178 void libvlc_vlm_release( libvlc_instance_t *p_instance, libvlc_exception_t *p_exception)
179 {
180 #ifdef ENABLE_VLM
181     vlm_t *p_vlm;
182
183     VLM(p_vlm);
184
185     vlm_Delete( p_vlm );
186 #else
187     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
188     return VLC_EGENERIC;
189 #endif
190 }
191
192 void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance, char *psz_name,
193                                char *psz_input, char *psz_output,
194                                int i_options, char **ppsz_options,
195                                int b_enabled, int b_loop,
196                                libvlc_exception_t *p_exception )
197 {
198 #ifdef ENABLE_VLM
199     vlm_t *p_vlm;
200     vlm_media_t m;
201     int n;
202
203     VLM(p_vlm);
204
205     vlm_media_Init( &m );
206     m.psz_name = strdup( psz_name );
207     m.b_enabled = b_enabled;
208     m.b_vod = false;
209     m.broadcast.b_loop = b_loop;
210     if( psz_input )
211         TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
212     if( psz_output )
213         m.psz_output = strdup( psz_output );
214     for( n = 0; n < i_options; n++ )
215         TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );
216
217     n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
218     vlm_media_Clean( &m );
219     if( n )
220         libvlc_exception_raise( p_exception, "Media %s creation failed", psz_name );
221 #else
222     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
223     return VLC_EGENERIC;
224 #endif
225 }
226
227 void libvlc_vlm_add_vod( libvlc_instance_t *p_instance, char *psz_name,
228                          char *psz_input, int i_options,
229                          char **ppsz_options, int b_enabled,
230                          char *psz_mux, libvlc_exception_t *p_exception )
231 {
232 #ifdef ENABLE_VLM
233     vlm_t *p_vlm;
234     vlm_media_t m;
235     int n;
236
237     VLM(p_vlm);
238
239     vlm_media_Init( &m );
240     m.psz_name = strdup( psz_name );
241     m.b_enabled = b_enabled;
242     m.b_vod = true;
243     m.vod.psz_mux = psz_mux ? strdup( psz_mux ) : NULL;
244     if( psz_input )
245         TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
246     for( n = 0; n < i_options; n++ )
247         TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );
248
249     n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
250     vlm_media_Clean( &m );
251     if( n )
252         libvlc_exception_raise( p_exception, "Media %s creation failed", psz_name );
253 #else
254     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
255     return VLC_EGENERIC;
256 #endif
257 }
258
259 void libvlc_vlm_del_media( libvlc_instance_t *p_instance, char *psz_name,
260                            libvlc_exception_t *p_exception )
261 {
262 #ifdef ENABLE_VLM
263     vlm_t *p_vlm;
264     int64_t id;
265
266     VLM(p_vlm);
267
268     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
269         vlm_Control( p_vlm, VLM_DEL_MEDIA, id ) )
270     {
271         libvlc_exception_raise( p_exception, "Unable to delete %s", psz_name );
272     }
273 #else
274     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
275     return VLC_EGENERIC;
276 #endif
277 }
278
279 #define VLM_CHANGE(psz_error, code ) do {   \
280     vlm_media_t *p_media;   \
281     vlm_t *p_vlm;           \
282     int64_t id;             \
283     VLM(p_vlm);             \
284     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||    \
285         vlm_Control( p_vlm, VLM_GET_MEDIA, id, &p_media ) ) {       \
286         libvlc_exception_raise( p_exception, psz_error, psz_name ); \
287         return;             \
288     }                       \
289     if( !p_media ) goto error;                                      \
290                             \
291     code;                   \
292                             \
293     if( vlm_Control( p_vlm, VLM_CHANGE_MEDIA, p_media ) ) {         \
294         vlm_media_Delete( p_media );                                \
295         goto error;         \
296     }                       \
297     vlm_media_Delete( p_media );                                    \
298     return;                 \
299   error:                    \
300     libvlc_exception_raise( p_exception, psz_error, psz_name );\
301   } while(0)
302
303 void libvlc_vlm_set_enabled( libvlc_instance_t *p_instance, char *psz_name,
304                              int b_enabled, libvlc_exception_t *p_exception )
305 {
306 #ifdef ENABLE_VLM
307 #define VLM_CHANGE_CODE { p_media->b_enabled = b_enabled; }
308     VLM_CHANGE( "Unable to delete %s", VLM_CHANGE_CODE );
309 #undef VLM_CHANGE_CODE
310 #else
311     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
312     return VLC_EGENERIC;
313 #endif
314 }
315
316 void libvlc_vlm_set_loop( libvlc_instance_t *p_instance, char *psz_name,
317                           int b_loop, libvlc_exception_t *p_exception )
318 {
319 #ifdef ENABLE_VLM
320 #define VLM_CHANGE_CODE { p_media->broadcast.b_loop = b_loop; }
321     VLM_CHANGE( "Unable to change %s loop property", VLM_CHANGE_CODE );
322 #undef VLM_CHANGE_CODE
323 #else
324     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
325     return VLC_EGENERIC;
326 #endif
327 }
328
329 void libvlc_vlm_set_mux( libvlc_instance_t *p_instance, char *psz_name,
330                          char *psz_mux, libvlc_exception_t *p_exception )
331 {
332 #ifdef ENABLE_VLM
333 #define VLM_CHANGE_CODE { if( p_media->b_vod ) { \
334                             free( p_media->vod.psz_mux ); \
335                             p_media->vod.psz_mux = psz_mux ? strdup( psz_mux ) : NULL; \
336                           } }
337     VLM_CHANGE( "Unable to change %s mux property", VLM_CHANGE_CODE );
338 #undef VLM_CHANGE_CODE
339 #else
340     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
341     return VLC_EGENERIC;
342 #endif
343 }
344
345 void libvlc_vlm_set_output( libvlc_instance_t *p_instance, char *psz_name,
346                             char *psz_output,  libvlc_exception_t *p_exception )
347 {
348 #ifdef ENABLE_VLM
349 #define VLM_CHANGE_CODE { free( p_media->psz_output ); \
350                           p_media->psz_output = strdup( psz_output ); }
351     VLM_CHANGE( "Unable to change %s output property", VLM_CHANGE_CODE );
352 #undef VLM_CHANGE_CODE
353 #else
354     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
355     return VLC_EGENERIC;
356 #endif
357 }
358
359 void libvlc_vlm_set_input( libvlc_instance_t *p_instance, char *psz_name,
360                            char *psz_input,  libvlc_exception_t *p_exception )
361 {
362 #ifdef ENABLE_VLM
363 #define VLM_CHANGE_CODE { while( p_media->i_input > 0 ) \
364                             free( p_media->ppsz_input[--p_media->i_input] );\
365                           TAB_APPEND( p_media->i_input, p_media->ppsz_input, strdup(psz_input) ); }
366     VLM_CHANGE( "Unable to change %s input property", VLM_CHANGE_CODE );
367 #undef VLM_CHANGE_CODE
368 #else
369     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
370     return VLC_EGENERIC;
371 #endif
372 }
373
374 void libvlc_vlm_add_input( libvlc_instance_t *p_instance, char *psz_name,
375                            char *psz_input,  libvlc_exception_t *p_exception )
376 {
377 #ifdef ENABLE_VLM
378 #define VLM_CHANGE_CODE { TAB_APPEND( p_media->i_input, p_media->ppsz_input, strdup(psz_input) ); }
379     VLM_CHANGE( "Unable to change %s input property", VLM_CHANGE_CODE );
380 #undef VLM_CHANGE_CODE
381 #else
382     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
383     return VLC_EGENERIC;
384 #endif
385 }
386
387 void libvlc_vlm_change_media( libvlc_instance_t *p_instance, char *psz_name,
388                               char *psz_input, char *psz_output, int i_options,
389                               char **ppsz_options, int b_enabled, int b_loop,
390                               libvlc_exception_t *p_exception )
391 {
392 #ifdef ENABLE_VLM
393 #define VLM_CHANGE_CODE { int n;        \
394     p_media->b_enabled = b_enabled;     \
395     p_media->broadcast.b_loop = b_loop; \
396     while( p_media->i_input > 0 )       \
397         free( p_media->ppsz_input[--p_media->i_input] );    \
398     if( psz_input )                     \
399         TAB_APPEND( p_media->i_input, p_media->ppsz_input, strdup(psz_input) ); \
400     free( p_media->psz_output );        \
401     p_media->psz_output = psz_output ? strdup( psz_output ) : NULL; \
402     while( p_media->i_option > 0 )     \
403         free( p_media->ppsz_option[--p_media->i_option] );        \
404     for( n = 0; n < i_options; n++ )    \
405         TAB_APPEND( p_media->i_option, p_media->ppsz_option, strdup(ppsz_options[n]) );   \
406   }
407     VLM_CHANGE( "Unable to change %s properties", VLM_CHANGE_CODE );
408 #undef VLM_CHANGE_CODE
409 #else
410     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
411     return VLC_EGENERIC;
412 #endif
413 }
414
415 void libvlc_vlm_play_media( libvlc_instance_t *p_instance, char *psz_name,
416                             libvlc_exception_t *p_exception )
417 {
418 #ifdef ENABLE_VLM
419     vlm_t *p_vlm;
420     int64_t id;
421
422     VLM(p_vlm);
423
424     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
425         vlm_Control( p_vlm, VLM_START_MEDIA_BROADCAST_INSTANCE, id, NULL, 0 ) )
426     {
427         libvlc_exception_raise( p_exception, "Unable to play %s", psz_name );
428     }
429 #else
430     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
431     return VLC_EGENERIC;
432 #endif
433 }
434
435 void libvlc_vlm_stop_media( libvlc_instance_t *p_instance, char *psz_name,
436                             libvlc_exception_t *p_exception )
437 {
438 #ifdef ENABLE_VLM
439     vlm_t *p_vlm;
440     int64_t id;
441
442     VLM(p_vlm);
443
444     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
445         vlm_Control( p_vlm, VLM_STOP_MEDIA_INSTANCE, id, NULL ) )
446     {
447         libvlc_exception_raise( p_exception, "Unable to stop %s", psz_name );
448     }
449 #else
450     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
451     return VLC_EGENERIC;
452 #endif
453 }
454
455 void libvlc_vlm_pause_media( libvlc_instance_t *p_instance, char *psz_name,
456                             libvlc_exception_t *p_exception )
457 {
458 #ifdef ENABLE_VLM
459     vlm_t *p_vlm;
460     int64_t id;
461
462     VLM(p_vlm);
463
464     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
465         vlm_Control( p_vlm, VLM_PAUSE_MEDIA_INSTANCE, id, NULL ) )
466     {
467         libvlc_exception_raise( p_exception, "Unable to pause %s", psz_name );
468     }
469 #else
470     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
471     return VLC_EGENERIC;
472 #endif
473 }
474
475 void libvlc_vlm_seek_media( libvlc_instance_t *p_instance, char *psz_name,
476                             float f_percentage, libvlc_exception_t *p_exception )
477 {
478 #ifdef ENABLE_VLM
479     vlm_t *p_vlm;
480     int64_t id;
481
482     VLM(p_vlm);
483
484     if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
485         vlm_Control( p_vlm, VLM_SET_MEDIA_INSTANCE_POSITION, id, NULL, f_percentage ) )
486     {
487         libvlc_exception_raise( p_exception, "Unable to seek %s to %f", psz_name, f_percentage );
488     }
489 #else
490     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
491     return VLC_EGENERIC;
492 #endif
493 }
494
495 float libvlc_vlm_get_media_instance_position( libvlc_instance_t *p_instance,
496     char *psz_name, int i_instance, libvlc_exception_t *p_exception )
497 {
498 #ifdef ENABLE_VLM
499     float result = -1;
500     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
501                                         i_instance, p_exception );
502     if( p_mi )
503     {
504         result = p_mi->d_position;
505         vlm_media_instance_Delete( p_mi );
506         return result;
507     }
508     libvlc_exception_raise( p_exception, "Unable to get position attribute" );
509     return result;
510 #else
511     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
512     return VLC_EGENERIC;
513 #endif
514 }
515
516 int libvlc_vlm_get_media_instance_time( libvlc_instance_t *p_instance,
517     char *psz_name, int i_instance, libvlc_exception_t *p_exception )
518 {
519 #ifdef ENABLE_VLM
520     int result = -1;
521     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
522                                         i_instance, p_exception );
523     if( p_mi )
524     {
525         result = p_mi->i_time;
526         vlm_media_instance_Delete( p_mi );
527         return result;
528     }
529     libvlc_exception_raise( p_exception, "Unable to get time attribute" );
530     return result;
531 #else
532     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
533     return VLC_EGENERIC;
534 #endif
535 }
536
537 int libvlc_vlm_get_media_instance_length( libvlc_instance_t *p_instance,
538     char *psz_name, int i_instance, libvlc_exception_t *p_exception )
539 {
540 #ifdef ENABLE_VLM
541     int result = -1;
542     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
543                                         i_instance, p_exception );
544     if( p_mi )
545     {
546         result = p_mi->i_length;
547         vlm_media_instance_Delete( p_mi );
548         return result;
549     }
550     libvlc_exception_raise( p_exception, "Unable to get length attribute" );
551     return result;
552 #else
553     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
554     return VLC_EGENERIC;
555 #endif
556 }
557
558 int libvlc_vlm_get_media_instance_rate( libvlc_instance_t *p_instance,
559     char *psz_name, int i_instance, libvlc_exception_t *p_exception )
560 {
561 #ifdef ENABLE_VLM
562     int result = -1;
563     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
564                                         i_instance, p_exception );
565     if( p_mi )
566     {
567         result = p_mi->i_rate;
568         vlm_media_instance_Delete( p_mi );
569         return result;
570     }
571     libvlc_exception_raise( p_exception, "Unable to get rate attribute" );
572     return result;
573 #else
574     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
575     return VLC_EGENERIC;
576 #endif
577 }
578
579 int libvlc_vlm_get_media_instance_title( libvlc_instance_t *p_instance,
580     char *psz_name, int i_instance, libvlc_exception_t *p_exception )
581 {
582 #ifdef ENABLE_VLM
583     int result = 0;
584     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
585                                         i_instance, p_exception );
586     if( p_mi )
587     {
588         vlm_media_instance_Delete( p_mi );
589         return result;
590     }
591     libvlc_exception_raise( p_exception, "Unable to get title attribute" );
592     return result;
593 #else
594     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
595     return VLC_EGENERIC;
596 #endif
597 }
598
599 int libvlc_vlm_get_media_instance_chapter( libvlc_instance_t *p_instance,
600     char *psz_name, int i_instance, 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 chapter 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_seekable( libvlc_instance_t *p_instance,
620     char *psz_name, int i_instance, libvlc_exception_t *p_exception )
621 {
622 #ifdef ENABLE_VLM
623     bool result = 0;
624     vlm_media_instance_t *p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
625                                         i_instance, p_exception );
626     if( p_mi )
627     {
628         vlm_media_instance_Delete( p_mi );
629         return result;
630     }
631     libvlc_exception_raise( p_exception, "Unable to get seekable attribute" );
632     return result;
633 #else
634     libvlc_exception_raise( p_exception, "VLM has been disabled in this libvlc." );
635     return VLC_EGENERIC;
636 #endif
637 }