demux: mp4: save track start point
[vlc.git] / modules / lua / extension.h
blob68e81fe66f1a5f5d815342fac64674caa39ca5de
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 */
33 typedef enum
35 CMD_ACTIVATE = 1,
36 CMD_DEACTIVATE,
37 CMD_TRIGGERMENU, /* Arg1 = int*, pointing to id to trigger. free */
38 CMD_CLICK, /* Arg1 = extension_widget_t* */
39 CMD_CLOSE,
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 */
43 } command_type_e;
45 //Data types
46 typedef enum
48 LUA_END = 0,
49 LUA_NUM,
50 LUA_TEXT
51 } lua_datatype_e;
53 struct extension_sys_t
55 /* Extension general */
56 int i_capabilities;
58 /* Lua specific */
59 lua_State *L;
61 vlclua_dtable_t dtable;
63 /* Thread data */
64 vlc_thread_t thread;
65 vlc_mutex_t command_lock;
66 vlc_mutex_t running_lock;
67 vlc_cond_t wait;
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 */
75 struct command_t
77 command_type_e i_command;
78 void *data[10]; ///< Optional void* arguments
79 struct command_t *next; ///< Next command
80 } *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
86 bool b_exiting;
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, ... )
100 va_list args;
101 va_start( args, cmd );
102 int i_ret = PushCommand__( ext, false, cmd, args );
103 va_end( args );
104 return i_ret;
106 static inline int PushCommandUnique( extension_t *ext, int cmd, ... )
108 va_list args;
109 va_start( args, cmd );
110 int i_ret = PushCommand__( ext, true, cmd, args );
111 va_end( args );
112 return i_ret;
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,
125 extension_t *p_ext,
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