contrib:tiger: update libtiger to 0.3.4
[vlc.git] / lib / vlm.c
blob8093dc8689607525c4610cea9c8a24d1f4d44e9b
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 /* VLM events callback. Transmit to libvlc */
38 static int VlmEvent( vlc_object_t *p_this, const char * name,
39 vlc_value_t old_val, vlc_value_t newval, void *param )
41 VLC_UNUSED(p_this);
42 VLC_UNUSED(name);
43 VLC_UNUSED(old_val);
44 vlm_event_t *event = (vlm_event_t*)newval.p_address;
45 libvlc_event_manager_t *p_event_manager = (libvlc_event_manager_t *) param;
46 libvlc_event_t libvlc_event;
48 libvlc_event.u.vlm_media_event.psz_instance_name = NULL;
49 libvlc_event.u.vlm_media_event.psz_media_name = event->psz_name;
51 switch( event->i_type )
53 case VLM_EVENT_MEDIA_ADDED:
54 libvlc_event.type = libvlc_VlmMediaAdded;
55 break;
56 case VLM_EVENT_MEDIA_REMOVED:
57 libvlc_event.type = libvlc_VlmMediaRemoved;
58 break;
59 case VLM_EVENT_MEDIA_CHANGED:
60 libvlc_event.type = libvlc_VlmMediaChanged;
61 break;
62 case VLM_EVENT_MEDIA_INSTANCE_STARTED:
63 libvlc_event.type = libvlc_VlmMediaInstanceStarted;
64 break;
65 case VLM_EVENT_MEDIA_INSTANCE_STOPPED:
66 libvlc_event.type = libvlc_VlmMediaInstanceStopped;
67 break;
68 case VLM_EVENT_MEDIA_INSTANCE_STATE:
69 libvlc_event.u.vlm_media_event.psz_instance_name =
70 event->psz_instance_name;
71 switch( event->input_state )
73 case INIT_S:
74 libvlc_event.type = libvlc_VlmMediaInstanceStatusInit;
75 break;
76 case OPENING_S:
77 libvlc_event.type =
78 libvlc_VlmMediaInstanceStatusOpening;
79 break;
80 case PLAYING_S:
81 libvlc_event.type =
82 libvlc_VlmMediaInstanceStatusPlaying;
83 break;
84 case PAUSE_S:
85 libvlc_event.type = libvlc_VlmMediaInstanceStatusPause;
86 break;
87 case END_S:
88 libvlc_event.type = libvlc_VlmMediaInstanceStatusEnd;
89 break;
90 case ERROR_S:
91 libvlc_event.type = libvlc_VlmMediaInstanceStatusError;
92 break;
93 default:
94 return 0;
96 break;
97 default:
98 return 0;
100 libvlc_event_send( p_event_manager, &libvlc_event );
101 return 0;
104 static void libvlc_vlm_release_internal( libvlc_instance_t *p_instance )
106 vlm_t *p_vlm = p_instance->libvlc_vlm.p_vlm;
107 if( !p_instance->libvlc_vlm.p_vlm )
108 return;
109 /* We need to remove medias in order to receive events */
110 vlm_Control( p_vlm, VLM_CLEAR_MEDIAS );
111 vlm_Control( p_vlm, VLM_CLEAR_SCHEDULES );
113 var_DelCallback( (vlc_object_t *)p_vlm, "intf-event", VlmEvent,
114 p_instance->libvlc_vlm.p_event_manager );
115 p_instance->libvlc_vlm.pf_release = NULL;
116 libvlc_event_manager_release( p_instance->libvlc_vlm.p_event_manager );
117 p_instance->libvlc_vlm.p_event_manager = NULL;
118 vlm_Delete( p_vlm );
119 p_instance->libvlc_vlm.p_vlm = NULL;
120 libvlc_release( p_instance );
123 static int libvlc_vlm_init( libvlc_instance_t *p_instance )
125 if( !p_instance->libvlc_vlm.p_event_manager )
127 p_instance->libvlc_vlm.p_event_manager =
128 libvlc_event_manager_new( p_instance->libvlc_vlm.p_vlm );
129 if( unlikely(p_instance->libvlc_vlm.p_event_manager == NULL) )
130 return VLC_ENOMEM;
133 if( !p_instance->libvlc_vlm.p_vlm )
135 p_instance->libvlc_vlm.p_vlm = vlm_New( p_instance->p_libvlc_int );
136 if( !p_instance->libvlc_vlm.p_vlm )
138 libvlc_printerr( "VLM not supported or out of memory" );
139 return VLC_EGENERIC;
141 var_AddCallback( (vlc_object_t *)p_instance->libvlc_vlm.p_vlm,
142 "intf-event", VlmEvent,
143 p_instance->libvlc_vlm.p_event_manager );
144 p_instance->libvlc_vlm.pf_release = libvlc_vlm_release_internal;
145 libvlc_retain( p_instance );
148 return VLC_SUCCESS;
151 void libvlc_vlm_release( libvlc_instance_t *p_instance )
153 libvlc_vlm_release_internal( p_instance );
156 #define VLM_RET(p,ret) do { \
157 if( libvlc_vlm_init( p_instance ) ) \
158 return (ret); \
159 (p) = p_instance->libvlc_vlm.p_vlm; \
160 } while(0)
162 static vlm_media_instance_t *
163 libvlc_vlm_get_media_instance( libvlc_instance_t *p_instance,
164 const char *psz_name, int i_minstance_idx )
166 vlm_t *p_vlm;
167 vlm_media_instance_t **pp_minstance;
168 vlm_media_instance_t *p_minstance;
169 int i_minstance;
170 int64_t id;
172 VLM_RET(p_vlm, NULL);
174 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
175 vlm_Control( p_vlm, VLM_GET_MEDIA_INSTANCES, id, &pp_minstance,
176 &i_minstance ) )
178 libvlc_printerr( "%s: media instances not found", psz_name );
179 return NULL;
181 p_minstance = NULL;
182 if( i_minstance_idx >= 0 && i_minstance_idx < i_minstance )
184 p_minstance = pp_minstance[i_minstance_idx];
185 TAB_REMOVE( i_minstance, pp_minstance, p_minstance );
187 while( i_minstance > 0 )
188 vlm_media_instance_Delete( pp_minstance[--i_minstance] );
189 TAB_CLEAN( i_minstance, pp_minstance );
190 return p_minstance;
193 /* local function to be used in libvlc_vlm_show_media only */
194 static char* recurse_answer( vlm_message_t *p_answer, const char* psz_delim,
195 const int i_list ) {
196 char* psz_childdelim = NULL;
197 char* psz_nametag = NULL;
198 char* psz_response = strdup( "" );
199 char *psz_tmp;
200 int i_success = 0;
201 int i;
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( i = 0; i < p_answer->i_child; i++ )
213 /* Spare comma if it is the last element */
214 char c_comma = ',';
215 if( i == (p_answer->i_child - 1) )
216 c_comma = ' ';
218 /* Append name of child node, if not in a list */
219 if( !i_list )
221 i_success = asprintf( &psz_tmp, "%s\"%s\": ",
222 psz_response, aw_child->psz_name );
223 if( i_success == -1 ) break;
224 free( psz_response );
225 psz_response = psz_tmp;
228 /* If child node has children, */
229 if( aw_child->i_child )
231 /* If the parent node is a list (hence the child node is
232 * inside a list), create a property of its name as if it
233 * had a name value node
235 free( psz_nametag );
236 if( i_list )
238 i_success = asprintf( &psz_nametag, "\"name\": \"%s\",%s",
239 aw_child->psz_name, psz_childdelim );
240 if( i_success == -1 )
242 psz_nametag = NULL;
243 break;
246 else
248 psz_nametag = strdup( "" );
250 /* If the child is a list itself, format it accordingly and
251 * recurse through the child's children, telling them that
252 * they are inside a list.
254 if( strcmp( aw_child->psz_name, "media" ) == 0 ||
255 strcmp( aw_child->psz_name, "inputs" ) == 0 ||
256 strcmp( aw_child->psz_name, "options" ) == 0 )
258 char *psz_recurse = recurse_answer( aw_child, psz_childdelim, 1 );
259 i_success = asprintf( &psz_tmp, "%s[%s%s%s]%c%s",
260 psz_response, psz_childdelim, psz_recurse,
261 psz_delim, c_comma, psz_delim );
262 free( psz_recurse );
263 if( i_success == -1 ) break;
264 free( psz_response );
265 psz_response = psz_tmp;
267 /* Not a list, so format the child as a JSON object and
268 * recurse through the child's children
270 else
272 char *psz_recurse = recurse_answer( aw_child, psz_childdelim, 0 );
273 i_success = asprintf( &psz_tmp, "%s{%s%s%s%s}%c%s",
274 psz_response, psz_childdelim, psz_nametag,
275 psz_recurse, psz_delim, c_comma, psz_delim );
276 free( psz_recurse );
277 if( i_success == -1 ) break;
278 free( psz_response );
279 psz_response = psz_tmp;
282 /* Otherwise - when no children are present - the node is a
283 * value node. So print the value string
285 else
287 /* If value is equivalent to NULL, print it as null */
288 if( aw_child->psz_value == NULL
289 || strcmp( aw_child->psz_value, "(null)" ) == 0 )
291 i_success = asprintf( &psz_tmp, "%snull%c%s",
292 psz_response, c_comma, psz_delim );
293 if( i_success == -1 ) break;
294 free( psz_response );
295 psz_response = psz_tmp;
297 /* Otherwise print the value in quotation marks */
298 else
300 i_success = asprintf( &psz_tmp, "%s\"%s\"%c%s",
301 psz_response, aw_child->psz_value,
302 c_comma, psz_delim );
303 if( i_success == -1 ) break;
304 free( psz_response );
305 psz_response = psz_tmp;
308 /* getting next child */
309 paw_child++;
310 aw_child = *( paw_child );
312 free( psz_nametag );
313 free( psz_childdelim );
314 if( i_success == -1 )
316 free( psz_response );
317 psz_response = strdup( "" );
319 return psz_response;
322 const char* libvlc_vlm_show_media( libvlc_instance_t *p_instance,
323 const char *psz_name )
325 char *psz_message = NULL;
326 vlm_message_t *answer = NULL;
327 char *psz_response = NULL;
328 const char *psz_fmt = NULL;
329 const char *psz_delimiter = NULL;
330 int i_list;
331 vlm_t *p_vlm = NULL;
333 VLM_RET(p_vlm, NULL);
335 assert( psz_name );
337 if( asprintf( &psz_message, "show %s", psz_name ) == -1 )
338 return NULL;
340 vlm_ExecuteCommand( p_vlm, psz_message, &answer );
341 if( answer->psz_value )
343 libvlc_printerr( "Unable to call show %s: %s",
344 psz_name, answer->psz_value );
346 else if ( answer->child )
347 { /* in case everything was requested */
348 if ( strcmp( psz_name, "" ) == 0 )
350 psz_fmt = "{\n\t%s\n}\n";
351 psz_delimiter = "\n\t";
352 i_list = 0;
354 else
356 psz_fmt = "%s\n";
357 psz_delimiter = "\n";
358 i_list = 1;
360 char *psz_tmp = recurse_answer( answer, psz_delimiter, i_list );
361 if( asprintf( &psz_response, psz_fmt, psz_tmp ) == -1 )
363 libvlc_printerr( "Out of memory" );
364 psz_response = NULL;
366 free( psz_tmp );
368 vlm_MessageDelete( answer );
369 free( psz_message );
370 return( psz_response );
374 int libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance,
375 const char *psz_name,
376 const char *psz_input,
377 const char *psz_output, int i_options,
378 const char * const *ppsz_options,
379 int b_enabled, int b_loop )
381 vlm_t *p_vlm;
382 vlm_media_t m;
383 int n;
385 VLM_RET(p_vlm, -1);
387 vlm_media_Init( &m );
388 m.psz_name = strdup( psz_name );
389 m.b_enabled = b_enabled;
390 m.b_vod = false;
391 m.broadcast.b_loop = b_loop;
392 if( psz_input )
393 TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
394 if( psz_output )
395 m.psz_output = strdup( psz_output );
396 for( n = 0; n < i_options; n++ )
397 TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );
399 n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
400 vlm_media_Clean( &m );
401 if( n )
403 libvlc_printerr( "Media %s creation failed", psz_name );
404 return -1;
406 return 0;
409 int libvlc_vlm_add_vod( libvlc_instance_t *p_instance, const char *psz_name,
410 const char *psz_input, int i_options,
411 const char * const *ppsz_options, int b_enabled,
412 const char *psz_mux )
414 vlm_t *p_vlm;
415 vlm_media_t m;
416 int n;
418 VLM_RET(p_vlm, -1);
420 vlm_media_Init( &m );
421 m.psz_name = strdup( psz_name );
422 m.b_enabled = b_enabled;
423 m.b_vod = true;
424 m.vod.psz_mux = psz_mux ? strdup( psz_mux ) : NULL;
425 if( psz_input )
426 TAB_APPEND( m.i_input, m.ppsz_input, strdup(psz_input) );
427 for( n = 0; n < i_options; n++ )
428 TAB_APPEND( m.i_option, m.ppsz_option, strdup(ppsz_options[n]) );
430 n = vlm_Control( p_vlm, VLM_ADD_MEDIA, &m, NULL );
431 vlm_media_Clean( &m );
432 if( n )
434 libvlc_printerr( "Media %s creation failed", psz_name );
435 return -1;
437 return 0;
440 int libvlc_vlm_del_media( libvlc_instance_t *p_instance, const char *psz_name )
442 vlm_t *p_vlm;
443 int64_t id;
445 VLM_RET(p_vlm, -1);
447 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
448 vlm_Control( p_vlm, VLM_DEL_MEDIA, id ) )
450 libvlc_printerr( "Unable to delete %s", psz_name );
451 return -1;
453 return 0;
456 static vlm_media_t *get_media( libvlc_instance_t *p_instance,
457 vlm_t **restrict pp_vlm, const char *name )
459 vlm_media_t *p_media;
460 vlm_t *p_vlm;
461 int64_t id;
463 VLM_RET(p_vlm, NULL);
464 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, name, &id ) ||
465 vlm_Control( p_vlm, VLM_GET_MEDIA, id, &p_media ) )
466 return NULL;
467 *pp_vlm = p_vlm;
468 return p_media;
471 #define VLM_CHANGE(psz_error, code ) do { \
472 vlm_t *p_vlm; \
473 vlm_media_t *p_media = get_media( p_instance, &p_vlm, psz_name ); \
474 if( p_media != NULL ) { \
475 code; \
476 if( vlm_Control( p_vlm, VLM_CHANGE_MEDIA, p_media ) ) \
477 p_vlm = NULL; \
478 vlm_media_Delete( p_media ); \
479 if( p_vlm != NULL ) \
480 return 0; \
482 libvlc_printerr( psz_error, psz_name ); \
483 return -1; \
484 } while(0)
486 int libvlc_vlm_set_enabled( libvlc_instance_t *p_instance,
487 const char *psz_name, int b_enabled )
489 #define VLM_CHANGE_CODE { p_media->b_enabled = b_enabled; }
490 VLM_CHANGE( "Unable to delete %s", VLM_CHANGE_CODE );
491 #undef VLM_CHANGE_CODE
494 int libvlc_vlm_set_loop( libvlc_instance_t *p_instance, const char *psz_name,
495 int b_loop )
497 #define VLM_CHANGE_CODE { p_media->broadcast.b_loop = b_loop; }
498 VLM_CHANGE( "Unable to change %s loop property", VLM_CHANGE_CODE );
499 #undef VLM_CHANGE_CODE
502 int libvlc_vlm_set_mux( libvlc_instance_t *p_instance, const char *psz_name,
503 const char *psz_mux )
505 #define VLM_CHANGE_CODE { if( p_media->b_vod ) { \
506 free( p_media->vod.psz_mux ); \
507 p_media->vod.psz_mux = psz_mux \
508 ? strdup( psz_mux ) : NULL; \
510 VLM_CHANGE( "Unable to change %s mux property", VLM_CHANGE_CODE );
511 #undef VLM_CHANGE_CODE
514 int libvlc_vlm_set_output( libvlc_instance_t *p_instance,
515 const char *psz_name, const char *psz_output )
517 #define VLM_CHANGE_CODE { free( p_media->psz_output ); \
518 p_media->psz_output = strdup( psz_output ); }
519 VLM_CHANGE( "Unable to change %s output property", VLM_CHANGE_CODE );
520 #undef VLM_CHANGE_CODE
523 int libvlc_vlm_set_input( libvlc_instance_t *p_instance,
524 const char *psz_name, const char *psz_input )
526 #define VLM_CHANGE_CODE { while( p_media->i_input > 0 ) \
527 free( p_media->ppsz_input[--p_media->i_input] );\
528 TAB_APPEND( p_media->i_input, p_media->ppsz_input, \
529 strdup(psz_input) ); }
530 VLM_CHANGE( "Unable to change %s input property", VLM_CHANGE_CODE );
531 #undef VLM_CHANGE_CODE
534 int libvlc_vlm_add_input( libvlc_instance_t *p_instance,
535 const char *psz_name, const char *psz_input )
537 #define VLM_CHANGE_CODE { TAB_APPEND( p_media->i_input, p_media->ppsz_input, \
538 strdup(psz_input) ); }
539 VLM_CHANGE( "Unable to change %s input property", VLM_CHANGE_CODE );
540 #undef VLM_CHANGE_CODE
543 int libvlc_vlm_change_media( libvlc_instance_t *p_instance,
544 const char *psz_name, const char *psz_input,
545 const char *psz_output, int i_options,
546 const char * const *ppsz_options, int b_enabled,
547 int b_loop )
549 #define VLM_CHANGE_CODE { int n; \
550 p_media->b_enabled = b_enabled; \
551 p_media->broadcast.b_loop = b_loop; \
552 while( p_media->i_input > 0 ) \
553 free( p_media->ppsz_input[--p_media->i_input] ); \
554 if( psz_input ) \
555 TAB_APPEND( p_media->i_input, p_media->ppsz_input, strdup(psz_input) ); \
556 free( p_media->psz_output ); \
557 p_media->psz_output = psz_output ? strdup( psz_output ) : NULL; \
558 while( p_media->i_option > 0 ) \
559 free( p_media->ppsz_option[--p_media->i_option] ); \
560 for( n = 0; n < i_options; n++ ) \
561 TAB_APPEND( p_media->i_option, p_media->ppsz_option, \
562 strdup(ppsz_options[n]) ); \
564 VLM_CHANGE( "Unable to change %s properties", VLM_CHANGE_CODE );
565 #undef VLM_CHANGE_CODE
568 int libvlc_vlm_play_media( libvlc_instance_t *p_instance,
569 const char *psz_name )
571 vlm_t *p_vlm;
572 int64_t id;
574 VLM_RET(p_vlm, -1);
576 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
577 vlm_Control( p_vlm, VLM_START_MEDIA_BROADCAST_INSTANCE, id, NULL, 0 ) )
579 libvlc_printerr( "Unable to play %s", psz_name );
580 return -1;
582 return 0;
585 int libvlc_vlm_stop_media( libvlc_instance_t *p_instance,
586 const char *psz_name )
588 vlm_t *p_vlm;
589 int64_t id;
591 VLM_RET(p_vlm, -1);
593 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
594 vlm_Control( p_vlm, VLM_STOP_MEDIA_INSTANCE, id, NULL ) )
596 libvlc_printerr( "Unable to stop %s", psz_name );
597 return -1;
599 return 0;
602 int libvlc_vlm_pause_media( libvlc_instance_t *p_instance,
603 const char *psz_name )
605 vlm_t *p_vlm;
606 int64_t id;
608 VLM_RET(p_vlm, -1);
610 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
611 vlm_Control( p_vlm, VLM_PAUSE_MEDIA_INSTANCE, id, NULL ) )
613 libvlc_printerr( "Unable to pause %s", psz_name );
614 return -1;
616 return 0;
619 int libvlc_vlm_seek_media( libvlc_instance_t *p_instance,
620 const char *psz_name, float f_percentage )
622 vlm_t *p_vlm;
623 int64_t id;
625 VLM_RET(p_vlm, -1);
627 if( vlm_Control( p_vlm, VLM_GET_MEDIA_ID, psz_name, &id ) ||
628 vlm_Control( p_vlm, VLM_SET_MEDIA_INSTANCE_POSITION, id, NULL,
629 f_percentage ) )
631 libvlc_printerr( "Unable to seek %s to %f%%", psz_name, f_percentage );
632 return -1;
634 return 0;
637 float libvlc_vlm_get_media_instance_position( libvlc_instance_t *p_instance,
638 const char *psz_name,
639 int i_instance )
641 vlm_media_instance_t *p_mi;
642 float result = -1.;
644 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
645 if( p_mi )
647 result = p_mi->d_position;
648 vlm_media_instance_Delete( p_mi );
650 return result;
653 int libvlc_vlm_get_media_instance_time( libvlc_instance_t *p_instance,
654 const char *psz_name, int i_instance )
656 vlm_media_instance_t *p_mi;
657 int result = -1;
659 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
660 if( p_mi )
662 result = p_mi->i_time;
663 vlm_media_instance_Delete( p_mi );
665 return result;
668 int libvlc_vlm_get_media_instance_length( libvlc_instance_t *p_instance,
669 const char *psz_name,
670 int i_instance )
672 vlm_media_instance_t *p_mi;
673 int result = -1;
675 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
676 if( p_mi )
678 result = p_mi->i_length;
679 vlm_media_instance_Delete( p_mi );
681 return result;
684 int libvlc_vlm_get_media_instance_rate( libvlc_instance_t *p_instance,
685 const char *psz_name, int i_instance )
687 vlm_media_instance_t *p_mi;
688 int result = -1;
690 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
691 if( p_mi )
693 result = p_mi->i_rate;
694 vlm_media_instance_Delete( p_mi );
696 return result;
699 #if 0
700 int libvlc_vlm_get_media_instance_title( libvlc_instance_t *p_instance,
701 const char *psz_name, int i_instance )
703 vlm_media_instance_t *p_mi;
705 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
706 if( p_mi )
707 vlm_media_instance_Delete( p_mi );
708 return p_mi ? 0 : -1;
711 int libvlc_vlm_get_media_instance_chapter( libvlc_instance_t *p_instance,
712 const char *psz_name,
713 int i_instance )
715 vlm_media_instance_t *p_mi;
717 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name,
718 i_instance );
719 if( p_mi )
720 vlm_media_instance_Delete( p_mi );
721 return p_mi ? 0 : -1;
724 int libvlc_vlm_get_media_instance_seekable( libvlc_instance_t *p_instance,
725 const char *psz_name,
726 int i_instance )
728 vlm_media_instance_t *p_mi;
730 p_mi = libvlc_vlm_get_media_instance( p_instance, psz_name, i_instance );
731 if( p_mi )
732 vlm_media_instance_Delete( p_mi );
733 return p_mi ? 0 : -1;
735 #endif
737 libvlc_event_manager_t *
738 libvlc_vlm_get_event_manager( libvlc_instance_t *p_instance )
740 if( libvlc_vlm_init( p_instance ) )
741 return NULL;
742 return p_instance->libvlc_vlm.p_event_manager;