Contribs: update gcrypt to 1.7.10
[vlc.git] / lib / vlm.c
blob1f66058efa486e6ade88d8ef88c98dce40771487
1 /*****************************************************************************
2 * vlm.c: libvlc new API VLM handling functions
3 *****************************************************************************
4 * Copyright (C) 2005 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifdef HAVE_CONFIG_H
25 # include <config.h>
26 #endif
28 #include <vlc/libvlc.h>
29 #include <vlc/libvlc_vlm.h>
30 #include <vlc_es.h>
31 #include <vlc_input.h>
32 #include <vlc_vlm.h>
33 #include <assert.h>
35 #include "libvlc_internal.h"
37 typedef struct libvlc_vlm_t
39 libvlc_event_manager_t event_manager;
40 vlm_t *p_vlm;
41 } libvlc_vlm_t;
43 /* VLM events callback. Transmit to libvlc */
44 static int VlmEvent( vlc_object_t *p_this, const char * name,
45 vlc_value_t old_val, vlc_value_t newval, void *param )
47 VLC_UNUSED(p_this);
48 VLC_UNUSED(name);
49 VLC_UNUSED(old_val);
50 vlm_event_t *event = (vlm_event_t*)newval.p_address;
51 libvlc_event_manager_t *p_event_manager = (libvlc_event_manager_t *) param;
52 libvlc_event_t libvlc_event;
54 libvlc_event.u.vlm_media_event.psz_instance_name = NULL;
55 libvlc_event.u.vlm_media_event.psz_media_name = event->psz_name;
57 switch( event->i_type )
59 case VLM_EVENT_MEDIA_ADDED:
60 libvlc_event.type = libvlc_VlmMediaAdded;
61 break;
62 case VLM_EVENT_MEDIA_REMOVED:
63 libvlc_event.type = libvlc_VlmMediaRemoved;
64 break;
65 case VLM_EVENT_MEDIA_CHANGED:
66 libvlc_event.type = libvlc_VlmMediaChanged;
67 break;
68 case VLM_EVENT_MEDIA_INSTANCE_STARTED:
69 libvlc_event.type = libvlc_VlmMediaInstanceStarted;
70 break;
71 case VLM_EVENT_MEDIA_INSTANCE_STOPPED:
72 libvlc_event.type = libvlc_VlmMediaInstanceStopped;
73 break;
74 case VLM_EVENT_MEDIA_INSTANCE_STATE:
75 libvlc_event.u.vlm_media_event.psz_instance_name =
76 event->psz_instance_name;
77 switch( event->input_state )
79 case INIT_S:
80 libvlc_event.type = libvlc_VlmMediaInstanceStatusInit;
81 break;
82 case OPENING_S:
83 libvlc_event.type =
84 libvlc_VlmMediaInstanceStatusOpening;
85 break;
86 case PLAYING_S:
87 libvlc_event.type =
88 libvlc_VlmMediaInstanceStatusPlaying;
89 break;
90 case PAUSE_S:
91 libvlc_event.type = libvlc_VlmMediaInstanceStatusPause;
92 break;
93 case END_S:
94 libvlc_event.type = libvlc_VlmMediaInstanceStatusEnd;
95 break;
96 case ERROR_S:
97 libvlc_event.type = libvlc_VlmMediaInstanceStatusError;
98 break;
99 default:
100 return 0;
102 break;
103 default:
104 return 0;
106 libvlc_event_send( p_event_manager, &libvlc_event );
107 return 0;
110 void libvlc_vlm_release( libvlc_instance_t *p_instance )
112 vlm_t *p_vlm = p_instance->vlm->p_vlm;
113 if( !p_vlm )
114 return;
115 /* We need to remove medias in order to receive events */
116 vlm_Control( p_vlm, VLM_CLEAR_MEDIAS );
117 vlm_Control( p_vlm, VLM_CLEAR_SCHEDULES );
119 var_DelCallback( (vlc_object_t *)p_vlm, "intf-event", VlmEvent,
120 &p_instance->vlm->event_manager );
121 libvlc_event_manager_destroy( &p_instance->vlm->event_manager );
122 vlm_Delete( p_vlm );
123 free( p_instance->vlm );
124 p_instance->vlm = NULL;
125 libvlc_release( p_instance );
128 static int libvlc_vlm_init( libvlc_instance_t *p_instance )
130 if( !p_instance->vlm )
132 p_instance->vlm = malloc( sizeof(*p_instance->vlm) );
133 if( p_instance->vlm == NULL )
134 return VLC_ENOMEM;
135 p_instance->vlm->p_vlm = NULL;
136 libvlc_event_manager_init( &p_instance->vlm->event_manager,
137 p_instance->vlm );
140 if( !p_instance->vlm->p_vlm )
142 p_instance->vlm->p_vlm = vlm_New( p_instance->p_libvlc_int, NULL );
143 if( !p_instance->vlm->p_vlm )
145 libvlc_printerr( "VLM not supported or out of memory" );
146 return VLC_EGENERIC;
148 var_AddCallback( (vlc_object_t *)p_instance->vlm->p_vlm,
149 "intf-event", VlmEvent,
150 &p_instance->vlm->event_manager );
151 libvlc_retain( p_instance );
154 return VLC_SUCCESS;
157 #define VLM_RET(p,ret) do { \
158 if( libvlc_vlm_init( p_instance ) ) \
159 return (ret); \
160 (p) = p_instance->vlm->p_vlm; \
161 } while(0)
163 static vlm_media_instance_t *
164 libvlc_vlm_get_media_instance( libvlc_instance_t *p_instance,
165 const char *psz_name, int i_minstance_idx )
167 vlm_t *p_vlm;
168 vlm_media_instance_t **pp_minstance;
169 vlm_media_instance_t *p_minstance;
170 int i_minstance;
171 int64_t id;
173 VLM_RET(p_vlm, NULL);
175 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
176 vlm_Control( p_vlm, VLM_GET_MEDIA_INSTANCES, id, &pp_minstance,
177 &i_minstance ) )
179 libvlc_printerr( "%s: media instances not found", psz_name );
180 return NULL;
182 p_minstance = NULL;
183 if( i_minstance_idx >= 0 && i_minstance_idx < i_minstance )
185 p_minstance = pp_minstance[i_minstance_idx];
186 TAB_REMOVE( i_minstance, pp_minstance, p_minstance );
188 while( i_minstance > 0 )
189 vlm_media_instance_Delete( pp_minstance[--i_minstance] );
190 TAB_CLEAN( i_minstance, pp_minstance );
191 return p_minstance;
194 /* local function to be used in libvlc_vlm_show_media only */
195 static char* recurse_answer( vlm_message_t *p_answer, const char* psz_delim,
196 const int i_list ) {
197 char* psz_childdelim = NULL;
198 char* psz_nametag = NULL;
199 char* psz_response = strdup( "" );
200 int i_success = 0;
202 vlm_message_t *aw_child, **paw_child;
204 i_success = asprintf( &psz_childdelim, "%s\t", psz_delim);
205 if( i_success == -1 )
206 return psz_response;
208 paw_child = p_answer->child;
209 aw_child = *( paw_child );
210 /* Iterate over children */
211 for( int i = 0; i < p_answer->i_child; i++ )
213 char *psz_tmp;
214 /* Spare comma if it is the last element */
215 char c_comma = ',';
216 if( i == (p_answer->i_child - 1) )
217 c_comma = ' ';
219 /* Append name of child node, if not in a list */
220 if( !i_list )
222 i_success = asprintf( &psz_tmp, "%s\"%s\": ",
223 psz_response, aw_child->psz_name );
224 if( i_success == -1 ) break;
225 free( psz_response );
226 psz_response = psz_tmp;
229 /* If child node has children, */
230 if( aw_child->i_child )
232 /* If the parent node is a list (hence the child node is
233 * inside a list), create a property of its name as if it
234 * had a name value node
236 free( psz_nametag );
237 if( i_list )
239 i_success = asprintf( &psz_nametag, "\"name\": \"%s\",%s",
240 aw_child->psz_name, psz_childdelim );
241 if( i_success == -1 )
243 psz_nametag = NULL;
244 break;
247 else
249 psz_nametag = strdup( "" );
251 /* If the child is a list itself, format it accordingly and
252 * recurse through the child's children, telling them that
253 * they are inside a list.
255 if( strcmp( aw_child->psz_name, "media" ) == 0 ||
256 strcmp( aw_child->psz_name, "inputs" ) == 0 ||
257 strcmp( aw_child->psz_name, "options" ) == 0 )
259 char *psz_recurse = recurse_answer( aw_child, psz_childdelim, 1 );
260 i_success = asprintf( &psz_tmp, "%s[%s%s%s]%c%s",
261 psz_response, psz_childdelim, psz_recurse,
262 psz_delim, c_comma, psz_delim );
263 free( psz_recurse );
264 if( i_success == -1 ) break;
265 free( psz_response );
266 psz_response = psz_tmp;
268 /* Not a list, so format the child as a JSON object and
269 * recurse through the child's children
271 else
273 char *psz_recurse = recurse_answer( aw_child, psz_childdelim, 0 );
274 i_success = asprintf( &psz_tmp, "%s{%s%s%s%s}%c%s",
275 psz_response, psz_childdelim, psz_nametag,
276 psz_recurse, psz_delim, c_comma, psz_delim );
277 free( psz_recurse );
278 if( i_success == -1 ) break;
279 free( psz_response );
280 psz_response = psz_tmp;
283 /* Otherwise - when no children are present - the node is a
284 * value node. So print the value string
286 else
288 /* If value is equivalent to NULL, print it as null */
289 if( aw_child->psz_value == NULL
290 || strcmp( aw_child->psz_value, "(null)" ) == 0 )
292 i_success = asprintf( &psz_tmp, "%snull%c%s",
293 psz_response, c_comma, psz_delim );
294 if( i_success == -1 ) break;
295 free( psz_response );
296 psz_response = psz_tmp;
298 /* Otherwise print the value in quotation marks */
299 else
301 i_success = asprintf( &psz_tmp, "%s\"%s\"%c%s",
302 psz_response, aw_child->psz_value,
303 c_comma, psz_delim );
304 if( i_success == -1 ) break;
305 free( psz_response );
306 psz_response = psz_tmp;
309 /* getting next child */
310 paw_child++;
311 aw_child = *( paw_child );
313 free( psz_nametag );
314 free( psz_childdelim );
315 if( i_success == -1 )
317 free( psz_response );
318 psz_response = strdup( "" );
320 return psz_response;
323 const char* libvlc_vlm_show_media( libvlc_instance_t *p_instance,
324 const char *psz_name )
326 char *psz_message = NULL;
327 vlm_message_t *answer = NULL;
328 char *psz_response = NULL;
329 const char *psz_fmt = NULL;
330 const char *psz_delimiter = NULL;
331 int i_list;
332 vlm_t *p_vlm = NULL;
334 VLM_RET(p_vlm, NULL);
336 assert( psz_name );
338 if( asprintf( &psz_message, "show %s", psz_name ) == -1 )
339 return NULL;
341 vlm_ExecuteCommand( p_vlm, psz_message, &answer );
342 if( answer->psz_value )
344 libvlc_printerr( "Unable to call show %s: %s",
345 psz_name, answer->psz_value );
347 else if ( answer->child )
348 { /* in case everything was requested */
349 if ( strcmp( psz_name, "" ) == 0 )
351 psz_fmt = "{\n\t%s\n}\n";
352 psz_delimiter = "\n\t";
353 i_list = 0;
355 else
357 psz_fmt = "%s\n";
358 psz_delimiter = "\n";
359 i_list = 1;
361 char *psz_tmp = recurse_answer( answer, psz_delimiter, i_list );
362 if( asprintf( &psz_response, psz_fmt, psz_tmp ) == -1 )
364 libvlc_printerr( "Out of memory" );
365 psz_response = NULL;
367 free( psz_tmp );
369 vlm_MessageDelete( answer );
370 free( psz_message );
371 return( psz_response );
375 int libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance,
376 const char *psz_name,
377 const char *psz_input,
378 const char *psz_output, int i_options,
379 const char * const *ppsz_options,
380 int b_enabled, int b_loop )
382 vlm_t *p_vlm;
383 vlm_media_t m;
384 int n;
386 VLM_RET(p_vlm, -1);
388 vlm_media_Init( &m );
389 m.psz_name = strdup( psz_name );
390 m.b_enabled = b_enabled;
391 m.b_vod = false;
392 m.broadcast.b_loop = b_loop;
393 if( psz_input )
394 TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
395 if( psz_output )
396 m.psz_output = strdup( psz_output );
397 for( n = 0; n < i_options; n++ )
398 TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );
400 n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
401 vlm_media_Clean( &m );
402 if( n )
404 libvlc_printerr( "Media %s creation failed", psz_name );
405 return -1;
407 return 0;
410 int libvlc_vlm_add_vod( libvlc_instance_t *p_instance, const char *psz_name,
411 const char *psz_input, int i_options,
412 const char * const *ppsz_options, int b_enabled,
413 const char *psz_mux )
415 vlm_t *p_vlm;
416 vlm_media_t m;
417 int n;
419 VLM_RET(p_vlm, -1);
421 vlm_media_Init( &m );
422 m.psz_name = strdup( psz_name );
423 m.b_enabled = b_enabled;
424 m.b_vod = true;
425 m.vod.psz_mux = psz_mux ? strdup( psz_mux ) : NULL;
426 if( psz_input )
427 TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
428 for( n = 0; n < i_options; n++ )
429 TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );
431 n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
432 vlm_media_Clean( &m );
433 if( n )
435 libvlc_printerr( "Media %s creation failed", psz_name );
436 return -1;
438 return 0;
441 int libvlc_vlm_del_media( libvlc_instance_t *p_instance, const char *psz_name )
443 vlm_t *p_vlm;
444 int64_t id;
446 VLM_RET(p_vlm, -1);
448 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
449 vlm_Control( p_vlm, VLM_DEL_MEDIA, id ) )
451 libvlc_printerr( "Unable to delete %s", psz_name );
452 return -1;
454 return 0;
457 static vlm_media_t *get_media( libvlc_instance_t *p_instance,
458 vlm_t **restrict pp_vlm, const char *name )
460 vlm_media_t *p_media;
461 vlm_t *p_vlm;
462 int64_t id;
464 VLM_RET(p_vlm, NULL);
465 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, name, &id ) ||
466 vlm_Control( p_vlm, VLM_GET_MEDIA, id, &p_media ) )
467 return NULL;
468 *pp_vlm = p_vlm;
469 return p_media;
472 #define VLM_CHANGE(psz_error, code ) do { \
473 vlm_t *p_vlm; \
474 vlm_media_t *p_media = get_media( p_instance, &p_vlm, psz_name ); \
475 if( p_media != NULL ) { \
476 code; \
477 if( vlm_Control( p_vlm, VLM_CHANGE_MEDIA, p_media ) ) \
478 p_vlm = NULL; \
479 vlm_media_Delete( p_media ); \
480 if( p_vlm != NULL ) \
481 return 0; \
483 libvlc_printerr( psz_error, psz_name ); \
484 return -1; \
485 } while(0)
487 int libvlc_vlm_set_enabled( libvlc_instance_t *p_instance,
488 const char *psz_name, int b_enabled )
490 #define VLM_CHANGE_CODE { p_media->b_enabled = b_enabled; }
491 VLM_CHANGE( "Unable to delete %s", VLM_CHANGE_CODE );
492 #undef VLM_CHANGE_CODE
495 int libvlc_vlm_set_loop( libvlc_instance_t *p_instance, const char *psz_name,
496 int b_loop )
498 #define VLM_CHANGE_CODE { p_media->broadcast.b_loop = b_loop; }
499 VLM_CHANGE( "Unable to change %s loop property", VLM_CHANGE_CODE );
500 #undef VLM_CHANGE_CODE
503 int libvlc_vlm_set_mux( libvlc_instance_t *p_instance, const char *psz_name,
504 const char *psz_mux )
506 #define VLM_CHANGE_CODE { if( p_media->b_vod ) { \
507 free( p_media->vod.psz_mux ); \
508 p_media->vod.psz_mux = psz_mux \
509 ? strdup( psz_mux ) : NULL; \
511 VLM_CHANGE( "Unable to change %s mux property", VLM_CHANGE_CODE );
512 #undef VLM_CHANGE_CODE
515 int libvlc_vlm_set_output( libvlc_instance_t *p_instance,
516 const char *psz_name, const char *psz_output )
518 #define VLM_CHANGE_CODE { free( p_media->psz_output ); \
519 p_media->psz_output = strdup( psz_output ); }
520 VLM_CHANGE( "Unable to change %s output property", VLM_CHANGE_CODE );
521 #undef VLM_CHANGE_CODE
524 int libvlc_vlm_set_input( libvlc_instance_t *p_instance,
525 const char *psz_name, const char *psz_input )
527 #define VLM_CHANGE_CODE { while( p_media->i_input > 0 ) \
528 free( p_media->ppsz_input[--p_media->i_input] );\
529 TAB_APPEND( p_media->i_input, p_media->ppsz_input, \
530 strdup(psz_input) ); }
531 VLM_CHANGE( "Unable to change %s input property", VLM_CHANGE_CODE );
532 #undef VLM_CHANGE_CODE
535 int libvlc_vlm_add_input( libvlc_instance_t *p_instance,
536 const char *psz_name, const char *psz_input )
538 #define VLM_CHANGE_CODE { TAB_APPEND( p_media->i_input, p_media->ppsz_input, \
539 strdup(psz_input) ); }
540 VLM_CHANGE( "Unable to change %s input property", VLM_CHANGE_CODE );
541 #undef VLM_CHANGE_CODE
544 int libvlc_vlm_change_media( libvlc_instance_t *p_instance,
545 const char *psz_name, const char *psz_input,
546 const char *psz_output, int i_options,
547 const char * const *ppsz_options, int b_enabled,
548 int b_loop )
550 #define VLM_CHANGE_CODE { int n; \
551 p_media->b_enabled = b_enabled; \
552 p_media->broadcast.b_loop = b_loop; \
553 while( p_media->i_input > 0 ) \
554 free( p_media->ppsz_input[--p_media->i_input] ); \
555 if( psz_input ) \
556 TAB_APPEND( p_media->i_input, p_media->ppsz_input, strdup(psz_input) ); \
557 free( p_media->psz_output ); \
558 p_media->psz_output = psz_output ? strdup( psz_output ) : NULL; \
559 while( p_media->i_option > 0 ) \
560 free( p_media->ppsz_option[--p_media->i_option] ); \
561 for( n = 0; n < i_options; n++ ) \
562 TAB_APPEND( p_media->i_option, p_media->ppsz_option, \
563 strdup(ppsz_options[n]) ); \
565 VLM_CHANGE( "Unable to change %s properties", VLM_CHANGE_CODE );
566 #undef VLM_CHANGE_CODE
569 int libvlc_vlm_play_media( libvlc_instance_t *p_instance,
570 const char *psz_name )
572 vlm_t *p_vlm;
573 int64_t id;
575 VLM_RET(p_vlm, -1);
577 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
578 vlm_Control( p_vlm, VLM_START_MEDIA_BROADCAST_INSTANCE, id, NULL, 0 ) )
580 libvlc_printerr( "Unable to play %s", psz_name );
581 return -1;
583 return 0;
586 int libvlc_vlm_stop_media( libvlc_instance_t *p_instance,
587 const char *psz_name )
589 vlm_t *p_vlm;
590 int64_t id;
592 VLM_RET(p_vlm, -1);
594 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
595 vlm_Control( p_vlm, VLM_STOP_MEDIA_INSTANCE, id, NULL ) )
597 libvlc_printerr( "Unable to stop %s", psz_name );
598 return -1;
600 return 0;
603 int libvlc_vlm_pause_media( libvlc_instance_t *p_instance,
604 const char *psz_name )
606 vlm_t *p_vlm;
607 int64_t id;
609 VLM_RET(p_vlm, -1);
611 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
612 vlm_Control( p_vlm, VLM_PAUSE_MEDIA_INSTANCE, id, NULL ) )
614 libvlc_printerr( "Unable to pause %s", psz_name );
615 return -1;
617 return 0;
620 int libvlc_vlm_seek_media( libvlc_instance_t *p_instance,
621 const char *psz_name, float f_percentage )
623 vlm_t *p_vlm;
624 int64_t id;
626 VLM_RET(p_vlm, -1);
628 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
629 vlm_Control( p_vlm, VLM_SET_MEDIA_INSTANCE_POSITION, id, NULL,
630 f_percentage ) )
632 libvlc_printerr( "Unable to seek %s to %f%%", psz_name, f_percentage );
633 return -1;
635 return 0;
638 float libvlc_vlm_get_media_instance_position( libvlc_instance_t *p_instance,
639 const char *psz_name,
640 int i_instance )
642 vlm_media_instance_t *p_mi;
643 float result = -1.;
645 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
646 if( p_mi )
648 result = p_mi->d_position;
649 vlm_media_instance_Delete( p_mi );
651 return result;
654 int libvlc_vlm_get_media_instance_time( libvlc_instance_t *p_instance,
655 const char *psz_name, int i_instance )
657 vlm_media_instance_t *p_mi;
658 int result = -1;
660 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
661 if( p_mi )
663 result = p_mi->i_time;
664 vlm_media_instance_Delete( p_mi );
666 return result;
669 int libvlc_vlm_get_media_instance_length( libvlc_instance_t *p_instance,
670 const char *psz_name,
671 int i_instance )
673 vlm_media_instance_t *p_mi;
674 int result = -1;
676 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
677 if( p_mi )
679 result = p_mi->i_length;
680 vlm_media_instance_Delete( p_mi );
682 return result;
685 int libvlc_vlm_get_media_instance_rate( libvlc_instance_t *p_instance,
686 const char *psz_name, int i_instance )
688 vlm_media_instance_t *p_mi;
689 int result = -1;
691 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
692 if( p_mi )
694 result = p_mi->i_rate;
695 vlm_media_instance_Delete( p_mi );
697 return result;
700 #if 0
701 int libvlc_vlm_get_media_instance_title( libvlc_instance_t *p_instance,
702 const char *psz_name, int i_instance )
704 vlm_media_instance_t *p_mi;
706 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
707 if( p_mi )
708 vlm_media_instance_Delete( p_mi );
709 return p_mi ? 0 : -1;
712 int libvlc_vlm_get_media_instance_chapter( libvlc_instance_t *p_instance,
713 const char *psz_name,
714 int i_instance )
716 vlm_media_instance_t *p_mi;
718 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
719 i_instance );
720 if( p_mi )
721 vlm_media_instance_Delete( p_mi );
722 return p_mi ? 0 : -1;
725 int libvlc_vlm_get_media_instance_seekable( libvlc_instance_t *p_instance,
726 const char *psz_name,
727 int i_instance )
729 vlm_media_instance_t *p_mi;
731 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
732 if( p_mi )
733 vlm_media_instance_Delete( p_mi );
734 return p_mi ? 0 : -1;
736 #endif
738 libvlc_event_manager_t *
739 libvlc_vlm_get_event_manager( libvlc_instance_t *p_instance )
741 if( libvlc_vlm_init( p_instance ) )
742 return NULL;
743 return &p_instance->vlm->event_manager;