]> git.sesse.net Git - vlc/blob - src/control/libvlc_internal.h
libvlc_InternalAddIntf: remove the other boolean
[vlc] / src / control / libvlc_internal.h
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
6  * $Id$
7  *
8  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #ifndef _LIBVLC_INTERNAL_H
26 #define _LIBVLC_INTERNAL_H 1
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc/vlc.h>
33 #include <vlc/libvlc_structures.h>
34
35 #include <vlc_common.h>
36 #include <vlc_arrays.h>
37 #include <vlc_input.h>
38
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 *, bool ) );
46
47 VLC_EXPORT (int, libvlc_InternalAddIntf, ( libvlc_int_t *, const char * ) );
48
49 /***************************************************************************
50  * Opaque structures for libvlc API
51  ***************************************************************************/
52
53 typedef int * libvlc_media_list_path_t; /* (Media List Player Internal) */
54
55 typedef enum libvlc_lock_state_t
56 {
57     libvlc_Locked,
58     libvlc_UnLocked
59 } libvlc_lock_state_t;
60
61 struct libvlc_instance_t
62 {
63     libvlc_int_t *p_libvlc_int;
64     vlm_t        *p_vlm;
65     int           b_playlist_locked;
66     unsigned      ref_count;
67     vlc_mutex_t   instance_lock;
68     vlc_mutex_t   event_callback_lock;
69     struct libvlc_callback_entry_list_t *p_callback_list;
70 };
71
72 struct libvlc_media_t
73 {
74     libvlc_event_manager_t * p_event_manager;
75     int                b_preparsed;
76     input_item_t      *p_input_item;
77     int                i_refcount;
78     libvlc_instance_t *p_libvlc_instance;
79     libvlc_state_t     state;
80     struct libvlc_media_list_t *p_subitems; /* A media descriptor can have
81                                            * Sub item */
82     void *p_user_data; /* Allows for VLC.framework to hook into media descriptor without creating a new VLCMedia object. */
83 };
84
85 struct libvlc_media_list_t
86 {
87     libvlc_event_manager_t *    p_event_manager;
88     libvlc_instance_t *         p_libvlc_instance;
89     int                         i_refcount;
90     vlc_mutex_t                 object_lock;
91     libvlc_media_t * p_md; /* The media from which the
92                                        * mlist comes, if any. */
93     vlc_array_t                items;
94  
95     /* Other way to see that media list */
96     /* Used in flat_media_list.c */
97     libvlc_media_list_t *       p_flat_mlist;
98
99     /* This indicates if this media list is read-only
100      * from a user point of view */
101     bool                  b_read_only;
102 };
103
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 ) ;
106
107 typedef int (*libvlc_media_list_view_count_func_t)( libvlc_media_list_view_t * p_mlv,
108         libvlc_exception_t * ) ;
109
110 typedef libvlc_media_t *
111         (*libvlc_media_list_view_item_at_index_func_t)(
112                 libvlc_media_list_view_t * p_mlv,
113                 int index,
114                 libvlc_exception_t * ) ;
115
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,
119                 int index,
120                 libvlc_exception_t * ) ;
121
122 /* A way to see a media list */
123 struct libvlc_media_list_view_t
124 {
125     libvlc_event_manager_t *    p_event_manager;
126     libvlc_instance_t *         p_libvlc_instance;
127     int                         i_refcount;
128     vlc_mutex_t                 object_lock;
129     
130     libvlc_media_list_t *       p_mlist;
131
132     struct libvlc_media_list_view_private_t * p_this_view_data;
133
134     /* Accessors */
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;
138
139     libvlc_media_list_view_constructor_func_t         pf_constructor;
140     libvlc_media_list_view_release_func_t            pf_release;
141
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 *);
145 };
146
147 struct libvlc_media_player_t
148 {
149     int                i_refcount;
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;
156     
157     bool        b_own_its_input_thread;
158 };
159
160 struct libvlc_media_list_player_t
161 {
162     libvlc_event_manager_t *    p_event_manager;
163     libvlc_instance_t *         p_libvlc_instance;
164     int                         i_refcount;
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;
170 };
171
172 struct libvlc_media_library_t
173 {
174     libvlc_event_manager_t * p_event_manager;
175     libvlc_instance_t *      p_libvlc_instance;
176     int                      i_refcount;
177     libvlc_media_list_t *    p_mlist;
178 };
179
180 struct libvlc_media_discoverer_t
181 {
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;
186     bool               running;
187     vlc_dictionary_t         catname_to_submedialist;
188 };
189
190 /*
191  * Event Handling
192  */
193 /* Example usage
194  *
195  * struct libvlc_cool_object_t
196  * {
197  *        ...
198  *        libvlc_event_manager_t * p_event_manager;
199  *        ...
200  * }
201  *
202  * libvlc_my_cool_object_new()
203  * {
204  *        ...
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)
209  *        ...
210  * }
211  *
212  * libvlc_my_cool_object_release()
213  * {
214  *         ...
215  *         libvlc_event_manager_release( p_self->p_event_manager );
216  *         ...
217  * }
218  *
219  * libvlc_my_cool_object_do_something()
220  * {
221  *        ...
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 );
226  * }
227  * */
228
229 typedef struct libvlc_event_listener_t
230 {
231     libvlc_event_type_t event_type;
232     void *              p_user_data;
233     libvlc_callback_t   pf_callback;
234 } libvlc_event_listener_t;
235
236 typedef struct libvlc_event_listeners_group_t
237 {
238     libvlc_event_type_t event_type;
239     vlc_array_t listeners;
240     bool b_sublistener_removed;
241 } libvlc_event_listeners_group_t;
242
243 typedef struct libvlc_event_manager_t
244 {
245     void * p_obj;
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;
251
252
253 /***************************************************************************
254  * Other internal functions
255  ***************************************************************************/
256 input_thread_t *libvlc_get_input_thread(
257      libvlc_media_player_t *,
258     libvlc_exception_t * );
259
260 /* Media instance */
261 libvlc_media_player_t *
262 libvlc_media_player_new_from_input_thread( libvlc_instance_t *,
263                                            input_thread_t *,
264                                            libvlc_exception_t * );
265
266 void libvlc_media_player_destroy(
267         libvlc_media_player_t * );
268
269 /* Media Descriptor */
270 libvlc_media_t * libvlc_media_new_from_input_item(
271         libvlc_instance_t *, input_item_t *,
272         libvlc_exception_t * );
273
274 void libvlc_media_set_state(
275         libvlc_media_t *, libvlc_state_t,
276         libvlc_exception_t * );
277
278 /* Media List */
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 );
283
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 );
288
289 void _libvlc_media_list_remove_index(
290         libvlc_media_list_t * p_mlist, int index,
291         libvlc_exception_t * p_e );
292
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 );
303
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 *) );
308
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 );
312
313 void libvlc_media_list_view_item_deleted(
314         libvlc_media_list_view_t * p_mlv,
315         libvlc_media_t * p_item, int index );
316
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 );
320
321 void libvlc_media_list_view_item_added(
322         libvlc_media_list_view_t * p_mlv,
323         libvlc_media_t * p_item, int index );
324
325 /* Events */
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 );
329
330 void libvlc_event_manager_release(
331         libvlc_event_manager_t * p_em );
332
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 );
337
338 void libvlc_event_send(
339         libvlc_event_manager_t * p_em,
340         libvlc_event_t * p_event );
341
342
343 /* Exception shorcuts */
344
345 #define RAISENULL( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
346                                 return NULL; }
347 #define RAISEVOID( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
348                                 return; }
349 #define RAISEZERO( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
350                                 return 0; }
351
352 #endif