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 VLC authors and VideoLAN
6  * $Id: d1cc28486cda2cbe750663123eabe6bdc50df02e $
7  *
8  * Authors: Clément Stenac <zorglub@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * 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.h>
33 #include <vlc/libvlc_dialog.h>
34 #include <vlc/libvlc_media.h>
35 #include <vlc/libvlc_events.h>
36 
37 #include <vlc_common.h>
38 
39 /* Note well: this header is included from LibVLC core.
40  * Therefore, static inline functions MUST NOT call LibVLC functions here
41  * (this can cause linkage failure on some platforms). */
42 
43 /***************************************************************************
44  * Internal creation and destruction functions
45  ***************************************************************************/
46 VLC_API libvlc_int_t *libvlc_InternalCreate( void );
47 VLC_API int libvlc_InternalInit( libvlc_int_t *, int, const char *ppsz_argv[] );
48 VLC_API void libvlc_InternalCleanup( libvlc_int_t * );
49 VLC_API void libvlc_InternalDestroy( libvlc_int_t * );
50 
51 VLC_API int libvlc_InternalAddIntf( libvlc_int_t *, const char * );
52 VLC_API void libvlc_InternalPlay( libvlc_int_t * );
53 VLC_API void libvlc_InternalWait( libvlc_int_t * );
54 VLC_API void libvlc_SetExitHandler( libvlc_int_t *, void (*) (void *), void * );
55 
56 /***************************************************************************
57  * Opaque structures for libvlc API
58  ***************************************************************************/
59 
60 struct libvlc_instance_t
61 {
62     libvlc_int_t *p_libvlc_int;
63     struct libvlc_vlm_t *vlm;
64     unsigned      ref_count;
65     vlc_mutex_t   instance_lock;
66     struct libvlc_callback_entry_list_t *p_callback_list;
67     struct
68     {
69         void (*cb) (void *, int, const libvlc_log_t *, const char *, va_list);
70         void *data;
71     } log;
72     struct
73     {
74         libvlc_dialog_cbs cbs;
75         void *data;
76     } dialog;
77 };
78 
79 struct libvlc_event_manager_t
80 {
81     void * p_obj;
82     vlc_array_t listeners;
83     vlc_mutex_t lock;
84 };
85 
86 /***************************************************************************
87  * Other internal functions
88  ***************************************************************************/
89 
90 /* Thread context */
91 void libvlc_threads_init (void);
92 void libvlc_threads_deinit (void);
93 
94 /* Events */
95 void libvlc_event_manager_init(libvlc_event_manager_t *, void *);
96 void libvlc_event_manager_destroy(libvlc_event_manager_t *);
97 
98 void libvlc_event_send(
99         libvlc_event_manager_t * p_em,
100         libvlc_event_t * p_event );
101 
from_mtime(mtime_t time)102 static inline libvlc_time_t from_mtime(mtime_t time)
103 {
104     return (time + 500ULL)/ 1000ULL;
105 }
106 
to_mtime(libvlc_time_t time)107 static inline mtime_t to_mtime(libvlc_time_t time)
108 {
109     return time * 1000ULL;
110 }
111 
112 #endif
113