VLC  4.0.0-dev
libvlc.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * libvlc.h: Internal libvlc generic/misc declaration
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001, 2002 VLC authors and VideoLAN
5  * Copyright © 2006-2007 Rémi Denis-Courmont
6  *
7  * Authors: Vincent Seguin <seguin@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 
24 #ifndef LIBVLC_LIBVLC_H
25 # define LIBVLC_LIBVLC_H 1
26 
27 #include <vlc_input_item.h>
28 
29 extern const char psz_vlc_changeset[];
30 
31 typedef struct variable_t variable_t;
32 
33 /*
34  * OS-specific initialization
35  */
36 void system_Init ( void );
37 void system_Configure ( libvlc_int_t *, int, const char *const [] );
38 #if defined(_WIN32) || defined(__OS2__)
39 void system_End(void);
40 #endif
42 
43 /*
44  * Threads subsystem
45  */
46 
47 int vlc_set_priority( vlc_thread_t, int );
48 
50 
51 void vlc_trace (const char *fn, const char *file, unsigned line);
52 #define vlc_backtrace() vlc_trace(__func__, __FILE__, __LINE__)
53 
54 /*
55  * Logging
56  */
57 typedef struct vlc_logger vlc_logger_t;
58 
61 
62 /*
63  * Tracing
64  */
65 typedef struct vlc_tracer vlc_tracer_t;
66 
69 
70 /*
71  * LibVLC exit event handling
72  */
73 typedef struct vlc_exit
74 {
76  void (*handler) (void *);
77  void *opaque;
79 
80 void vlc_ExitInit( vlc_exit_t * );
81 
82 /*
83  * LibVLC objects stuff
84  */
85 
86 /**
87  * Initializes a VLC object.
88  *
89  * @param obj storage space for object to initialize [OUT]
90  * @param parent parent object (or NULL to initialize the root) [IN]
91  * @param type_name object type name
92  *
93  * @note The type name pointer must remain valid even after the object is
94  * deinitialized, as it might be passed by address to log message queue.
95  * Using constant string literals is appropriate.
96  *
97  * @retval 0 on success
98  * @retval -1 on (out of memory) error
99  */
101  const char *type_name);
102 
103 /**
104  * Deinitializes a VLC object.
105  *
106  * This frees resources allocated by vlc_object_init().
107  */
109 
110 /**
111  * Creates a VLC object.
112  *
113  * Note that because the object name pointer must remain valid, potentially
114  * even after the destruction of the object (through the message queues), this
115  * function CANNOT be exported to plugins as is. In this case, the old
116  * vlc_object_create() must be used instead.
117  *
118  * @param p_this an existing VLC object
119  * @param i_size byte size of the object structure
120  * @param psz_type object type name
121  * @return the created object, or NULL.
122  */
123 extern void *
124 vlc_custom_create (vlc_object_t *p_this, size_t i_size, const char *psz_type);
125 #define vlc_custom_create(o, s, n) \
126  vlc_custom_create(VLC_OBJECT(o), s, n)
127 
128 /**
129  * Allocates an object resource.
130  *
131  * @param size storage size in bytes of the resource data
132  * @param release callback to release the resource
133  *
134  * @return a pointer to the (uninitialized) storage space, or NULL on error
135  */
136 void *vlc_objres_new(size_t size, void (*release)(void *));
137 
138 /**
139  * Pushes an object resource on the object resources stack.
140  *
141  * @param obj object to allocate the resource for
142  * @param data resource base address (as returned by vlc_objres_new())
143  */
144 void vlc_objres_push(vlc_object_t *obj, void *data);
145 
146 /**
147  * Releases all resources of an object.
148  *
149  * All resources added with vlc_objres_add() are released in reverse order.
150  * The resource list is reset to empty.
151  *
152  * @param obj object whose resources to release
153  */
154 void vlc_objres_clear(vlc_object_t *obj);
155 
156 /**
157  * Releases one object resource explicitly.
158  *
159  * If a resource associated with an object needs to be released explicitly
160  * earlier than normal, call this function. This is relatively slow and should
161  * be avoided.
162  *
163  * @param obj object whose resource to release
164  * @param data private data for the comparison function
165  * @param match comparison function to match the targeted resource
166  */
167 void vlc_objres_remove(vlc_object_t *obj, void *data,
168  bool (*match)(void *, void *));
169 
170 /**
171  * Private LibVLC instance data.
172  */
174 typedef struct vlc_keystore vlc_keystore;
175 typedef struct vlc_actions_t vlc_actions_t;
176 typedef struct vlc_playlist vlc_playlist_t;
178 typedef struct intf_thread_t intf_thread_t;
179 
180 typedef struct libvlc_priv_t
181 {
183 
184  /* Singleton objects */
185  vlc_mutex_t lock; ///< protect playlist and interfaces
186  vlm_t *p_vlm; ///< the VLM singleton (or NULL)
187  vlc_dialog_provider *p_dialog_provider; ///< dialog provider
188  vlc_keystore *p_memory_keystore; ///< memory keystore
189  intf_thread_t *interfaces; ///< Linked-list of interfaces
191  struct input_preparser_t *parser; ///< Input item meta data handler
193  vlc_actions_t *actions; ///< Hotkeys handler
194  struct vlc_medialibrary_t *p_media_library; ///< Media library instance
195  struct vlc_thumbnailer_t *p_thumbnailer; ///< Lazily instantiated media thumbnailer
196  struct vlc_tracer *tracer; ///< Tracer callbacks
197 
198  /* Exit callback */
201 
202 static inline libvlc_priv_t *libvlc_priv (libvlc_int_t *libvlc)
203 {
204  return container_of(libvlc, libvlc_priv_t, public_data);
205 }
206 
207 int intf_InsertItem(libvlc_int_t *, const char *mrl, unsigned optc,
208  const char * const *optv, unsigned flags);
209 void intf_DestroyAll( libvlc_int_t * );
210 
213  const input_preparser_callbacks_t *cbs,
214  void *cbs_userdata,
215  int timeout, void *id);
216 
217 /*
218  * Variables stuff
219  */
220 void var_OptionParse (vlc_object_t *, const char *, bool trusted);
221 
222 #endif
#define VLC_USED
Definition: fourcc_gen.c:32
void system_End(void)
Cleans up after system_Init() and system_Configure().
Definition: specific.c:272
void vlc_objres_push(vlc_object_t *obj, void *data)
Pushes an object resource on the object resources stack.
Definition: objres.c:64
struct libvlc_priv_t libvlc_priv_t
void intf_DestroyAll(libvlc_int_t *)
Stops and destroys all interfaces, then the playlist.
Definition: interface.c:291
void vlc_object_deinit(vlc_object_t *obj)
Deinitializes a VLC object.
Definition: objects.c:126
void vlc_LogInit(libvlc_int_t *)
Initializes the messages logging subsystem and drain the early messages to the configured log.
Definition: messages.c:445
void var_OptionParse(vlc_object_t *, const char *, bool trusted)
Parse a stringified option This function parse a string option and create the associated object varia...
Definition: variables.c:911
struct vlc_exit vlc_exit_t
void vlc_tracer_Destroy(libvlc_int_t *)
Definition: tracer.c:104
int vlc_object_init(vlc_object_t *obj, vlc_object_t *parent, const char *type_name)
Initializes a VLC object.
void vlc_trace(const char *fn, const char *file, unsigned line)
Print a backtrace to the standard error for debugging purpose.
Definition: thread.c:68
void system_Init(void)
Initializes MME timer, Winsock.
Definition: specific.c:167
int vlc_LogPreinit(libvlc_int_t *)
Performs preinitialization of the messages logging subsystem.
Definition: messages.c:463
void vlc_objres_remove(vlc_object_t *obj, void *data, bool(*match)(void *, void *))
Releases one object resource explicitly.
Definition: objres.c:97
void vlc_tracer_Init(libvlc_int_t *)
Initializes the messages tracing system.
Definition: tracer.c:97
void vlc_ExitInit(vlc_exit_t *)
Definition: exit.c:30
int vlc_MetadataRequest(libvlc_int_t *libvlc, input_item_t *item, input_item_meta_request_option_t i_options, const input_preparser_callbacks_t *cbs, void *cbs_userdata, int timeout, void *id)
Definition: libvlc.c:452
#define vlc_custom_create(o, s, n)
Definition: libvlc.h:125
const char psz_vlc_changeset[]
void vlc_CPU_dump(vlc_object_t *)
Definition: cpu.c:254
void system_Configure(libvlc_int_t *, int, const char *const [])
Definition: specific.c:172
int intf_InsertItem(libvlc_int_t *, const char *mrl, unsigned optc, const char *const *optv, unsigned flags)
Inserts an item in the playlist.
Definition: interface.c:202
int vlc_set_priority(vlc_thread_t, int)
Definition: thread.c:161
void vlc_threads_setup(libvlc_int_t *)
Definition: thread.c:89
static libvlc_priv_t * libvlc_priv(libvlc_int_t *libvlc)
Definition: libvlc.h:202
void vlc_objres_clear(vlc_object_t *obj)
Releases all resources of an object.
Definition: objres.c:84
void * vlc_objres_new(size_t size, void(*release)(void *))
Allocates an object resource.
Definition: objres.c:48
Describes an input and is used to spawn input_thread_t objects.
Definition: vlc_input_item.h:78
Definition: vlc_input_item.h:484
Definition: preparser.c:35
Describe all interface-specific data of the interface thread.
Definition: vlc_interface.h:49
Definition: vlc_objects.h:114
Definition: libvlc.h:181
vlc_keystore * p_memory_keystore
memory keystore
Definition: libvlc.h:188
struct vlc_thumbnailer_t * p_thumbnailer
Lazily instantiated media thumbnailer.
Definition: libvlc.h:195
struct vlc_tracer * tracer
Tracer callbacks.
Definition: libvlc.h:196
vlc_playlist_t * main_playlist
Definition: libvlc.h:190
libvlc_int_t public_data
Definition: libvlc.h:182
intf_thread_t * interfaces
Linked-list of interfaces.
Definition: libvlc.h:189
vlc_actions_t * actions
Hotkeys handler.
Definition: libvlc.h:193
vlc_mutex_t lock
protect playlist and interfaces
Definition: libvlc.h:185
struct vlc_medialibrary_t * p_media_library
Media library instance.
Definition: libvlc.h:194
vlc_media_source_provider_t * media_source_provider
Definition: libvlc.h:192
vlc_exit_t exit
Definition: libvlc.h:199
vlm_t * p_vlm
the VLM singleton (or NULL)
Definition: libvlc.h:186
struct input_preparser_t * parser
Input item meta data handler.
Definition: libvlc.h:191
vlc_dialog_provider * p_dialog_provider
dialog provider
Definition: libvlc.h:187
The structure describing a variable.
Definition: variables.c:69
Definition: actions.c:394
Definition: dialog.c:37
Definition: libvlc.h:74
void * opaque
Definition: libvlc.h:77
vlc_mutex_t lock
Definition: libvlc.h:75
void(* handler)(void *)
Definition: libvlc.h:76
Definition: vlc_keystore.h:297
Definition: messages.c:54
Definition: media_source.c:53
Definition: medialibrary.c:42
Mutex.
Definition: vlc_threads.h:226
VLC object common members.
Definition: vlc_objects.h:45
Definition: playlist.h:49
Thread handle.
Definition: vlc_threads.h:181
Definition: thumbnailer.c:32
Definition: tracer.c:36
Definition: vlm_internal.h:78
#define container_of(ptr, type, member)
Definition: vlc_common.h:1141
This file defines functions, structures and enums for input items in vlc.
input_item_meta_request_option_t
Definition: vlc_input_item.h:464