1 /*****************************************************************************
2 * extension.h: Lua Extensions (meta data, web information, ...)
3 *****************************************************************************
4 * Copyright (C) 2009-2010 VideoLAN and authors
6 * Authors: Jean-Philippe André < jpeg # videolan.org >
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
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 General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifndef LUA_EXTENSION_H
24 #define LUA_EXTENSION_H
26 #include <vlc_extensions.h>
27 #include <vlc_arrays.h>
28 #include <vlc_dialog.h>
30 #define WATCH_TIMER_PERIOD VLC_TICK_FROM_SEC(10) ///< 10s period for the timer
32 /* List of available commands */
37 CMD_TRIGGERMENU
, /* Arg1 = int*, pointing to id to trigger. free */
38 CMD_CLICK
, /* Arg1 = extension_widget_t* */
40 CMD_SET_INPUT
, /* No arg. Just signal current input changed */
41 CMD_UPDATE_META
, /* No arg. Just signal current input item meta changed */
42 CMD_PLAYING_CHANGED
/* Arg1 = int*, New playing status */
53 struct extension_sys_t
55 /* Extension general */
61 vlclua_dtable_t dtable
;
65 vlc_mutex_t command_lock
;
66 vlc_mutex_t running_lock
;
69 /* The item this extension should use for vlc.input
70 * or NULL if it should use playlist's current input */
71 struct input_item_t
*p_item
;
73 extensions_manager_t
*p_mgr
; ///< Parent
74 /* Queue of commands to execute */
77 command_type_e i_command
;
78 void *data
[10]; ///< Optional void* arguments
79 struct command_t
*next
; ///< Next command
82 // The two following booleans are protected by command_lock
83 vlc_dialog_id
*p_progress_id
;
84 vlc_timer_t timer
; ///< This timer makes sure Lua never gets stuck >5s
88 bool b_thread_running
; //< Only accessed out of the extension thread.
89 bool b_activated
; ///< Protected by the command lock
92 /* Extensions: manager functions */
93 int Activate( extensions_manager_t
*p_mgr
, extension_t
* );
94 int Deactivate( extensions_manager_t
*p_mgr
, extension_t
* );
95 bool QueueDeactivateCommand( extension_t
*p_ext
);
96 void KillExtension( extensions_manager_t
*p_mgr
, extension_t
*p_ext
);
97 int PushCommand__( extension_t
*ext
, bool unique
, command_type_e cmd
, va_list options
);
98 static inline int PushCommand( extension_t
*ext
, int cmd
, ... )
101 va_start( args
, cmd
);
102 int i_ret
= PushCommand__( ext
, false, cmd
, args
);
106 static inline int PushCommandUnique( extension_t
*ext
, int cmd
, ... )
109 va_start( args
, cmd
);
110 int i_ret
= PushCommand__( ext
, true, cmd
, args
);
115 /* Lua specific functions */
116 void vlclua_extension_set( lua_State
*L
, extension_t
* );
117 extension_t
*vlclua_extension_get( lua_State
*L
);
118 int lua_ExtensionActivate( extensions_manager_t
*, extension_t
* );
119 int lua_ExtensionDeactivate( extensions_manager_t
*, extension_t
* );
120 int lua_ExecuteFunctionVa( extensions_manager_t
*p_mgr
, extension_t
*p_ext
,
121 const char *psz_function
, va_list args
);
122 int lua_ExecuteFunction( extensions_manager_t
*p_mgr
, extension_t
*p_ext
,
123 const char *psz_function
, ... );
124 int lua_ExtensionWidgetClick( extensions_manager_t
*p_mgr
,
126 extension_widget_t
*p_widget
);
127 int lua_ExtensionTriggerMenu( extensions_manager_t
*p_mgr
,
128 extension_t
*p_ext
, int id
);
130 /* Dialog specific */
131 int lua_DialogFlush( lua_State
*L
);
133 #endif // LUA_EXTENSION_H