VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_extensions.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vlc_extensions.h: Extensions (meta data, web information, ...)
3 *****************************************************************************
4 * Copyright (C) 2009-2010 VideoLAN and authors
5 *
6 * Authors: Jean-Philippe André < jpeg # videolan.org >
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
22
23#ifndef VLC_EXTENSIONS_H
24#define VLC_EXTENSIONS_H
25
26#include "vlc_common.h"
27#include "vlc_threads.h"
28#include "vlc_arrays.h"
29
30/* Structures */
34struct vlc_logger;
35
36/** Extension descriptor: name, title, author, ... */
37typedef struct extension_t {
38 void *p_sys; /**< Reserved for the manager module */
40 /**
41 * The LibVLC logger to use for the extension.
42 */
43 struct vlc_logger *logger;
45 /* Below, (ro) means read-only for the GUI */
46 char *psz_name; /**< Real name of the extension (ro) */
48 char *psz_title; /**< Display title (ro) */
49 char *psz_author; /**< Author of the extension (ro) */
50 char *psz_version; /**< Version (ro) */
51 char *psz_url; /**< A URL to the official page (ro) */
52 char *psz_description; /**< Full description (ro) */
53 char *psz_shortdescription; /**< Short description (eg. 1 line) (ro) */
54 char *p_icondata; /**< Embedded data for the icon (ro) */
55 int i_icondata_size; /**< Size of that data */
72/** Extensions manager object */
75 struct vlc_object_t obj;
77 module_t *p_module; /**< Extensions manager module */
78 void *p_sys; /**< Reserved for the module */
81 DECL_ARRAY(extension_t*) extensions; /**< Array of extension descriptors */
82 vlc_mutex_t lock; /**< A lock for the extensions array */
84 /** Control, see extension_Control
85 *
86 * Legacy way of implementing callbacks.
87 * \ref vlc_extensions_manager_operations should be preferred.
88 */
89 int (*pf_control)(extensions_manager_t*, int, extension_t *, va_list);
91 /**
92 * Implementation of the extension manager operations.
93 *
94 * If NULL all operations will be redirected to \ref extensions_manager_t.pf_control
95 */
97};
98
99/* Control commands */
100enum
101{
102 /* Control extensions */
103 EXTENSION_ACTIVATE, /**< arg1: extension_t* */
104 EXTENSION_DEACTIVATE, /**< arg1: extension_t* */
105 EXTENSION_IS_ACTIVATED, /**< arg1: extension_t*, arg2: bool* */
106 EXTENSION_HAS_MENU, /**< arg1: extension_t* */
107 EXTENSION_GET_MENU, /**< arg1: extension_t*, arg2: char***, arg3: uint16_t** */
108 EXTENSION_TRIGGER_ONLY, /**< arg1: extension_t*, arg2: bool* */
109 EXTENSION_TRIGGER, /**< arg1: extension_t* */
110 EXTENSION_TRIGGER_MENU, /**< arg1: extension_t*, int (uint16_t) */
111 EXTENSION_SET_INPUT, /**< arg1: extension_t*, arg2 (input_item_t*) */
112 EXTENSION_PLAYING_CHANGED, /**< arg1: extension_t*, arg2 int( playing status ) */
113 EXTENSION_META_CHANGED, /**< arg1: extension_t*, arg2 (input_item_t*) */
115
117 int i_control,
118 extension_t *ext,
119 va_list args );
120
121/**
122 * Control function for extensions.
123 * Every GUI -> extension command will go through this function.
124 **/
125static inline int extension_Control( extensions_manager_t *p_mgr,
126 int i_control,
127 extension_t *ext, ... )
128{
129 va_list args;
130 va_start(args, ext);
131 int i_ret = vlc_extension_VaControl(p_mgr, i_control, ext, args);
132 va_end( args );
133 return i_ret;
134}
135
136/**
137 * Helper for extension_HasMenu, extension_IsActivated...
138 * Do not use.
139 **/
140static inline bool
142 int i_flag, bool b_default )
143{
144 bool b = b_default;
145 int i_ret = extension_Control( p_mgr, i_flag, p_ext, &b );
146 if( i_ret != VLC_SUCCESS )
147 return b_default;
148 else
149 return b;
150}
151
152/** Activate or trigger an extension */
153#define extension_Activate( mgr, ext ) \
154 extension_Control( mgr, EXTENSION_ACTIVATE, ext )
155
156/** Trigger the extension. Attention: NOT multithreaded! */
157#define extension_Trigger( mgr, ext ) \
158 extension_Control( mgr, EXTENSION_TRIGGER, ext )
159
160/** Deactivate an extension */
161#define extension_Deactivate( mgr, ext ) \
162 extension_Control( mgr, EXTENSION_DEACTIVATE, ext )
163
164/** Is this extension activated? */
165#define extension_IsActivated( mgr, ext ) \
166 vlc_extension_GetBool( mgr, ext, EXTENSION_IS_ACTIVATED, false )
167
168/** Does this extension have a sub-menu? */
169#define extension_HasMenu( mgr, ext ) \
170 vlc_extension_GetBool( mgr, ext, EXTENSION_HAS_MENU, false )
171
172/** Get this extension's sub-menu */
173static inline int extension_GetMenu( extensions_manager_t *p_mgr,
175 char ***pppsz,
176 uint16_t **ppi )
177{
178 return extension_Control( p_mgr, EXTENSION_GET_MENU, p_ext, pppsz, ppi );
179}
180
181/** Trigger an entry of the extension menu */
182static inline int extension_TriggerMenu( extensions_manager_t *p_mgr,
184 uint16_t i )
185{
186 return extension_Control( p_mgr, EXTENSION_TRIGGER_MENU, p_ext, i );
187}
188
189/** Trigger an entry of the extension menu */
190/* TODO: use player */
191static inline int extension_SetInput( extensions_manager_t *p_mgr,
192 extension_t *p_ext, input_item_t *p_item )
193{
194 return extension_Control( p_mgr, EXTENSION_SET_INPUT, p_ext, p_item );
195}
196
197static inline int extension_PlayingChanged( extensions_manager_t *p_mgr,
199 int state )
200{
201 return extension_Control( p_mgr, EXTENSION_PLAYING_CHANGED, p_ext, state );
202}
203
204static inline int extension_MetaChanged( extensions_manager_t *p_mgr,
205 extension_t *p_ext )
206{
207 return extension_Control( p_mgr, EXTENSION_META_CHANGED, p_ext );
208}
209
210/** Can this extension only be triggered but not activated?
211 Not compatible with HasMenu */
212#define extension_TriggerOnly( mgr, ext ) \
213 vlc_extension_GetBool( mgr, ext, EXTENSION_TRIGGER_ONLY, false )
214
215
216/*****************************************************************************
217 * Extension dialogs
218 *****************************************************************************/
219
223/// User interface event types
224typedef enum
226 EXTENSION_EVENT_CLICK, ///< Click on a widget: data = widget
227 EXTENSION_EVENT_CLOSE, ///< Close the dialog: no data
228 // EXTENSION_EVENT_SELECTION_CHANGED,
229 // EXTENSION_EVENT_TEXT_CHANGED,
231
232/// Command to pass to the extension dialog owner
233typedef struct
235 extension_dialog_t *p_dlg; ///< Destination dialog
236 extension_dialog_event_e event; ///< Event, @see extension_dialog_event_e
237 void *p_data; ///< Opaque data to send
239
240
241/// Dialog descriptor for extensions
244 vlc_object_t *p_object; ///< Owner object (callback on "dialog-event")
246 char *psz_title; ///< Title for the Dialog (in TitleBar)
247 int i_width; ///< Width hint in pixels (may be discarded)
248 int i_height; ///< Height hint in pixels (may be discarded)
250 DECL_ARRAY(extension_widget_t*) widgets; ///< Widgets owned by the dialog
252 bool b_hide; ///< Hide this dialog (!b_hide shows)
253 bool b_kill; ///< Kill this dialog
255 void *p_sys; ///< Dialog private pointer
256 void *p_sys_intf; ///< GUI private pointer
257 vlc_mutex_t lock; ///< Dialog mutex
258 vlc_cond_t cond; ///< Signaled == UI is done working on the dialog
260
261/** Send a command to an Extension dialog
262 * @param p_dialog The dialog
263 * @param event @see extension_dialog_event_e for a list of possible events
264 * @param data Optional opaque data, @see extension_dialog_event_e
265 * @return VLC error code
266 **/
267static inline int extension_DialogCommand( extension_dialog_t* p_dialog,
269 void *data )
270{
272 command.p_dlg = p_dialog;
273 command.event = event;
274 command.p_data = data;
275 var_SetAddress( p_dialog->p_object, "dialog-event", &command );
276 return VLC_SUCCESS;
277}
278
279/** Close the dialog
280 * @param dlg The dialog
281 **/
282#define extension_DialogClosed( dlg ) \
283 extension_DialogCommand( dlg, EXTENSION_EVENT_CLOSE, NULL )
284
285/** Forward a click on a widget
286 * @param dlg The dialog
287 * @param wdg The widget (button, ...)
288 **/
289#define extension_WidgetClicked( dlg, wdg ) \
290 extension_DialogCommand( dlg, EXTENSION_EVENT_CLICK, wdg )
291
292/// Widget types
293typedef enum
295 EXTENSION_WIDGET_LABEL, ///< Text label
296 EXTENSION_WIDGET_BUTTON, ///< Clickable button
297 EXTENSION_WIDGET_IMAGE, ///< Image label (psz_text is local URI)
298 EXTENSION_WIDGET_HTML, ///< HTML or rich text area (non editable)
299 EXTENSION_WIDGET_TEXT_FIELD, ///< Editable text line for user input
300 EXTENSION_WIDGET_PASSWORD, ///< Editable password input (******)
301 EXTENSION_WIDGET_DROPDOWN, ///< Drop-down box
302 EXTENSION_WIDGET_LIST, ///< Vertical list box (of strings)
303 EXTENSION_WIDGET_CHECK_BOX, ///< Checkable box with label
304 EXTENSION_WIDGET_SPIN_ICON, ///< A "loading..." spinning icon
306
307/// Widget descriptor for extensions
310 /* All widgets */
311 extension_widget_type_e type; ///< Type of the widget
312 char *psz_text; ///< Text. May be NULL or modified by the UI
314 /* Drop-down & List widgets */
316 int i_id; ///< Identifier for the extension module
317 ///< (weird behavior may occur if not unique)
318 char *psz_text; ///< String value
319 bool b_selected; ///< True if this item is selected
320 struct extension_widget_value_t *p_next; ///< Next value or NULL
321 } *p_values; ///< Chained list of values (Drop-down/List)
323 /* Check-box */
324 bool b_checked; ///< Is this entry checked
326 /* Layout */
327 int i_row; ///< Row in the grid
328 int i_column; ///< Column in the grid
329 int i_horiz_span; ///< Horizontal size of the object
330 int i_vert_span; ///< Vertical size of the object
331 int i_width; ///< Width hint
332 int i_height; ///< Height hint
333 bool b_hide; ///< Hide this widget (make it invisible)
335 /* Spinning icon */
336 int i_spin_loops; ///< Number of loops to play (-1 = infinite,
337 ///< 0 = stop animation)
338
339 /* Orders */
340 bool b_kill; ///< Destroy this widget
341 bool b_update; ///< Update this widget
343 /* Misc */
344 void *p_sys; ///< Reserved for the extension manager
345 void *p_sys_intf; ///< Reserved for the UI, but:
346 ///< NULL means the UI has destroyed the widget
347 ///< or has not created it yet
348 extension_dialog_t *p_dialog; ///< Parent dialog
350
351#endif /* VLC_EXTENSIONS_H */
#define VLC_API
Definition fourcc_gen.c:31
#define VLC_SUCCESS
No error.
Definition vlc_common.h:478
static int var_SetAddress(vlc_object_t *p_obj, const char *psz_name, void *ptr)
Set the value of a pointer variable.
Definition vlc_variables.h:392
static thread_local struct @85 state
Command to pass to the extension dialog owner.
Definition vlc_extensions.h:235
void * p_data
Opaque data to send.
Definition vlc_extensions.h:238
extension_dialog_t * p_dlg
Destination dialog.
Definition vlc_extensions.h:236
extension_dialog_event_e event
Event,.
Definition vlc_extensions.h:237
Dialog descriptor for extensions.
Definition vlc_extensions.h:244
vlc_cond_t cond
Signaled == UI is done working on the dialog.
Definition vlc_extensions.h:259
bool b_hide
Hide this dialog (!b_hide shows)
Definition vlc_extensions.h:253
char * psz_title
Title for the Dialog (in TitleBar)
Definition vlc_extensions.h:247
int i_height
Height hint in pixels (may be discarded)
Definition vlc_extensions.h:249
vlc_object_t * p_object
Owner object (callback on "dialog-event")
Definition vlc_extensions.h:245
void * p_sys_intf
GUI private pointer.
Definition vlc_extensions.h:257
int i_width
Width hint in pixels (may be discarded)
Definition vlc_extensions.h:248
void * p_sys
Dialog private pointer.
Definition vlc_extensions.h:256
struct extension_dialog_t::@224 widgets
Widgets owned by the dialog.
bool b_kill
Kill this dialog.
Definition vlc_extensions.h:254
vlc_mutex_t lock
Dialog mutex.
Definition vlc_extensions.h:258
Extension descriptor: name, title, author, ...
Definition vlc_extensions.h:38
char * psz_version
Version (ro)
Definition vlc_extensions.h:51
struct vlc_logger * logger
The LibVLC logger to use for the extension.
Definition vlc_extensions.h:44
char * psz_url
A URL to the official page (ro)
Definition vlc_extensions.h:52
char * psz_shortdescription
Short description (eg.
Definition vlc_extensions.h:54
char * psz_name
Real name of the extension (ro)
Definition vlc_extensions.h:47
char * p_icondata
Embedded data for the icon (ro)
Definition vlc_extensions.h:55
char * psz_description
Full description (ro)
Definition vlc_extensions.h:53
char * psz_title
Display title (ro)
Definition vlc_extensions.h:49
void * p_sys
Reserved for the manager module.
Definition vlc_extensions.h:39
char * psz_author
Author of the extension (ro)
Definition vlc_extensions.h:50
int i_icondata_size
Size of that data.
Definition vlc_extensions.h:56
Definition vlc_extensions.h:316
int i_id
Identifier for the extension module (weird behavior may occur if not unique)
Definition vlc_extensions.h:317
bool b_selected
True if this item is selected.
Definition vlc_extensions.h:320
struct extension_widget_value_t * p_next
Next value or NULL.
Definition vlc_extensions.h:321
char * psz_text
String value.
Definition vlc_extensions.h:319
Widget descriptor for extensions.
Definition vlc_extensions.h:310
int i_spin_loops
Number of loops to play (-1 = infinite, 0 = stop animation)
Definition vlc_extensions.h:337
char * psz_text
Text. May be NULL or modified by the UI.
Definition vlc_extensions.h:313
bool b_hide
Hide this widget (make it invisible)
Definition vlc_extensions.h:334
extension_widget_type_e type
Type of the widget.
Definition vlc_extensions.h:312
int i_horiz_span
Horizontal size of the object.
Definition vlc_extensions.h:330
bool b_checked
Is this entry checked.
Definition vlc_extensions.h:325
struct extension_widget_t::extension_widget_value_t * p_values
Chained list of values (Drop-down/List)
int i_column
Column in the grid.
Definition vlc_extensions.h:329
int i_width
Width hint.
Definition vlc_extensions.h:332
int i_vert_span
Vertical size of the object.
Definition vlc_extensions.h:331
bool b_kill
Destroy this widget.
Definition vlc_extensions.h:341
void * p_sys
Reserved for the extension manager.
Definition vlc_extensions.h:345
int i_row
Row in the grid.
Definition vlc_extensions.h:328
int i_height
Height hint.
Definition vlc_extensions.h:333
extension_dialog_t * p_dialog
Parent dialog.
Definition vlc_extensions.h:349
bool b_update
Update this widget.
Definition vlc_extensions.h:342
void * p_sys_intf
Reserved for the UI, but: NULL means the UI has destroyed the widget or has not created it yet.
Definition vlc_extensions.h:346
Extensions manager object.
Definition vlc_extensions.h:75
int(* pf_control)(extensions_manager_t *, int, extension_t *, va_list)
Control, see extension_Control.
Definition vlc_extensions.h:90
struct vlc_player_t * player
Definition vlc_extensions.h:80
struct vlc_object_t obj
Definition vlc_extensions.h:76
void * p_sys
Reserved for the module.
Definition vlc_extensions.h:79
module_t * p_module
Extensions manager module.
Definition vlc_extensions.h:78
struct extensions_manager_t::@223 extensions
Array of extension descriptors.
const struct vlc_extensions_manager_operations * ops
Implementation of the extension manager operations.
Definition vlc_extensions.h:97
vlc_mutex_t lock
A lock for the extensions array.
Definition vlc_extensions.h:83
Describes an input and is used to spawn input_thread_t objects.
Definition vlc_input_item.h:98
Internal module descriptor.
Definition modules.h:76
Condition variable.
Definition vlc_threads.h:270
Definition vlc_extensions.h:59
int(* trigger_menu)(extensions_manager_t *, extension_t *, int)
Definition vlc_extensions.h:67
int(* activate)(extensions_manager_t *, extension_t *)
Definition vlc_extensions.h:60
bool(* has_menu)(extensions_manager_t *, extension_t *)
Definition vlc_extensions.h:63
int(* get_menu)(extensions_manager_t *, extension_t *, char ***, uint16_t **)
Definition vlc_extensions.h:64
bool(* trigger_only)(extensions_manager_t *, extension_t *)
Definition vlc_extensions.h:65
bool(* is_activated)(extensions_manager_t *, extension_t *)
Definition vlc_extensions.h:62
int(* set_input)(extensions_manager_t *, extension_t *, input_item_t *)
Definition vlc_extensions.h:68
int(* playing_changed)(extensions_manager_t *, extension_t *, int)
Definition vlc_extensions.h:69
int(* meta_changed)(extensions_manager_t *, extension_t *)
Definition vlc_extensions.h:70
int(* trigger)(extensions_manager_t *, extension_t *)
Definition vlc_extensions.h:66
int(* deactivate)(extensions_manager_t *, extension_t *)
Definition vlc_extensions.h:61
Definition messages.c:85
Mutex.
Definition vlc_threads.h:143
VLC object common members.
Definition vlc_objects.h:53
Definition player.h:236
This file defines functions, structures and macros for handling arrays in vlc.
#define DECL_ARRAY(type)
Definition vlc_arrays.h:181
This file is a collection of common definitions and types.
static bool vlc_extension_GetBool(extensions_manager_t *p_mgr, extension_t *p_ext, int i_flag, bool b_default)
Helper for extension_HasMenu, extension_IsActivated... Do not use.
Definition vlc_extensions.h:142
static int extension_Control(extensions_manager_t *p_mgr, int i_control, extension_t *ext,...)
Control function for extensions.
Definition vlc_extensions.h:126
struct extensions_manager_sys_t extensions_manager_sys_t
Definition vlc_extensions.h:32
static int extension_SetInput(extensions_manager_t *p_mgr, extension_t *p_ext, input_item_t *p_item)
Trigger an entry of the extension menu.
Definition vlc_extensions.h:192
extension_dialog_event_e
User interface event types.
Definition vlc_extensions.h:226
@ EXTENSION_EVENT_CLOSE
Close the dialog: no data.
Definition vlc_extensions.h:228
@ EXTENSION_EVENT_CLICK
Click on a widget: data = widget.
Definition vlc_extensions.h:227
static int extension_TriggerMenu(extensions_manager_t *p_mgr, extension_t *p_ext, uint16_t i)
Trigger an entry of the extension menu.
Definition vlc_extensions.h:183
extension_widget_type_e
Widget types.
Definition vlc_extensions.h:295
@ EXTENSION_WIDGET_LIST
Vertical list box (of strings)
Definition vlc_extensions.h:303
@ EXTENSION_WIDGET_BUTTON
Clickable button.
Definition vlc_extensions.h:297
@ EXTENSION_WIDGET_CHECK_BOX
Checkable box with label.
Definition vlc_extensions.h:304
@ EXTENSION_WIDGET_HTML
HTML or rich text area (non editable)
Definition vlc_extensions.h:299
@ EXTENSION_WIDGET_DROPDOWN
Drop-down box.
Definition vlc_extensions.h:302
@ EXTENSION_WIDGET_TEXT_FIELD
Editable text line for user input.
Definition vlc_extensions.h:300
@ EXTENSION_WIDGET_PASSWORD
Editable password input (******)
Definition vlc_extensions.h:301
@ EXTENSION_WIDGET_SPIN_ICON
A "loading..." spinning icon.
Definition vlc_extensions.h:305
@ EXTENSION_WIDGET_IMAGE
Image label (psz_text is local URI)
Definition vlc_extensions.h:298
@ EXTENSION_WIDGET_LABEL
Text label.
Definition vlc_extensions.h:296
static int extension_DialogCommand(extension_dialog_t *p_dialog, extension_dialog_event_e event, void *data)
Send a command to an Extension dialog.
Definition vlc_extensions.h:268
@ EXTENSION_GET_MENU
arg1: extension_t*, arg2: char***, arg3: uint16_t**
Definition vlc_extensions.h:108
@ EXTENSION_PLAYING_CHANGED
arg1: extension_t*, arg2 int( playing status )
Definition vlc_extensions.h:113
@ EXTENSION_IS_ACTIVATED
arg1: extension_t*, arg2: bool*
Definition vlc_extensions.h:106
@ EXTENSION_ACTIVATE
arg1: extension_t*
Definition vlc_extensions.h:104
@ EXTENSION_HAS_MENU
arg1: extension_t*
Definition vlc_extensions.h:107
@ EXTENSION_TRIGGER
arg1: extension_t*
Definition vlc_extensions.h:110
@ EXTENSION_SET_INPUT
arg1: extension_t*, arg2 (input_item_t*)
Definition vlc_extensions.h:112
@ EXTENSION_META_CHANGED
arg1: extension_t*, arg2 (input_item_t*)
Definition vlc_extensions.h:114
@ EXTENSION_TRIGGER_MENU
arg1: extension_t*, int (uint16_t)
Definition vlc_extensions.h:111
@ EXTENSION_TRIGGER_ONLY
arg1: extension_t*, arg2: bool*
Definition vlc_extensions.h:109
@ EXTENSION_DEACTIVATE
arg1: extension_t*
Definition vlc_extensions.h:105
static int extension_GetMenu(extensions_manager_t *p_mgr, extension_t *p_ext, char ***pppsz, uint16_t **ppi)
Get this extension's sub-menu.
Definition vlc_extensions.h:174
int vlc_extension_VaControl(extensions_manager_t *p_mgr, int i_control, extension_t *ext, va_list args)
Definition extensions.c:32
static int extension_PlayingChanged(extensions_manager_t *p_mgr, extension_t *p_ext, int state)
Definition vlc_extensions.h:198
static int extension_MetaChanged(extensions_manager_t *p_mgr, extension_t *p_ext)
Definition vlc_extensions.h:205
Thread primitive declarations.