libvlc.h 8.65 KB
Newer Older
1
/*****************************************************************************
2
 * libvlc.h: Internal libvlc generic/misc declaration
3
 *****************************************************************************
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
4
 * Copyright (C) 1999, 2000, 2001, 2002 VLC authors and VideoLAN
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
5
 * Copyright © 2006-2007 Rémi Denis-Courmont
Carlo Calabrò's avatar
Carlo Calabrò committed
6
 * $Id$
7
 *
8
9
 * Authors: Vincent Seguin <seguin@via.ecp.fr>
 *
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
10
11
12
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
13
14
15
16
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
17
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
19
 *
Jean-Baptiste Kempf's avatar
LGPL    
Jean-Baptiste Kempf committed
20
21
22
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
24
 *****************************************************************************/

25
26
#ifndef LIBVLC_LIBVLC_H
# define LIBVLC_LIBVLC_H 1
27

28
29
extern const char psz_vlc_changeset[];

30
31
typedef struct variable_t variable_t;

32
/* Actions (hot keys) */
33
34
35
struct vlc_actions;
struct vlc_actions *vlc_InitActions (libvlc_int_t *);
extern void vlc_DeinitActions (libvlc_int_t *, struct vlc_actions *);
36

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
37
38
size_t vlc_towc (const char *str, uint32_t *restrict pwc);

39
40
41
/*
 * OS-specific initialization
 */
42
void system_Init      ( void );
43
void system_Configure ( libvlc_int_t *, int, const char *const [] );
44
void system_End       ( void );
45

46
void vlc_CPU_init(void);
47
48
void vlc_CPU_dump(vlc_object_t *);

49
50
51
52
/*
 * Threads subsystem
 */

53
/* This cannot be used as is from plugins yet: */
54
int vlc_clone_detach (vlc_thread_t *, void *(*)(void *), void *, int);
55

56
int vlc_object_waitpipe (vlc_object_t *obj);
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
57

58
59
int vlc_set_priority( vlc_thread_t, int );

60
61
void vlc_threads_setup (libvlc_int_t *);

62
63
void vlc_trace (const char *fn, const char *file, unsigned line);
#define vlc_backtrace() vlc_trace(__func__, __FILE__, __LINE__)
64

65
#if defined (LIBVLC_USE_PTHREAD) && !defined (NDEBUG)
66
void vlc_assert_locked (vlc_mutex_t *);
67
68
69
70
#else
# define vlc_assert_locked( m ) (void)m
#endif

71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * LibVLC exit event handling
 */
typedef struct vlc_exit
{
    vlc_mutex_t lock;
    void (*handler) (void *);
    void *opaque;
    bool killed;
} vlc_exit_t;

void vlc_ExitInit( vlc_exit_t * );
void vlc_ExitDestroy( vlc_exit_t * );

85
86
87
88
/*
 * LibVLC objects stuff
 */

89
90
91
92
93
94
95
96
97
98
99
100
101
/**
 * Creates a VLC object.
 *
 * Note that because the object name pointer must remain valid, potentially
 * even after the destruction of the object (through the message queues), this
 * function CANNOT be exported to plugins as is. In this case, the old
 * vlc_object_create() must be used instead.
 *
 * @param p_this an existing VLC object
 * @param i_size byte size of the object structure
 * @param psz_type object type name
 * @return the created object, or NULL.
 */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
102
extern void *
103
104
105
vlc_custom_create (vlc_object_t *p_this, size_t i_size, const char *psz_type);
#define vlc_custom_create(o, s, n) \
        vlc_custom_create(VLC_OBJECT(o), s, n)
106

107
108
109
110
111
112
/**
 * Assign a name to an object for vlc_object_find_name().
 */
extern int vlc_object_set_name(vlc_object_t *, const char *);
#define vlc_object_set_name(o, n) vlc_object_set_name(VLC_OBJECT(o), n)

113
114
115
116
117
118
/* Types */
typedef void (*vlc_destructor_t) (struct vlc_object_t *);
void vlc_object_set_destructor (vlc_object_t *, vlc_destructor_t);
#define vlc_object_set_destructor(a,b) \
        vlc_object_set_destructor (VLC_OBJECT(a), b)

119
120
121
/*
 * To be cleaned-up module stuff:
 */
122
extern char *psz_vlcpath;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
123

124
module_t *module_find_by_shortcut (const char *psz_shortcut);
125

126
127
128
/**
 * Private LibVLC data for each object.
 */
129
130
131
typedef struct vlc_object_internals vlc_object_internals_t;

struct vlc_object_internals
132
{
133
    char           *psz_name; /* given name */
134

135
    /* Object variables */
136
    void           *var_root;
137
    vlc_mutex_t     var_lock;
138
    vlc_cond_t      var_wait;
139

140
141
142
    /* Objects thread synchronization */
    int             pipes[2];

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
143
    /* Objects management */
144
    vlc_spinlock_t   ref_spin;
145
146
    unsigned         i_refcount;
    vlc_destructor_t pf_destructor;
147

148
    /* Objects tree structure */
149
150
151
152
    vlc_object_internals_t *next;  /* next sibling */
    vlc_object_internals_t *prev;  /* previous sibling */
    vlc_object_internals_t *first; /* first child */
};
153

154
155
156
157
158
#define ZOOM_SECTION N_("Zoom")
#define ZOOM_QUARTER_KEY_TEXT N_("1:4 Quarter")
#define ZOOM_HALF_KEY_TEXT N_("1:2 Half")
#define ZOOM_ORIGINAL_KEY_TEXT N_("1:1 Original")
#define ZOOM_DOUBLE_KEY_TEXT N_("2:1 Double")
159

