1 /*****************************************************************************
2 * libvlc_internal.h : Definition of opaque structures for libvlc exported API
3 * Also contains some internal utility functions
4 *****************************************************************************
5 * Copyright (C) 2005 the VideoLAN team
8 * Authors: Clément Stenac <zorglub@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef _LIBVLC_INTERNAL_H
26 #define _LIBVLC_INTERNAL_H 1
33 #include <vlc/libvlc_structures.h>
35 #include <vlc_common.h>
36 #include <vlc_arrays.h>
37 #include <vlc_input.h>
39 /***************************************************************************
40 * Internal creation and destruction functions
41 ***************************************************************************/
42 VLC_EXPORT (libvlc_int_t *, libvlc_InternalCreate, ( void ) );
43 VLC_EXPORT (int, libvlc_InternalInit, ( libvlc_int_t *, int, const char *ppsz_argv[] ) );
44 VLC_EXPORT (int, libvlc_InternalCleanup, ( libvlc_int_t * ) );
45 VLC_EXPORT (int, libvlc_InternalDestroy, ( libvlc_int_t * ) );
47 VLC_EXPORT (int, libvlc_InternalAddIntf, ( libvlc_int_t *, const char * ) );
49 /***************************************************************************
50 * Opaque structures for libvlc API
51 ***************************************************************************/
53 typedef int * libvlc_media_list_path_t; /* (Media List Player Internal) */
55 typedef enum libvlc_lock_state_t
59 } libvlc_lock_state_t;
61 struct libvlc_instance_t
63 libvlc_int_t *p_libvlc_int;
65 int b_playlist_locked;
67 vlc_mutex_t instance_lock;
68 vlc_mutex_t event_callback_lock;
69 struct libvlc_callback_entry_list_t *p_callback_list;
74 libvlc_event_manager_t * p_event_manager;
76 input_item_t *p_input_item;
78 libvlc_instance_t *p_libvlc_instance;
80 struct libvlc_media_list_t *p_subitems; /* A media descriptor can have
82 void *p_user_data; /* Allows for VLC.framework to hook into media descriptor without creating a new VLCMedia object. */
85 struct libvlc_media_list_t
87 libvlc_event_manager_t * p_event_manager;
88 libvlc_instance_t * p_libvlc_instance;
90 vlc_mutex_t object_lock;
91 libvlc_media_t * p_md; /* The media from which the
92 * mlist comes, if any. */
95 /* Other way to see that media list */
96 /* Used in flat_media_list.c */
97 libvlc_media_list_t * p_flat_mlist;
99 /* This indicates if this media list is read-only
100 * from a user point of view */
104 typedef libvlc_media_list_view_t * (*libvlc_media_list_view_constructor_func_t)( libvlc_media_list_t * p_mlist, libvlc_exception_t * p_e ) ;
105 typedef void (*libvlc_media_list_view_release_func_t)( libvlc_media_list_view_t * p_mlv ) ;
107 typedef int (*libvlc_media_list_view_count_func_t)( libvlc_media_list_view_t * p_mlv,
108 libvlc_exception_t * ) ;
110 typedef libvlc_media_t *
111 (*libvlc_media_list_view_item_at_index_func_t)(
112 libvlc_media_list_view_t * p_mlv,
114 libvlc_exception_t * ) ;
116 typedef libvlc_media_list_view_t *
117 (*libvlc_media_list_view_children_at_index_func_t)(
118 libvlc_media_list_view_t * p_mlv,
120 libvlc_exception_t * ) ;
122 /* A way to see a media list */
123 struct libvlc_media_list_view_t
125 libvlc_event_manager_t * p_event_manager;
126 libvlc_instance_t * p_libvlc_instance;
128 vlc_mutex_t object_lock;
130 libvlc_media_list_t * p_mlist;
132 struct libvlc_media_list_view_private_t * p_this_view_data;
135 libvlc_media_list_view_count_func_t pf_count;
136 libvlc_media_list_view_item_at_index_func_t pf_item_at_index;
137 libvlc_media_list_view_children_at_index_func_t pf_children_at_index;
139 libvlc_media_list_view_constructor_func_t pf_constructor;
140 libvlc_media_list_view_release_func_t pf_release;
142 /* Notification callback */
143 void (*pf_ml_item_added)(const libvlc_event_t *, libvlc_media_list_view_t *);
144 void (*pf_ml_item_removed)(const libvlc_event_t *, libvlc_media_list_view_t *);
147 struct libvlc_media_player_t
150 vlc_mutex_t object_lock;
151 input_thread_t * p_input_thread;
152 struct libvlc_instance_t * p_libvlc_instance; /* Parent instance */
153 libvlc_media_t * p_md; /* current media descriptor */
154 libvlc_event_manager_t * p_event_manager;
155 libvlc_drawable_t drawable;
157 bool b_own_its_input_thread;
160 struct libvlc_media_list_player_t
162 libvlc_event_manager_t * p_event_manager;
163 libvlc_instance_t * p_libvlc_instance;
165 vlc_mutex_t object_lock;
166 libvlc_media_list_path_t current_playing_item_path;
167 libvlc_media_t * p_current_playing_item;
168 libvlc_media_list_t * p_mlist;
169 libvlc_media_player_t * p_mi;
172 struct libvlc_media_library_t
174 libvlc_event_manager_t * p_event_manager;
175 libvlc_instance_t * p_libvlc_instance;
177 libvlc_media_list_t * p_mlist;
180 struct libvlc_media_discoverer_t
182 libvlc_event_manager_t * p_event_manager;
183 libvlc_instance_t * p_libvlc_instance;
184 services_discovery_t * p_sd;
185 libvlc_media_list_t * p_mlist;
187 vlc_dictionary_t catname_to_submedialist;
195 * struct libvlc_cool_object_t
198 * libvlc_event_manager_t * p_event_manager;
202 * libvlc_my_cool_object_new()
205 * p_self->p_event_manager = libvlc_event_manager_init( p_self,
206 * p_self->p_libvlc_instance, p_e);
207 * libvlc_event_manager_register_event_type(p_self->p_event_manager,
208 * libvlc_MyCoolObjectDidSomething, p_e)
212 * libvlc_my_cool_object_release()
215 * libvlc_event_manager_release( p_self->p_event_manager );
219 * libvlc_my_cool_object_do_something()
222 * libvlc_event_t event;
223 * event.type = libvlc_MyCoolObjectDidSomething;
224 * event.u.my_cool_object_did_something.what_it_did = kSomething;
225 * libvlc_event_send( p_self->p_event_manager, &event );
229 typedef struct libvlc_event_listener_t
231 libvlc_event_type_t event_type;
233 libvlc_callback_t pf_callback;
234 } libvlc_event_listener_t;
236 typedef struct libvlc_event_listeners_group_t
238 libvlc_event_type_t event_type;
239 vlc_array_t listeners;
240 bool b_sublistener_removed;
241 } libvlc_event_listeners_group_t;
243 typedef struct libvlc_event_manager_t
246 struct libvlc_instance_t * p_libvlc_instance;
247 vlc_array_t listeners_groups;
248 vlc_mutex_t object_lock;
249 vlc_mutex_t event_sending_lock;
250 } libvlc_event_sender_t;
253 /***************************************************************************
254 * Other internal functions
255 ***************************************************************************/
256 input_thread_t *libvlc_get_input_thread(
257 libvlc_media_player_t *,
258 libvlc_exception_t * );
261 libvlc_media_player_t *
262 libvlc_media_player_new_from_input_thread( libvlc_instance_t *,
264 libvlc_exception_t * );
266 void libvlc_media_player_destroy(
267 libvlc_media_player_t * );
269 /* Media Descriptor */
270 libvlc_media_t * libvlc_media_new_from_input_item(
271 libvlc_instance_t *, input_item_t *,
272 libvlc_exception_t * );
274 void libvlc_media_set_state(
275 libvlc_media_t *, libvlc_state_t,
276 libvlc_exception_t * );
279 void _libvlc_media_list_add_media(
280 libvlc_media_list_t * p_mlist,
281 libvlc_media_t * p_md,
282 libvlc_exception_t * p_e );
284 void _libvlc_media_list_insert_media(
285 libvlc_media_list_t * p_mlist,
286 libvlc_media_t * p_md, int index,
287 libvlc_exception_t * p_e );
289 void _libvlc_media_list_remove_index(
290 libvlc_media_list_t * p_mlist, int index,
291 libvlc_exception_t * p_e );
293 /* Media List View */
294 libvlc_media_list_view_t * libvlc_media_list_view_new(
295 libvlc_media_list_t * p_mlist,
296 libvlc_media_list_view_count_func_t pf_count,
297 libvlc_media_list_view_item_at_index_func_t pf_item_at_index,
298 libvlc_media_list_view_children_at_index_func_t pf_children_at_index,
299 libvlc_media_list_view_constructor_func_t pf_constructor,
300 libvlc_media_list_view_release_func_t pf_release,
301 void * this_view_data,
302 libvlc_exception_t * p_e );
304 void libvlc_media_list_view_set_ml_notification_callback(
305 libvlc_media_list_view_t * p_mlv,
306 void (*item_added)(const libvlc_event_t *, libvlc_media_list_view_t *),
307 void (*item_removed)(const libvlc_event_t *, libvlc_media_list_view_t *) );
309 void libvlc_media_list_view_will_delete_item(
310 libvlc_media_list_view_t * p_mlv,
311 libvlc_media_t * p_item, int index );
313 void libvlc_media_list_view_item_deleted(
314 libvlc_media_list_view_t * p_mlv,
315 libvlc_media_t * p_item, int index );
317 void libvlc_media_list_view_will_add_item (
318 libvlc_media_list_view_t * p_mlv,
319 libvlc_media_t * p_item, int index );
321 void libvlc_media_list_view_item_added(
322 libvlc_media_list_view_t * p_mlv,
323 libvlc_media_t * p_item, int index );
326 libvlc_event_manager_t * libvlc_event_manager_new(
327 void * p_obj, libvlc_instance_t * p_libvlc_inst,
328 libvlc_exception_t *p_e );
330 void libvlc_event_manager_release(
331 libvlc_event_manager_t * p_em );
333 void libvlc_event_manager_register_event_type(
334 libvlc_event_manager_t * p_em,
335 libvlc_event_type_t event_type,
336 libvlc_exception_t * p_e );
338 void libvlc_event_send(
339 libvlc_event_manager_t * p_em,
340 libvlc_event_t * p_event );
343 /* Exception shorcuts */
345 #define RAISENULL( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
347 #define RAISEVOID( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
349 #define RAISEZERO( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \