]> git.sesse.net Git - vlc/blob - src/control/media.c
bdb0ce310dbd186480205cec848f03da8409e954
[vlc] / src / control / media.c
1 /*****************************************************************************
2  * media.c: Libvlc API media descripor management
3  *****************************************************************************
4  * Copyright (C) 2007 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Pierre d'Herbemont <pdherbemont@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 <assert.h>
29
30 #include <vlc/libvlc.h>
31 #include <vlc/libvlc_media.h>
32 #include <vlc/libvlc_media_list.h> // For the subitems, here for convenience
33 #include <vlc/libvlc_events.h>
34
35 #include <vlc_common.h>
36 #include <vlc_input.h>
37 #include <vlc_meta.h>
38 #include <vlc_playlist.h> /* For the preparser */
39 #include <vlc_url.h>
40
41 #include "libvlc.h"
42
43 #include "libvlc_internal.h"
44 #include "media_internal.h"
45
46 static const vlc_meta_type_t libvlc_to_vlc_meta[] =
47 {
48     [libvlc_meta_Title]        = vlc_meta_Title,
49     [libvlc_meta_Artist]       = vlc_meta_Artist,
50     [libvlc_meta_Genre]        = vlc_meta_Genre,
51     [libvlc_meta_Copyright]    = vlc_meta_Copyright,
52     [libvlc_meta_Album]        = vlc_meta_Album,
53     [libvlc_meta_TrackNumber]  = vlc_meta_TrackNumber,
54     [libvlc_meta_Description]  = vlc_meta_Description,
55     [libvlc_meta_Rating]       = vlc_meta_Rating,
56     [libvlc_meta_Date]         = vlc_meta_Date,
57     [libvlc_meta_Setting]      = vlc_meta_Setting,
58     [libvlc_meta_URL]          = vlc_meta_URL,
59     [libvlc_meta_Language]     = vlc_meta_Language,
60     [libvlc_meta_NowPlaying]   = vlc_meta_NowPlaying,
61     [libvlc_meta_Publisher]    = vlc_meta_Publisher,
62     [libvlc_meta_EncodedBy]    = vlc_meta_EncodedBy,
63     [libvlc_meta_ArtworkURL]   = vlc_meta_ArtworkURL,
64     [libvlc_meta_TrackID]      = vlc_meta_TrackID
65 };
66
67 static const libvlc_meta_t vlc_to_libvlc_meta[] =
68 {
69     [vlc_meta_Title]        = libvlc_meta_Title,
70     [vlc_meta_Artist]       = libvlc_meta_Artist,
71     [vlc_meta_Genre]        = libvlc_meta_Genre,
72     [vlc_meta_Copyright]    = libvlc_meta_Copyright,
73     [vlc_meta_Album]        = libvlc_meta_Album,
74     [vlc_meta_TrackNumber]  = libvlc_meta_TrackNumber,
75     [vlc_meta_Description]  = libvlc_meta_Description,
76     [vlc_meta_Rating]       = libvlc_meta_Rating,
77     [vlc_meta_Date]         = libvlc_meta_Date,
78     [vlc_meta_Setting]      = libvlc_meta_Setting,
79     [vlc_meta_URL]          = libvlc_meta_URL,
80     [vlc_meta_Language]     = libvlc_meta_Language,
81     [vlc_meta_NowPlaying]   = libvlc_meta_NowPlaying,
82     [vlc_meta_Publisher]    = libvlc_meta_Publisher,
83     [vlc_meta_EncodedBy]    = libvlc_meta_EncodedBy,
84     [vlc_meta_ArtworkURL]   = libvlc_meta_ArtworkURL,
85     [vlc_meta_TrackID]      = libvlc_meta_TrackID
86 };
87
88 /**************************************************************************
89  * input_item_subitem_added (Private) (vlc event Callback)
90  **************************************************************************/
91 static void input_item_subitem_added( const vlc_event_t *p_event,
92                                        void * user_data )
93 {
94     libvlc_media_t * p_md = user_data;
95     libvlc_media_t * p_md_child;
96     libvlc_event_t event;
97
98     p_md_child = libvlc_media_new_from_input_item(
99                 p_md->p_libvlc_instance,
100                 p_event->u.input_item_subitem_added.p_new_child );
101
102     /* Add this to our media list */
103     if( !p_md->p_subitems )
104     {
105         p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance );
106         libvlc_media_list_set_media( p_md->p_subitems, p_md );
107     }
108     if( p_md->p_subitems )
109     {
110         libvlc_media_list_add_media( p_md->p_subitems, p_md_child );
111     }
112
113     /* Construct the event */
114     event.type = libvlc_MediaSubItemAdded;
115     event.u.media_subitem_added.new_child = p_md_child;
116
117     /* Send the event */
118     libvlc_event_send( p_md->p_event_manager, &event );
119     libvlc_media_release( p_md_child );
120 }
121
122 /**************************************************************************
123  * input_item_meta_changed (Private) (vlc event Callback)
124  **************************************************************************/
125 static void input_item_meta_changed( const vlc_event_t *p_event,
126                                      void * user_data )
127 {
128     libvlc_media_t * p_md = user_data;
129     libvlc_event_t event;
130
131     /* Construct the event */
132     event.type = libvlc_MediaMetaChanged;
133     event.u.media_meta_changed.meta_type =
134         vlc_to_libvlc_meta[p_event->u.input_item_meta_changed.meta_type];
135
136     /* Send the event */
137     libvlc_event_send( p_md->p_event_manager, &event );
138 }
139
140 /**************************************************************************
141  * input_item_duration_changed (Private) (vlc event Callback)
142  **************************************************************************/
143 static void input_item_duration_changed( const vlc_event_t *p_event,
144                                          void * user_data )
145 {
146     libvlc_media_t * p_md = user_data;
147     libvlc_event_t event;
148
149     /* Construct the event */
150     event.type = libvlc_MediaDurationChanged;
151     event.u.media_duration_changed.new_duration =
152         from_mtime(p_event->u.input_item_duration_changed.new_duration);
153
154     /* Send the event */
155     libvlc_event_send( p_md->p_event_manager, &event );
156 }
157
158 /**************************************************************************
159  * input_item_preparsed_changed (Private) (vlc event Callback)
160  **************************************************************************/
161 static void input_item_preparsed_changed( const vlc_event_t *p_event,
162                                           void * user_data )
163 {
164     libvlc_media_t * p_md = user_data;
165     libvlc_event_t event;
166
167     /* Construct the event */
168     event.type = libvlc_MediaPreparsedChanged;
169     event.u.media_preparsed_changed.new_status = 
170         p_event->u.input_item_preparsed_changed.new_status;
171
172     /* Send the event */
173     libvlc_event_send( p_md->p_event_manager, &event );
174 }
175
176 /**************************************************************************
177  * Install event handler (Private)
178  **************************************************************************/
179 static void install_input_item_observer( libvlc_media_t *p_md )
180 {
181     vlc_event_attach( &p_md->p_input_item->event_manager,
182                       vlc_InputItemSubItemAdded,
183                       input_item_subitem_added,
184                       p_md );
185     vlc_event_attach( &p_md->p_input_item->event_manager,
186                       vlc_InputItemMetaChanged,
187                       input_item_meta_changed,
188                       p_md );
189     vlc_event_attach( &p_md->p_input_item->event_manager,
190                       vlc_InputItemDurationChanged,
191                       input_item_duration_changed,
192                       p_md );
193     vlc_event_attach( &p_md->p_input_item->event_manager,
194                       vlc_InputItemPreparsedChanged,
195                       input_item_preparsed_changed,
196                       p_md );
197 }
198
199 /**************************************************************************
200  * Uninstall event handler (Private)
201  **************************************************************************/
202 static void uninstall_input_item_observer( libvlc_media_t *p_md )
203 {
204     vlc_event_detach( &p_md->p_input_item->event_manager,
205                       vlc_InputItemSubItemAdded,
206                       input_item_subitem_added,
207                       p_md );
208     vlc_event_detach( &p_md->p_input_item->event_manager,
209                       vlc_InputItemMetaChanged,
210                       input_item_meta_changed,
211                       p_md );
212     vlc_event_detach( &p_md->p_input_item->event_manager,
213                       vlc_InputItemDurationChanged,
214                       input_item_duration_changed,
215                       p_md );
216     vlc_event_detach( &p_md->p_input_item->event_manager,
217                       vlc_InputItemPreparsedChanged,
218                       input_item_preparsed_changed,
219                       p_md );
220 }
221
222 /**************************************************************************
223  * Preparse if not already done (Private)
224  **************************************************************************/
225 static void preparse_if_needed( libvlc_media_t *p_md )
226 {
227     /* XXX: need some locking here */
228     if (!p_md->b_preparsed)
229     {
230         playlist_PreparseEnqueue(
231                 libvlc_priv (p_md->p_libvlc_instance->p_libvlc_int)->p_playlist,
232                 p_md->p_input_item );
233         p_md->b_preparsed = true;
234     }
235 }
236
237 /**************************************************************************
238  * Create a new media descriptor object from an input_item
239  * (libvlc internal)
240  * That's the generic constructor
241  **************************************************************************/
242 libvlc_media_t * libvlc_media_new_from_input_item(
243                                    libvlc_instance_t *p_instance,
244                                    input_item_t *p_input_item )
245 {
246     libvlc_media_t * p_md;
247
248     if (!p_input_item)
249     {
250         libvlc_printerr( "No input item given" );
251         return NULL;
252     }
253
254     p_md = calloc( 1, sizeof(libvlc_media_t) );
255     if( !p_md )
256     {
257         libvlc_printerr( "Not enough memory" );
258         return NULL;
259     }
260
261     p_md->p_libvlc_instance = p_instance;
262     p_md->p_input_item      = p_input_item;
263     p_md->i_refcount        = 1;
264
265     p_md->state = libvlc_NothingSpecial;
266
267     /* A media descriptor can be a playlist. When you open a playlist
268      * It can give a bunch of item to read. */
269     p_md->p_subitems        = NULL;
270
271     p_md->p_event_manager = libvlc_event_manager_new( p_md, p_instance );
272     if( unlikely(p_md->p_event_manager == NULL) )
273     {
274         free(p_md);
275         return NULL;
276     }
277     libvlc_event_manager_register_event_type( p_md->p_event_manager,
278         libvlc_MediaMetaChanged );
279     libvlc_event_manager_register_event_type( p_md->p_event_manager,
280         libvlc_MediaSubItemAdded );
281     libvlc_event_manager_register_event_type( p_md->p_event_manager,
282         libvlc_MediaFreed );
283     libvlc_event_manager_register_event_type( p_md->p_event_manager,
284         libvlc_MediaDurationChanged );
285     libvlc_event_manager_register_event_type( p_md->p_event_manager,
286         libvlc_MediaStateChanged );
287
288     vlc_gc_incref( p_md->p_input_item );
289
290     install_input_item_observer( p_md );
291
292     return p_md;
293 }
294
295 /**************************************************************************
296  * Create a new media descriptor object
297  **************************************************************************/
298 libvlc_media_t *libvlc_media_new_location( libvlc_instance_t *p_instance,
299                                            const char * psz_mrl )
300 {
301     input_item_t * p_input_item;
302     libvlc_media_t * p_md;
303
304     p_input_item = input_item_New( p_instance->p_libvlc_int, psz_mrl, NULL );
305
306     if (!p_input_item)
307     {
308         libvlc_printerr( "Not enough memory" );
309         return NULL;
310     }
311
312     p_md = libvlc_media_new_from_input_item( p_instance, p_input_item );
313
314     /* The p_input_item is retained in libvlc_media_new_from_input_item */
315     vlc_gc_decref( p_input_item );
316
317     return p_md;
318 }
319
320 libvlc_media_t *libvlc_media_new_path( libvlc_instance_t *p_instance,
321                                        const char *path )
322 {
323     char *mrl = make_URI( path );
324     if( unlikely(mrl == NULL) )
325     {
326         libvlc_printerr( "Not enough memory" );
327         return NULL;
328     }
329
330     libvlc_media_t *m = libvlc_media_new_location( p_instance, mrl );
331     free( mrl );
332     return m;
333 }
334
335 /**************************************************************************
336  * Create a new media descriptor object
337  **************************************************************************/
338 libvlc_media_t * libvlc_media_new_as_node( libvlc_instance_t *p_instance,
339                                            const char * psz_name )
340 {
341     input_item_t * p_input_item;
342     libvlc_media_t * p_md;
343
344     p_input_item = input_item_New( p_instance->p_libvlc_int, "vlc://nop", psz_name );
345
346     if (!p_input_item)
347     {
348         libvlc_printerr( "Not enough memory" );
349         return NULL;
350     }
351
352     p_md = libvlc_media_new_from_input_item( p_instance, p_input_item );
353
354     p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance );
355
356     return p_md;
357 }
358
359 /**************************************************************************
360  * Add an option to the media descriptor,
361  * that will be used to determine how the media_player will read the
362  * media. This allow to use VLC advanced reading/streaming
363  * options in a per-media basis
364  *
365  * The options are detailled in vlc --long-help, for instance "--sout-all"
366  **************************************************************************/
367 void libvlc_media_add_option( libvlc_media_t * p_md,
368                               const char * psz_option )
369 {
370     libvlc_media_add_option_flag( p_md, psz_option,
371                           VLC_INPUT_OPTION_UNIQUE|VLC_INPUT_OPTION_TRUSTED );
372 }
373
374 /**************************************************************************
375  * Same as libvlc_media_add_option but with configurable flags.
376  **************************************************************************/
377 void libvlc_media_add_option_flag( libvlc_media_t * p_md,
378                                    const char * ppsz_option,
379                                    unsigned i_flags )
380 {
381     input_item_AddOption( p_md->p_input_item, ppsz_option, i_flags );
382 }
383
384 /**************************************************************************
385  * Delete a media descriptor object
386  **************************************************************************/
387 void libvlc_media_release( libvlc_media_t *p_md )
388 {
389     if (!p_md)
390         return;
391
392     p_md->i_refcount--;
393
394     if( p_md->i_refcount > 0 )
395         return;
396
397     if( p_md->p_subitems )
398         libvlc_media_list_release( p_md->p_subitems );
399
400     uninstall_input_item_observer( p_md );
401     vlc_gc_decref( p_md->p_input_item );
402
403     /* Construct the event */
404     libvlc_event_t event;
405     event.type = libvlc_MediaFreed;
406     event.u.media_freed.md = p_md;
407
408     /* Send the event */
409     libvlc_event_send( p_md->p_event_manager, &event );
410
411     libvlc_event_manager_release( p_md->p_event_manager );
412
413     free( p_md );
414 }
415
416 /**************************************************************************
417  * Retain a media descriptor object
418  **************************************************************************/
419 void libvlc_media_retain( libvlc_media_t *p_md )
420 {
421     assert (p_md);
422     p_md->i_refcount++;
423 }
424
425 /**************************************************************************
426  * Duplicate a media descriptor object
427  **************************************************************************/
428 libvlc_media_t *
429 libvlc_media_duplicate( libvlc_media_t *p_md_orig )
430 {
431     return libvlc_media_new_from_input_item(
432         p_md_orig->p_libvlc_instance, p_md_orig->p_input_item );
433 }
434
435 /**************************************************************************
436  * Get mrl from a media descriptor object
437  **************************************************************************/
438 char *
439 libvlc_media_get_mrl( libvlc_media_t * p_md )
440 {
441     assert( p_md );
442     return input_item_GetURI( p_md->p_input_item );
443 }
444
445 /**************************************************************************
446  * Getter for meta information
447  **************************************************************************/
448
449 char *libvlc_media_get_meta( libvlc_media_t *p_md, libvlc_meta_t e_meta )
450 {
451     char * psz_meta;
452
453     assert( p_md );
454     /* XXX: locking */
455
456     preparse_if_needed( p_md );
457
458     psz_meta = input_item_GetMeta( p_md->p_input_item,
459                                    libvlc_to_vlc_meta[e_meta] );
460
461     if( e_meta == libvlc_meta_ArtworkURL && !psz_meta && !p_md->has_asked_art )
462     {
463         p_md->has_asked_art = true;
464         playlist_AskForArtEnqueue(
465                 libvlc_priv(p_md->p_libvlc_instance->p_libvlc_int)->p_playlist,
466                 p_md->p_input_item );
467     }
468
469     /* Should be integrated in core */
470     if( !psz_meta && e_meta == libvlc_meta_Title && p_md->p_input_item->psz_name )
471     {
472         free( psz_meta );
473         return strdup( p_md->p_input_item->psz_name );
474     }
475
476     return psz_meta;
477 }
478
479 /**************************************************************************
480  * Setter for meta information
481  **************************************************************************/
482
483 void libvlc_media_set_meta( libvlc_media_t *p_md, libvlc_meta_t e_meta, const char *psz_value )
484 {
485     assert( p_md );
486     input_item_SetMeta( p_md->p_input_item, libvlc_to_vlc_meta[e_meta], psz_value );
487 }
488
489 int libvlc_media_save_meta( libvlc_media_t *p_md )
490 {
491     assert( p_md );
492     vlc_object_t *p_obj = VLC_OBJECT(libvlc_priv(
493                             p_md->p_libvlc_instance->p_libvlc_int)->p_playlist);
494     return input_item_WriteMeta( p_obj, p_md->p_input_item ) == VLC_SUCCESS;
495 }
496
497 /**************************************************************************
498  * Getter for state information
499  * Can be error, playing, buffering, NothingSpecial.
500  **************************************************************************/
501
502 libvlc_state_t
503 libvlc_media_get_state( libvlc_media_t *p_md )
504 {
505     assert( p_md );
506     return p_md->state;
507 }
508
509 /**************************************************************************
510  * Setter for state information (LibVLC Internal)
511  **************************************************************************/
512
513 void
514 libvlc_media_set_state( libvlc_media_t *p_md,
515                                    libvlc_state_t state )
516 {
517     libvlc_event_t event;
518
519     p_md->state = state;
520
521     /* Construct the event */
522     event.type = libvlc_MediaStateChanged;
523     event.u.media_state_changed.new_state = state;
524
525     /* Send the event */
526     libvlc_event_send( p_md->p_event_manager, &event );
527 }
528
529 /**************************************************************************
530  * subitems
531  **************************************************************************/
532 libvlc_media_list_t *
533 libvlc_media_subitems( libvlc_media_t * p_md )
534 {
535     if( p_md->p_subitems )
536         libvlc_media_list_retain( p_md->p_subitems );
537     return p_md->p_subitems;
538 }
539
540 /**************************************************************************
541  * Getter for statistics information
542  **************************************************************************/
543 int libvlc_media_get_stats( libvlc_media_t *p_md,
544                             libvlc_media_stats_t *p_stats )
545 {
546     if( !p_md->p_input_item )
547         return false;
548
549     input_stats_t *p_itm_stats = p_md->p_input_item->p_stats;
550     vlc_mutex_lock( &p_itm_stats->lock );
551     p_stats->i_read_bytes = p_itm_stats->i_read_bytes;
552     p_stats->f_input_bitrate = p_itm_stats->f_input_bitrate;
553
554     p_stats->i_demux_read_bytes = p_itm_stats->i_demux_read_bytes;
555     p_stats->f_demux_bitrate = p_itm_stats->f_demux_bitrate;
556     p_stats->i_demux_corrupted = p_itm_stats->i_demux_corrupted;
557     p_stats->i_demux_discontinuity = p_itm_stats->i_demux_discontinuity;
558
559     p_stats->i_decoded_video = p_itm_stats->i_decoded_video;
560     p_stats->i_decoded_audio = p_itm_stats->i_decoded_audio;
561
562     p_stats->i_displayed_pictures = p_itm_stats->i_displayed_pictures;
563     p_stats->i_lost_pictures = p_itm_stats->i_lost_pictures;
564
565     p_stats->i_played_abuffers = p_itm_stats->i_played_abuffers;
566     p_stats->i_lost_abuffers = p_itm_stats->i_lost_abuffers;
567
568     p_stats->i_sent_packets = p_itm_stats->i_sent_packets;
569     p_stats->i_sent_bytes = p_itm_stats->i_sent_bytes;
570     p_stats->f_send_bitrate = p_itm_stats->f_send_bitrate;
571     vlc_mutex_unlock( &p_itm_stats->lock );
572     return true;
573 }
574
575 /**************************************************************************
576  * event_manager
577  **************************************************************************/
578 libvlc_event_manager_t *
579 libvlc_media_event_manager( libvlc_media_t * p_md )
580 {
581     assert( p_md );
582
583     return p_md->p_event_manager;
584 }
585
586 /**************************************************************************
587  * Get duration of media object (in ms)
588  **************************************************************************/
589 int64_t
590 libvlc_media_get_duration( libvlc_media_t * p_md )
591 {
592     assert( p_md );
593
594     if( !p_md->p_input_item )
595     {
596         libvlc_printerr( "No input item" );
597         return -1;
598     }
599
600     preparse_if_needed( p_md );
601
602     if (!input_item_IsPreparsed( p_md->p_input_item ))
603         return -1;
604
605     return from_mtime(input_item_GetDuration( p_md->p_input_item ));
606 }
607
608 /**************************************************************************
609  * Get preparsed status for media object.
610  **************************************************************************/
611 int
612 libvlc_media_is_preparsed( libvlc_media_t * p_md )
613 {
614     assert( p_md );
615
616     if( !p_md->p_input_item )
617         return false;
618
619     return input_item_IsPreparsed( p_md->p_input_item );
620 }
621
622 /**************************************************************************
623  * Sets media descriptor's user_data. user_data is specialized data 
624  * accessed by the host application, VLC.framework uses it as a pointer to 
625  * an native object that references a libvlc_media_t pointer
626  **************************************************************************/
627 void 
628 libvlc_media_set_user_data( libvlc_media_t * p_md, void * p_new_user_data )
629 {
630     assert( p_md );
631     p_md->p_user_data = p_new_user_data;
632 }
633
634 /**************************************************************************
635  * Get media descriptor's user_data. user_data is specialized data 
636  * accessed by the host application, VLC.framework uses it as a pointer to 
637  * an native object that references a libvlc_media_t pointer
638  **************************************************************************/
639 void *
640 libvlc_media_get_user_data( libvlc_media_t * p_md )
641 {
642     assert( p_md );
643     return p_md->p_user_data;
644 }
645
646 /**************************************************************************
647  * Get media descriptor's elementary streams description
648  **************************************************************************/
649 int
650 libvlc_media_get_es( libvlc_media_t *p_md, libvlc_media_es_t ** pp_es )
651 {
652     assert( p_md );
653
654     input_item_t *p_input_item = p_md->p_input_item;
655     vlc_mutex_lock( &p_input_item->lock );
656
657     const int i_es = p_input_item->i_es;
658     *pp_es = (i_es > 0) ? malloc( i_es * sizeof(libvlc_media_es_t) ) : NULL;
659
660     if( !pp_es ) /* no ES, or OOM */
661     {
662         vlc_mutex_unlock( &p_input_item->lock );
663         return 0;
664     }
665
666     /* Fill array */
667     for( int i = 0; i < i_es; i++ )
668     {
669         libvlc_media_es_t *p_mes = *pp_es+i;
670         const es_format_t *p_es = p_input_item->es[i];
671
672         p_mes->i_channels = p_mes->i_rate = 0;
673         p_mes->i_width = p_mes->i_height = 0;
674
675
676         p_mes->i_codec = p_es->i_codec;
677         p_mes->i_id = p_es->i_id;
678
679         p_mes->i_profile = p_es->i_profile;
680         p_mes->i_level = p_es->i_level;
681
682         switch(p_es->i_cat)
683         {
684         case UNKNOWN_ES:
685         default:
686             p_mes->i_type = libvlc_es_unknown;
687             break;
688         case VIDEO_ES:
689             p_mes->i_type = libvlc_es_video;
690             p_mes->i_height = p_es->video.i_height;
691             p_mes->i_width = p_es->video.i_width;
692             break;
693         case AUDIO_ES:
694             p_mes->i_type = libvlc_es_audio;
695             p_mes->i_channels = p_es->audio.i_channels;
696             p_mes->i_rate = p_es->audio.i_rate;
697             break;
698         case SPU_ES:
699             p_mes->i_type = libvlc_es_text;
700             break;
701         }
702     }
703
704     vlc_mutex_unlock( &p_input_item->lock );
705     return i_es;
706 }