summaryrefslogtreecommitdiffstats
path: root/player/lua.c
Commit message (Collapse)AuthorAgeFilesLines
* lua: add API for observing property changeswm42014-04-081-4/+12
| | | | | A low level API was added already earlier, but that was merely a binding for the raw C API. Add a "proper" one, and document it.
* lua: add basic mpv_observe_property supportwm42014-04-061-0/+58
| | | | Undocumented and only the most basic functionality for now.
* lua: add license headerwm42014-03-071-0/+17
| | | | Oops.
* lua: set a proper chunk name for builtin moduleswm42014-03-011-1/+2
| | | | | | | | luaL_loadstring(), which was used until now, uses the start of the Lua code itself as chunk name. Since the chunk name shows up even with runtime errors triggered by e.g. Lua code loaded from user scripts, this looks a but ugly. Switch to luaL_loadbuffer(), which is almost the same as luaL_loadstring(), but allows setting a chunk name.
* lua: fix format string in luaL_error()wm42014-03-011-1/+1
|
* lua: add option to disable auto-loading of lua scriptswm42014-02-281-0/+2
|
* lua: add set_property_native functionwm42014-02-261-3/+132
| | | | | | Probably completely useless, at least for now. Also not very well tested, but initial test seems successful.
* lua: mark table values returned by get_property_native with their typewm42014-02-261-0/+14
| | | | | | | Lua doesn't distinguish between arrays and maps on the language level; there are just tables. Use metatables to mark these tables with their actual types. In particular, it allows distinguishing empty arrays from empty tables.
* lua: implement mp.get_opt() in Luawm42014-02-261-24/+0
| | | | | | Will be more expensive if used very often, but it's probably ok. Reduce the dependency of lua.c on MPContext a bit further.
* osd: override user bindings for OSC inputwm42014-02-261-2/+2
| | | | | | | | | E.g. binding MOUSE_BTN0 always used the user defined binding. While it is ok that the user can override mouse_move and mouse_leave (for whatever reasons), we want to strictly override the bindings when input is sent to the OSC itself. Regression since 03624a1.
* client API: report pause/unpause reasonwm42014-02-241-0/+16
| | | | | | | | | Not sure about this... might redo. At least this provides a case of a broadcasted event, which requires per-event data allocation. See github issue #576.
* client API: expose the internal clockwm42014-02-241-1/+2
| | | | | | | | | May or may not be useful in some ways. We require a context parameter for this just to be sure, even if the internal implementation currently doesn't. That's one less mpv internal function for the Lua wrapper.
* lua, osc: use properties for chapter/track listswm42014-02-241-77/+0
|
* lua: add a bunch of functions to get/set properties by their native typewm42014-02-241-5/+150
| | | | | | There are some complications because the client API distinguishes between integers and floats, while Lua has only "numbers" (which are usually floats). But I think this should work now.
* lua: add mechanism for script provided key bindingswm42014-02-171-1/+12
| | | | | | | | | | | | | There was already an undocumented mechanism provided by mp.set_key_bindings and other functions, but this was relatively verbose, and also weird. It was mainly to make the OSC happy (including being efficient and supporting weird corner cases), while the new functions try to be a bit simpler. This also provides a way to let users rebind script-provided commands. (This mechanism is less efficient, because it's O(n^2) for n added key bindings, but it shouldn't matter.)
* client API: add a client message eventwm42014-02-171-0/+13
| | | | | This comes with a "script_message" input command, which sends these messages. Used by the following commits.
* lua: allow giving fallback values in get_property() callswm42014-02-171-2/+5
| | | | | E.g. ``mp.get_property("foo", "value")`` will return ``value`` if the property can't be read.
* lua: auto-load scripts from ~/.mpv/lua/wm42014-02-141-3/+48
| | | | This is like passing them to --lua.
* lua: some minor API changeswm42014-02-111-12/+15
|
* lua: add set_property functionwm42014-02-111-0/+10
|
* lua: change error behaviorwm42014-02-111-13/+11
| | | | | | | Return the error Lua-style, instead of raising it as Lua error. This is better, because raising errors is reserved for more "fatal" conditions. Pretending they're exceptions and trying to do exception-style error handling will just lead to pain in this language.
* lua: rename some API functionswm42014-02-111-13/+13
| | | | | | | | | send_command -> command send_commandv -> commandv get_timer -> get_time property_get -> get_property property_get_string -> get_property_osd getopt -> get_opt
* lua: port to client APIwm42014-02-101-152/+185
| | | | | | | | | | | | | | | | This is partial only, and it still accesses some MPContext internals. Specifically, chapter and track lists are still read directly, and OSD access is special-cased too. The OSC seems to work fine, except using the fast-forward/backward buttons. These buttons behave differently, because the OSC code had certain assumptions how often its update code is called. The Lua interface changes slightly. Note that this has the odd property that Lua script and video start at the same time, asynchronously. If this becomes an issue, explicit synchronization could be added.
* lua: allow ~ path convention for --luawm42014-01-211-1/+3
| | | | | Paths passed to the --lua option now follow the convention for paths starting with ~ documented in mpv.rst.
* sub: uglify OSD code path with lockingwm42014-01-181-22/+9
| | | | | | | | | | | | | | | Do two things: 1. add locking to struct osd_state 2. make struct osd_state opaque While 1. is somewhat simple, 2. is quite horrible. Lots of code accesses lots of osd_state (and osd_object) members. To make sure everything is accessed synchronously, I prefer making osd_state opaque, even if it means adding pretty dumb accessors. All of this is meant to allow running VO in their own threads. Eventually, VOs will request OSD on their own, which means osd_state will be accessed from foreign threads.
* lua: add a --lua-opts option, which can be queried by scriptswm42014-01-161-0/+16
| | | | | | | The values set by this new option can be queried by Lua scripts using the mp.getopt() function. The function takes a string parameter, and returns the value of the first key that matches. If no key matches, nil is returned.
* lua: use core log level nameswm42014-01-161-11/+2
| | | | | | When the Lua code was written, the core didn't have names for log levels yet (just numbers). The only user visible change is that "verbose" becomes "v", since this level had different names.
* lua: allow scripts to snoop messageswm42014-01-161-10/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the following Lua function to enable message events: mp.enable_messages(size, level) size is the maximum number of messages the ringbuffer consists of. level is the minimum log level for a message to be added to the ringbuffer, and uses the same values as the mp.log() function. (Actually not yet, but this will be fixed in the following commit.) The messages will be delivered via the mp_event() in the user script, using "message" as event name. The event argument is a table with the following fields: level: log level of the message (string as in mp.log()) prefix: string identifying the module of origin text: contents of the message As of currently, the message text will contain newline characters. A message can consist of several lines. It is also possible that a message doesn't end with a newline, and a caller can use multiple messages to "build" a line. Most messages will contain exactly 1 line ending with a single newline character, though. If the message buffer overflows (messages are not read quickly enough), new messages are lost until the queued up messages are read. At the point of the overflow, a special overflow message is inserted. It will have prefix set to "overflow", and the message text is set to "". Care should be taken not to print any messages from the message event handler. This would lead to an infinite loop (the event handler would be called again after returning, because a new message is available). This includes mp.log() and all mp.msg.* functions. Keep in mind that the Lua print() function is mapped to mp.msg.info().
* msg: rename mp_msg_log -> mp_msgwm42013-12-211-2/+2
| | | | Same for companion functions.
* msg: convert defines to enumwm42013-12-211-1/+1
| | | | Also get rid of MSGL_HINT and the many MSGL_DBG* levels.
* path lookup functions: mp_msg conversionswm42013-12-211-1/+2
| | | | | | | | | | | | | | | | | There's a single mp_msg() in path.c, but all path lookup functions seem to depend on it, so we get a rat-tail of stuff we have to change. This is probably a good thing though, because we can have the path lookup functions also access options, so we could allow overriding the default config path, or ignore the MPV_HOME environment variable, and such things. Also take the chance to consistently add talloc_ctx parameters to the path lookup functions. Also, this change causes a big mess on configfiles.c. It's the same issue: everything suddenly needs a (different) context argument. Make it less wild by providing a mp_load_auto_profiles() function, which isolates most of it to configfiles.c.
* lua: minor simplificationwm42013-12-211-2/+1
| | | | | Using m_property_do() is more complicated, and will have to be changed later for mp_msg conversions.
* input, lua: add functions to take pre-split input commandswm42013-12-201-0/+23
| | | | | | | | | | | | | | So you can pass a command as list of strings (each item is an argument), instead of having to worry about escaping and such. These functions also take an argument for the default command flags. In particular, this allows setting saner defaults for commands sent by program code. Expose this to Lua as mp.send_commandv command (suggestions for a better name welcome). The Lua version doesn't allow setting the default command flags, but it can still use command prefixes. The default flags are different from input.conf, and disable OSD and property expansion.
* player: replace some overlooked mp_msgswm42013-12-191-4/+4
| | | | | There are still some using IDENTIFY, and some without context in configfiles.c.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-3/+3
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-3/+3
| | | | | | | | | Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.
* Move mpvcore/input/ to input/wm42013-12-171-1/+1
|
* Rename mp_lua.c/h to lua.c/hwm42013-12-171-0/+683