libvlc.h 7.46 KB
Newer Older
1
/*****************************************************************************
2
 * libvlc.h: Internal libvlc generic/misc declaration
3
 *****************************************************************************
Jean-Baptiste Kempf's avatar
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
6
 * $Id$
7
 *
8 9
 * Authors: Vincent Seguin <seguin@via.ecp.fr>
 *
Jean-Baptiste Kempf's avatar
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
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
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);
57 58
void vlc_object_kill (vlc_object_t *) VLC_DEPRECATED;
#define vlc_object_kill(o) vlc_object_kill(VLC_OBJECT(o))
59

60 61
int vlc_set_priority( vlc_thread_t, int );

62 63
void vlc_threads_setup (libvlc_int_t *);

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

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

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

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

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

90 91 92 93 94 95 96 97 98 99 100 101 102
/**
 * 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
103
extern void *
104 105 106
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)
107

108 109 110 111 112 113
/**
 * 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)

114 115 116 117 118 119
/* 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)

120 121 122
/*
 * To be cleaned-up module stuff:
 */
123
module_t *module_find_by_shortcut (const char *psz_shortcut);
124

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

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

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

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

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

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

153 154 155 156 157
#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")
158

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

162 163
typedef struct sap_handler_t sap_handler_t;

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

171
    bool               playlist_active;
172

173
    /* Messages */
174
    signed char        i_verbose;   ///< info messages
175 176
    bool               b_color;     ///< color messages?
    bool               b_stats;     ///< Whether to collect stats
177

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

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

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

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

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

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

208
#define libvlc_stats( o ) (libvlc_priv((VLC_OBJECT(o))->p_libvlc)->b_stats)
209

210 211 212
/*
 * Variables stuff
 */
213
void var_OptionParse (vlc_object_t *, const char *, bool trusted);
214 215 216 217

/*
 * Stats stuff
 */
218 219 220 221 222 223 224 225
enum
{
    STATS_COUNTER,
    STATS_DERIVATIVE,
};

typedef struct counter_sample_t
{
226 227
    uint64_t value;
    mtime_t  date;
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
} counter_sample_t;

typedef struct counter_t
{
    int                 i_compute_type;
    int                 i_samples;
    counter_sample_t ** pp_samples;

    mtime_t             last_update;
} counter_t;

enum
{
    STATS_INPUT_BITRATE,
    STATS_READ_BYTES,
    STATS_READ_PACKETS,
    STATS_DEMUX_READ,
    STATS_DEMUX_BITRATE,
    STATS_DEMUX_CORRUPTED,
    STATS_DEMUX_DISCONTINUITY,
    STATS_PLAYED_ABUFFERS,
    STATS_LOST_ABUFFERS,
    STATS_DECODED_AUDIO,
    STATS_DECODED_VIDEO,
    STATS_DECODED_SUB,
    STATS_CLIENT_CONNECTIONS,
    STATS_ACTIVE_CONNECTIONS,
    STATS_SOUT_SENT_PACKETS,
    STATS_SOUT_SENT_BYTES,
    STATS_SOUT_SEND_BITRATE,
    STATS_DISPLAYED_PICTURES,
    STATS_LOST_PICTURES,
};

262 263
counter_t * stats_CounterCreate (int);
void stats_Update (counter_t *, uint64_t, uint64_t *);
264 265
void stats_CounterClean (counter_t * );

266 267
void stats_ComputeInputStats(input_thread_t*, input_stats_t*);
void stats_ReinitInputStats(input_stats_t *);
268

269
#endif