demux: mkv: handle WAVE_FORMAT_MPEG_ADTS_AAC
[vlc.git] / modules / lua / extension.h
blob2897991297609f4a3edbab58dce3fdc9c741ab2d
1 /*****************************************************************************
2 * extension.h: Lua Extensions (meta data, web information, ...)
3 *****************************************************************************
4 * Copyright (C) 2009-2010 VideoLAN and authors
5 * $Id$
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 (10 * CLOCK_FREQ) ///< 10s period for the timer
33 /* List of available commands */
34 typedef enum
36 CMD_ACTIVATE = 1,
37 CMD_DEACTIVATE,
38 CMD_TRIGGERMENU, /* Arg1 = int*, pointing to id to trigger. free */
39 CMD_CLICK, /* Arg1 = extension_widget_t* */
40 CMD_CLOSE,
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 */
44 } command_type_e;
46 //Data types
47 typedef enum
49 LUA_END = 0,
50 LUA_NUM,
51 LUA_TEXT
52 } lua_datatype_e;
54 struct extension_sys_t
56 /* Extension general */
57 int i_capabilities;
59 /* Lua specific */
60 lua_State *L;
62 vlclua_dtable_t dtable;
64 /* Thread data */
65 vlc_thread_t thread;
66 vlc_mutex_t command_lock;
67 vlc_mutex_t running_lock;
68 vlc_cond_t wait;
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 */
76 struct command_t
78 command_type_e i_command;
79 void *data[10]; ///< Optional void* arguments
80 struct command_t *next; ///< Next command
81 } *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
87 bool b_exiting;
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, ... )
101 va_list args;
102 va_start( args, cmd );
103 int i_ret = PushCommand__( ext, false, cmd, args );
104 va_end( args );
105 return i_ret;
107 static inline int PushCommandUnique( extension_t *ext, int cmd, ... )
109 va_list args;
110 va_start( args, cmd );
111 int i_ret = PushCommand__( ext, true, cmd, args );
112 va_end( args );
113 return i_ret;
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,
126 extension_t *p_ext,
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