/src/vlc/include/vlc/libvlc.h
Line | Count | Source |
1 | | /***************************************************************************** |
2 | | * libvlc.h: libvlc external API |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 1998-2009 VLC authors and VideoLAN |
5 | | * |
6 | | * Authors: Clément Stenac <zorglub@videolan.org> |
7 | | * Jean-Paul Saman <jpsaman@videolan.org> |
8 | | * Pierre d'Herbemont <pdherbemont@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 | | /** |
26 | | * \defgroup libvlc LibVLC |
27 | | * LibVLC is the external programming interface of the VLC media player. |
28 | | * It is used to embed VLC into other applications or frameworks. |
29 | | * @{ |
30 | | * \file |
31 | | * LibVLC core external API |
32 | | */ |
33 | | |
34 | | #ifndef VLC_LIBVLC_H |
35 | | #define VLC_LIBVLC_H 1 |
36 | | |
37 | | #if (defined (_WIN32) || defined (__OS2__)) && defined (LIBVLC_DLL_EXPORT) |
38 | | # define LIBVLC_API __declspec(dllexport) |
39 | | #elif defined (__GNUC__) && (__GNUC__ >= 4) |
40 | | # define LIBVLC_API __attribute__((visibility("default"))) |
41 | | #else |
42 | | # define LIBVLC_API |
43 | | #endif |
44 | | |
45 | | #ifdef LIBVLC_INTERNAL_ |
46 | | /* Avoid unhelpful warnings from libvlc with our deprecated APIs */ |
47 | | # define LIBVLC_DEPRECATED |
48 | | #elif defined(__GNUC__) && \ |
49 | | (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) |
50 | | # define LIBVLC_DEPRECATED __attribute__((deprecated)) |
51 | | #else |
52 | | # define LIBVLC_DEPRECATED |
53 | | #endif |
54 | | |
55 | | #include <stdio.h> |
56 | | #include <stdarg.h> |
57 | | #include <stdint.h> |
58 | | |
59 | | # ifdef __cplusplus |
60 | | extern "C" { |
61 | | # endif |
62 | | |
63 | | /** \defgroup libvlc_core LibVLC core |
64 | | * \ingroup libvlc |
65 | | * Before it can do anything useful, LibVLC must be initialized. |
66 | | * You can create one (or more) instance(s) of LibVLC in a given process, |
67 | | * with libvlc_new() and destroy them with libvlc_release(). |
68 | | * |
69 | | * \version Unless otherwise stated, these functions are available |
70 | | * from LibVLC versions numbered 1.1.0 or more. |
71 | | * Earlier versions (0.9.x and 1.0.x) are <b>not</b> compatible. |
72 | | * @{ |
73 | | */ |
74 | | |
75 | | /** This structure is opaque. It represents a libvlc instance */ |
76 | | typedef struct libvlc_instance_t libvlc_instance_t; |
77 | | |
78 | | /** Represents a time value in microseconds */ |
79 | | typedef int64_t libvlc_time_t; |
80 | | |
81 | | /** \defgroup libvlc_error LibVLC error handling |
82 | | * @{ |
83 | | */ |
84 | | |
85 | | /** |
86 | | * A human-readable error message for the last LibVLC error in the calling |
87 | | * thread. The resulting string is valid until another error occurs (at least |
88 | | * until the next LibVLC call). |
89 | | * |
90 | | * @warning |
91 | | * This will be NULL if there was no error. |
92 | | */ |
93 | | LIBVLC_API const char *libvlc_errmsg (void); |
94 | | |
95 | | /** |
96 | | * Clears the LibVLC error status for the current thread. This is optional. |
97 | | * By default, the error status is automatically overridden when a new error |
98 | | * occurs, and destroyed when the thread exits. |
99 | | */ |
100 | | LIBVLC_API void libvlc_clearerr (void); |
101 | | |
102 | | /** |
103 | | * Sets the LibVLC error status and message for the current thread. |
104 | | * Any previous error is overridden. |
105 | | * \param fmt the format string |
106 | | * \param ... the arguments for the format string |
107 | | * \return a nul terminated string in any case |
108 | | */ |
109 | | const char *libvlc_printerr (const char *fmt, ...); |
110 | | |
111 | | /**@} */ |
112 | | |
113 | | /** |
114 | | * Create and initialize a libvlc instance. |
115 | | * This functions accept a list of "command line" arguments similar to the |
116 | | * main(). These arguments affect the LibVLC instance default configuration. |
117 | | * |
118 | | * \note |
119 | | * LibVLC may create threads. Therefore, any thread-unsafe process |
120 | | * initialization must be performed before calling libvlc_new(). In particular |
121 | | * and where applicable: |
122 | | * - setlocale() and textdomain(), |
123 | | * - setenv(), unsetenv() and putenv(), |
124 | | * - with the X11 display system, XInitThreads() |
125 | | * (see also libvlc_media_player_set_xwindow()) and |
126 | | * - on Microsoft Windows, SetErrorMode(). |
127 | | * - sigprocmask() shall never be invoked; pthread_sigmask() can be used. |
128 | | * |
129 | | * On POSIX systems, the SIGCHLD signal <b>must not</b> be ignored, i.e. the |
130 | | * signal handler must set to SIG_DFL or a function pointer, not SIG_IGN. |
131 | | * Also while LibVLC is active, the wait() function shall not be called, and |
132 | | * any call to waitpid() shall use a strictly positive value for the first |
133 | | * parameter (i.e. the PID). Failure to follow those rules may lead to a |
134 | | * deadlock or a busy loop. |
135 | | * Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked, |
136 | | * even if it is not, in principles, necessary, e.g.: |
137 | | * @code |
138 | | sigset_t set; |
139 | | |
140 | | signal(SIGCHLD, SIG_DFL); |
141 | | sigemptyset(&set); |
142 | | sigaddset(&set, SIGPIPE); |
143 | | pthread_sigmask(SIG_BLOCK, &set, NULL); |
144 | | * @endcode |
145 | | * |
146 | | * On Microsoft Windows, setting the default DLL directories to SYSTEM32 |
147 | | * exclusively is strongly recommended for security reasons: |
148 | | * @code |
149 | | SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32); |
150 | | * @endcode |
151 | | * |
152 | | * \version |
153 | | * Arguments are meant to be passed from the command line to LibVLC, just like |
154 | | * VLC media player does. The list of valid arguments depends on the LibVLC |
155 | | * version, the operating system and platform, and set of available LibVLC |
156 | | * plugins. Invalid or unsupported arguments will cause the function to fail |
157 | | * (i.e. return NULL). Also, some arguments may alter the behaviour or |
158 | | * otherwise interfere with other LibVLC functions. |
159 | | * |
160 | | * \warning |
161 | | * There is absolutely no warranty or promise of forward, backward and |
162 | | * cross-platform compatibility with regards to libvlc_new() arguments. |
163 | | * We recommend that you do not use them, other than when debugging. |
164 | | * |
165 | | * \param argc the number of arguments (should be 0) |
166 | | * \param argv list of arguments (should be NULL) |
167 | | * \return the libvlc instance or NULL in case of error |
168 | | */ |
169 | | LIBVLC_API libvlc_instance_t * |
170 | | libvlc_new( int argc , const char *const *argv ); |
171 | | |
172 | | /** |
173 | | * Decrement the reference count of a libvlc instance, and destroy it |
174 | | * if it reaches zero. |
175 | | * |
176 | | * \param p_instance the instance to destroy |
177 | | */ |
178 | | LIBVLC_API void libvlc_release( libvlc_instance_t *p_instance ); |
179 | | |
180 | | /** |
181 | | * Increments the reference count of a libvlc instance. |
182 | | * The initial reference count is 1 after libvlc_new() returns. |
183 | | * |
184 | | * \param p_instance the instance to reference |
185 | | * \return the same object |
186 | | */ |
187 | | LIBVLC_API libvlc_instance_t *libvlc_retain( libvlc_instance_t *p_instance ); |
188 | | |
189 | | /** |
190 | | * Get the ABI version of the libvlc library. |
191 | | * |
192 | | * This is different than the VLC version, which is the version of the whole |
193 | | * VLC package. The value is the same as LIBVLC_ABI_VERSION_INT used when |
194 | | * compiling. |
195 | | * |
196 | | * \return a value with the following mask in hexadecimal |
197 | | * 0xFF000000: major VLC version, similar to VLC major version, |
198 | | * 0x00FF0000: major ABI version, incremented incompatible changes are added, |
199 | | * 0x0000FF00: minor ABI version, incremented when new functions are added |
200 | | * 0x000000FF: micro ABI version, incremented with new release/builds |
201 | | * |
202 | | * \note This the same value as the .so version but cross platform. |
203 | | */ |
204 | | LIBVLC_API int libvlc_abi_version(void); |
205 | | |
206 | | /** |
207 | | * Sets the application name. LibVLC passes this as the user agent string |
208 | | * when a protocol requires it. |
209 | | * |
210 | | * \param p_instance LibVLC instance |
211 | | * \param name human-readable application name, e.g. "FooBar player 1.2.3" |
212 | | * \param http HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0" |
213 | | * \version LibVLC 1.1.1 or later |
214 | | */ |
215 | | LIBVLC_API |
216 | | void libvlc_set_user_agent( libvlc_instance_t *p_instance, |
217 | | const char *name, const char *http ); |
218 | | |
219 | | /** |
220 | | * Sets some meta-information about the application. |
221 | | * See also libvlc_set_user_agent(). |
222 | | * |
223 | | * \param p_instance LibVLC instance |
224 | | * \param id Java-style application identifier, e.g. "com.acme.foobar" |
225 | | * \param version application version numbers, e.g. "1.2.3" |
226 | | * \param icon application icon name, e.g. "foobar" |
227 | | * \version LibVLC 2.1.0 or later. |
228 | | */ |
229 | | LIBVLC_API |
230 | | void libvlc_set_app_id( libvlc_instance_t *p_instance, const char *id, |
231 | | const char *version, const char *icon ); |
232 | | |
233 | | /** |
234 | | * Retrieve libvlc version. |
235 | | * |
236 | | * Example: "1.1.0-git The Luggage" |
237 | | * |
238 | | * \return a string containing the libvlc version |
239 | | */ |
240 | | LIBVLC_API const char * libvlc_get_version(void); |
241 | | |
242 | | /** |
243 | | * Retrieve libvlc compiler version. |
244 | | * |
245 | | * Example: "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)" |
246 | | * |
247 | | * \return a string containing the libvlc compiler version |
248 | | */ |
249 | | LIBVLC_API const char * libvlc_get_compiler(void); |
250 | | |
251 | | /** |
252 | | * Retrieve libvlc changeset. |
253 | | * |
254 | | * Example: "aa9bce0bc4" |
255 | | * |
256 | | * \return a string containing the libvlc changeset |
257 | | */ |
258 | | LIBVLC_API const char * libvlc_get_changeset(void); |
259 | | |
260 | | /** |
261 | | * Frees an heap allocation returned by a LibVLC function. |
262 | | * If you know you're using the same underlying C run-time as the LibVLC |
263 | | * implementation, then you can call ANSI C free() directly instead. |
264 | | * |
265 | | * \param ptr the pointer |
266 | | */ |
267 | | LIBVLC_API void libvlc_free( void *ptr ); |
268 | | |
269 | | /** \defgroup libvlc_log LibVLC logging |
270 | | * libvlc_log_* functions provide access to the LibVLC messages log. |
271 | | * This is used for logging and debugging. |
272 | | * @{ |
273 | | */ |
274 | | |
275 | | /** |
276 | | * Logging messages level. |
277 | | * \note Future LibVLC versions may define new levels. |
278 | | */ |
279 | | enum libvlc_log_level |
280 | | { |
281 | | LIBVLC_DEBUG=0, /**< Debug message */ |
282 | | LIBVLC_NOTICE=2, /**< Important informational message */ |
283 | | LIBVLC_WARNING=3, /**< Warning (potential error) message */ |
284 | | LIBVLC_ERROR=4 /**< Error message */ |
285 | | }; |
286 | | |
287 | | typedef struct vlc_log_t libvlc_log_t; |
288 | | |
289 | | /** |
290 | | * Gets log message debug infos. |
291 | | * |
292 | | * This function retrieves self-debug information about a log message: |
293 | | * - the name of the VLC module emitting the message, |
294 | | * - the name of the source code module (i.e. file) and |
295 | | * - the line number within the source code module. |
296 | | * |
297 | | * The returned module name and file name will be NULL if unknown. |
298 | | * The returned line number will similarly be zero if unknown. |
299 | | * |
300 | | * \param ctx message context (as passed to the @ref libvlc_log_cb callback) |
301 | | * \param module module name storage (or NULL) [OUT] |
302 | | * \param file source code file name storage (or NULL) [OUT] |
303 | | * \param line source code file line number storage (or NULL) [OUT] |
304 | | * \warning The returned module name and source code file name, if non-NULL, |
305 | | * are only valid until the logging callback returns. |
306 | | * |
307 | | * \version LibVLC 2.1.0 or later |
308 | | */ |
309 | | LIBVLC_API void libvlc_log_get_context(const libvlc_log_t *ctx, |
310 | | const char **module, const char **file, unsigned *line); |
311 | | |
312 | | /** |
313 | | * Gets log message info. |
314 | | * |
315 | | * This function retrieves meta-information about a log message: |
316 | | * - the type name of the VLC object emitting the message, |
317 | | * - the object header if any, and |
318 | | * - a temporaly-unique object identifier. |
319 | | * |
320 | | * This information is mainly meant for <b>manual</b> troubleshooting. |
321 | | * |
322 | | * The returned type name may be "generic" if unknown, but it cannot be NULL. |
323 | | * The returned header will be NULL if unset; in current versions, the header |
324 | | * is used to distinguish for VLM inputs. |
325 | | * The returned object ID will be zero if the message is not associated with |
326 | | * any VLC object. |
327 | | * |
328 | | * \param ctx message context (as passed to the @ref libvlc_log_cb callback) |
329 | | * \param name object name storage (or NULL) [OUT] |
330 | | * \param header object header (or NULL) [OUT] |
331 | | * \param id temporarily-unique object identifier (or 0) [OUT] |
332 | | * \warning The returned module name and source code file name, if non-NULL, |
333 | | * are only valid until the logging callback returns. |
334 | | * |
335 | | * \version LibVLC 2.1.0 or later |
336 | | */ |
337 | | LIBVLC_API void libvlc_log_get_object(const libvlc_log_t *ctx, |
338 | | const char **name, const char **header, uintptr_t *id); |
339 | | |
340 | | /** |
341 | | * Callback prototype for LibVLC log message handler. |
342 | | * |
343 | | * \param data data pointer as given to libvlc_log_set() |
344 | | * \param level message level (@ref libvlc_log_level) |
345 | | * \param ctx message context (meta-information about the message) |
346 | | * \param fmt printf() format string (as defined by ISO C11) |
347 | | * \param args variable argument list for the format |
348 | | * \note Log message handlers <b>must</b> be thread-safe. |
349 | | * \warning The message context pointer, the format string parameters and the |
350 | | * variable arguments are only valid until the callback returns. |
351 | | */ |
352 | | typedef void (*libvlc_log_cb)(void *data, int level, const libvlc_log_t *ctx, |
353 | | const char *fmt, va_list args); |
354 | | |
355 | | /** |
356 | | * Unsets the logging callback. |
357 | | * |
358 | | * This function deregisters the logging callback for a LibVLC instance. |
359 | | * This is rarely needed as the callback is implicitly unset when the instance |
360 | | * is destroyed. |
361 | | * |
362 | | * \note This function will wait for any pending callbacks invocation to |
363 | | * complete (causing a deadlock if called from within the callback). |
364 | | * |
365 | | * \param p_instance libvlc instance |
366 | | * \version LibVLC 2.1.0 or later |
367 | | */ |
368 | | LIBVLC_API void libvlc_log_unset( libvlc_instance_t *p_instance ); |
369 | | |
370 | | /** |
371 | | * Sets the logging callback for a LibVLC instance. |
372 | | * |
373 | | * This function is thread-safe: it will wait for any pending callbacks |
374 | | * invocation to complete. |
375 | | * |
376 | | * \param cb callback function pointer |
377 | | * \param data opaque data pointer for the callback function |
378 | | * |
379 | | * \note Some log messages (especially debug) are emitted by LibVLC while |
380 | | * is being initialized. These messages cannot be captured with this interface. |
381 | | * |
382 | | * \warning A deadlock may occur if this function is called from the callback. |
383 | | * |
384 | | * \param p_instance libvlc instance |
385 | | * \version LibVLC 2.1.0 or later |
386 | | */ |
387 | | LIBVLC_API void libvlc_log_set( libvlc_instance_t *p_instance, |
388 | | libvlc_log_cb cb, void *data ); |
389 | | |
390 | | |
391 | | /** |
392 | | * Sets up logging to a file. |
393 | | * \param p_instance libvlc instance |
394 | | * \param stream FILE pointer opened for writing |
395 | | * (the FILE pointer must remain valid until libvlc_log_unset()) |
396 | | * \version LibVLC 2.1.0 or later |
397 | | */ |
398 | | LIBVLC_API void libvlc_log_set_file( libvlc_instance_t *p_instance, FILE *stream ); |
399 | | |
400 | | /** @} */ |
401 | | |
402 | | /** |
403 | | * Description of a module. |
404 | | */ |
405 | | typedef struct libvlc_module_description_t |
406 | | { |
407 | | char *psz_name; |
408 | | char *psz_shortname; |
409 | | char *psz_longname; |
410 | | char *psz_help; |
411 | | char *psz_help_html; |
412 | | struct libvlc_module_description_t *p_next; |
413 | | } libvlc_module_description_t; |
414 | | |
415 | | /** |
416 | | * Release a list of module descriptions. |
417 | | * |
418 | | * \param p_list the list to be released |
419 | | */ |
420 | | LIBVLC_API |
421 | | void libvlc_module_description_list_release( libvlc_module_description_t *p_list ); |
422 | | |
423 | | /** |
424 | | * Returns a list of audio filters that are available. |
425 | | * |
426 | | * \param p_instance libvlc instance |
427 | | * |
428 | | * \return a list of module descriptions. It should be freed with libvlc_module_description_list_release(). |
429 | | * In case of an error, NULL is returned. |
430 | | * |
431 | | * \see libvlc_module_description_t |
432 | | * \see libvlc_module_description_list_release |
433 | | */ |
434 | | LIBVLC_API |
435 | | libvlc_module_description_t *libvlc_audio_filter_list_get( libvlc_instance_t *p_instance ); |
436 | | |
437 | | /** |
438 | | * Returns a list of video filters that are available. |
439 | | * |
440 | | * \param p_instance libvlc instance |
441 | | * |
442 | | * \return a list of module descriptions. It should be freed with libvlc_module_description_list_release(). |
443 | | * In case of an error, NULL is returned. |
444 | | * |
445 | | * \see libvlc_module_description_t |
446 | | * \see libvlc_module_description_list_release |
447 | | */ |
448 | | LIBVLC_API |
449 | | libvlc_module_description_t *libvlc_video_filter_list_get( libvlc_instance_t *p_instance ); |
450 | | |
451 | | /** @} */ |
452 | | |
453 | | /** \defgroup libvlc_clock LibVLC time |
454 | | * These functions provide access to the LibVLC time/clock. |
455 | | * @{ |
456 | | */ |
457 | | |
458 | | /** |
459 | | * Return the current time as defined by LibVLC. The unit is the microsecond. |
460 | | * Time increases monotonically (regardless of time zone changes and RTC |
461 | | * adjustments). |
462 | | * The origin is arbitrary but consistent across the whole system |
463 | | * (e.g. the system uptime, the time since the system was booted). |
464 | | * \note On systems that support it, the POSIX monotonic clock is used. |
465 | | */ |
466 | | LIBVLC_API |
467 | | libvlc_time_t libvlc_clock(void); |
468 | | |
469 | | /** |
470 | | * Return the delay (in microseconds) until a certain timestamp. |
471 | | * \param pts timestamp |
472 | | * \return negative if timestamp is in the past, |
473 | | * positive if it is in the future |
474 | | */ |
475 | | static inline libvlc_time_t libvlc_delay(libvlc_time_t pts) |
476 | 0 | { |
477 | 0 | return pts - libvlc_clock(); |
478 | 0 | } Unexecuted instantiation: vlc-demux-libfuzzer.c:libvlc_delay Unexecuted instantiation: demux-run.c:libvlc_delay Unexecuted instantiation: common.c:libvlc_delay Unexecuted instantiation: decoder.c:libvlc_delay Unexecuted instantiation: core.c:libvlc_delay Unexecuted instantiation: error.c:libvlc_delay Unexecuted instantiation: libvlc.c:libvlc_delay Unexecuted instantiation: interface.c:libvlc_delay Unexecuted instantiation: exit.c:libvlc_delay Unexecuted instantiation: specific.c:libvlc_delay |
479 | | |
480 | | /** @} */ |
481 | | |
482 | | # ifdef __cplusplus |
483 | | } |
484 | | # endif |
485 | | |
486 | | #endif /** @} */ |