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