]> git.sesse.net Git - vlc/blob - src/control/libvlc_internal.h
bc545a598e94f6c57688274f38664f079058e035
[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 typedef void (*libvlc_vlm_release_func_t)( libvlc_instance_t * ) ;
51
52 /***************************************************************************
53  * Opaque structures for libvlc API
54  ***************************************************************************/
55
56 typedef struct libvlc_vlm_t
57 {
58     vlm_t                  *p_vlm;
59     libvlc_event_manager_t *p_event_manager;
60     libvlc_vlm_release_func_t pf_release;
61 } libvlc_vlm_t;
62
63 struct libvlc_instance_t
64 {
65     libvlc_int_t *p_libvlc_int;
66     libvlc_vlm_t  libvlc_vlm;
67     unsigned      ref_count;
68     int           verbosity;
69     vlc_mutex_t   instance_lock;
70     struct libvlc_callback_entry_list_t *p_callback_list;
71 };
72
73
74 /***************************************************************************
75  * Other internal functions
76  ***************************************************************************/
77
78 /* Thread context */
79 void libvlc_init_threads (void);
80 void libvlc_deinit_threads (void);
81
82 /* Events */
83 libvlc_event_manager_t * libvlc_event_manager_new(
84         void * p_obj, libvlc_instance_t * p_libvlc_inst,
85         libvlc_exception_t *p_e );
86
87 void libvlc_event_manager_release(
88         libvlc_event_manager_t * p_em );
89
90 void libvlc_event_manager_register_event_type(
91         libvlc_event_manager_t * p_em,
92         libvlc_event_type_t event_type,
93         libvlc_exception_t * p_e );
94
95 void libvlc_event_send(
96         libvlc_event_manager_t * p_em,
97         libvlc_event_t * p_event );
98
99 void libvlc_event_attach_async( libvlc_event_manager_t * p_event_manager,
100                                libvlc_event_type_t event_type,
101                                libvlc_callback_t pf_callback,
102                                void *p_user_data,
103                                libvlc_exception_t *p_e );
104
105 /* Exception shorcuts */
106
107 #define RAISENULL( ... ) { libvlc_printerr(__VA_ARGS__); \
108                            libvlc_exception_raise( p_e ); \
109                            return NULL; }
110 #define RAISEZERO( ... ) { libvlc_printerr(__VA_ARGS__); \
111                            libvlc_exception_raise( p_e ); \
112                            return 0; }
113
114 static inline void clear_if_needed(libvlc_exception_t *e)
115 {
116     if (libvlc_exception_raised(e))
117         libvlc_exception_clear(e);
118 }
119
120 static inline libvlc_time_t from_mtime(mtime_t time)
121 {
122     return (time + 500ULL)/ 1000ULL;
123 }
124
125 static inline mtime_t to_mtime(libvlc_time_t time)
126 {
127     return time * 1000ULL;
128 }
129
130 #endif