]> git.sesse.net Git - vlc/blob - src/control/libvlc_internal.h
VLC_PRIVATE_API: no-op, removed
[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_arrays.h>
36 #include <vlc_input.h>
37
38 # ifdef __cplusplus
39 extern "C" {
40 # endif
41
42 /***************************************************************************
43  * Internal creation and destruction functions
44  ***************************************************************************/
45 VLC_EXPORT (libvlc_int_t *, libvlc_InternalCreate, ( void ) );
46 VLC_EXPORT (int, libvlc_InternalInit, ( libvlc_int_t *, int, const char *ppsz_argv[] ) );
47 VLC_EXPORT (int, libvlc_InternalCleanup, ( libvlc_int_t * ) );
48 VLC_EXPORT (int, libvlc_InternalDestroy, ( libvlc_int_t *, bool ) );
49
50 VLC_EXPORT (int, libvlc_InternalAddIntf, ( libvlc_int_t *, const char *, bool,
51                             bool, int, const char *const * ) );
52
53 /***************************************************************************
54  * Opaque structures for libvlc API
55  ***************************************************************************/
56
57 typedef int * libvlc_media_list_path_t; /* (Media List Player Internal) */
58
59 typedef enum libvlc_lock_state_t
60 {
61     libvlc_Locked,
62     libvlc_UnLocked
63 } libvlc_lock_state_t;
64
65 struct libvlc_instance_t
66 {
67     libvlc_int_t *p_libvlc_int;
68     vlm_t        *p_vlm;
69     int           b_playlist_locked;
70     unsigned      ref_count;
71     vlc_mutex_t   instance_lock;
72     vlc_mutex_t   event_callback_lock;
73     struct libvlc_callback_entry_list_t *p_callback_list;
74 };
75
76 struct libvlc_media_t
77 {
78     libvlc_event_manager_t * p_event_manager;
79     int                b_preparsed;
80     input_item_t      *p_input_item;
81     int                i_refcount;
82     libvlc_instance_t *p_libvlc_instance;
83     libvlc_state_t     state;
84     struct libvlc_media_list_t *p_subitems; /* A media descriptor can have
85                                            * Sub item */
86     void *p_user_data; /* Allows for VLC.framework to hook into media descriptor without creating a new VLCMedia object. */
87 };
88
89 struct libvlc_media_list_t
90 {
91     libvlc_event_manager_t *    p_event_manager;
92     libvlc_instance_t *         p_libvlc_instance;
93     int                         i_refcount;
94     vlc_mutex_t                 object_lock;
95     libvlc_media_t * p_md; /* The media from which the
96                                        * mlist comes, if any. */
97     vlc_array_t                items;
98  
99     /* Other way to see that media list */
100     /* Used in flat_media_list.c */
101     libvlc_media_list_t *       p_flat_mlist;
102
103     /* This indicates if this media list is read-only
104      * from a user point of view */
105     bool                  b_read_only;
106 };
107
108 typedef libvlc_media_list_view_t * (*libvlc_media_list_view_constructor_func_t)( libvlc_media_list_t * p_mlist, libvlc_exception_t * p_e ) ;
109 typedef void (*libvlc_media_list_view_release_func_t)( libvlc_media_list_view_t * p_mlv ) ;
110
111 typedef int (*libvlc_media_list_view_count_func_t)( libvlc_media_list_view_t * p_mlv,
112         libvlc_exception_t * ) ;
113
114 typedef libvlc_media_t *
115         (*libvlc_media_list_view_item_at_index_func_t)(
116                 libvlc_media_list_view_t * p_mlv,
117                 int index,
118                 libvlc_exception_t * ) ;
119
120 typedef libvlc_media_list_view_t *
121         (*libvlc_media_list_view_children_at_index_func_t)(
122                 libvlc_media_list_view_t * p_mlv,
123                 int index,
124                 libvlc_exception_t * ) ;
125
126 /* A way to see a media list */
127 struct libvlc_media_list_view_t
128 {
129     libvlc_event_manager_t *    p_event_manager;
130     libvlc_instance_t *         p_libvlc_instance;
131     int                         i_refcount;
132     vlc_mutex_t                 object_lock;
133     
134     libvlc_media_list_t *       p_mlist;
135
136     struct libvlc_media_list_view_private_t * p_this_view_data;
137
138     /* Accessors */
139     libvlc_media_list_view_count_func_t              pf_count;
140     libvlc_media_list_view_item_at_index_func_t      pf_item_at_index;
141     libvlc_media_list_view_children_at_index_func_t  pf_children_at_index;
142
143     libvlc_media_list_view_constructor_func_t         pf_constructor;
144     libvlc_media_list_view_release_func_t            pf_release;
145
146     /* Notification callback */
147     void (*pf_ml_item_added)(const libvlc_event_t *, libvlc_media_list_view_t *);
148     void (*pf_ml_item_removed)(const libvlc_event_t *, libvlc_media_list_view_t *);
149 };
150
151 struct libvlc_media_player_t
152 {
153     int                i_refcount;
154     vlc_mutex_t        object_lock;
155     input_thread_t *   p_input_thread;
156     struct libvlc_instance_t *  p_libvlc_instance; /* Parent instance */
157     libvlc_media_t * p_md; /* current media descriptor */
158     libvlc_event_manager_t *    p_event_manager;
159     libvlc_drawable_t           drawable;
160     
161     bool        b_own_its_input_thread;
162 };
163
164 struct libvlc_media_list_player_t
165 {
166     libvlc_event_manager_t *    p_event_manager;
167     libvlc_instance_t *         p_libvlc_instance;
168     int                         i_refcount;
169     vlc_mutex_t                 object_lock;
170     libvlc_media_list_path_t    current_playing_item_path;
171     libvlc_media_t * p_current_playing_item;
172     libvlc_media_list_t *       p_mlist;
173     libvlc_media_player_t *   p_mi;
174 };
175
176 struct libvlc_media_library_t
177 {
178     libvlc_event_manager_t * p_event_manager;
179     libvlc_instance_t *      p_libvlc_instance;
180     int                      i_refcount;
181     libvlc_media_list_t *    p_mlist;
182 };
183
184 struct libvlc_media_discoverer_t
185 {
186     libvlc_event_manager_t * p_event_manager;
187     libvlc_instance_t *      p_libvlc_instance;
188     services_discovery_t *   p_sd;
189     libvlc_media_list_t *    p_mlist;
190     bool               running;
191     vlc_dictionary_t         catname_to_submedialist;
192 };
193
194 /*
195  * Event Handling
196  */
197 /* Example usage
198  *
199  * struct libvlc_cool_object_t
200  * {
201  *        ...
202  *        libvlc_event_manager_t * p_event_manager;
203  *        ...
204  * }
205  *
206  * libvlc_my_cool_object_new()
207  * {
208  *        ...
209  *        p_self->p_event_manager = libvlc_event_manager_init( p_self,
210  *                                                   p_self->p_libvlc_instance, p_e);
211  *        libvlc_event_manager_register_event_type(p_self->p_event_manager,
212  *                libvlc_MyCoolObjectDidSomething, p_e)
213  *        ...
214  * }
215  *
216  * libvlc_my_cool_object_release()
217  * {
218  *         ...
219  *         libvlc_event_manager_release( p_self->p_event_manager );
220  *         ...
221  * }
222  *
223  * libvlc_my_cool_object_do_something()
224  * {
225  *        ...
226  *        libvlc_event_t event;
227  *        event.type = libvlc_MyCoolObjectDidSomething;
228  *        event.u.my_cool_object_did_something.what_it_did = kSomething;
229  *        libvlc_event_send( p_self->p_event_manager, &event );
230  * }
231  * */
232
233 typedef struct libvlc_event_listener_t
234 {
235     libvlc_event_type_t event_type;
236     void *              p_user_data;
237     libvlc_callback_t   pf_callback;
238 } libvlc_event_listener_t;
239
240 typedef struct libvlc_event_listeners_group_t
241 {
242     libvlc_event_type_t event_type;
243     vlc_array_t listeners;
244     bool b_sublistener_removed;
245 } libvlc_event_listeners_group_t;
246
247 typedef struct libvlc_event_manager_t
248 {
249     void * p_obj;
250     struct libvlc_instance_t * p_libvlc_instance;
251     vlc_array_t listeners_groups;
252     vlc_mutex_t object_lock;
253     vlc_mutex_t event_sending_lock;
254 } libvlc_event_sender_t;
255
256
257 /***************************************************************************
258  * Other internal functions
259  ***************************************************************************/
260 input_thread_t *libvlc_get_input_thread(
261      libvlc_media_player_t *,
262     libvlc_exception_t * );
263
264 /* Media instance */
265 libvlc_media_player_t *
266 libvlc_media_player_new_from_input_thread( libvlc_instance_t *,
267                                            input_thread_t *,
268                                            libvlc_exception_t * );
269
270 void libvlc_media_player_destroy(
271         libvlc_media_player_t * );
272
273 /* Media Descriptor */
274 libvlc_media_t * libvlc_media_new_from_input_item(
275         libvlc_instance_t *, input_item_t *,
276         libvlc_exception_t * );
277
278 void libvlc_media_set_state(
279         libvlc_media_t *, libvlc_state_t,
280         libvlc_exception_t * );
281
282 /* Media List */
283 void _libvlc_media_list_add_media(
284         libvlc_media_list_t * p_mlist,
285         libvlc_media_t * p_md,
286         libvlc_exception_t * p_e );
287
288 void _libvlc_media_list_insert_media(
289         libvlc_media_list_t * p_mlist,
290         libvlc_media_t * p_md, int index,
291         libvlc_exception_t * p_e );
292
293 void _libvlc_media_list_remove_index(
294         libvlc_media_list_t * p_mlist, int index,
295         libvlc_exception_t * p_e );
296
297 /* Media List View */
298 libvlc_media_list_view_t * libvlc_media_list_view_new(
299         libvlc_media_list_t * p_mlist,
300         libvlc_media_list_view_count_func_t pf_count,
301         libvlc_media_list_view_item_at_index_func_t pf_item_at_index,
302         libvlc_media_list_view_children_at_index_func_t pf_children_at_index,
303         libvlc_media_list_view_constructor_func_t pf_constructor,
304         libvlc_media_list_view_release_func_t pf_release,
305         void * this_view_data,
306         libvlc_exception_t * p_e );
307
308 void libvlc_media_list_view_set_ml_notification_callback(
309         libvlc_media_list_view_t * p_mlv,
310         void (*item_added)(const libvlc_event_t *, libvlc_media_list_view_t *),
311         void (*item_removed)(const libvlc_event_t *, libvlc_media_list_view_t *) );
312
313 void libvlc_media_list_view_will_delete_item(
314         libvlc_media_list_view_t * p_mlv,
315         libvlc_media_t * p_item, int index );
316
317 void libvlc_media_list_view_item_deleted(
318         libvlc_media_list_view_t * p_mlv,
319         libvlc_media_t * p_item, int index );
320
321 void libvlc_media_list_view_will_add_item (
322         libvlc_media_list_view_t * p_mlv,
323         libvlc_media_t * p_item, int index );
324
325 void libvlc_media_list_view_item_added(
326         libvlc_media_list_view_t * p_mlv,
327         libvlc_media_t * p_item, int index );
328
329 /* Events */
330 libvlc_event_manager_t * libvlc_event_manager_new(
331         void * p_obj, libvlc_instance_t * p_libvlc_inst,
332         libvlc_exception_t *p_e );
333
334 void libvlc_event_manager_release(
335         libvlc_event_manager_t * p_em );
336
337 void libvlc_event_manager_register_event_type(
338         libvlc_event_manager_t * p_em,
339         libvlc_event_type_t event_type,
340         libvlc_exception_t * p_e );
341
342 void libvlc_event_send(
343         libvlc_event_manager_t * p_em,
344         libvlc_event_t * p_event );
345
346
347 /* Exception shorcuts */
348
349 #define RAISENULL( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
350                                 return NULL; }
351 #define RAISEVOID( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
352                                 return; }
353 #define RAISEZERO( psz,a... ) { libvlc_exception_raise( p_e, psz,##a ); \
354                                 return 0; }
355
356 # ifdef __cplusplus
357 }
358 # endif
359
360 #endif