audiotrack: refactor
[vlc.git] / lib / media_internal.h
blobe4d0d03faec45bb11621c0bfae1cb269c783f258
1 /*****************************************************************************
2 * media_internal.h : Definition of opaque structures for libvlc exported API
3 * Also contains some internal utility functions
4 *****************************************************************************
5 * Copyright (C) 2005-2009 VLC authors and VideoLAN
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 #ifndef _LIBVLC_MEDIA_INTERNAL_H
25 #define _LIBVLC_MEDIA_INTERNAL_H 1
27 #include <vlc/libvlc.h>
28 #include <vlc/libvlc_media.h>
30 #include <vlc_common.h>
31 #include <vlc_input.h>
32 #include <vlc_player.h>
33 #include <vlc_atomic.h>
35 struct libvlc_media_t
37 libvlc_event_manager_t event_manager;
38 input_item_t *p_input_item;
39 int i_refcount;
40 libvlc_instance_t *p_libvlc_instance;
41 libvlc_state_t state;
42 VLC_FORWARD_DECLARE_OBJECT(libvlc_media_list_t*) p_subitems; /* A media descriptor can have Sub items. This is the only dependancy we really have on media_list */
43 void *p_user_data;
45 vlc_cond_t parsed_cond;
46 vlc_mutex_t parsed_lock;
47 vlc_mutex_t subitems_lock;
49 libvlc_media_parsed_status_t parsed_status;
50 bool is_parsed;
51 bool has_asked_preparse;
54 /* Media Descriptor */
55 libvlc_media_t * libvlc_media_new_from_input_item(
56 libvlc_instance_t *, input_item_t * );
58 void libvlc_media_set_state( libvlc_media_t *, libvlc_state_t );
59 void libvlc_media_add_subtree(libvlc_media_t *, input_item_node_t *);
61 static inline enum es_format_category_e
62 libvlc_track_type_to_escat( libvlc_track_type_t i_type )
64 switch( i_type )
66 case libvlc_track_audio:
67 return AUDIO_ES;
68 case libvlc_track_video:
69 return VIDEO_ES;
70 case libvlc_track_text:
71 return SPU_ES;
72 case libvlc_track_unknown:
73 default:
74 return UNKNOWN_ES;
78 typedef struct libvlc_media_trackpriv_t
80 libvlc_media_track_t t;
81 union {
82 libvlc_audio_track_t audio;
83 libvlc_video_track_t video;
84 libvlc_subtitle_track_t subtitle;
86 vlc_es_id_t *es_id;
87 vlc_atomic_rc_t rc;
88 } libvlc_media_trackpriv_t;
90 static inline const libvlc_media_trackpriv_t *
91 libvlc_media_track_to_priv( const libvlc_media_track_t *track )
93 return container_of( track, const libvlc_media_trackpriv_t, t );
96 void
97 libvlc_media_trackpriv_from_es( libvlc_media_trackpriv_t *trackpriv,
98 const es_format_t *es );
100 libvlc_media_track_t *
101 libvlc_media_track_create_from_player_track( const struct vlc_player_track *track );
103 libvlc_media_tracklist_t *
104 libvlc_media_tracklist_from_es_array( es_format_t **es_array,
105 size_t es_count,
106 libvlc_track_type_t type );
108 libvlc_media_tracklist_t *
109 libvlc_media_tracklist_from_player( vlc_player_t *player,
110 libvlc_track_type_t type );
112 void
113 libvlc_media_track_clean( libvlc_media_track_t *track );
115 #endif