]> git.sesse.net Git - vlc/blob - src/control/libvlc_internal.h
Merge branch '1.0-bugfix'
[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-2009 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/libvlc_structures.h>
33 #include <vlc/libvlc.h>
34 #include <vlc/libvlc_media.h>
35 #include <vlc/libvlc_events.h>
36
37 #include <vlc_common.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 (void, libvlc_InternalCleanup, ( libvlc_int_t * ) );
45 VLC_EXPORT (void, libvlc_InternalDestroy, ( libvlc_int_t * ) );
46
47 VLC_EXPORT (int, libvlc_InternalAddIntf, ( libvlc_int_t *, const char * ) );
48 VLC_EXPORT (void, libvlc_InternalWait, ( libvlc_int_t * ) );
49
50 /***************************************************************************
51  * Opaque structures for libvlc API
52  ***************************************************************************/
53
54 typedef enum libvlc_lock_state_t
55 {
56     libvlc_Locked,
57     libvlc_UnLocked
58 } libvlc_lock_state_t;
59
60 struct libvlc_instance_t
61 {
62     libvlc_int_t *p_libvlc_int;
63     vlm_t        *p_vlm;
64     int           b_playlist_locked;
65     unsigned      ref_count;
66     int           verbosity;
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
73 /*
74  * Event Handling
75  */
76 /* Example usage
77  *
78  * struct libvlc_cool_object_t
79  * {
80  *        ...
81  *        libvlc_event_manager_t * p_event_manager;
82  *        ...
83  * }
84  *
85  * libvlc_my_cool_object_new()
86  * {
87  *        ...
88  *        p_self->p_event_manager = libvlc_event_manager_new( p_self,
89  *                                                   p_self->p_libvlc_instance, p_e);
90  *        libvlc_event_manager_register_event_type(p_self->p_event_manager,
91  *                libvlc_MyCoolObjectDidSomething, p_e)
92  *        ...
93  * }
94  *
95  * libvlc_my_cool_object_release()
96  * {
97  *         ...
98  *         libvlc_event_manager_release( p_self->p_event_manager );
99  *         ...
100  * }
101  *
102  * libvlc_my_cool_object_do_something()
103  * {
104  *        ...
105  *        libvlc_event_t event;
106  *        event.type = libvlc_MyCoolObjectDidSomething;
107  *        event.u.my_cool_object_did_something.what_it_did = kSomething;
108  *        libvlc_event_send( p_self->p_event_manager, &event );
109  * }
110  * */
111
112 typedef struct libvlc_event_listener_t
113 {
114     libvlc_event_type_t event_type;
115     void *              p_user_data;
116     libvlc_callback_t   pf_callback;
117 } libvlc_event_listener_t;
118
119 typedef struct libvlc_event_listeners_group_t
120 {
121     libvlc_event_type_t event_type;
122     vlc_array_t listeners;
123     bool b_sublistener_removed;
124 } libvlc_event_listeners_group_t;
125
126 typedef struct libvlc_event_manager_t
127 {
128     void * p_obj;
129     struct libvlc_instance_t * p_libvlc_instance;
130     vlc_array_t listeners_groups;
131     vlc_mutex_t object_lock;
132     vlc_mutex_t event_sending_lock;
133 } libvlc_event_sender_t;
134
135
136 /***************************************************************************
137  * Other internal functions
138  ***************************************************************************/
139
140 /* Events */
141 libvlc_event_manager_t * libvlc_event_manager_new(
142         void * p_obj, libvlc_instance_t * p_libvlc_inst,
143         libvlc_exception_t *p_e );
144
145 void libvlc_event_manager_release(
146         libvlc_event_manager_t * p_em );
147
148 void libvlc_event_manager_register_event_type(
149         libvlc_event_manager_t * p_em,
150         libvlc_event_type_t event_type,
151         libvlc_exception_t * p_e );
152
153 void libvlc_event_send(
154         libvlc_event_manager_t * p_em,
155         libvlc_event_t * p_event );
156
157
158 /* Exception shorcuts */
159
160 #define RAISENULL( ... ) { libvlc_exception_raise( p_e, __VA_ARGS__ ); \
161                            return NULL; }
162 #define RAISEVOID( ... ) { libvlc_exception_raise( p_e, __VA_ARGS__ ); \
163                            return; }
164 #define RAISEZERO( ... ) { libvlc_exception_raise( p_e, __VA_ARGS__ ); \
165                            return 0; }
166
167 #endif