160
#define vlc_internals( obj ) (((vlc_object_internals_t*)(VLC_OBJECT(obj)))-1)
161
#define vlc_externals( priv ) ((vlc_object_t *)((priv) + 1))
162

163
164
typedef struct sap_handler_t sap_handler_t;

165
166
167
168
169
/**
 * Private LibVLC instance data.
 */
typedef struct libvlc_priv_t
{
170
171
    libvlc_int_t       public_data;

172
    bool               playlist_active;
173

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
174
    /* Messages */
175
    signed char        i_verbose;   ///< info messages
ivoire's avatar
ivoire committed
176
177
    bool               b_color;     ///< color messages?
    bool               b_stats;     ///< Whether to collect stats
178

179
    /* Singleton objects */
180
    module_t          *p_memcpy_module;  ///< Fast memcpy plugin used
jetru's avatar
jetru committed
181
    playlist_t        *p_playlist; ///< the playlist singleton
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
182
    struct media_library_t *p_ml;    ///< the ML singleton
jetru's avatar
jetru committed
183
    vlc_mutex_t       ml_lock; ///< Mutex for ML creation
184
    vlm_t             *p_vlm;  ///< the VLM singleton (or NULL)
185
    vlc_object_t      *p_dialog_provider; ///< dialog provider
186
187
188
#ifdef ENABLE_SOUT
    sap_handler_t     *p_sap; ///< SAP SDP advertiser
#endif
189
    struct vlc_actions *actions; ///< Hotkeys handler
190
191
192
193
194

    /* Interfaces */
    struct intf_thread_t *p_intf; ///< Interfaces linked-list

    /* Objects tree */
195
    vlc_mutex_t        structure_lock;
196
197
198

    /* Exit callback */
    vlc_exit_t       exit;
199
200
201
202
} libvlc_priv_t;

static inline libvlc_priv_t *libvlc_priv (libvlc_int_t *libvlc)
{
203
    return (libvlc_priv_t *)libvlc;
204
205
}

206
void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist );
207
void intf_DestroyAll( libvlc_int_t * );
208

209
#define libvlc_stats( o ) (libvlc_priv((VLC_OBJECT(o))->p_libvlc)->b_stats)
210
211
212
213

/**
 * LibVLC "main module" configuration settings array.
 */
214
extern module_config_t libvlc_config[];
215
216
extern const size_t libvlc_config_count;

217
218
219
/*
 * Variables stuff
 */
220
void var_OptionParse (vlc_object_t *, const char *, bool trusted);
221
222
223
224

/*
 * Stats stuff
 */
225
226
227
228
229
int stats_Update (vlc_object_t*, counter_t *, vlc_value_t, vlc_value_t *);
counter_t * stats_CounterCreate (vlc_object_t*, int, int);
#define stats_CounterCreate(a,b,c) stats_CounterCreate( VLC_OBJECT(a), b, c )
int stats_Get (vlc_object_t*, counter_t *, vlc_value_t*);
#define stats_Get(a,b,c) stats_Get( VLC_OBJECT(a), b, c)
230
231
232

void stats_CounterClean (counter_t * );

233
static inline int stats_GetInteger( vlc_object_t *p_obj, counter_t *p_counter,
234
                                    int64_t *value )
235
236
237
238
{
    int i_ret;
    vlc_value_t val; val.i_int = 0;
    if( !p_counter ) return VLC_EGENERIC;
239
    i_ret = stats_Get( p_obj, p_counter, &val );
240
241
242
    *value = val.i_int;
    return i_ret;
}
243
#define stats_GetInteger(a,b,c) stats_GetInteger( VLC_OBJECT(a), b, c )
244

245
static inline int stats_GetFloat( vlc_object_t *p_obj, counter_t *p_counter,
246
247
248
249
250
                                    float *value )
{
    int i_ret;
    vlc_value_t val; val.f_float = 0.0;
    if( !p_counter ) return VLC_EGENERIC;
251
    i_ret = stats_Get( p_obj, p_counter, &val );
252
253
254
    *value = val.f_float;
    return i_ret;
}
255
256
257
#define stats_GetFloat(a,b,c) stats_GetFloat( VLC_OBJECT(a), b, c )

static inline int stats_UpdateInteger( vlc_object_t *p_obj,counter_t *p_co,
258
259
260
261
262
263
264
                                         int i, int *pi_new )
{
    int i_ret;
    vlc_value_t val;
    vlc_value_t new_val; new_val.i_int = 0;
    if( !p_co ) return VLC_EGENERIC;
    val.i_int = i;
265
    i_ret = stats_Update( p_obj, p_co, val, &new_val );
266
267
268
269
    if( pi_new )
        *pi_new = new_val.i_int;
    return i_ret;
}
270
271
272
#define stats_UpdateInteger(a,b,c,d) stats_UpdateInteger( VLC_OBJECT(a),b,c,d )

static inline int stats_UpdateFloat( vlc_object_t *p_obj, counter_t *p_co,
273
274
275
276
277
278
279
                                       float f, float *pf_new )
{
    vlc_value_t val;
    int i_ret;
    vlc_value_t new_val;new_val.f_float = 0.0;
    if( !p_co ) return VLC_EGENERIC;
    val.f_float = f;
280
    i_ret =  stats_Update( p_obj, p_co, val, &new_val );
281
282
283
284
    if( pf_new )
        *pf_new = new_val.f_float;
    return i_ret;
}
285
#define stats_UpdateFloat(a,b,c,d) stats_UpdateFloat( VLC_OBJECT(a),b,c,d )
286

287
288
void stats_ComputeInputStats(input_thread_t*, input_stats_t*);
void stats_ReinitInputStats(input_stats_t *);
289

290
#endif