2010-01-30 23:24:23 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2010-01-30 23:24:23 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or modify
|
2010-01-30 23:24:23 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2010-01-30 23:24:23 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2015-04-13 07:36:54 +00:00
|
|
|
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-30 23:24:23 +00:00
|
|
|
*/
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <unistd.h>
|
2007-03-09 14:04:07 +00:00
|
|
|
#include <string.h>
|
2008-11-29 06:09:57 +00:00
|
|
|
#include <stdbool.h>
|
2012-02-10 18:03:24 +00:00
|
|
|
#include <assert.h>
|
2013-06-04 11:33:01 +00:00
|
|
|
#include <time.h>
|
2014-11-28 23:34:53 +00:00
|
|
|
#include <math.h>
|
2014-04-05 21:54:21 +00:00
|
|
|
#include <pthread.h>
|
2013-11-30 21:47:17 +00:00
|
|
|
#include <sys/types.h>
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-06-27 16:21:07 +00:00
|
|
|
#include <libavutil/avstring.h>
|
|
|
|
#include <libavutil/common.h>
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "config.h"
|
2009-04-02 02:00:22 +00:00
|
|
|
#include "talloc.h"
|
2014-02-10 20:01:35 +00:00
|
|
|
#include "client.h"
|
2014-01-16 20:24:39 +00:00
|
|
|
#include "common/msg.h"
|
|
|
|
#include "common/msg_control.h"
|
2008-03-28 01:07:59 +00:00
|
|
|
#include "command.h"
|
2013-12-01 01:07:32 +00:00
|
|
|
#include "osdep/timer.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/common.h"
|
2013-12-17 00:23:09 +00:00
|
|
|
#include "input/input.h"
|
2015-01-23 20:45:13 +00:00
|
|
|
#include "input/keycodes.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "stream/stream.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "demux/demux.h"
|
|
|
|
#include "demux/stheader.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/playlist.h"
|
2013-11-24 11:58:06 +00:00
|
|
|
#include "sub/osd.h"
|
2011-01-16 18:03:08 +00:00
|
|
|
#include "sub/dec_sub.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_option.h"
|
|
|
|
#include "options/m_property.h"
|
|
|
|
#include "options/m_config.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/filter/vf.h"
|
|
|
|
#include "video/decode/vd.h"
|
|
|
|
#include "video/out/vo.h"
|
|
|
|
#include "video/csputils.h"
|
|
|
|
#include "audio/mixer.h"
|
2013-11-23 20:25:05 +00:00
|
|
|
#include "audio/audio_buffer.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "audio/out/ao.h"
|
|
|
|
#include "audio/filter/af.h"
|
|
|
|
#include "video/decode/dec_video.h"
|
|
|
|
#include "audio/decode/dec_audio.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/path.h"
|
2011-10-06 18:46:01 +00:00
|
|
|
#include "screenshot.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-11-30 21:40:51 +00:00
|
|
|
#include "osdep/io.h"
|
2015-01-01 19:37:49 +00:00
|
|
|
#include "osdep/subprocess.h"
|
2013-11-30 21:40:51 +00:00
|
|
|
|
2013-12-17 00:08:53 +00:00
|
|
|
#include "core.h"
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
struct command_ctx {
|
2014-12-10 13:42:57 +00:00
|
|
|
bool is_idle;
|
|
|
|
|
2013-12-01 01:07:32 +00:00
|
|
|
double last_seek_time;
|
|
|
|
double last_seek_pts;
|
2014-12-17 21:56:45 +00:00
|
|
|
double marked_pts;
|
2013-12-01 01:07:32 +00:00
|
|
|
|
2014-11-17 23:09:42 +00:00
|
|
|
double prev_pts;
|
|
|
|
|
2015-05-22 18:01:12 +00:00
|
|
|
char **warned_deprecated;
|
|
|
|
int num_warned_deprecated;
|
|
|
|
|
2013-11-29 23:18:24 +00:00
|
|
|
struct cycle_counter *cycle_counters;
|
|
|
|
int num_cycle_counters;
|
|
|
|
|
2014-10-02 23:22:07 +00:00
|
|
|
struct overlay *overlays;
|
2014-07-25 12:22:40 +00:00
|
|
|
int num_overlays;
|
|
|
|
// One of these is in use by the OSD; the other one exists so that the
|
|
|
|
// bitmap list can be manipulated without additional synchronization.
|
|
|
|
struct sub_bitmaps overlay_osd[2];
|
|
|
|
struct sub_bitmaps *overlay_osd_current;
|
2014-10-10 17:46:21 +00:00
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
struct hook_handler **hooks;
|
|
|
|
int num_hooks;
|
|
|
|
int64_t hook_seq; // for hook_handler.seq
|
|
|
|
|
2015-02-12 15:53:56 +00:00
|
|
|
struct ao_hotplug *hotplug;
|
2013-09-30 20:27:37 +00:00
|
|
|
};
|
|
|
|
|
2014-10-02 23:22:07 +00:00
|
|
|
struct overlay {
|
2014-12-26 16:43:59 +00:00
|
|
|
void *map_start;
|
2014-10-02 23:22:07 +00:00
|
|
|
size_t map_size;
|
|
|
|
struct sub_bitmap osd;
|
|
|
|
};
|
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
struct hook_handler {
|
|
|
|
char *client; // client API user name
|
|
|
|
char *type; // kind of hook, e.g. "on_load"
|
|
|
|
char *user_id; // numeric user-chosen ID, printed as string
|
|
|
|
int priority; // priority for global hook order
|
|
|
|
int64_t seq; // unique ID (also age -> fixed order for equal priorities)
|
|
|
|
bool active; // hook is currently in progress (only 1 at a time for now)
|
|
|
|
};
|
|
|
|
|
2015-07-21 19:54:15 +00:00
|
|
|
static int edit_filters(struct MPContext *mpctx, struct mp_log *log,
|
|
|
|
enum stream_type mediatype,
|
2013-09-20 13:09:29 +00:00
|
|
|
const char *cmd, const char *arg);
|
2013-08-03 11:41:38 +00:00
|
|
|
static int set_filters(struct MPContext *mpctx, enum stream_type mediatype,
|
|
|
|
struct m_obj_settings *new_chain);
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
|
2014-10-24 19:52:16 +00:00
|
|
|
static void hook_remove(struct MPContext *mpctx, int index)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
assert(index >= 0 && index < cmd->num_hooks);
|
|
|
|
talloc_free(cmd->hooks[index]);
|
|
|
|
MP_TARRAY_REMOVE_AT(cmd->hooks, cmd->num_hooks, index);
|
|
|
|
}
|
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
bool mp_hook_test_completion(struct MPContext *mpctx, char *type)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
for (int n = 0; n < cmd->num_hooks; n++) {
|
|
|
|
struct hook_handler *h = cmd->hooks[n];
|
2014-10-24 19:52:16 +00:00
|
|
|
if (h->active && strcmp(h->type, type) == 0) {
|
|
|
|
if (!mp_client_exists(mpctx, h->client)) {
|
|
|
|
hook_remove(mpctx, n);
|
|
|
|
break;
|
|
|
|
}
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
return false;
|
2014-10-24 19:52:16 +00:00
|
|
|
}
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool send_hook_msg(struct MPContext *mpctx, struct hook_handler *h,
|
|
|
|
char *cmd)
|
|
|
|
{
|
|
|
|
mpv_event_client_message *m = talloc_ptrtype(NULL, m);
|
|
|
|
*m = (mpv_event_client_message){0};
|
2014-10-20 21:43:10 +00:00
|
|
|
MP_TARRAY_APPEND(m, m->args, m->num_args, cmd);
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
MP_TARRAY_APPEND(m, m->args, m->num_args, talloc_strdup(m, h->user_id));
|
|
|
|
MP_TARRAY_APPEND(m, m->args, m->num_args, talloc_strdup(m, h->type));
|
|
|
|
bool r =
|
|
|
|
mp_client_send_event(mpctx, h->client, MPV_EVENT_CLIENT_MESSAGE, m) >= 0;
|
|
|
|
if (!r)
|
|
|
|
MP_WARN(mpctx, "Sending hook command failed.\n");
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
// client==NULL means start the hook chain
|
|
|
|
void mp_hook_run(struct MPContext *mpctx, char *client, char *type)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
bool found_current = !client;
|
2014-10-24 19:52:16 +00:00
|
|
|
int index = -1;
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
for (int n = 0; n < cmd->num_hooks; n++) {
|
|
|
|
struct hook_handler *h = cmd->hooks[n];
|
|
|
|
if (!found_current) {
|
|
|
|
if (h->active && strcmp(h->type, type) == 0) {
|
|
|
|
h->active = false;
|
|
|
|
found_current = true;
|
|
|
|
}
|
|
|
|
} else if (strcmp(h->type, type) == 0) {
|
2014-10-24 19:52:16 +00:00
|
|
|
index = n;
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-10-24 19:52:16 +00:00
|
|
|
if (index < 0)
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
return;
|
2014-10-24 19:52:16 +00:00
|
|
|
struct hook_handler *next = cmd->hooks[index];
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
MP_VERBOSE(mpctx, "Running hook: %s/%s\n", next->client, type);
|
|
|
|
next->active = true;
|
2014-10-24 19:52:16 +00:00
|
|
|
if (!send_hook_msg(mpctx, next, "hook_run")) {
|
|
|
|
hook_remove(mpctx, index);
|
|
|
|
mp_input_wakeup(mpctx->input); // repeat next iteration to finish
|
|
|
|
}
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int compare_hook(const void *pa, const void *pb)
|
|
|
|
{
|
|
|
|
struct hook_handler **h1 = (void *)pa;
|
|
|
|
struct hook_handler **h2 = (void *)pb;
|
|
|
|
if ((*h1)->priority != (*h2)->priority)
|
|
|
|
return (*h1)->priority - (*h2)->priority;
|
|
|
|
return (*h1)->seq - (*h2)->seq;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mp_hook_add(struct MPContext *mpctx, char *client, char *name,
|
|
|
|
int id, int pri)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
struct hook_handler *h = talloc_ptrtype(cmd, h);
|
|
|
|
int64_t seq = cmd->hook_seq++;
|
|
|
|
*h = (struct hook_handler){
|
|
|
|
.client = talloc_strdup(h, client),
|
|
|
|
.type = talloc_strdup(h, name),
|
|
|
|
.user_id = talloc_asprintf(h, "%d", id),
|
|
|
|
.priority = pri,
|
|
|
|
.seq = seq,
|
|
|
|
};
|
|
|
|
MP_TARRAY_APPEND(cmd, cmd->hooks, cmd->num_hooks, h);
|
|
|
|
qsort(cmd->hooks, cmd->num_hooks, sizeof(cmd->hooks[0]), compare_hook);
|
|
|
|
}
|
|
|
|
|
2013-12-01 01:07:32 +00:00
|
|
|
// Call before a seek, in order to allow revert_seek to undo the seek.
|
|
|
|
static void mark_seek(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
double now = mp_time_sec();
|
|
|
|
if (now > cmd->last_seek_time + 2.0 || cmd->last_seek_pts == MP_NOPTS_VALUE)
|
|
|
|
cmd->last_seek_pts = get_current_time(mpctx);
|
|
|
|
cmd->last_seek_time = now;
|
|
|
|
}
|
|
|
|
|
2014-05-05 21:52:50 +00:00
|
|
|
static char *format_file_size(int64_t size)
|
|
|
|
{
|
|
|
|
double s = size;
|
|
|
|
if (size < 1024)
|
|
|
|
return talloc_asprintf(NULL, "%.0f", s);
|
|
|
|
|
|
|
|
if (size < (1024 * 1024))
|
|
|
|
return talloc_asprintf(NULL, "%.3f Kb", s / (1024.0));
|
|
|
|
|
|
|
|
if (size < (1024 * 1024 * 1024))
|
|
|
|
return talloc_asprintf(NULL, "%.3f Mb", s / (1024.0 * 1024.0));
|
|
|
|
|
|
|
|
if (size < (1024LL * 1024LL * 1024LL * 1024LL))
|
|
|
|
return talloc_asprintf(NULL, "%.3f Gb", s / (1024.0 * 1024.0 * 1024.0));
|
|
|
|
|
|
|
|
return talloc_asprintf(NULL, "%.3f Tb", s / (1024.0 * 1024.0 * 1024.0 * 1024.0));
|
|
|
|
}
|
|
|
|
|
2012-09-18 13:31:46 +00:00
|
|
|
static char *format_delay(double time)
|
|
|
|
{
|
2015-12-26 17:36:45 +00:00
|
|
|
return talloc_asprintf(NULL, "%d ms", (int)lrint(time * 1000));
|
2012-09-18 13:31:46 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
// Property-option bridge. (Maps the property to the option with the same name.)
|
|
|
|
static int mp_property_generic_option(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2010-12-18 06:02:48 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
const char *optname = prop->name;
|
2012-09-18 18:07:24 +00:00
|
|
|
struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
|
|
|
|
bstr0(optname));
|
2014-09-21 14:00:03 +00:00
|
|
|
|
|
|
|
if (!opt)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
|
|
|
|
2012-09-18 18:07:24 +00:00
|
|
|
void *valptr = opt->data;
|
2010-12-18 06:02:48 +00:00
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
2012-09-21 12:05:52 +00:00
|
|
|
*(struct m_option *)arg = *(opt->opt);
|
2010-12-18 06:02:48 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET:
|
2012-09-18 18:07:24 +00:00
|
|
|
m_option_copy(opt->opt, arg, valptr);
|
2010-12-18 06:02:48 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_SET:
|
2012-09-18 18:07:24 +00:00
|
|
|
m_option_copy(opt->opt, valptr, arg);
|
2010-12-18 06:02:48 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Playback speed (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_playback_speed(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-10-02 00:49:05 +00:00
|
|
|
double speed = mpctx->opts->playback_speed;
|
2012-09-25 01:24:38 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET: {
|
2015-08-10 16:40:16 +00:00
|
|
|
mpctx->opts->playback_speed = *(double *)arg;
|
|
|
|
update_playback_speed(mpctx);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2012-09-25 01:24:38 +00:00
|
|
|
case M_PROPERTY_PRINT:
|
2014-10-02 00:49:05 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%.2f", speed);
|
2012-09-25 01:24:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 16:40:16 +00:00
|
|
|
static int mp_property_av_speed_correction(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
char *type = prop->priv;
|
2015-08-10 16:43:25 +00:00
|
|
|
double val = 0;
|
2015-08-10 16:40:16 +00:00
|
|
|
switch (type[0]) {
|
2015-08-10 16:43:25 +00:00
|
|
|
case 'a': val = mpctx->speed_factor_a; break;
|
|
|
|
case 'v': val = mpctx->speed_factor_v; break;
|
|
|
|
default: abort();
|
2015-08-10 16:40:16 +00:00
|
|
|
}
|
2015-08-10 16:43:25 +00:00
|
|
|
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%+.05f%%", (val - 1) * 100);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_property_double_ro(action, arg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_display_sync_active(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return m_property_flag_ro(action, arg, mpctx->display_sync_active);
|
2015-08-10 16:40:16 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// filename with path (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_path(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-10-13 15:09:35 +00:00
|
|
|
if (!mpctx->filename)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, mpctx->filename);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_filename(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-10-30 18:32:57 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-10-30 18:32:57 +00:00
|
|
|
if (!mpctx->filename)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-09-04 12:31:08 +00:00
|
|
|
char *filename = talloc_strdup(NULL, mpctx->filename);
|
|
|
|
if (mp_is_url(bstr0(filename)))
|
|
|
|
mp_url_unescape_inplace(filename);
|
|
|
|
char *f = (char *)mp_basename(filename);
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
int r = m_property_strdup_ro(action, arg, f[0] ? f : filename);
|
2013-09-04 12:31:08 +00:00
|
|
|
talloc_free(filename);
|
|
|
|
return r;
|
2012-10-30 18:32:57 +00:00
|
|
|
}
|
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
static int mp_property_stream_open_filename(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->stream_open_filename || !mpctx->playing)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
if (mpctx->stream)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
mpctx->stream_open_filename =
|
|
|
|
talloc_strdup(mpctx->stream_open_filename, *(char **)arg);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
return m_property_strdup_ro(action, arg, mpctx->stream_open_filename);
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_file_size(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-05-05 21:52:50 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
if (!mpctx->demuxer)
|
2014-05-05 21:52:50 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2014-05-24 12:04:09 +00:00
|
|
|
int64_t size;
|
2014-07-16 20:40:21 +00:00
|
|
|
if (demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_SIZE, &size) < 1)
|
2014-05-24 12:04:09 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-05-05 21:52:50 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2014-05-05 21:52:50 +00:00
|
|
|
*(char **)arg = format_file_size(size);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_int64_ro(action, arg, size);
|
2014-05-05 21:52:50 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_media_title(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-10-13 15:09:35 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-10-30 18:32:57 +00:00
|
|
|
char *name = NULL;
|
2014-09-02 20:28:11 +00:00
|
|
|
if (mpctx->opts->media_title)
|
|
|
|
name = mpctx->opts->media_title;
|
|
|
|
if (name && name[0])
|
|
|
|
return m_property_strdup_ro(action, arg, name);
|
2013-05-15 13:06:21 +00:00
|
|
|
if (mpctx->master_demuxer) {
|
2014-09-01 20:12:39 +00:00
|
|
|
name = mp_tags_get_str(mpctx->master_demuxer->metadata, "title");
|
2013-05-15 13:06:21 +00:00
|
|
|
if (name && name[0])
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, name);
|
2014-10-27 13:59:07 +00:00
|
|
|
name = mp_tags_get_str(mpctx->master_demuxer->metadata, "icy-title");
|
|
|
|
if (name && name[0])
|
|
|
|
return m_property_strdup_ro(action, arg, name);
|
2012-10-30 18:32:57 +00:00
|
|
|
}
|
2015-07-10 19:22:35 +00:00
|
|
|
if (mpctx->playing && mpctx->playing->title)
|
|
|
|
return m_property_strdup_ro(action, arg, mpctx->playing->title);
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_filename(ctx, prop, action, arg);
|
2012-10-13 15:09:35 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_stream_path(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-10-13 15:09:35 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
// demuxer->stream as well as stream->url are immutable -> ok to access
|
|
|
|
struct stream *stream = mpctx->demuxer ? mpctx->demuxer->stream : NULL;
|
2012-10-13 15:09:35 +00:00
|
|
|
if (!stream || !stream->url)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, stream->url);
|
2012-10-13 15:09:35 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_stream_capture(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-05-11 20:19:33 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
if (!mpctx->demuxer)
|
2013-05-11 20:19:33 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
if (action == M_PROPERTY_SET) {
|
|
|
|
char *filename = *(char **)arg;
|
2014-07-16 20:40:21 +00:00
|
|
|
demux_pause(mpctx->demuxer);
|
|
|
|
stream_set_capture_file(mpctx->demuxer->stream, filename);
|
|
|
|
demux_unpause(mpctx->demuxer);
|
2013-05-11 20:19:33 +00:00
|
|
|
// fall through to mp_property_generic_option
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2013-05-11 20:19:33 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Demuxer name (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_demuxer(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-08-19 16:07:06 +00:00
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, demuxer->desc->name);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2015-01-23 14:59:06 +00:00
|
|
|
static int mp_property_file_format(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
const char *name = demuxer->filetype ? demuxer->filetype : demuxer->desc->name;
|
|
|
|
return m_property_strdup_ro(action, arg, name);
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Position in the stream (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_stream_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
|
|
|
if (!demuxer)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-07-16 20:40:21 +00:00
|
|
|
demux_pause(demuxer);
|
|
|
|
int r;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2014-07-16 20:40:21 +00:00
|
|
|
stream_seek(demuxer->stream, *(int64_t *) arg);
|
|
|
|
r = M_PROPERTY_OK;
|
|
|
|
} else {
|
|
|
|
r = m_property_int64_ro(action, arg, stream_tell(demuxer->stream));
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2014-07-16 20:40:21 +00:00
|
|
|
demux_unpause(demuxer);
|
|
|
|
return r;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Stream end offset (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_stream_end(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_file_size(ctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2013-07-25 22:18:05 +00:00
|
|
|
// Does some magic to handle "<name>/full" as time formatted with milliseconds.
|
|
|
|
// Assumes prop is the type of the actual property.
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_time(int action, void *arg, double time)
|
2013-07-25 22:18:05 +00:00
|
|
|
{
|
2015-10-16 14:16:10 +00:00
|
|
|
if (time == MP_NOPTS_VALUE)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
const struct m_option time_type = {.type = CONF_TYPE_TIME};
|
2013-07-25 22:18:05 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(double *)arg = time;
|
|
|
|
return M_PROPERTY_OK;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = time_type;
|
|
|
|
return M_PROPERTY_OK;
|
2013-07-25 22:18:05 +00:00
|
|
|
case M_PROPERTY_KEY_ACTION: {
|
|
|
|
struct m_property_action_arg *ka = arg;
|
|
|
|
|
|
|
|
if (strcmp(ka->key, "full") != 0)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
|
|
|
|
|
|
|
switch (ka->action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(double *)ka->arg = time;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_PRINT:
|
|
|
|
*(char **)ka->arg = mp_format_time(time, true);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
*(struct m_option *)ka->arg = time_type;
|
2013-07-25 22:18:05 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-05-22 18:02:47 +00:00
|
|
|
static int mp_property_duration(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-10-29 20:54:59 +00:00
|
|
|
double len = get_time_length(mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2014-10-29 20:54:59 +00:00
|
|
|
if (len < 0)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_time(action, arg, len);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_avsync(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-11-16 19:10:05 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-11-23 20:36:20 +00:00
|
|
|
if (!mpctx->d_audio || !mpctx->d_video)
|
2012-11-16 19:10:05 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-12-16 04:07:38 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%7.3f", mpctx->last_av_difference);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_double_ro(action, arg, mpctx->last_av_difference);
|
2012-11-16 19:10:05 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_total_avsync_change(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-12 18:26:28 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-04-12 18:26:28 +00:00
|
|
|
if (!mpctx->d_audio || !mpctx->d_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (mpctx->total_avsync_change == MP_NOPTS_VALUE)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_double_ro(action, arg, mpctx->total_avsync_change);
|
2014-04-12 18:26:28 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_drop_frame_cnt(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-12 18:26:28 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-04-12 18:26:28 +00:00
|
|
|
if (!mpctx->d_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2014-11-01 00:07:21 +00:00
|
|
|
return m_property_int_ro(action, arg, mpctx->dropped_frames_total);
|
2014-04-12 18:26:28 +00:00
|
|
|
}
|
|
|
|
|
2015-10-30 13:05:41 +00:00
|
|
|
static int mp_property_mistimed_frame_count(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-11-13 21:48:32 +00:00
|
|
|
if (!mpctx->d_video || !mpctx->display_sync_active)
|
2015-10-30 13:05:41 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_int_ro(action, arg, mpctx->mistimed_frames_total);
|
|
|
|
}
|
|
|
|
|
2015-11-13 21:48:32 +00:00
|
|
|
static int mp_property_vsync_ratio(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->d_video || !mpctx->display_sync_active)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
int vsyncs = 0, frames = 0;
|
|
|
|
for (int n = 0; n < mpctx->num_past_frames; n++) {
|
|
|
|
int vsync = mpctx->past_frames[n].num_vsyncs;
|
|
|
|
if (vsync < 0)
|
|
|
|
break;
|
|
|
|
vsyncs += vsync;
|
|
|
|
frames += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!frames)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_double_ro(action, arg, vsyncs / (double)frames);
|
|
|
|
}
|
|
|
|
|
video: add VO framedropping mode
This mostly uses the same idea as with vo_vdpau.c, but much simplified.
On X11, it tries to get the display framerate with XF86VM, and limits
the frequency of new video frames against it. Note that this is an old
extension, and is confirmed not to work correctly with multi-monitor
setups. But we're using it because it was already around (it is also
used by vo_vdpau).
This attempts to predict the next vsync event by using the time of the
last frame and the display FPS. Even if that goes completely wrong,
the results are still relatively good.
On other systems, or if the X11 code doesn't return a display FPS, a
framerate of 1000 is assumed. This is infinite for all practical
purposes, and means that only frames which are definitely too late are
dropped. This probably has worse results, but is still useful.
"--framedrop=yes" is basically replaced with "--framedrop=decoder". The
old framedropping mode is kept around, and should perhaps be improved.
Dropping on the decoder level is still useful if decoding itself is too
slow.
2014-08-15 21:33:33 +00:00
|
|
|
static int mp_property_vo_drop_frame_count(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->d_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_int_ro(action, arg, vo_get_drop_count(mpctx->video_out));
|
|
|
|
}
|
|
|
|
|
2015-11-13 21:41:41 +00:00
|
|
|
static int mp_property_vo_delayed_frame_count(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2015-08-10 16:43:25 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->d_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2015-11-13 21:41:41 +00:00
|
|
|
return m_property_int_ro(action, arg, vo_get_delayed_count(mpctx->video_out));
|
2015-08-10 16:43:25 +00:00
|
|
|
}
|
|
|
|
|
2007-05-31 13:07:52 +00:00
|
|
|
/// Current position in percent (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_percent_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2011-08-07 01:45:40 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-05-31 13:07:52 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
switch (action) {
|
2014-01-15 21:24:56 +00:00
|
|
|
case M_PROPERTY_SET: {
|
2013-06-28 20:28:21 +00:00
|
|
|
double pos = *(double *)arg;
|
2015-03-04 16:21:05 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, MPSEEK_DEFAULT, true);
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2014-01-15 21:24:56 +00:00
|
|
|
}
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
double pos = get_current_pos_ratio(mpctx, false) * 100.0;
|
|
|
|
if (pos < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
*(double *)arg = pos;
|
2013-06-28 20:28:21 +00:00
|
|
|
return M_PROPERTY_OK;
|
2014-01-15 21:24:56 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_DOUBLE,
|
|
|
|
.flags = M_OPT_RANGE,
|
|
|
|
.min = 0,
|
|
|
|
.max = 100,
|
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2014-12-20 16:31:58 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
int pos = get_percent_pos(mpctx);
|
|
|
|
if (pos < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d", pos);
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-05-31 13:07:52 +00:00
|
|
|
}
|
2014-12-20 16:31:58 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-05-31 13:07:52 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_time_start(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-02-28 14:04:10 +00:00
|
|
|
{
|
2015-11-16 21:47:17 +00:00
|
|
|
// minor backwards-compat.
|
|
|
|
return property_time(action, arg, 0);
|
2014-02-28 14:04:10 +00:00
|
|
|
}
|
|
|
|
|
2007-05-31 13:07:52 +00:00
|
|
|
/// Current position in seconds (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_time_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2011-08-07 01:45:40 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2007-05-31 13:07:52 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2013-07-25 22:18:05 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2015-03-04 16:21:05 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, MPSEEK_DEFAULT, true);
|
2007-05-31 13:07:52 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_time(action, arg, get_current_time(mpctx));
|
2007-05-31 13:07:52 +00:00
|
|
|
}
|
|
|
|
|
2013-12-16 19:12:53 +00:00
|
|
|
static bool time_remaining(MPContext *mpctx, double *remaining)
|
2013-05-10 13:20:40 +00:00
|
|
|
{
|
2013-12-16 19:12:53 +00:00
|
|
|
double len = get_time_length(mpctx);
|
2014-06-29 17:27:46 +00:00
|
|
|
double playback = get_playback_time(mpctx);
|
2013-05-10 13:20:40 +00:00
|
|
|
|
2015-10-16 14:16:10 +00:00
|
|
|
if (playback == MP_NOPTS_VALUE)
|
|
|
|
return false;
|
|
|
|
|
2014-06-29 17:27:46 +00:00
|
|
|
*remaining = len - playback;
|
2013-12-16 19:12:53 +00:00
|
|
|
|
2014-10-29 20:54:59 +00:00
|
|
|
return len >= 0;
|
2013-12-16 14:55:36 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_remaining(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-12-16 14:55:36 +00:00
|
|
|
{
|
2013-12-16 19:12:53 +00:00
|
|
|
double remaining;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
if (!time_remaining(ctx, &remaining))
|
2013-12-16 14:55:36 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_time(action, arg, remaining);
|
2013-12-16 14:55:36 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_playtime_remaining(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-12-16 14:55:36 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-12-16 19:12:53 +00:00
|
|
|
double remaining;
|
|
|
|
if (!time_remaining(mpctx, &remaining))
|
2013-05-10 13:20:40 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2015-08-10 16:40:16 +00:00
|
|
|
double speed = mpctx->video_speed;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_time(action, arg, remaining / speed);
|
2013-05-10 13:20:40 +00:00
|
|
|
}
|
|
|
|
|
2014-06-29 17:27:46 +00:00
|
|
|
static int mp_property_playback_time(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-06-29 17:27:46 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2015-08-21 13:51:50 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2015-11-16 21:47:17 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, MPSEEK_DEFAULT, true);
|
2015-08-21 13:51:50 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2014-06-29 17:27:46 +00:00
|
|
|
return property_time(action, arg, get_playback_time(mpctx));
|
|
|
|
}
|
|
|
|
|
2014-07-14 23:49:02 +00:00
|
|
|
/// Current BD/DVD title (RW)
|
|
|
|
static int mp_property_disc_title(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
struct demuxer *d = mpctx->master_demuxer;
|
|
|
|
if (!d)
|
2014-07-14 23:49:02 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
unsigned int title = -1;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2014-07-16 20:40:21 +00:00
|
|
|
if (demux_stream_control(d, STREAM_CTRL_GET_CURRENT_TITLE, &title) < 0)
|
2014-07-14 23:49:02 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
*(int*)arg = title;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.flags = M_OPT_MIN,
|
|
|
|
.min = -1,
|
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
title = *(int*)arg;
|
2014-07-16 20:40:21 +00:00
|
|
|
if (demux_stream_control(d, STREAM_CTRL_SET_CURRENT_TITLE, &title) < 0)
|
2014-07-14 23:49:02 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2015-07-08 19:31:31 +00:00
|
|
|
if (!mpctx->stop_play)
|
|
|
|
mpctx->stop_play = PT_RELOAD_FILE;
|
2014-07-14 23:49:02 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2007-12-14 08:33:11 +00:00
|
|
|
/// Current chapter (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_chapter(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-12-14 08:33:11 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-08-19 16:07:06 +00:00
|
|
|
int chapter = get_current_chapter(mpctx);
|
2015-01-05 05:34:25 +00:00
|
|
|
int num = get_chapter_count(mpctx);
|
2010-04-24 17:46:54 +00:00
|
|
|
if (chapter < -1)
|
2007-12-22 06:20:48 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2007-12-14 08:33:11 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2007-12-17 03:42:54 +00:00
|
|
|
*(int *) arg = chapter;
|
2007-12-14 08:33:11 +00:00
|
|
|
return M_PROPERTY_OK;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.flags = M_OPT_MIN | M_OPT_MAX,
|
|
|
|
.min = -1,
|
2015-01-05 05:34:25 +00:00
|
|
|
.max = num - 1,
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2007-12-14 08:33:11 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
2013-09-07 17:59:39 +00:00
|
|
|
*(char **) arg = chapter_display_name(mpctx, chapter);
|
2007-12-14 08:33:11 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2013-08-14 01:25:50 +00:00
|
|
|
case M_PROPERTY_SWITCH:
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_SET: ;
|
2013-12-01 01:07:32 +00:00
|
|
|
mark_seek(mpctx);
|
2013-08-14 01:25:50 +00:00
|
|
|
int step_all;
|
|
|
|
if (action == M_PROPERTY_SWITCH) {
|
|
|
|
struct m_property_switch_arg *sarg = arg;
|
2015-12-26 17:36:45 +00:00
|
|
|
step_all = lrint(sarg->inc);
|
2013-08-14 01:25:50 +00:00
|
|
|
// Check threshold for relative backward seeks
|
|
|
|
if (mpctx->opts->chapter_seek_threshold >= 0 && step_all < 0) {
|
|
|
|
double current_chapter_start =
|
|
|
|
chapter_start_time(mpctx, chapter);
|
|
|
|
// If we are far enough into a chapter, seek back to the
|
|
|
|
// beginning of current chapter instead of previous one
|
2014-03-25 01:18:12 +00:00
|
|
|
if (current_chapter_start != MP_NOPTS_VALUE &&
|
2013-08-14 01:25:50 +00:00
|
|
|
get_current_time(mpctx) - current_chapter_start >
|
|
|
|
mpctx->opts->chapter_seek_threshold)
|
|
|
|
step_all++;
|
|
|
|
}
|
|
|
|
} else // Absolute set
|
|
|
|
step_all = *(int *)arg - chapter;
|
2007-12-14 08:33:11 +00:00
|
|
|
chapter += step_all;
|
2013-08-14 01:25:50 +00:00
|
|
|
if (chapter < -1)
|
|
|
|
chapter = -1;
|
2015-01-05 05:34:25 +00:00
|
|
|
if (chapter >= num && step_all > 0) {
|
2014-12-08 16:27:07 +00:00
|
|
|
if (mpctx->opts->keep_open) {
|
|
|
|
seek_to_last_frame(mpctx);
|
|
|
|
} else {
|
2015-12-25 12:58:50 +00:00
|
|
|
// semi-broken file; ignore for user convenience
|
|
|
|
if (action == M_PROPERTY_SWITCH && num < 2)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2015-07-08 19:31:31 +00:00
|
|
|
if (!mpctx->stop_play)
|
|
|
|
mpctx->stop_play = PT_NEXT_ENTRY;
|
2014-12-08 16:27:07 +00:00
|
|
|
}
|
2013-05-03 22:36:53 +00:00
|
|
|
} else {
|
2015-07-10 10:11:14 +00:00
|
|
|
double pts = chapter_start_time(mpctx, chapter);
|
|
|
|
if (pts != MP_NOPTS_VALUE) {
|
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, pts, MPSEEK_DEFAULT, true);
|
|
|
|
mpctx->last_chapter_seek = chapter;
|
|
|
|
mpctx->last_chapter_pts = pts;
|
|
|
|
}
|
2013-05-03 22:36:53 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-12-14 08:33:11 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-12-14 08:33:11 +00:00
|
|
|
}
|
|
|
|
|
2014-02-15 15:55:40 +00:00
|
|
|
static int get_chapter_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
char *name = chapter_name(mpctx, item);
|
|
|
|
double time = chapter_start_time(mpctx, item);
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"title", SUB_PROP_STR(name)},
|
2014-11-13 16:25:59 +00:00
|
|
|
{"time", {.type = CONF_TYPE_TIME}, {.time = time}},
|
2014-02-15 15:55:40 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
int r = m_property_read_sub(props, action, arg);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_list_chapters(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-05-15 00:17:47 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-15 15:55:40 +00:00
|
|
|
int count = get_chapter_count(mpctx);
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2015-05-26 19:42:34 +00:00
|
|
|
int cur = mpctx->playback_initialized ? get_current_chapter(mpctx) : -1;
|
2013-05-15 00:17:47 +00:00
|
|
|
char *res = NULL;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if (count < 1) {
|
|
|
|
res = talloc_asprintf_append(res, "No chapters.");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = 0; n < count; n++) {
|
|
|
|
char *name = chapter_display_name(mpctx, n);
|
|
|
|
double t = chapter_start_time(mpctx, n);
|
|
|
|
char* time = mp_format_time(t, false);
|
|
|
|
res = talloc_asprintf_append(res, "%s", time);
|
|
|
|
talloc_free(time);
|
|
|
|
char *m1 = "> ", *m2 = " <";
|
|
|
|
if (n != cur)
|
|
|
|
m1 = m2 = "";
|
|
|
|
res = talloc_asprintf_append(res, " %s%s%s\n", m1, name, m2);
|
|
|
|
talloc_free(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2014-02-15 15:55:40 +00:00
|
|
|
return m_property_read_list(action, arg, count, get_chapter_entry, mpctx);
|
2013-05-15 00:17:47 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_edition(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-08-25 23:19:42 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2012-08-25 23:19:42 +00:00
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (demuxer->num_editions <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
int edition = demuxer->edition;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2012-09-18 18:07:24 +00:00
|
|
|
*(int *)arg = edition;
|
|
|
|
return M_PROPERTY_OK;
|
2012-09-21 12:22:23 +00:00
|
|
|
case M_PROPERTY_SET: {
|
2012-08-25 23:19:42 +00:00
|
|
|
edition = *(int *)arg;
|
2012-09-21 12:22:23 +00:00
|
|
|
if (edition != demuxer->edition) {
|
|
|
|
opts->edition_id = edition;
|
2015-07-08 19:31:31 +00:00
|
|
|
if (!mpctx->stop_play)
|
|
|
|
mpctx->stop_play = PT_RELOAD_FILE;
|
2012-09-21 12:22:23 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_OK;
|
2012-08-25 23:19:42 +00:00
|
|
|
}
|
2012-09-21 12:22:23 +00:00
|
|
|
case M_PROPERTY_GET_TYPE: {
|
|
|
|
struct m_option opt = {
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.flags = CONF_RANGE,
|
|
|
|
.min = 0,
|
|
|
|
.max = demuxer->num_editions - 1,
|
|
|
|
};
|
|
|
|
*(struct m_option *)arg = opt;
|
|
|
|
return M_PROPERTY_OK;
|
2012-08-25 23:19:42 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-21 12:22:23 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2012-08-25 23:19:42 +00:00
|
|
|
}
|
|
|
|
|
2014-02-18 23:41:12 +00:00
|
|
|
static int get_edition_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
struct demux_edition *ed = &demuxer->editions[item];
|
|
|
|
|
|
|
|
char *title = mp_tags_get_str(ed->metadata, "title");
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"id", SUB_PROP_INT(item)},
|
|
|
|
{"title", SUB_PROP_STR(title),
|
|
|
|
.unavailable = !title},
|
|
|
|
{"default", SUB_PROP_FLAG(ed->default_edition)},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_list_editions(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-02-18 23:41:12 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-18 23:41:12 +00:00
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
char *res = NULL;
|
|
|
|
|
|
|
|
struct demux_edition *editions = demuxer->editions;
|
|
|
|
int num_editions = demuxer->num_editions;
|
|
|
|
int current = demuxer->edition;
|
|
|
|
|
|
|
|
if (!num_editions)
|
|
|
|
res = talloc_asprintf_append(res, "No editions.");
|
|
|
|
|
|
|
|
for (int n = 0; n < num_editions; n++) {
|
|
|
|
struct demux_edition *ed = &editions[n];
|
|
|
|
|
|
|
|
if (n == current)
|
|
|
|
res = talloc_asprintf_append(res, "> ");
|
|
|
|
res = talloc_asprintf_append(res, "%d: ", n);
|
|
|
|
char *title = mp_tags_get_str(ed->metadata, "title");
|
|
|
|
if (!title)
|
|
|
|
title = "unnamed";
|
|
|
|
res = talloc_asprintf_append(res, "'%s' ", title);
|
|
|
|
if (n == current)
|
|
|
|
res = talloc_asprintf_append(res, "<");
|
|
|
|
res = talloc_asprintf_append(res, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return m_property_read_list(action, arg, demuxer->num_editions,
|
|
|
|
get_edition_entry, mpctx);
|
|
|
|
}
|
|
|
|
|
2014-07-14 23:49:02 +00:00
|
|
|
/// Number of titles in BD/DVD
|
|
|
|
static int mp_property_disc_titles(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
unsigned int num_titles;
|
2014-07-16 20:40:21 +00:00
|
|
|
if (!demuxer || demux_stream_control(demuxer, STREAM_CTRL_GET_NUM_TITLES,
|
|
|
|
&num_titles) < 1)
|
2014-07-14 23:49:02 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_int_ro(action, arg, num_titles);
|
|
|
|
}
|
|
|
|
|
2014-12-13 19:25:31 +00:00
|
|
|
static int get_disc_title_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
|
|
|
|
double len = item;
|
|
|
|
if (demux_stream_control(demuxer, STREAM_CTRL_GET_TITLE_LENGTH, &len) < 1)
|
|
|
|
len = -1;
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"id", SUB_PROP_INT(item)},
|
|
|
|
{"length", {.type = CONF_TYPE_TIME}, {.time = len},
|
|
|
|
.unavailable = len < 0},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_list_disc_titles(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
unsigned int num_titles;
|
|
|
|
if (!demuxer || demux_stream_control(demuxer, STREAM_CTRL_GET_NUM_TITLES,
|
|
|
|
&num_titles) < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_read_list(action, arg, num_titles,
|
|
|
|
get_disc_title_entry, mpctx);
|
|
|
|
}
|
|
|
|
|
2008-09-26 21:17:01 +00:00
|
|
|
/// Number of chapters in file
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_chapters(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2008-09-26 21:17:01 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2008-09-26 21:17:01 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2011-10-23 02:51:44 +00:00
|
|
|
int count = get_chapter_count(mpctx);
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_int_ro(action, arg, count);
|
2008-09-26 21:17:01 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_editions(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-08-25 23:19:42 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-08-25 23:19:42 +00:00
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (demuxer->num_editions <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_int_ro(action, arg, demuxer->num_editions);
|
2012-08-25 23:19:42 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 23:49:02 +00:00
|
|
|
/// Current dvd angle (RW)
|
|
|
|
static int mp_property_angle(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
int ris, angles = -1, angle = 1;
|
|
|
|
|
2014-07-16 20:40:21 +00:00
|
|
|
ris = demux_stream_control(demuxer, STREAM_CTRL_GET_NUM_ANGLES, &angles);
|
2014-07-14 23:49:02 +00:00
|
|
|
if (ris == STREAM_UNSUPPORTED)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2014-07-16 20:40:21 +00:00
|
|
|
ris = demux_stream_control(demuxer, STREAM_CTRL_GET_ANGLE, &angle);
|
2014-07-14 23:49:02 +00:00
|
|
|
if (ris == STREAM_UNSUPPORTED)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (angle < 0 || angles <= 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(int *) arg = angle;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
*(char **) arg = talloc_asprintf(NULL, "%d/%d", angle, angles);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
angle = *(int *)arg;
|
|
|
|
if (angle < 0 || angle > angles)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
|
2014-07-20 12:13:24 +00:00
|
|
|
demux_pause(demuxer);
|
|
|
|
demux_flush(demuxer);
|
2014-07-16 20:40:21 +00:00
|
|
|
ris = demux_stream_control(demuxer, STREAM_CTRL_SET_ANGLE, &angle);
|
2014-07-14 23:49:02 +00:00
|
|
|
demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL);
|
2014-07-20 12:13:24 +00:00
|
|
|
demux_unpause(demuxer);
|
2014-07-14 23:49:02 +00:00
|
|
|
|
2014-11-20 21:45:02 +00:00
|
|
|
reset_audio_state(mpctx);
|
|
|
|
reset_video_state(mpctx);
|
2014-07-14 23:49:02 +00:00
|
|
|
|
2014-07-20 12:13:24 +00:00
|
|
|
return ris == STREAM_OK ? M_PROPERTY_OK : M_PROPERTY_ERROR;
|
2014-07-14 23:49:02 +00:00
|
|
|
case M_PROPERTY_GET_TYPE: {
|
|
|
|
struct m_option opt = {
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.flags = CONF_RANGE,
|
|
|
|
.min = 1,
|
|
|
|
.max = angles,
|
|
|
|
};
|
|
|
|
*(struct m_option *)arg = opt;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-02-19 15:29:04 +00:00
|
|
|
static int get_tag_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct mp_tags *tags = ctx;
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"key", SUB_PROP_STR(tags->keys[item])},
|
|
|
|
{"value", SUB_PROP_STR(tags->values[item])},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int tag_property(int action, void *arg, struct mp_tags *tags)
|
2011-08-07 01:45:40 +00:00
|
|
|
{
|
|
|
|
switch (action) {
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_GET: {
|
2014-03-30 17:09:31 +00:00
|
|
|
mpv_node_list *list = talloc_zero(NULL, mpv_node_list);
|
|
|
|
mpv_node node = {
|
|
|
|
.format = MPV_FORMAT_NODE_MAP,
|
|
|
|
.u.list = list,
|
|
|
|
};
|
|
|
|
list->num = tags->num_keys;
|
|
|
|
list->values = talloc_array(list, mpv_node, list->num);
|
|
|
|
list->keys = talloc_array(list, char*, list->num);
|
2013-09-08 04:32:48 +00:00
|
|
|
for (int n = 0; n < tags->num_keys; n++) {
|
2014-03-30 17:09:31 +00:00
|
|
|
list->keys[n] = talloc_strdup(list, tags->keys[n]);
|
|
|
|
list->values[n] = (struct mpv_node){
|
|
|
|
.format = MPV_FORMAT_STRING,
|
|
|
|
.u.string = talloc_strdup(list, tags->values[n]),
|
|
|
|
};
|
2013-09-08 04:32:48 +00:00
|
|
|
}
|
2014-03-30 17:09:31 +00:00
|
|
|
*(mpv_node*)arg = node;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET_TYPE: {
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE};
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 18:07:24 +00:00
|
|
|
}
|
2013-06-07 15:31:30 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
char *res = NULL;
|
2013-09-08 04:32:48 +00:00
|
|
|
for (int n = 0; n < tags->num_keys; n++) {
|
2013-06-07 15:31:30 +00:00
|
|
|
res = talloc_asprintf_append_buffer(res, "%s: %s\n",
|
2013-09-08 04:32:48 +00:00
|
|
|
tags->keys[n], tags->values[n]);
|
2013-06-07 15:31:30 +00:00
|
|
|
}
|
2014-12-30 13:04:53 +00:00
|
|
|
if (!res)
|
|
|
|
res = talloc_strdup(NULL, "(empty)");
|
2013-06-07 15:31:30 +00:00
|
|
|
*(char **)arg = res;
|
2014-12-30 13:04:53 +00:00
|
|
|
return M_PROPERTY_OK;
|
2013-06-07 15:31:30 +00:00
|
|
|
}
|
2012-09-21 10:19:59 +00:00
|
|
|
case M_PROPERTY_KEY_ACTION: {
|
2012-09-22 04:15:36 +00:00
|
|
|
struct m_property_action_arg *ka = arg;
|
2014-03-30 11:41:03 +00:00
|
|
|
bstr key;
|
|
|
|
char *rem;
|
|
|
|
m_property_split_path(ka->key, &key, &rem);
|
|
|
|
if (bstr_equals0(key, "list")) {
|
2014-02-19 15:29:04 +00:00
|
|
|
struct m_property_action_arg nka = *ka;
|
2014-03-30 11:41:03 +00:00
|
|
|
nka.key = rem;
|
2014-02-19 15:29:04 +00:00
|
|
|
return m_property_read_list(action, &nka, tags->num_keys,
|
|
|
|
get_tag_entry, tags);
|
|
|
|
}
|
2014-02-19 15:16:42 +00:00
|
|
|
// Direct access without this prefix is allowed for compatibility.
|
2014-03-30 11:41:03 +00:00
|
|
|
bstr k = bstr0(ka->key);
|
|
|
|
bstr_eatstart0(&k, "by-key/");
|
|
|
|
char *meta = mp_tags_get_bstr(tags, k);
|
2012-09-21 10:19:59 +00:00
|
|
|
if (!meta)
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_UNKNOWN;
|
2011-08-07 01:45:40 +00:00
|
|
|
switch (ka->action) {
|
2007-05-29 22:14:41 +00:00
|
|
|
case M_PROPERTY_GET:
|
2012-09-18 18:07:24 +00:00
|
|
|
*(char **)ka->arg = talloc_strdup(NULL, meta);
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
2014-03-30 16:50:35 +00:00
|
|
|
*(struct m_option *)ka->arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_STRING,
|
|
|
|
};
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
2012-09-21 10:19:59 +00:00
|
|
|
}
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-09-08 04:32:48 +00:00
|
|
|
/// Demuxer meta data
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_metadata(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-08 04:32:48 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-09-08 04:32:48 +00:00
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return tag_property(action, arg, demuxer->metadata);
|
2013-09-08 04:32:48 +00:00
|
|
|
}
|
|
|
|
|
2014-12-29 22:03:39 +00:00
|
|
|
static int mp_property_filtered_metadata(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->filtered_tags)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return tag_property(action, arg, mpctx->filtered_tags);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_chapter_metadata(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-08 05:42:05 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-09-08 05:42:05 +00:00
|
|
|
int chapter = get_current_chapter(mpctx);
|
2015-08-12 09:10:45 +00:00
|
|
|
if (chapter < 0)
|
2014-11-02 16:20:04 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return tag_property(action, arg, mpctx->chapters[chapter].metadata);
|
2013-09-08 05:42:05 +00:00
|
|
|
}
|
|
|
|
|
2015-09-11 21:04:02 +00:00
|
|
|
static int mp_property_filter_metadata(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-13 14:08:58 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-09-11 21:04:02 +00:00
|
|
|
const char *type = prop->priv;
|
2014-04-13 14:08:58 +00:00
|
|
|
|
2014-12-30 13:04:53 +00:00
|
|
|
if (action == M_PROPERTY_KEY_ACTION) {
|
2014-04-13 14:08:58 +00:00
|
|
|
struct m_property_action_arg *ka = arg;
|
|
|
|
bstr key;
|
|
|
|
char *rem;
|
|
|
|
m_property_split_path(ka->key, &key, &rem);
|
2015-09-11 21:04:02 +00:00
|
|
|
struct mp_tags metadata = {0};
|
|
|
|
int res = CONTROL_UNKNOWN;
|
|
|
|
if (strcmp(type, "vf") == 0) {
|
|
|
|
if (!(mpctx->d_video && mpctx->d_video->vfilter))
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
struct vf_chain *vf = mpctx->d_video->vfilter;
|
|
|
|
res = vf_control_by_label(vf, VFCTRL_GET_METADATA, &metadata, key);
|
|
|
|
} else if (strcmp(type, "af") == 0) {
|
|
|
|
if (!(mpctx->d_audio && mpctx->d_audio->afilter))
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
struct af_stream *af = mpctx->d_audio->afilter;
|
|
|
|
res = af_control_by_label(af, AF_CONTROL_GET_METADATA, &metadata, key);
|
|
|
|
}
|
|
|
|
switch (res) {
|
2014-04-29 15:00:52 +00:00
|
|
|
case CONTROL_UNKNOWN:
|
2014-04-13 14:08:58 +00:00
|
|
|
return M_PROPERTY_UNKNOWN;
|
2014-12-30 13:04:53 +00:00
|
|
|
case CONTROL_NA: // empty
|
2014-04-29 15:00:52 +00:00
|
|
|
case CONTROL_OK:
|
|
|
|
if (strlen(rem)) {
|
|
|
|
struct m_property_action_arg next_ka = *ka;
|
|
|
|
next_ka.key = rem;
|
2015-09-11 21:04:02 +00:00
|
|
|
return tag_property(M_PROPERTY_KEY_ACTION, &next_ka, &metadata);
|
2014-04-29 15:00:52 +00:00
|
|
|
} else {
|
2015-09-11 21:04:02 +00:00
|
|
|
return tag_property(ka->action, ka->arg, &metadata);
|
2014-04-29 15:00:52 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
default:
|
|
|
|
return M_PROPERTY_ERROR;
|
2014-04-13 14:08:58 +00:00
|
|
|
}
|
|
|
|
}
|
2014-04-14 00:45:45 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2014-04-13 14:08:58 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_pause(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2008-10-01 17:05:30 +00:00
|
|
|
{
|
2008-11-29 06:09:57 +00:00
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
|
2013-04-25 18:38:22 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2012-09-18 12:00:08 +00:00
|
|
|
if (*(int *)arg) {
|
2014-04-14 20:33:41 +00:00
|
|
|
pause_player(mpctx);
|
2012-09-18 12:00:08 +00:00
|
|
|
} else {
|
2014-04-14 20:33:41 +00:00
|
|
|
unpause_player(mpctx);
|
2008-12-01 17:53:57 +00:00
|
|
|
}
|
2010-05-07 19:02:47 +00:00
|
|
|
return M_PROPERTY_OK;
|
2008-11-29 06:09:57 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2008-10-01 17:05:30 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_core_idle(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-14 20:03:43 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2014-10-07 19:01:19 +00:00
|
|
|
bool idle = mpctx->paused || !mpctx->restart_complete || !mpctx->playing;
|
|
|
|
return m_property_flag_ro(action, arg, idle);
|
2014-04-14 20:03:43 +00:00
|
|
|
}
|
|
|
|
|
2014-12-10 13:42:57 +00:00
|
|
|
static int mp_property_idle(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
return m_property_flag_ro(action, arg, cmd->is_idle);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_eof_reached(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-14 20:19:07 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-07-29 22:22:25 +00:00
|
|
|
bool eof = mpctx->video_status == STATUS_EOF &&
|
|
|
|
mpctx->audio_status == STATUS_EOF;
|
|
|
|
return m_property_flag_ro(action, arg, eof);
|
2014-04-14 20:19:07 +00:00
|
|
|
}
|
|
|
|
|
2014-08-07 22:13:27 +00:00
|
|
|
static int mp_property_seeking(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-08-07 22:13:27 +00:00
|
|
|
return m_property_flag_ro(action, arg, !mpctx->restart_complete);
|
|
|
|
}
|
|
|
|
|
2014-10-21 11:32:30 +00:00
|
|
|
static int mp_property_playback_abort(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return m_property_flag_ro(action, arg, !mpctx->playing || mpctx->stop_play);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_cache(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-02-17 19:24:59 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2014-07-01 22:14:30 +00:00
|
|
|
float cache = mp_get_cache_percent(mpctx);
|
2013-02-17 19:24:59 +00:00
|
|
|
if (cache < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-07-01 22:14:30 +00:00
|
|
|
|
2014-08-11 11:30:08 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2014-08-17 23:42:43 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d", (int)cache);
|
2014-08-11 11:30:08 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-01 22:14:30 +00:00
|
|
|
return m_property_float_ro(action, arg, cache);
|
2013-02-17 19:24:59 +00:00
|
|
|
}
|
2007-05-29 22:14:41 +00:00
|
|
|
|
2014-07-01 23:46:04 +00:00
|
|
|
static int property_int_kb_size(int kb_size, int action, void *arg)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(int *)arg = kb_size;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_PRINT:
|
|
|
|
*(char **)arg = format_file_size(kb_size * 1024LL);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_INT};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_cache_size(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-09 17:15:23 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
|
|
|
if (!demuxer)
|
2014-04-09 17:15:23 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
switch (action) {
|
2014-07-01 23:46:04 +00:00
|
|
|
case M_PROPERTY_GET:
|
|
|
|
case M_PROPERTY_PRINT: {
|
2014-04-09 17:15:23 +00:00
|
|
|
int64_t size = -1;
|
2014-07-16 20:40:21 +00:00
|
|
|
demux_stream_control(demuxer, STREAM_CTRL_GET_CACHE_SIZE, &size);
|
2014-04-09 17:15:23 +00:00
|
|
|
if (size <= 0)
|
|
|
|
break;
|
2014-07-01 23:46:04 +00:00
|
|
|
return property_int_kb_size(size / 1024, action, arg);
|
2014-04-09 17:15:23 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.flags = M_OPT_MIN,
|
|
|
|
.min = 0,
|
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2014-04-09 17:15:23 +00:00
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
int64_t size = *(int *)arg * 1024LL;
|
2014-07-16 20:40:21 +00:00
|
|
|
int r = demux_stream_control(demuxer, STREAM_CTRL_SET_CACHE_SIZE, &size);
|
2014-04-09 17:15:23 +00:00
|
|
|
if (r == STREAM_UNSUPPORTED)
|
|
|
|
break;
|
|
|
|
if (r == STREAM_OK)
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-07-01 22:14:30 +00:00
|
|
|
static int mp_property_cache_used(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
if (!mpctx->demuxer)
|
2014-07-01 22:14:30 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2014-07-01 23:46:04 +00:00
|
|
|
int64_t size = -1;
|
2014-07-16 20:40:21 +00:00
|
|
|
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &size);
|
2014-07-01 23:46:04 +00:00
|
|
|
if (size < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return property_int_kb_size(size / 1024, action, arg);
|
2014-07-01 22:14:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_cache_free(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2014-07-16 20:40:21 +00:00
|
|
|
if (!mpctx->demuxer)
|
2014-07-01 22:14:30 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2014-07-01 23:46:04 +00:00
|
|
|
int64_t size_used = -1;
|
2014-07-16 20:40:21 +00:00
|
|
|
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_FILL, &size_used);
|
2014-07-01 23:46:04 +00:00
|
|
|
if (size_used < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-07-01 22:14:30 +00:00
|
|
|
|
2014-07-01 23:46:04 +00:00
|
|
|
int64_t size = -1;
|
2014-07-16 20:40:21 +00:00
|
|
|
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_SIZE, &size);
|
2014-07-01 23:46:04 +00:00
|
|
|
if (size <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-07-01 22:14:30 +00:00
|
|
|
|
2014-07-01 23:46:04 +00:00
|
|
|
return property_int_kb_size((size - size_used) / 1024, action, arg);
|
2014-07-01 22:14:30 +00:00
|
|
|
}
|
|
|
|
|
2014-07-31 02:25:39 +00:00
|
|
|
static int mp_property_cache_idle(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
int idle = -1;
|
|
|
|
if (mpctx->demuxer)
|
|
|
|
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_IDLE, &idle);
|
|
|
|
if (idle < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_flag_ro(action, arg, !!idle);
|
|
|
|
}
|
|
|
|
|
2014-08-28 15:48:31 +00:00
|
|
|
static int mp_property_demuxer_cache_duration(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
struct demux_ctrl_reader_state s;
|
|
|
|
if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
if (s.ts_duration < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_double_ro(action, arg, s.ts_duration);
|
|
|
|
}
|
|
|
|
|
2015-04-20 21:47:13 +00:00
|
|
|
static int mp_property_demuxer_cache_time(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
struct demux_ctrl_reader_state s;
|
|
|
|
if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
double ts = s.ts_range[1];
|
|
|
|
if (ts == MP_NOPTS_VALUE)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_double_ro(action, arg, ts);
|
|
|
|
}
|
|
|
|
|
2014-08-28 15:48:31 +00:00
|
|
|
static int mp_property_demuxer_cache_idle(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
struct demux_ctrl_reader_state s;
|
|
|
|
if (demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s) < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_flag_ro(action, arg, s.idle);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_paused_for_cache(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-12 18:26:28 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_flag_ro(action, arg, mpctx->paused_for_cache);
|
2014-04-12 18:26:28 +00:00
|
|
|
}
|
|
|
|
|
2014-10-07 20:07:07 +00:00
|
|
|
static int mp_property_cache_buffering(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
double state = get_cache_buffering_percentage(mpctx);
|
|
|
|
if (state < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_int_ro(action, arg, state * 100);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_clock(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-06-04 11:33:01 +00:00
|
|
|
{
|
|
|
|
char outstr[6];
|
|
|
|
time_t t = time(NULL);
|
|
|
|
struct tm *tmp = localtime(&t);
|
|
|
|
|
2013-06-13 22:46:28 +00:00
|
|
|
if ((tmp != NULL) && (strftime(outstr, sizeof(outstr), "%H:%M", tmp) == 5))
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, outstr);
|
2013-06-04 11:33:01 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_seekable(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-02-28 14:04:10 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-28 14:04:10 +00:00
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_flag_ro(action, arg, mpctx->demuxer->seekable);
|
2014-02-28 14:04:10 +00:00
|
|
|
}
|
|
|
|
|
2015-01-26 12:46:33 +00:00
|
|
|
static int mp_property_partially_seekable(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_flag_ro(action, arg, mpctx->demuxer->partially_seekable);
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Volume (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_volume(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-10-11 19:28:45 +00:00
|
|
|
if (!mixer_audio_initialized(mpctx->mixer))
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2013-09-19 12:33:26 +00:00
|
|
|
mixer_getbothvolume(mpctx->mixer, arg);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_FLOAT,
|
|
|
|
.flags = M_OPT_RANGE,
|
|
|
|
.min = 0,
|
2015-05-22 16:35:03 +00:00
|
|
|
.max = mixer_getmaxvolume(mpctx->mixer),
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2014-06-08 21:52:58 +00:00
|
|
|
case M_PROPERTY_GET_NEUTRAL:
|
2015-05-22 16:35:03 +00:00
|
|
|
*(float *)arg = 100;
|
2014-06-08 21:52:58 +00:00
|
|
|
return M_PROPERTY_OK;
|
2014-02-26 23:57:41 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
float val;
|
|
|
|
mixer_getbothvolume(mpctx->mixer, &val);
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%i", (int)val);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_SET:
|
2013-09-19 12:33:26 +00:00
|
|
|
mixer_setvolume(mpctx->mixer, *(float *) arg, *(float *) arg);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-22 04:15:36 +00:00
|
|
|
case M_PROPERTY_SWITCH: {
|
|
|
|
struct m_property_switch_arg *sarg = arg;
|
2014-09-21 13:41:33 +00:00
|
|
|
mixer_addvolume(mpctx->mixer, sarg->inc);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2012-09-22 04:15:36 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Mute (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_mute(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-10-11 19:28:45 +00:00
|
|
|
if (!mixer_audio_initialized(mpctx->mixer))
|
|
|
|
return M_PROPERTY_ERROR;
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
2013-09-19 12:33:26 +00:00
|
|
|
mixer_setmute(mpctx->mixer, *(int *) arg);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_GET:
|
2013-09-19 12:33:26 +00:00
|
|
|
*(int *)arg = mixer_getmute(mpctx->mixer);
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_FLAG};
|
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_volrestore(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-19 12:32:47 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-09-19 12:32:47 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET: {
|
2013-09-19 12:33:26 +00:00
|
|
|
char *s = mixer_get_volume_restore_data(mpctx->mixer);
|
2013-09-19 12:32:47 +00:00
|
|
|
*(char **)arg = s;
|
|
|
|
return s ? M_PROPERTY_OK : M_PROPERTY_UNAVAILABLE;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2013-09-19 12:32:47 +00:00
|
|
|
}
|
|
|
|
|
2014-10-10 17:46:21 +00:00
|
|
|
static int get_device_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct ao_device_list *list = ctx;
|
|
|
|
struct ao_device_desc *entry = &list->devices[item];
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"name", SUB_PROP_STR(entry->name)},
|
|
|
|
{"description", SUB_PROP_STR(entry->desc)},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
2014-10-27 10:52:42 +00:00
|
|
|
static void reload_audio_output(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
if (!mpctx->ao)
|
|
|
|
return;
|
2014-11-09 08:58:44 +00:00
|
|
|
ao_request_reload(mpctx->ao);
|
2014-10-27 10:52:42 +00:00
|
|
|
}
|
|
|
|
|
2014-10-27 11:16:32 +00:00
|
|
|
static int mp_property_audio_device(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
2015-02-16 20:35:13 +00:00
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
if (!cmd->hotplug)
|
|
|
|
cmd->hotplug = ao_hotplug_create(mpctx->global, mpctx->input);
|
|
|
|
struct ao_device_list *list = ao_hotplug_get_device_list(cmd->hotplug);
|
|
|
|
for (int n = 0; n < list->num_devices; n++) {
|
|
|
|
struct ao_device_desc *dev = &list->devices[n];
|
2015-10-13 20:09:13 +00:00
|
|
|
if (dev->name && strcmp(dev->name, mpctx->opts->audio_device) == 0) {
|
2015-02-16 20:35:13 +00:00
|
|
|
*(char **)arg = talloc_strdup(NULL, dev->desc ? dev->desc : "?");
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-27 11:16:32 +00:00
|
|
|
int r = mp_property_generic_option(mpctx, prop, action, arg);
|
|
|
|
if (action == M_PROPERTY_SET)
|
|
|
|
reload_audio_output(mpctx);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-10-10 17:46:21 +00:00
|
|
|
static int mp_property_audio_devices(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2015-02-12 15:53:56 +00:00
|
|
|
if (!cmd->hotplug)
|
|
|
|
cmd->hotplug = ao_hotplug_create(mpctx->global, mpctx->input);
|
2014-10-10 17:46:21 +00:00
|
|
|
|
2015-02-12 15:53:56 +00:00
|
|
|
struct ao_device_list *list = ao_hotplug_get_device_list(cmd->hotplug);
|
|
|
|
return m_property_read_list(action, arg, list->num_devices,
|
|
|
|
get_device_entry, list);
|
2014-10-10 17:46:21 +00:00
|
|
|
}
|
|
|
|
|
2015-02-02 16:35:31 +00:00
|
|
|
static int mp_property_ao(void *ctx, struct m_property *p, int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return m_property_strdup_ro(action, arg,
|
|
|
|
mpctx->ao ? ao_get_name(mpctx->ao) : NULL);
|
|
|
|
}
|
|
|
|
|
2015-02-02 22:01:11 +00:00
|
|
|
static int mp_property_ao_detected_device(void *ctx,struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
2015-02-14 11:43:55 +00:00
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2015-06-09 16:14:15 +00:00
|
|
|
if (!cmd->hotplug)
|
|
|
|
cmd->hotplug = ao_hotplug_create(mpctx->global, mpctx->input);
|
|
|
|
|
2015-02-14 11:43:55 +00:00
|
|
|
const char *d = ao_hotplug_get_detected_device(cmd->hotplug);
|
|
|
|
return m_property_strdup_ro(action, arg, d);
|
2015-02-02 22:01:11 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Audio delay (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_audio_delay(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-11-23 20:36:20 +00:00
|
|
|
if (!(mpctx->d_audio && mpctx->d_video))
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-07-27 19:24:54 +00:00
|
|
|
float delay = mpctx->opts->audio_delay;
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
2012-09-18 13:31:46 +00:00
|
|
|
case M_PROPERTY_PRINT:
|
2012-10-30 18:44:09 +00:00
|
|
|
*(char **)arg = format_delay(delay);
|
2012-09-18 13:31:46 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_SET:
|
2015-01-29 11:10:07 +00:00
|
|
|
mpctx->opts->audio_delay = *(float *)arg;
|
|
|
|
mpctx->delay += mpctx->opts->audio_delay - delay;
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Audio codec tag (RO)
|
2015-05-22 18:05:04 +00:00
|
|
|
static int mp_property_audio_codec_name(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-11-23 20:22:17 +00:00
|
|
|
const char *c = mpctx->d_audio ? mpctx->d_audio->header->codec : NULL;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, c);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 22:14:41 +00:00
|
|
|
/// Audio codec name (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_audio_codec(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-05-29 22:14:41 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-11-23 20:22:17 +00:00
|
|
|
const char *c = mpctx->d_audio ? mpctx->d_audio->decoder_desc : NULL;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, c);
|
2007-05-29 22:14:41 +00:00
|
|
|
}
|
|
|
|
|
2015-05-22 18:23:47 +00:00
|
|
|
static int property_audiofmt(struct mp_audio a, int action, void *arg)
|
|
|
|
{
|
|
|
|
if (!mp_audio_config_valid(&a))
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"samplerate", SUB_PROP_INT(a.rate)},
|
|
|
|
{"channel-count", SUB_PROP_INT(a.channels.num)},
|
|
|
|
{"channels", SUB_PROP_STR(mp_chmap_to_str(&a.channels))},
|
2015-06-25 17:10:24 +00:00
|
|
|
{"hr-channels", SUB_PROP_STR(mp_chmap_to_str_hr(&a.channels))},
|
2015-05-22 18:23:47 +00:00
|
|
|
{"format", SUB_PROP_STR(af_fmt_to_str(a.format))},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_audio_params(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct mp_audio fmt = {0};
|
|
|
|
if (mpctx->d_audio)
|
|
|
|
fmt = mpctx->d_audio->decode_format;
|
|
|
|
return property_audiofmt(fmt, action, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_audio_out_params(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct mp_audio fmt = {0};
|
|
|
|
if (mpctx->ao)
|
|
|
|
ao_get_format(mpctx->ao, &fmt);
|
|
|
|
return property_audiofmt(fmt, action, arg);
|
|
|
|
}
|
|
|
|
|
2007-06-20 02:26:20 +00:00
|
|
|
/// Balance (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_balance(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-06-20 02:26:20 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2007-06-20 02:26:20 +00:00
|
|
|
float bal;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2013-09-19 12:33:26 +00:00
|
|
|
mixer_getbalance(mpctx->mixer, arg);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_FLOAT,
|
|
|
|
.flags = M_OPT_RANGE,
|
|
|
|
.min = -1,
|
|
|
|
.max = 1,
|
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2007-06-20 02:26:20 +00:00
|
|
|
case M_PROPERTY_PRINT: {
|
2011-08-07 01:45:40 +00:00
|
|
|
char **str = arg;
|
2013-09-19 12:33:26 +00:00
|
|
|
mixer_getbalance(mpctx->mixer, &bal);
|
2011-08-07 01:45:40 +00:00
|
|
|
if (bal == 0.f)
|
|
|
|
*str = talloc_strdup(NULL, "center");
|
|
|
|
else if (bal == -1.f)
|
|
|
|
*str = talloc_strdup(NULL, "left only");
|
|
|
|
else if (bal == 1.f)
|
|
|
|
*str = talloc_strdup(NULL, "right only");
|
|
|
|
else {
|
|
|
|
unsigned right = (bal + 1.f) / 2.f * 100.f;
|
|
|
|
*str = talloc_asprintf(NULL, "left %d%%, right %d%%",
|
|
|
|
100 - right, right);
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2007-06-20 02:26:20 +00:00
|
|
|
case M_PROPERTY_SET:
|
2013-09-19 12:33:26 +00:00
|
|
|
mixer_setbalance(mpctx->mixer, *(float *)arg);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-06-20 02:26:20 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-12-24 16:46:14 +00:00
|
|
|
static struct track* track_next(struct MPContext *mpctx, int order,
|
|
|
|
enum stream_type type, int direction,
|
|
|
|
struct track *track)
|
2012-08-19 16:01:30 +00:00
|
|
|
{
|
|
|
|
assert(direction == -1 || direction == +1);
|
|
|
|
struct track *prev = NULL, *next = NULL;
|
|
|
|
bool seen = track == NULL;
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *cur = mpctx->tracks[n];
|
2013-12-24 16:46:14 +00:00
|
|
|
// One track can be selected only one time - pretend already selected
|
|
|
|
// tracks don't exist.
|
|
|
|
for (int r = 0; r < NUM_PTRACKS; r++) {
|
|
|
|
if (r != order && mpctx->current_track[r][type] == cur)
|
|
|
|
cur = NULL;
|
|
|
|
}
|
|
|
|
if (!cur)
|
|
|
|
continue;
|
2012-08-19 16:01:30 +00:00
|
|
|
if (cur->type == type) {
|
|
|
|
if (cur == track) {
|
|
|
|
seen = true;
|
|
|
|
} else {
|
|
|
|
if (seen && !next) {
|
|
|
|
next = cur;
|
2013-07-21 16:06:52 +00:00
|
|
|
}
|
|
|
|
if (!seen || !track) {
|
2012-08-19 16:01:30 +00:00
|
|
|
prev = cur;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return direction > 0 ? next : prev;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_switch_track(struct m_property *prop, int action, void *arg,
|
2013-12-24 16:46:14 +00:00
|
|
|
MPContext *mpctx, int order,
|
|
|
|
enum stream_type type)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-12-24 16:46:14 +00:00
|
|
|
struct track *track = mpctx->current_track[order][type];
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2015-07-28 22:09:44 +00:00
|
|
|
if (mpctx->playback_initialized) {
|
|
|
|
*(int *)arg = track ? track->user_tid : -2;
|
|
|
|
} else {
|
|
|
|
*(int *)arg = mpctx->opts->stream_id[order][type];
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_PRINT:
|
2012-08-19 16:01:30 +00:00
|
|
|
if (!track)
|
2012-11-20 13:00:12 +00:00
|
|
|
*(char **) arg = talloc_strdup(NULL, "no");
|
2012-02-19 13:15:41 +00:00
|
|
|
else {
|
2012-08-19 16:01:30 +00:00
|
|
|
char *lang = track->lang;
|
2012-02-19 13:15:41 +00:00
|
|
|
if (!lang)
|
2013-12-16 19:40:02 +00:00
|
|
|
lang = "unknown";
|
2012-02-19 13:15:41 +00:00
|
|
|
|
2012-08-19 16:01:30 +00:00
|
|
|
if (track->title)
|
2011-07-03 17:41:46 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "(%d) %s (\"%s\")",
|
2012-08-19 16:01:30 +00:00
|
|
|
track->user_tid, lang, track->title);
|
2011-07-03 17:41:46 +00:00
|
|
|
else
|
2012-08-19 16:01:30 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "(%d) %s",
|
|
|
|
track->user_tid, lang);
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-09-22 04:15:36 +00:00
|
|
|
case M_PROPERTY_SWITCH: {
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2015-05-26 19:33:34 +00:00
|
|
|
return M_PROPERTY_ERROR;
|
2012-09-22 04:15:36 +00:00
|
|
|
struct m_property_switch_arg *sarg = arg;
|
2013-12-24 16:46:14 +00:00
|
|
|
mp_switch_track_n(mpctx, order, type,
|
2015-05-26 12:01:23 +00:00
|
|
|
track_next(mpctx, order, type, sarg->inc >= 0 ? +1 : -1, track),
|
|
|
|
FLAG_MARK_SELECTION);
|
2015-06-03 19:52:32 +00:00
|
|
|
print_track_list(mpctx, "Track switched:");
|
2012-09-18 12:00:08 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-22 04:15:36 +00:00
|
|
|
}
|
2012-09-18 12:00:08 +00:00
|
|
|
case M_PROPERTY_SET:
|
2015-05-26 19:42:34 +00:00
|
|
|
if (mpctx->playback_initialized) {
|
2015-05-26 19:33:34 +00:00
|
|
|
track = mp_track_by_tid(mpctx, type, *(int *)arg);
|
|
|
|
mp_switch_track_n(mpctx, order, type, track, FLAG_MARK_SELECTION);
|
2015-06-03 19:52:32 +00:00
|
|
|
print_track_list(mpctx, "Track switched:");
|
2015-05-26 19:33:34 +00:00
|
|
|
} else {
|
|
|
|
mpctx->opts->stream_id[order][type] = *(int *)arg;
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2012-08-19 16:01:30 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2014-10-21 11:16:48 +00:00
|
|
|
// Similar, less featured, for selecting by ff-index.
|
|
|
|
static int property_switch_track_ff(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
enum stream_type type = (intptr_t)prop->priv;
|
|
|
|
struct track *track = mpctx->current_track[0][type];
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(int *) arg = track ? track->ff_index : -2;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_SET: {
|
2014-10-23 10:03:26 +00:00
|
|
|
int id = *(int *)arg;
|
2015-05-26 19:42:34 +00:00
|
|
|
if (mpctx->playback_initialized) {
|
2015-05-22 19:05:03 +00:00
|
|
|
track = NULL;
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *cur = mpctx->tracks[n];
|
|
|
|
if (cur->type == type && cur->ff_index == id) {
|
|
|
|
track = cur;
|
|
|
|
break;
|
|
|
|
}
|
2014-10-21 11:16:48 +00:00
|
|
|
}
|
2015-05-22 19:05:03 +00:00
|
|
|
if (!track && id >= 0)
|
|
|
|
return M_PROPERTY_ERROR;
|
2015-05-26 12:01:23 +00:00
|
|
|
mp_switch_track_n(mpctx, 0, type, track, 0);
|
2015-06-03 19:52:32 +00:00
|
|
|
print_track_list(mpctx, "Track switched:");
|
2015-05-22 19:05:03 +00:00
|
|
|
} else {
|
|
|
|
mpctx->opts->stream_id_ff[type] = *(int *)arg;
|
2014-10-21 11:16:48 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
|
|
|
}
|
|
|
|
|
2015-07-03 00:33:54 +00:00
|
|
|
static int track_channels(struct track *track)
|
|
|
|
{
|
|
|
|
return track->stream && track->stream->audio
|
|
|
|
? track->stream->audio->channels.num : 0;
|
|
|
|
}
|
|
|
|
|
2014-02-15 15:53:11 +00:00
|
|
|
static int get_track_entry(int item, int action, void *arg, void *ctx)
|
|
|
|
{
|
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct track *track = mpctx->tracks[item];
|
|
|
|
|
2014-02-18 23:21:56 +00:00
|
|
|
const char *codec = track->stream ? track->stream->codec : NULL;
|
|
|
|
|
2014-02-15 15:53:11 +00:00
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"id", SUB_PROP_INT(track->user_tid)},
|
|
|
|
{"type", SUB_PROP_STR(stream_type_name(track->type)),
|
|
|
|
.unavailable = !stream_type_name(track->type)},
|
|
|
|
{"src-id", SUB_PROP_INT(track->demuxer_id),
|
|
|
|
.unavailable = track->demuxer_id == -1},
|
|
|
|
{"title", SUB_PROP_STR(track->title),
|
|
|
|
.unavailable = !track->title},
|
|
|
|
{"lang", SUB_PROP_STR(track->lang),
|
|
|
|
.unavailable = !track->lang},
|
2015-07-03 00:33:54 +00:00
|
|
|
{"audio-channels", SUB_PROP_INT(track_channels(track)),
|
|
|
|
.unavailable = track_channels(track) <= 0},
|
2014-02-15 15:53:11 +00:00
|
|
|
{"albumart", SUB_PROP_FLAG(track->attached_picture)},
|
|
|
|
{"default", SUB_PROP_FLAG(track->default_track)},
|
2015-06-27 20:02:24 +00:00
|
|
|
{"forced", SUB_PROP_FLAG(track->forced_track)},
|
2014-02-15 15:53:11 +00:00
|
|
|
{"external", SUB_PROP_FLAG(track->is_external)},
|
|
|
|
{"selected", SUB_PROP_FLAG(track->selected)},
|
|
|
|
{"external-filename", SUB_PROP_STR(track->external_filename),
|
|
|
|
.unavailable = !track->external_filename},
|
2014-02-18 23:21:56 +00:00
|
|
|
{"codec", SUB_PROP_STR(codec),
|
|
|
|
.unavailable = !codec},
|
2014-10-21 11:16:48 +00:00
|
|
|
{"ff-index", SUB_PROP_INT(track->ff_index)},
|
2014-02-15 15:53:11 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
2013-05-15 00:17:47 +00:00
|
|
|
static const char *track_type_name(enum stream_type t)
|
|
|
|
{
|
|
|
|
switch (t) {
|
|
|
|
case STREAM_VIDEO: return "Video";
|
|
|
|
case STREAM_AUDIO: return "Audio";
|
|
|
|
case STREAM_SUB: return "Sub";
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_list_tracks(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-05-15 00:17:47 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-15 15:53:11 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2013-05-15 00:17:47 +00:00
|
|
|
char *res = NULL;
|
|
|
|
|
|
|
|
for (int type = 0; type < STREAM_TYPE_COUNT; type++) {
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *track = mpctx->tracks[n];
|
|
|
|
if (track->type != type)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
res = talloc_asprintf_append(res, "%s: ",
|
|
|
|
track_type_name(track->type));
|
2013-12-23 19:14:54 +00:00
|
|
|
if (track->selected)
|
2013-05-15 00:17:47 +00:00
|
|
|
res = talloc_asprintf_append(res, "> ");
|
|
|
|
res = talloc_asprintf_append(res, "(%d) ", track->user_tid);
|
|
|
|
if (track->title)
|
|
|
|
res = talloc_asprintf_append(res, "'%s' ", track->title);
|
|
|
|
if (track->lang)
|
|
|
|
res = talloc_asprintf_append(res, "(%s) ", track->lang);
|
|
|
|
if (track->is_external)
|
|
|
|
res = talloc_asprintf_append(res, "(external) ");
|
2013-12-23 19:14:54 +00:00
|
|
|
if (track->selected)
|
2013-05-15 00:17:47 +00:00
|
|
|
res = talloc_asprintf_append(res, "<");
|
|
|
|
res = talloc_asprintf_append(res, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
res = talloc_asprintf_append(res, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (demuxer && demuxer->num_editions > 1)
|
|
|
|
res = talloc_asprintf_append(res, "\nEdition: %d of %d\n",
|
|
|
|
demuxer->edition + 1,
|
|
|
|
demuxer->num_editions);
|
|
|
|
|
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2014-02-15 15:53:11 +00:00
|
|
|
return m_property_read_list(action, arg, mpctx->num_tracks,
|
|
|
|
get_track_entry, mpctx);
|
2013-05-15 00:17:47 +00:00
|
|
|
}
|
|
|
|
|
2012-08-19 16:01:30 +00:00
|
|
|
/// Selected audio id (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_audio(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-08-19 16:01:30 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_switch_track(prop, action, arg, ctx, 0, STREAM_AUDIO);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Selected video id (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_video(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_switch_track(prop, action, arg, ctx, 0, STREAM_VIDEO);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2012-09-26 21:56:48 +00:00
|
|
|
static struct track *find_track_by_demuxer_id(MPContext *mpctx,
|
|
|
|
enum stream_type type,
|
|
|
|
int demuxer_id)
|
|
|
|
{
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *track = mpctx->tracks[n];
|
|
|
|
if (track->type == type && track->demuxer_id == demuxer_id)
|
|
|
|
return track;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_program(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2007-02-21 00:49:24 +00:00
|
|
|
demux_program_t prog;
|
|
|
|
|
2012-08-19 16:07:06 +00:00
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
mplayer: fix idle mode regressions
Commit 89a17bcda6c16 simplified the idle loop to run any commands
mplayer receives, not just playlist related commands. Unfortunately, it
turns out many slave commands always assume the presence of a demuxer.
MPContext->demuxer is assumed not to be NULL. This made the player
crash when receiving slave commands like pause/unpause, chapter
control, subtitle selection.
We want mplayer being able to handle this. Any slave command or
property, as long as it's backed by a persistent setting, should be run
successfully, even if no file is being played. If the slave command
doesn't make sense in this state, it shouldn't crash the player.
Insert some NULL checks when accessing demuxers. If sh_video or
sh_audio are not NULL, assume demuxer can't be NULL.
(There actually aren't that many properties which need to be changed. If
it gets too complicated, we could employ alternative mechanisms instead,
such as explicitly marking safe properties with a flag.)
2012-08-04 00:00:28 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
2012-09-18 12:00:08 +00:00
|
|
|
case M_PROPERTY_SWITCH:
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_SET:
|
2010-05-03 23:34:38 +00:00
|
|
|
if (action == M_PROPERTY_SET && arg)
|
|
|
|
prog.progid = *((int *) arg);
|
|
|
|
else
|
|
|
|
prog.progid = -1;
|
2012-08-19 16:07:06 +00:00
|
|
|
if (demux_control(demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM, &prog) ==
|
|
|
|
DEMUXER_CTRL_NOTIMPL)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
|
|
|
|
if (prog.aid < 0 && prog.vid < 0) {
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_ERR(mpctx, "Selected program contains no audio or video streams!\n");
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
}
|
2012-09-26 21:56:48 +00:00
|
|
|
mp_switch_track(mpctx, STREAM_VIDEO,
|
2015-05-26 12:01:23 +00:00
|
|
|
find_track_by_demuxer_id(mpctx, STREAM_VIDEO, prog.vid), 0);
|
2013-04-14 19:32:34 +00:00
|
|
|
mp_switch_track(mpctx, STREAM_AUDIO,
|
2015-05-26 12:01:23 +00:00
|
|
|
find_track_by_demuxer_id(mpctx, STREAM_AUDIO, prog.aid), 0);
|
2013-04-14 19:32:34 +00:00
|
|
|
mp_switch_track(mpctx, STREAM_SUB,
|
2015-05-26 12:01:23 +00:00
|
|
|
find_track_by_demuxer_id(mpctx, STREAM_VIDEO, prog.sid), 0);
|
2015-06-03 19:52:32 +00:00
|
|
|
print_track_list(mpctx, "Program switched:");
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.flags = CONF_RANGE,
|
|
|
|
.min = -1,
|
|
|
|
.max = (1 << 16) - 1,
|
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_hwdec(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-04-22 23:17:28 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-04-22 23:17:28 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
struct dec_video *vd = mpctx->d_video;
|
|
|
|
|
2015-05-25 19:44:48 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2014-04-22 23:17:28 +00:00
|
|
|
int new = *(int *)arg;
|
2015-05-25 19:44:48 +00:00
|
|
|
|
|
|
|
if (opts->hwdec_api == new)
|
2014-04-22 23:17:28 +00:00
|
|
|
return M_PROPERTY_OK;
|
2015-05-25 19:44:48 +00:00
|
|
|
|
2014-04-22 23:17:28 +00:00
|
|
|
opts->hwdec_api = new;
|
2015-05-25 19:44:48 +00:00
|
|
|
|
|
|
|
if (!vd)
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
|
|
|
|
int current = -2;
|
|
|
|
video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t);
|
|
|
|
if (current != opts->hwdec_api) {
|
|
|
|
double last_pts = mpctx->last_vo_pts;
|
|
|
|
uninit_video_chain(mpctx);
|
|
|
|
reinit_video_chain(mpctx);
|
|
|
|
if (last_pts != MP_NOPTS_VALUE)
|
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, true);
|
|
|
|
}
|
2014-04-22 23:17:28 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2014-04-22 23:17:28 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2015-05-25 19:44:48 +00:00
|
|
|
static int mp_property_hwdec_active(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct dec_video *vd = mpctx->d_video;
|
|
|
|
bool active = false;
|
|
|
|
if (vd) {
|
|
|
|
int current = 0;
|
|
|
|
video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t);
|
|
|
|
active = current > 0;
|
|
|
|
}
|
|
|
|
return m_property_flag_ro(action, arg, active);
|
|
|
|
}
|
|
|
|
|
2015-02-02 21:43:05 +00:00
|
|
|
static int mp_property_detected_hwdec(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct dec_video *vd = mpctx->d_video;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE: {
|
|
|
|
// Abuse another hwdec option to resolve the value names
|
|
|
|
struct m_property dummy = {.name = "hwdec"};
|
|
|
|
return mp_property_generic_option(mpctx, &dummy, action, arg);
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET: {
|
2015-05-25 19:44:48 +00:00
|
|
|
int current = 0;
|
|
|
|
if (vd)
|
|
|
|
video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t);
|
|
|
|
|
|
|
|
if (current <= 0 && vd && vd->hwdec_info && vd->hwdec_info->hwctx)
|
|
|
|
current = vd->hwdec_info->hwctx->type;
|
|
|
|
|
|
|
|
// In case of the "-copy" ones, which are "detected" every time the
|
|
|
|
// decoder is opened, return "no" if no decoding is active.
|
|
|
|
*(int *)arg = current > 0 ? current : 0;
|
2015-02-02 21:43:05 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
#define VF_DEINTERLACE_LABEL "deinterlace"
|
|
|
|
|
2014-04-29 13:17:27 +00:00
|
|
|
static bool probe_deint_filter(struct MPContext *mpctx, const char *filt)
|
|
|
|
{
|
|
|
|
char filter[80];
|
|
|
|
// add a label so that removing the filter is easier
|
|
|
|
snprintf(filter, sizeof(filter), "@%s:%s", VF_DEINTERLACE_LABEL, filt);
|
2015-07-21 19:54:15 +00:00
|
|
|
return edit_filters(mpctx, mp_null_log, STREAM_VIDEO, "pre", filter) >= 0;
|
2014-04-29 13:17:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool check_output_format(struct MPContext *mpctx, int imgfmt)
|
|
|
|
{
|
|
|
|
struct dec_video *vd = mpctx->d_video;
|
|
|
|
if (!vd)
|
|
|
|
return false;
|
|
|
|
return vd->vfilter->allowed_output_formats[imgfmt - IMGFMT_START];
|
|
|
|
}
|
|
|
|
|
|
|
|
static int probe_deint_filters(struct MPContext *mpctx)
|
|
|
|
{
|
2014-04-29 13:18:19 +00:00
|
|
|
if (check_output_format(mpctx, IMGFMT_VDPAU)) {
|
|
|
|
char filter[80] = "vdpaupp:deint=yes";
|
|
|
|
int pref = 0;
|
2014-11-21 04:12:55 +00:00
|
|
|
vo_control(mpctx->video_out, VOCTRL_GET_PREF_DEINT, &pref);
|
2014-04-29 13:18:19 +00:00
|
|
|
pref = pref < 0 ? -pref : pref;
|
|
|
|
if (pref > 0 && pref <= 4) {
|
|
|
|
const char *types[] =
|
|
|
|
{"", "first-field", "bob", "temporal", "temporal-spatial"};
|
2014-05-05 21:55:06 +00:00
|
|
|
mp_snprintf_cat(filter, sizeof(filter), ":deint-mode=%s",
|
|
|
|
types[pref]);
|
2014-04-29 13:18:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
probe_deint_filter(mpctx, filter);
|
2014-04-29 13:17:27 +00:00
|
|
|
return 0;
|
2014-04-29 13:18:19 +00:00
|
|
|
}
|
2014-04-29 13:17:27 +00:00
|
|
|
if (check_output_format(mpctx, IMGFMT_VAAPI) &&
|
|
|
|
probe_deint_filter(mpctx, "vavpp"))
|
|
|
|
return 0;
|
2015-12-21 21:04:53 +00:00
|
|
|
if (probe_deint_filter(mpctx, "yadif"))
|
2014-04-29 13:17:27 +00:00
|
|
|
return 0;
|
2013-09-20 13:09:29 +00:00
|
|
|
return -1;
|
|
|
|
}
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
|
|
|
|
static int get_deinterlacing(struct MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-12-10 18:08:56 +00:00
|
|
|
struct dec_video *vd = mpctx->d_video;
|
2012-10-28 19:59:15 +00:00
|
|
|
int enabled = 0;
|
2013-12-10 18:08:56 +00:00
|
|
|
if (video_vf_vo_control(vd, VFCTRL_GET_DEINTERLACE, &enabled) != CONTROL_OK)
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
enabled = -1;
|
|
|
|
if (enabled < 0) {
|
|
|
|
// vf_lavfi doesn't support VFCTRL_GET_DEINTERLACE
|
2013-12-10 18:08:56 +00:00
|
|
|
if (vf_find_by_label(vd->vfilter, VF_DEINTERLACE_LABEL))
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
enabled = 1;
|
|
|
|
}
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
2015-07-21 19:54:15 +00:00
|
|
|
void remove_deint_filter(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
edit_filters(mpctx, mp_null_log, STREAM_VIDEO, "del", "@" VF_DEINTERLACE_LABEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_deinterlacing(struct MPContext *mpctx, bool enable)
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
{
|
2013-12-10 18:08:56 +00:00
|
|
|
struct dec_video *vd = mpctx->d_video;
|
|
|
|
if (vf_find_by_label(vd->vfilter, VF_DEINTERLACE_LABEL)) {
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
if (!enable)
|
2015-07-21 19:54:15 +00:00
|
|
|
remove_deint_filter(mpctx);
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
} else {
|
core: add --deinterlace option, restore it with resume functionality
The --deinterlace option does on playback start what the "deinterlace"
property normally does at runtime. You could do this before by using the
--vf option or by messing with the vo_vdpau default options, but this
new option is supposed to be a "foolproof" way.
The main motivation for adding this is so that the deinterlace property
can be restored when using the video resume functionality
(quit_watch_later command).
Implementation-wise, this is a bit messy. The video chain is rebuilt in
mpcodecs_reconfig_vo(), where we don't have access to MPContext, so the
usual mechanism for enabling deinterlacing can't be used. Further,
mpcodecs_reconfig_vo() is called by the video decoder, which doesn't
have access to MPContext either. Moving this call to mplayer.c isn't
currently possible either (see below). So we just do this before frames
are filtered, which potentially means setting the deinterlacing every
frame. Fortunately, setting deinterlacing is stable and idempotent, so
this is hopefully not a problem. We also add a counter that is
incremented on each reconfig to reduce the amount of additional work per
frame to nearly zero.
The reason we can't move mpcodecs_reconfig_vo() to mplayer.c is because
of hardware decoding: we need to check whether the video chain works
before we decide that we can use hardware decoding. Changing it so that
this can be decided in advance without building a filter chain sounds
like a good idea and should be done, but we aren't there yet.
2013-09-13 16:06:08 +00:00
|
|
|
if ((get_deinterlacing(mpctx) > 0) != enable) {
|
|
|
|
int arg = enable;
|
2013-12-10 18:08:56 +00:00
|
|
|
if (video_vf_vo_control(vd, VFCTRL_SET_DEINTERLACE, &arg) != CONTROL_OK)
|
2014-04-29 13:17:27 +00:00
|
|
|
probe_deint_filters(mpctx);
|
core: add --deinterlace option, restore it with resume functionality
The --deinterlace option does on playback start what the "deinterlace"
property normally does at runtime. You could do this before by using the
--vf option or by messing with the vo_vdpau default options, but this
new option is supposed to be a "foolproof" way.
The main motivation for adding this is so that the deinterlace property
can be restored when using the video resume functionality
(quit_watch_later command).
Implementation-wise, this is a bit messy. The video chain is rebuilt in
mpcodecs_reconfig_vo(), where we don't have access to MPContext, so the
usual mechanism for enabling deinterlacing can't be used. Further,
mpcodecs_reconfig_vo() is called by the video decoder, which doesn't
have access to MPContext either. Moving this call to mplayer.c isn't
currently possible either (see below). So we just do this before frames
are filtered, which potentially means setting the deinterlacing every
frame. Fortunately, setting deinterlacing is stable and idempotent, so
this is hopefully not a problem. We also add a counter that is
incremented on each reconfig to reduce the amount of additional work per
frame to nearly zero.
The reason we can't move mpcodecs_reconfig_vo() to mplayer.c is because
of hardware decoding: we need to check whether the video chain works
before we decide that we can use hardware decoding. Changing it so that
this can be decided in advance without building a filter chain sounds
like a good idea and should be done, but we aren't there yet.
2013-09-13 16:06:08 +00:00
|
|
|
}
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
}
|
core: add --deinterlace option, restore it with resume functionality
The --deinterlace option does on playback start what the "deinterlace"
property normally does at runtime. You could do this before by using the
--vf option or by messing with the vo_vdpau default options, but this
new option is supposed to be a "foolproof" way.
The main motivation for adding this is so that the deinterlace property
can be restored when using the video resume functionality
(quit_watch_later command).
Implementation-wise, this is a bit messy. The video chain is rebuilt in
mpcodecs_reconfig_vo(), where we don't have access to MPContext, so the
usual mechanism for enabling deinterlacing can't be used. Further,
mpcodecs_reconfig_vo() is called by the video decoder, which doesn't
have access to MPContext either. Moving this call to mplayer.c isn't
currently possible either (see below). So we just do this before frames
are filtered, which potentially means setting the deinterlacing every
frame. Fortunately, setting deinterlacing is stable and idempotent, so
this is hopefully not a problem. We also add a counter that is
incremented on each reconfig to reduce the amount of additional work per
frame to nearly zero.
The reason we can't move mpcodecs_reconfig_vo() to mplayer.c is because
of hardware decoding: we need to check whether the video chain works
before we decide that we can use hardware decoding. Changing it so that
this can be decided in advance without building a filter chain sounds
like a good idea and should be done, but we aren't there yet.
2013-09-13 16:06:08 +00:00
|
|
|
mpctx->opts->deinterlace = get_deinterlacing(mpctx) > 0;
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_deinterlace(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-11-23 20:36:20 +00:00
|
|
|
if (!mpctx->d_video || !mpctx->d_video->vfilter)
|
2015-07-08 13:24:34 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
*(int *)arg = get_deinterlacing(mpctx) > 0;
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_FLAG};
|
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_SET:
|
command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.
If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.
This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.
The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-22 21:37:39 +00:00
|
|
|
set_deinterlacing(mpctx, *(int *)arg);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 21:34:56 +00:00
|
|
|
static int video_simple_refresh_property(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
int r = mp_property_generic_option(mpctx, prop, action, arg);
|
|
|
|
if (action == M_PROPERTY_SET && r == M_PROPERTY_OK)
|
|
|
|
mp_force_video_refresh(mpctx);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-06-14 22:15:32 +00:00
|
|
|
// Update options which are managed through VOCTRL_GET/SET_PANSCAN.
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int panscan_property_helper(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2007-02-21 00:49:24 +00:00
|
|
|
if (!mpctx->video_out
|
2010-05-07 19:02:47 +00:00
|
|
|
|| vo_control(mpctx->video_out, VOCTRL_GET_PANSCAN, NULL) != VO_TRUE)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
int r = mp_property_generic_option(mpctx, prop, action, arg);
|
2012-09-18 18:07:24 +00:00
|
|
|
if (action == M_PROPERTY_SET)
|
2010-05-07 19:02:47 +00:00
|
|
|
vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL);
|
2012-09-18 18:07:24 +00:00
|
|
|
return r;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Helper to set vo flags.
|
|
|
|
/** \ingroup PropertyImplHelper
|
|
|
|
*/
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_vo_flag(struct m_property *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
int vo_ctrl, int *vo_var, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2012-09-18 18:07:24 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2015-01-16 22:07:13 +00:00
|
|
|
int desired = !!*(int *) arg;
|
|
|
|
if (*vo_var == desired)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2015-03-11 11:07:52 +00:00
|
|
|
if (mpctx->video_out) {
|
2010-05-07 19:02:47 +00:00
|
|
|
vo_control(mpctx->video_out, vo_ctrl, 0);
|
2015-03-11 11:07:52 +00:00
|
|
|
} else {
|
|
|
|
*vo_var = desired;
|
|
|
|
}
|
2015-01-16 22:07:13 +00:00
|
|
|
return *vo_var == desired ? M_PROPERTY_OK : M_PROPERTY_ERROR;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2015-01-16 22:07:13 +00:00
|
|
|
/// Fullscreen state (RW)
|
|
|
|
static int mp_property_fullscreen(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-05-21 21:11:51 +00:00
|
|
|
int oldval = mpctx->opts->vo.fullscreen;
|
|
|
|
int r = mp_property_vo_flag(prop, action, arg, VOCTRL_FULLSCREEN,
|
|
|
|
&mpctx->opts->vo.fullscreen, mpctx);
|
|
|
|
if (oldval && oldval != mpctx->opts->vo.fullscreen)
|
|
|
|
mpctx->mouse_event_ts--; // Show mouse cursor
|
|
|
|
return r;
|
2015-01-16 22:07:13 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Window always on top (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_ontop(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2008-04-19 04:45:16 +00:00
|
|
|
return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP,
|
2013-07-27 19:24:54 +00:00
|
|
|
&mpctx->opts->vo.ontop, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Show window borders (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_border(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2007-02-21 00:49:24 +00:00
|
|
|
return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER,
|
2013-07-27 19:24:54 +00:00
|
|
|
&mpctx->opts->vo.border, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2015-01-16 22:38:47 +00:00
|
|
|
static int mp_property_all_workspaces(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return mp_property_vo_flag(prop, action, arg, VOCTRL_ALL_WORKSPACES,
|
|
|
|
&mpctx->opts->vo.all_workspaces, mpctx);
|
|
|
|
}
|
|
|
|
|
2014-08-19 19:19:38 +00:00
|
|
|
static int get_frame_count(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return 0;
|
|
|
|
if (!mpctx->d_video)
|
|
|
|
return 0;
|
2014-10-29 20:54:59 +00:00
|
|
|
double len = get_time_length(mpctx);
|
|
|
|
double fps = mpctx->d_video->fps;
|
|
|
|
if (len < 0 || fps <= 0)
|
|
|
|
return 0;
|
2014-08-19 19:19:38 +00:00
|
|
|
|
2014-10-29 20:54:59 +00:00
|
|
|
return len * fps;
|
2014-08-19 19:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_frame_number(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
if (!mpctx->d_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2015-12-26 17:36:45 +00:00
|
|
|
return m_property_int_ro(action, arg,
|
|
|
|
lrint(get_current_pos_ratio(mpctx, false) * get_frame_count(mpctx)));
|
2014-08-19 19:19:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_frame_count(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
|
|
|
|
if (!mpctx->d_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_int_ro(action, arg, get_frame_count(mpctx));
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_framedrop(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-11-23 20:36:20 +00:00
|
|
|
if (!mpctx->d_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_video_color(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2015-09-29 19:12:26 +00:00
|
|
|
const char *name = prop->priv ? prop->priv : prop->name;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-11-23 20:36:20 +00:00
|
|
|
if (!mpctx->d_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
switch (action) {
|
2013-08-20 14:23:44 +00:00
|
|
|
case M_PROPERTY_SET: {
|
2015-09-29 19:12:26 +00:00
|
|
|
if (video_set_colors(mpctx->d_video, name, *(int *) arg) <= 0)
|
2013-08-20 14:23:44 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2010-05-03 23:34:38 +00:00
|
|
|
break;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2013-08-20 14:23:44 +00:00
|
|
|
case M_PROPERTY_GET:
|
2015-09-29 19:12:26 +00:00
|
|
|
if (video_get_colors(mpctx->d_video, name, (int *)arg) <= 0)
|
2013-08-20 14:23:44 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
// Write new value to option variable
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
mp_property_generic_option(mpctx, prop, M_PROPERTY_SET, arg);
|
2013-08-20 14:23:44 +00:00
|
|
|
return M_PROPERTY_OK;
|
2014-06-08 21:52:58 +00:00
|
|
|
case M_PROPERTY_GET_NEUTRAL:
|
|
|
|
*(int *)arg = 0;
|
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Video codec tag (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_video_format(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-11-23 20:36:20 +00:00
|
|
|
const char *c = mpctx->d_video ? mpctx->d_video->header->codec : NULL;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, c);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 22:14:41 +00:00
|
|
|
/// Video codec name (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_video_codec(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-05-29 22:14:41 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-11-23 20:36:20 +00:00
|
|
|
const char *c = mpctx->d_video ? mpctx->d_video->decoder_desc : NULL;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_strdup_ro(action, arg, c);
|
2007-05-29 22:14:41 +00:00
|
|
|
}
|
|
|
|
|
2014-02-15 15:42:48 +00:00
|
|
|
static int property_imgparams(struct mp_image_params p, int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2014-02-15 15:42:48 +00:00
|
|
|
if (!p.imgfmt)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2015-12-19 19:04:31 +00:00
|
|
|
int d_w, d_h;
|
|
|
|
mp_image_params_get_dsize(&p, &d_w, &d_h);
|
2014-02-15 15:42:48 +00:00
|
|
|
|
2015-01-10 18:11:28 +00:00
|
|
|
struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(p.imgfmt);
|
2015-01-10 11:29:10 +00:00
|
|
|
int bpp = 0;
|
2015-01-10 18:11:28 +00:00
|
|
|
for (int i = 0; i < desc.num_planes; i++)
|
|
|
|
bpp += desc.bpp[i] >> (desc.xs[i] + desc.ys[i]);
|
2015-01-10 11:29:10 +00:00
|
|
|
|
2014-02-15 15:42:48 +00:00
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p.imgfmt))},
|
2015-01-10 20:16:34 +00:00
|
|
|
{"average-bpp", SUB_PROP_INT(bpp),
|
2015-01-10 18:11:28 +00:00
|
|
|
.unavailable = !bpp},
|
2015-01-10 20:16:34 +00:00
|
|
|
{"plane-depth", SUB_PROP_INT(desc.plane_bits),
|
2015-01-10 18:11:28 +00:00
|
|
|
.unavailable = !(desc.flags & MP_IMGFLAG_PLANAR)},
|
2014-02-15 15:42:48 +00:00
|
|
|
{"w", SUB_PROP_INT(p.w)},
|
|
|
|
{"h", SUB_PROP_INT(p.h)},
|
2015-12-19 19:04:31 +00:00
|
|
|
{"dw", SUB_PROP_INT(d_w)},
|
|
|
|
{"dh", SUB_PROP_INT(d_h)},
|
|
|
|
{"aspect", SUB_PROP_FLOAT(d_w / (double)d_h)},
|
|
|
|
{"par", SUB_PROP_FLOAT(p.p_w / (double)p.p_h)},
|
2015-03-30 21:52:28 +00:00
|
|
|
{"colormatrix",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_csp_names, p.colorspace))},
|
|
|
|
{"colorlevels",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_csp_levels_names, p.colorlevels))},
|
|
|
|
{"primaries",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_csp_prim_names, p.primaries))},
|
2015-03-31 02:50:49 +00:00
|
|
|
{"gamma",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_csp_trc_names, p.gamma))},
|
2015-03-30 21:52:28 +00:00
|
|
|
{"chroma-location",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_chroma_names, p.chroma_location))},
|
2015-06-23 13:20:21 +00:00
|
|
|
{"stereo-in",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_stereo3d_names, p.stereo_in))},
|
|
|
|
{"stereo-out",
|
|
|
|
SUB_PROP_STR(m_opt_choice_str(mp_stereo3d_names, p.stereo_out))},
|
2014-04-21 20:54:43 +00:00
|
|
|
{"rotate", SUB_PROP_INT(p.rotate)},
|
2014-02-15 15:42:48 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2014-01-09 20:19:19 +00:00
|
|
|
static struct mp_image_params get_video_out_params(struct MPContext *mpctx)
|
2013-03-25 20:25:11 +00:00
|
|
|
{
|
2014-01-09 20:19:19 +00:00
|
|
|
if (!mpctx->d_video || !mpctx->d_video->vfilter ||
|
|
|
|
mpctx->d_video->vfilter->initialized < 1)
|
|
|
|
return (struct mp_image_params){0};
|
|
|
|
|
|
|
|
return mpctx->d_video->vfilter->output_params;
|
2013-03-25 20:25:11 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_vo_imgparams(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-03-25 20:25:11 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_imgparams(get_video_out_params(ctx), action, arg);
|
2013-03-25 20:25:11 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_vd_imgparams(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-03-25 20:25:11 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-15 15:42:48 +00:00
|
|
|
struct dec_video *vd = mpctx->d_video;
|
|
|
|
if (!vd)
|
2014-01-09 20:19:19 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-02-15 15:42:48 +00:00
|
|
|
struct sh_video *sh = vd->header->video;
|
2014-05-01 21:15:50 +00:00
|
|
|
if (vd->vfilter->override_params.imgfmt) {
|
|
|
|
return property_imgparams(vd->vfilter->override_params, action, arg);
|
2014-02-15 15:42:48 +00:00
|
|
|
} else if (sh->disp_w && sh->disp_h) {
|
|
|
|
// Simplistic fallback for stupid scripts querying "width"/"height"
|
|
|
|
// before the first frame is decoded.
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"w", SUB_PROP_INT(sh->disp_w)},
|
|
|
|
{"h", SUB_PROP_INT(sh->disp_h)},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-03-25 20:25:11 +00:00
|
|
|
}
|
|
|
|
|
2015-11-22 17:54:22 +00:00
|
|
|
static int mp_property_video_frame_info(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct mp_image *f =
|
|
|
|
mpctx->video_out ? vo_get_current_frame(mpctx->video_out) : NULL;
|
|
|
|
if (!f)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
const char *pict_types[] = {0, "I", "P", "B"};
|
|
|
|
const char *pict_type = f->pict_type >= 1 && f->pict_type <= 3
|
|
|
|
? pict_types[f->pict_type] : NULL;
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"picture-type", SUB_PROP_STR(pict_type), .unavailable = !pict_type},
|
|
|
|
{"interlaced", SUB_PROP_FLAG(!!(f->fields & MP_IMGFIELD_INTERLACED))},
|
|
|
|
{"tff", SUB_PROP_FLAG(!!(f->fields & MP_IMGFIELD_TOP_FIRST))},
|
|
|
|
{"repeat", SUB_PROP_FLAG(!!(f->fields & MP_IMGFIELD_REPEAT_FIRST))},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_window_scale(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-10-31 19:19:40 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-10-31 19:19:40 +00:00
|
|
|
struct vo *vo = mpctx->video_out;
|
2014-01-09 20:19:19 +00:00
|
|
|
if (!vo)
|
2013-10-31 19:19:40 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2014-01-09 20:19:19 +00:00
|
|
|
struct mp_image_params params = get_video_out_params(mpctx);
|
2015-12-19 19:04:31 +00:00
|
|
|
int vid_w, vid_h;
|
|
|
|
mp_image_params_get_dsize(¶ms, &vid_w, &vid_h);
|
2013-10-31 19:19:40 +00:00
|
|
|
if (vid_w < 1 || vid_h < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
double scale = *(double *)arg;
|
|
|
|
int s[2] = {vid_w * scale, vid_h * scale};
|
2014-09-04 20:53:50 +00:00
|
|
|
if (s[0] > 0 && s[1] > 0 &&
|
|
|
|
vo_control(vo, VOCTRL_SET_UNFS_WINDOW_SIZE, s) > 0)
|
2013-10-31 19:19:40 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
int s[2];
|
2014-09-04 20:53:50 +00:00
|
|
|
if (vo_control(vo, VOCTRL_GET_UNFS_WINDOW_SIZE, s) <= 0 ||
|
|
|
|
s[0] < 1 || s[1] < 1)
|
2013-10-31 19:19:40 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
double xs = (double)s[0] / vid_w;
|
|
|
|
double ys = (double)s[1] / vid_h;
|
|
|
|
*(double *)arg = (xs + ys) / 2;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_DOUBLE,
|
|
|
|
.flags = CONF_RANGE,
|
|
|
|
.min = 0.125,
|
|
|
|
.max = 8,
|
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2013-10-31 19:19:40 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-11-02 19:48:45 +00:00
|
|
|
static int mp_property_win_minimized(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
int state = 0;
|
|
|
|
if (vo_control(vo, VOCTRL_GET_WIN_STATE, &state) < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return m_property_flag_ro(action, arg, state & VO_WIN_STATE_MINIMIZED);
|
|
|
|
}
|
|
|
|
|
2015-03-10 13:50:56 +00:00
|
|
|
static int mp_property_display_fps(void *ctx, struct m_property *prop,
|
2015-03-12 22:41:25 +00:00
|
|
|
int action, void *arg)
|
2015-03-10 13:50:56 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-11-09 12:52:46 +00:00
|
|
|
double fps = mpctx->opts->frame_drop_fps;
|
2015-03-10 13:50:56 +00:00
|
|
|
struct vo *vo = mpctx->video_out;
|
2015-11-09 12:52:46 +00:00
|
|
|
if (vo)
|
|
|
|
fps = vo_get_display_fps(vo);
|
|
|
|
if (action == M_PROPERTY_SET) {
|
|
|
|
int ret = mp_property_generic_option(mpctx, prop, action, arg);
|
|
|
|
if (vo)
|
|
|
|
vo_event(vo, VO_EVENT_WIN_STATE);
|
|
|
|
return ret;
|
|
|
|
}
|
2015-03-13 12:14:11 +00:00
|
|
|
return m_property_double_ro(action, arg, fps);
|
2015-03-10 13:50:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-25 21:07:56 +00:00
|
|
|
static int mp_property_estimated_display_fps(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
double interval = vo_get_estimated_vsync_interval(vo);
|
|
|
|
if (interval <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_double_ro(action, arg, 1.0 / interval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_vsync_jitter(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
double stddev = vo_get_estimated_vsync_jitter(vo);
|
|
|
|
if (stddev < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_double_ro(action, arg, stddev);
|
|
|
|
}
|
|
|
|
|
2014-11-06 02:16:32 +00:00
|
|
|
static int mp_property_display_names(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct vo *vo = mpctx->video_out;
|
|
|
|
if (!vo)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
char** display_names;
|
|
|
|
if (vo_control(vo, VOCTRL_GET_DISPLAY_NAMES, &display_names) < 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
*(char ***)arg = display_names;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-10-24 13:34:53 +00:00
|
|
|
static int mp_property_vo_configured(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return m_property_flag_ro(action, arg,
|
|
|
|
mpctx->video_out && mpctx->video_out->config_ok);
|
|
|
|
}
|
|
|
|
|
2015-02-02 16:35:31 +00:00
|
|
|
static int mp_property_vo(void *ctx, struct m_property *p, int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return m_property_strdup_ro(action, arg,
|
|
|
|
mpctx->video_out ? mpctx->video_out->driver->name : NULL);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_osd_w(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-30 20:25:34 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-01-18 00:19:20 +00:00
|
|
|
struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd, OSDTYPE_OSD);
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_int_ro(action, arg, vo_res.w);
|
2013-09-30 20:25:34 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_osd_h(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-30 20:25:34 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-01-18 00:19:20 +00:00
|
|
|
struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd, OSDTYPE_OSD);
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_int_ro(action, arg, vo_res.h);
|
2013-09-30 20:25:34 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_osd_par(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-09-30 20:25:34 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-01-18 00:19:20 +00:00
|
|
|
struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd, OSDTYPE_OSD);
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return m_property_double_ro(action, arg, vo_res.display_par);
|
2013-09-30 20:25:34 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 22:12:59 +00:00
|
|
|
static int mp_property_osd_sym(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
char temp[20];
|
|
|
|
get_current_osd_sym(mpctx, temp, sizeof(temp));
|
|
|
|
return m_property_strdup_ro(action, arg, temp);
|
|
|
|
}
|
|
|
|
|
2014-09-17 22:49:55 +00:00
|
|
|
static int mp_property_osd_ass(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"0", SUB_PROP_STR(osd_ass_0)},
|
|
|
|
{"1", SUB_PROP_STR(osd_ass_1)},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
return m_property_read_sub(props, action, arg);
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Video fps (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_fps(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-11-28 23:34:53 +00:00
|
|
|
float fps = mpctx->d_video ? mpctx->d_video->fps : 0;
|
|
|
|
if (fps < 0.1 || !isfinite(fps))
|
|
|
|
return M_PROPERTY_UNAVAILABLE;;
|
|
|
|
return m_property_float_ro(action, arg, fps);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_vf_fps(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-05-07 22:49:21 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-05-07 22:49:21 +00:00
|
|
|
if (!mpctx->d_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
player: refactor display-sync frame duration calculations
Get rid of get_past_frame_durations(), which was a bit too messy. Add
a past_frames array, which contains the same information in a more
reasonable way. This also means that we can get the exact current and
past frame durations without going through awful stuff. (The main
problem is that vo_pts_history contains future frames as well, which is
needed for frame backstepping etc., but gets in the way here.)
Also disable the automatic disabling of display-sync if the frame
duration changes, and extend the frame durations allowed for display
sync. To allow arbitrarily high durations, vo.c needs to be changed
to pause and potentially redraw OSD while showing a single frame, so
they're still limited.
In an attempt to deal with VFR, calculate the overall speed using the
average FPS. The frame scheduling itself does not use the average FPS,
but the duration of the current frame. This does not work too well,
but provides a good base for further improvements.
Where this commit actually helps a lot is dealing with rounded
timestamps, e.g. if the container framerate is wrong or unknown, or
if the muxer wrote incorrectly rounded timestamps. While the rounding
errors apparently can't be get rid of completely in the general case,
this is still much better than e.g. disabling display-sync completely
just because some frame durations go out of bounds.
2015-11-13 21:45:40 +00:00
|
|
|
double avg = calc_average_frame_duration(mpctx);
|
|
|
|
if (avg <= 0)
|
2015-08-10 16:38:57 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
player: refactor display-sync frame duration calculations
Get rid of get_past_frame_durations(), which was a bit too messy. Add
a past_frames array, which contains the same information in a more
reasonable way. This also means that we can get the exact current and
past frame durations without going through awful stuff. (The main
problem is that vo_pts_history contains future frames as well, which is
needed for frame backstepping etc., but gets in the way here.)
Also disable the automatic disabling of display-sync if the frame
duration changes, and extend the frame durations allowed for display
sync. To allow arbitrarily high durations, vo.c needs to be changed
to pause and potentially redraw OSD while showing a single frame, so
they're still limited.
In an attempt to deal with VFR, calculate the overall speed using the
average FPS. The frame scheduling itself does not use the average FPS,
but the duration of the current frame. This does not work too well,
but provides a good base for further improvements.
Where this commit actually helps a lot is dealing with rounded
timestamps, e.g. if the container framerate is wrong or unknown, or
if the muxer wrote incorrectly rounded timestamps. While the rounding
errors apparently can't be get rid of completely in the general case,
this is still much better than e.g. disabling display-sync completely
just because some frame durations go out of bounds.
2015-11-13 21:45:40 +00:00
|
|
|
return m_property_double_ro(action, arg, 1.0 / avg);
|
2014-05-07 22:49:21 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Video aspect (RO)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_aspect(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-09-22 03:13:29 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET: {
|
2013-09-26 14:53:17 +00:00
|
|
|
mpctx->opts->movie_aspect = *(float *)arg;
|
2015-08-04 16:04:48 +00:00
|
|
|
if (mpctx->d_video) {
|
|
|
|
reinit_video_filters(mpctx);
|
|
|
|
mp_force_video_refresh(mpctx);
|
|
|
|
}
|
2012-09-22 03:13:29 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2013-09-26 14:53:17 +00:00
|
|
|
case M_PROPERTY_GET: {
|
2015-08-04 16:04:48 +00:00
|
|
|
float aspect = mpctx->opts->movie_aspect;
|
|
|
|
if (mpctx->d_video && aspect <= 0) {
|
|
|
|
struct dec_video *d_video = mpctx->d_video;
|
|
|
|
struct sh_video *sh_video = d_video->header->video;
|
|
|
|
struct mp_image_params *params = &d_video->vfilter->override_params;
|
2015-12-19 19:04:31 +00:00
|
|
|
if (params && params->p_w > 0 && params->p_h > 0) {
|
|
|
|
int d_w, d_h;
|
|
|
|
mp_image_params_get_dsize(params, &d_w, &d_h);
|
|
|
|
aspect = (float)d_w / d_h;
|
2015-08-04 16:04:48 +00:00
|
|
|
} else if (sh_video->disp_w && sh_video->disp_h) {
|
|
|
|
aspect = (float)sh_video->disp_w / sh_video->disp_h;
|
|
|
|
}
|
2013-09-26 14:53:17 +00:00
|
|
|
}
|
|
|
|
*(float *)arg = aspect;
|
2012-09-22 03:13:29 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_FLOAT,
|
|
|
|
.flags = CONF_RANGE,
|
|
|
|
.min = -1,
|
|
|
|
.max = 10,
|
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
2013-09-26 14:53:17 +00:00
|
|
|
}
|
2012-09-22 03:13:29 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2013-05-14 21:14:23 +00:00
|
|
|
// For OSD and subtitle related properties using the generic option bridge.
|
2012-09-18 18:07:24 +00:00
|
|
|
// - Fail as unavailable if no video is active
|
|
|
|
// - Trigger OSD state update when property is set
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_osd_helper(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2012-09-18 18:07:24 +00:00
|
|
|
if (action == M_PROPERTY_SET)
|
2013-05-14 21:14:23 +00:00
|
|
|
osd_changed_all(mpctx->osd);
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Selected subtitles (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_sub(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_switch_track(prop, action, arg, ctx, 0, STREAM_SUB);
|
2013-12-24 16:46:14 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_sub2(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-12-24 16:46:14 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_switch_track(prop, action, arg, ctx, 1, STREAM_SUB);
|
2007-11-25 04:09:04 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Subtitle delay (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_sub_delay(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2013-10-01 23:32:03 +00:00
|
|
|
if (!mpctx->video_out)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-09-18 13:31:46 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_PRINT:
|
2013-04-28 23:49:20 +00:00
|
|
|
*(char **)arg = format_delay(opts->sub_delay);
|
2012-09-18 13:31:46 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_osd_helper(mpctx, prop, action, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_sub_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2012-09-25 01:24:38 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2013-10-01 23:32:03 +00:00
|
|
|
if (!mpctx->video_out)
|
2012-09-25 01:24:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2013-04-28 23:49:20 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d/100", opts->sub_pos);
|
2012-09-25 01:24:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_osd_helper(mpctx, prop, action, arg);
|
2012-09-25 01:24:38 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 11:41:19 +00:00
|
|
|
static int mp_property_cursor_autohide(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
int old_value = opts->cursor_autohide_delay;
|
|
|
|
int r = mp_property_generic_option(mpctx, prop, action, arg);
|
|
|
|
if (opts->cursor_autohide_delay != old_value)
|
|
|
|
mpctx->mouse_timer = 0;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
static int prop_stream_ctrl(struct MPContext *mpctx, int ctrl, void *arg)
|
2012-08-19 16:07:06 +00:00
|
|
|
{
|
2014-07-16 20:40:21 +00:00
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
int r = demux_stream_control(mpctx->demuxer, ctrl, arg);
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
switch (r) {
|
|
|
|
case STREAM_OK: return M_PROPERTY_OK;
|
|
|
|
case STREAM_UNSUPPORTED: return M_PROPERTY_UNAVAILABLE;
|
|
|
|
default: return M_PROPERTY_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_tv_norm(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return prop_stream_ctrl(ctx, STREAM_CTRL_TV_SET_NORM, *(char **)arg);
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
case M_PROPERTY_SWITCH:
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return prop_stream_ctrl(ctx, STREAM_CTRL_TV_STEP_NORM, NULL);
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
|
|
|
|
return M_PROPERTY_OK;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_tv_scan(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return prop_stream_ctrl(ctx, STREAM_CTRL_TV_SET_SCAN, arg);
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_FLAG};
|
|
|
|
return M_PROPERTY_OK;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2012-08-19 16:07:06 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// TV color settings (RW)
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_tv_color(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
int req[2] = {(intptr_t)prop->priv};
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
req[1] = *(int *)arg;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return prop_stream_ctrl(ctx, STREAM_CTRL_SET_TV_COLORS, req);
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
case M_PROPERTY_GET: {
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
int r = prop_stream_ctrl(ctx, STREAM_CTRL_GET_TV_COLORS, req);
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
if (r == M_PROPERTY_OK)
|
|
|
|
*(int *)arg = req[1];
|
|
|
|
return r;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.flags = M_OPT_RANGE,
|
|
|
|
.min = -100,
|
|
|
|
.max = 100,
|
|
|
|
};
|
|
|
|
return M_PROPERTY_OK;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_tv_freq(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
{
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return prop_stream_ctrl(ctx, STREAM_CTRL_SET_TV_FREQ, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_GET:
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return prop_stream_ctrl(ctx, STREAM_CTRL_GET_TV_FREQ, arg);
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_FLOAT};
|
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_tv_channel(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
{
|
|
|
|
switch (action) {
|
2014-06-25 15:41:16 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
|
|
|
|
return M_PROPERTY_OK;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
case M_PROPERTY_SET:
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return prop_stream_ctrl(ctx, STREAM_CTRL_TV_SET_CHAN, *(char **)arg);
|
2015-02-02 15:47:32 +00:00
|
|
|
case M_PROPERTY_GET:
|
|
|
|
return prop_stream_ctrl(ctx, STREAM_CTRL_TV_GET_CHAN, arg);
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
case M_PROPERTY_SWITCH: {
|
|
|
|
struct m_property_switch_arg *sa = arg;
|
|
|
|
int dir = sa->inc >= 0 ? 1 : -1;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return prop_stream_ctrl(ctx, STREAM_CTRL_TV_STEP_CHAN, &dir);
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_dvb_channel(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
int r;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
mpctx->last_dvb_step = 1;
|
|
|
|
r = prop_stream_ctrl(mpctx, STREAM_CTRL_DVB_SET_CHANNEL, arg);
|
2015-07-08 19:31:31 +00:00
|
|
|
if (r == M_PROPERTY_OK && !mpctx->stop_play)
|
2015-07-02 12:38:03 +00:00
|
|
|
mpctx->stop_play = PT_RELOAD_FILE;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
return r;
|
|
|
|
case M_PROPERTY_SWITCH: {
|
|
|
|
struct m_property_switch_arg *sa = arg;
|
|
|
|
int dir = sa->inc >= 0 ? 1 : -1;
|
|
|
|
mpctx->last_dvb_step = dir;
|
|
|
|
r = prop_stream_ctrl(mpctx, STREAM_CTRL_DVB_STEP_CHANNEL, &dir);
|
2015-07-08 19:31:31 +00:00
|
|
|
if (r == M_PROPERTY_OK && !mpctx->stop_play)
|
2015-07-02 12:38:03 +00:00
|
|
|
mpctx->stop_play = PT_RELOAD_FILE;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
return r;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = &m_option_type_intpair};
|
|
|
|
return M_PROPERTY_OK;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_playlist_pos(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-06-28 20:16:29 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2013-06-28 20:16:29 +00:00
|
|
|
struct playlist *pl = mpctx->playlist;
|
|
|
|
if (!pl->first)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
int pos = playlist_entry_to_index(pl, pl->current);
|
|
|
|
if (pos < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
*(int *)arg = pos;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
struct playlist_entry *e = playlist_entry_from_index(pl, *(int *)arg);
|
|
|
|
if (!e)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
mp_set_playlist_entry(mpctx, e);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET_TYPE: {
|
|
|
|
struct m_option opt = {
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.flags = CONF_RANGE,
|
|
|
|
.min = 0,
|
|
|
|
.max = playlist_entry_count(pl) - 1,
|
|
|
|
};
|
|
|
|
*(struct m_option *)arg = opt;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-02-15 15:54:55 +00:00
|
|
|
static int get_playlist_entry(int item, int action, void *arg, void *ctx)
|
2013-06-28 20:16:29 +00:00
|
|
|
{
|
2014-02-15 15:54:55 +00:00
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct playlist_entry *e = playlist_entry_from_index(mpctx->playlist, item);
|
|
|
|
if (!e)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
|
2014-11-17 21:43:30 +00:00
|
|
|
bool current = mpctx->playlist->current == e;
|
|
|
|
bool playing = mpctx->playing == e;
|
2014-02-15 15:54:55 +00:00
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"filename", SUB_PROP_STR(e->filename)},
|
2014-11-17 21:43:30 +00:00
|
|
|
{"current", SUB_PROP_FLAG(1), .unavailable = !current},
|
2014-11-17 21:07:50 +00:00
|
|
|
{"playing", SUB_PROP_FLAG(1), .unavailable = !playing},
|
2015-07-10 19:22:35 +00:00
|
|
|
{"title", SUB_PROP_STR(e->title), .unavailable = !e->title},
|
2014-02-15 15:54:55 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
2013-06-28 20:16:29 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_playlist(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-05-15 00:17:47 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
MPContext *mpctx = ctx;
|
2014-02-15 15:54:55 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2013-05-15 00:17:47 +00:00
|
|
|
char *res = talloc_strdup(NULL, "");
|
|
|
|
|
|
|
|
for (struct playlist_entry *e = mpctx->playlist->first; e; e = e->next)
|
|
|
|
{
|
2014-12-27 20:19:52 +00:00
|
|
|
char *p = e->filename;
|
|
|
|
if (!mp_is_url(bstr0(p))) {
|
|
|
|
char *s = mp_basename(e->filename);
|
|
|
|
if (s[0])
|
|
|
|
p = s;
|
|
|
|
}
|
2013-05-15 00:17:47 +00:00
|
|
|
if (mpctx->playlist->current == e) {
|
2014-12-27 20:19:52 +00:00
|
|
|
res = talloc_asprintf_append(res, "> %s <\n", p);
|
2013-05-15 00:17:47 +00:00
|
|
|
} else {
|
2014-12-27 20:19:52 +00:00
|
|
|
res = talloc_asprintf_append(res, "%s\n", p);
|
2013-05-15 00:17:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2014-02-15 15:54:55 +00:00
|
|
|
return m_property_read_list(action, arg, playlist_entry_count(mpctx->playlist),
|
|
|
|
get_playlist_entry, mpctx);
|
2013-05-15 00:17:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 11:41:38 +00:00
|
|
|
static char *print_obj_osd_list(struct m_obj_settings *list)
|
|
|
|
{
|
|
|
|
char *res = NULL;
|
|
|
|
for (int n = 0; list && list[n].name; n++) {
|
|
|
|
res = talloc_asprintf_append(res, "%s [", list[n].name);
|
|
|
|
for (int i = 0; list[n].attribs && list[n].attribs[i]; i += 2) {
|
|
|
|
res = talloc_asprintf_append(res, "%s%s=%s", i > 0 ? " " : "",
|
|
|
|
list[n].attribs[i],
|
|
|
|
list[n].attribs[i + 1]);
|
|
|
|
}
|
|
|
|
res = talloc_asprintf_append(res, "]\n");
|
|
|
|
}
|
|
|
|
if (!res)
|
|
|
|
res = talloc_strdup(NULL, "(empty)");
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int property_filter(struct m_property *prop, int action, void *arg,
|
2013-08-03 11:41:38 +00:00
|
|
|
MPContext *mpctx, enum stream_type mt)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_PRINT: {
|
|
|
|
struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
|
|
|
|
bstr0(prop->name));
|
|
|
|
*(char **)arg = print_obj_osd_list(*(struct m_obj_settings **)opt->data);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
return set_filters(mpctx, mt, *(struct m_obj_settings **)arg) >= 0
|
|
|
|
? M_PROPERTY_OK : M_PROPERTY_ERROR;
|
|
|
|
}
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
2013-08-03 11:41:38 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_vf(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-08-03 11:41:38 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_filter(prop, action, arg, ctx, STREAM_VIDEO);
|
2013-08-03 11:41:38 +00:00
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_af(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-08-03 11:41:38 +00:00
|
|
|
{
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return property_filter(prop, action, arg, ctx, STREAM_AUDIO);
|
2013-08-03 11:41:38 +00:00
|
|
|
}
|
|
|
|
|
2014-11-17 23:09:42 +00:00
|
|
|
static int mp_property_ab_loop(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
2014-11-18 19:28:54 +00:00
|
|
|
struct MPContext *mpctx = ctx;
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2014-11-17 23:09:42 +00:00
|
|
|
if (action == M_PROPERTY_KEY_ACTION) {
|
|
|
|
double val;
|
|
|
|
if (mp_property_generic_option(mpctx, prop, M_PROPERTY_GET, &val) < 1)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
|
|
|
|
return property_time(action, arg, val);
|
|
|
|
}
|
2014-11-18 19:28:54 +00:00
|
|
|
int r = mp_property_generic_option(mpctx, prop, action, arg);
|
|
|
|
if (r > 0 && action == M_PROPERTY_SET) {
|
|
|
|
if (strcmp(prop->name, "ab-loop-b") == 0) {
|
|
|
|
double now = mpctx->playback_pts;
|
|
|
|
if (now != MP_NOPTS_VALUE && opts->ab_loop[0] != MP_NOPTS_VALUE &&
|
|
|
|
opts->ab_loop[1] != MP_NOPTS_VALUE && now >= opts->ab_loop[1])
|
2015-03-04 16:21:05 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, opts->ab_loop[0],
|
|
|
|
MPSEEK_EXACT, false);
|
2014-11-18 19:28:54 +00:00
|
|
|
}
|
|
|
|
// Update if visible
|
|
|
|
set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
|
|
|
|
}
|
|
|
|
return r;
|
2014-11-17 23:09:42 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 00:00:58 +00:00
|
|
|
static int mp_property_packet_bitrate(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
2015-04-20 18:52:16 +00:00
|
|
|
int type = (uintptr_t)prop->priv & ~0x100;
|
|
|
|
bool old = (uintptr_t)prop->priv & 0x100;
|
2014-12-12 00:00:58 +00:00
|
|
|
|
2015-10-23 12:58:01 +00:00
|
|
|
struct demuxer *demuxer = NULL;
|
|
|
|
if (mpctx->current_track[0][type])
|
|
|
|
demuxer = mpctx->current_track[0][type]->demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
demuxer = mpctx->demuxer;
|
|
|
|
if (!demuxer)
|
2014-12-12 00:00:58 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
double r[STREAM_TYPE_COUNT];
|
2015-10-23 12:58:01 +00:00
|
|
|
if (demux_control(demuxer, DEMUXER_CTRL_GET_BITRATE_STATS, &r) < 1)
|
2014-12-12 00:00:58 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2015-10-23 12:53:19 +00:00
|
|
|
if (r[type] < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2014-12-12 00:00:58 +00:00
|
|
|
|
2015-04-20 18:52:16 +00:00
|
|
|
// r[type] is in bytes/second -> bits
|
|
|
|
double rate = r[type] * 8;
|
|
|
|
|
|
|
|
// Same story, but used kilobits for some reason.
|
|
|
|
if (old)
|
|
|
|
return m_property_int64_ro(action, arg, rate / 1000.0 + 0.5);
|
|
|
|
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
rate /= 1000;
|
|
|
|
if (rate < 1000) {
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d kbps", (int)rate);
|
|
|
|
} else {
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%.3f mbps", rate / 1000.0);
|
|
|
|
}
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return m_property_int64_ro(action, arg, rate);
|
2014-12-12 00:00:58 +00:00
|
|
|
}
|
|
|
|
|
2015-03-24 21:00:01 +00:00
|
|
|
static int mp_property_cwd(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
char *cwd = mp_getcwd(NULL);
|
|
|
|
if (!cwd)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
*(char **)arg = cwd;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-05-23 13:26:55 +00:00
|
|
|
static int mp_property_protocols(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(char ***)arg = stream_get_proto_list();
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-11-02 16:44:24 +00:00
|
|
|
static int mp_property_version(void *ctx, struct m_property *prop,
|
2014-11-17 23:09:42 +00:00
|
|
|
int action, void *arg)
|
2014-11-02 16:44:24 +00:00
|
|
|
{
|
|
|
|
return m_property_strdup_ro(action, arg, mpv_version);
|
|
|
|
}
|
|
|
|
|
2014-11-13 15:18:40 +00:00
|
|
|
static int mp_property_configuration(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
return m_property_strdup_ro(action, arg, CONFIGURATION);
|
|
|
|
}
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static int mp_property_alias(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2013-04-14 22:22:51 +00:00
|
|
|
{
|
|
|
|
const char *real_property = prop->priv;
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
return mp_property_do(real_property, action, arg, ctx);
|
2013-04-14 22:22:51 +00:00
|
|
|
}
|
|
|
|
|
2015-05-22 18:01:12 +00:00
|
|
|
static int mp_property_deprecated_alias(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
const char *real_property = prop->priv;
|
|
|
|
if (action == M_PROPERTY_SET || action == M_PROPERTY_GET ||
|
|
|
|
action == M_PROPERTY_PRINT)
|
|
|
|
{
|
|
|
|
for (int n = 0; n < cmd->num_warned_deprecated; n++) {
|
|
|
|
if (strcmp(cmd->warned_deprecated[n], prop->name) == 0)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
MP_WARN(mpctx, "Warning: property '%s' was replaced with '%s' and "
|
|
|
|
"might be removed in the future.\n", prop->name, real_property);
|
|
|
|
MP_TARRAY_APPEND(cmd, cmd->warned_deprecated, cmd->num_warned_deprecated,
|
|
|
|
(char *)prop->name);
|
|
|
|
|
|
|
|
done:;
|
|
|
|
}
|
|
|
|
return mp_property_do(real_property, action, arg, ctx);
|
|
|
|
}
|
|
|
|
|
2014-10-15 20:39:33 +00:00
|
|
|
static int access_options(struct m_property_action_arg *ka, bool local,
|
|
|
|
MPContext *mpctx)
|
2013-07-25 21:36:01 +00:00
|
|
|
{
|
|
|
|
struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
|
|
|
|
bstr0(ka->key));
|
|
|
|
if (!opt)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
2013-07-27 19:24:44 +00:00
|
|
|
if (!opt->data)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-07-25 21:36:01 +00:00
|
|
|
|
|
|
|
switch (ka->action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
m_option_copy(opt->opt, ka->arg, opt->data);
|
|
|
|
return M_PROPERTY_OK;
|
2014-05-18 16:57:02 +00:00
|
|
|
case M_PROPERTY_SET: {
|
2014-10-15 20:39:33 +00:00
|
|
|
if (local && !mpctx->playing)
|
|
|
|
return M_PROPERTY_ERROR;
|
|
|
|
int flags = M_SETOPT_RUNTIME | (local ? M_SETOPT_BACKUP : 0);
|
|
|
|
int r = m_config_set_option_raw(mpctx->mconfig, opt, ka->arg, flags);
|
2014-05-18 16:57:02 +00:00
|
|
|
return r < 0 ? M_PROPERTY_ERROR : M_PROPERTY_OK;
|
|
|
|
}
|
2013-07-25 21:36:01 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)ka->arg = *opt->opt;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2014-02-24 20:18:53 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
2013-07-25 21:36:01 +00:00
|
|
|
|
2014-10-15 20:39:33 +00:00
|
|
|
static int access_option_list(int action, void *arg, bool local, MPContext *mpctx)
|
2014-02-24 20:18:53 +00:00
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(char ***)arg = m_config_list_options(NULL, mpctx->mconfig);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_KEY_ACTION:
|
2014-10-15 20:39:33 +00:00
|
|
|
return access_options(arg, local, mpctx);
|
2014-02-24 20:18:53 +00:00
|
|
|
}
|
2013-07-25 21:36:01 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-10-15 20:39:33 +00:00
|
|
|
|
|
|
|
static int mp_property_options(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return access_option_list(action, arg, false, mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_local_options(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
return access_option_list(action, arg, true, mpctx);
|
|
|
|
}
|
|
|
|
|
2014-11-13 16:27:31 +00:00
|
|
|
static int mp_property_option_info(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
2014-11-07 15:33:41 +00:00
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_KEY_ACTION: {
|
|
|
|
struct m_property_action_arg *ka = arg;
|
|
|
|
bstr key;
|
|
|
|
char *rem;
|
|
|
|
m_property_split_path(ka->key, &key, &rem);
|
|
|
|
struct m_config_option *co = m_config_get_co(mpctx->mconfig, key);
|
|
|
|
if (!co)
|
|
|
|
return M_PROPERTY_UNKNOWN;
|
|
|
|
|
2014-11-13 17:00:07 +00:00
|
|
|
union m_option_value def = {0};
|
|
|
|
if (co->default_data)
|
|
|
|
memcpy(&def, co->default_data, co->opt->type->size);
|
|
|
|
|
|
|
|
const struct m_option *opt = co->opt;
|
|
|
|
bool has_minmax =
|
|
|
|
opt->type == &m_option_type_int ||
|
|
|
|
opt->type == &m_option_type_int64 ||
|
|
|
|
opt->type == &m_option_type_float ||
|
|
|
|
opt->type == &m_option_type_double;
|
|
|
|
char **choices = NULL;
|
|
|
|
|
|
|
|
if (opt->type == &m_option_type_choice) {
|
|
|
|
has_minmax = true;
|
|
|
|
struct m_opt_choice_alternatives *alt = opt->priv;
|
|
|
|
int num = 0;
|
|
|
|
for ( ; alt->name; alt++)
|
|
|
|
MP_TARRAY_APPEND(NULL, choices, num, alt->name);
|
|
|
|
MP_TARRAY_APPEND(NULL, choices, num, NULL);
|
2014-11-14 13:52:51 +00:00
|
|
|
}
|
|
|
|
if (opt->type == &m_option_type_obj_settings_list) {
|
|
|
|
struct m_obj_list *objs = opt->priv;
|
|
|
|
int num = 0;
|
|
|
|
for (int n = 0; ; n++) {
|
|
|
|
struct m_obj_desc desc = {0};
|
|
|
|
if (!objs->get_desc(&desc, n))
|
|
|
|
break;
|
|
|
|
MP_TARRAY_APPEND(NULL, choices, num, (char *)desc.name);
|
|
|
|
}
|
|
|
|
MP_TARRAY_APPEND(NULL, choices, num, NULL);
|
2014-11-13 17:00:07 +00:00
|
|
|
}
|
|
|
|
|
2014-11-07 15:33:41 +00:00
|
|
|
struct m_sub_property props[] = {
|
2014-11-13 17:00:07 +00:00
|
|
|
{"name", SUB_PROP_STR(co->name)},
|
|
|
|
{"type", SUB_PROP_STR(opt->type->name)},
|
2014-11-07 15:33:41 +00:00
|
|
|
{"set-from-commandline", SUB_PROP_FLAG(co->is_set_from_cmdline)},
|
2015-07-23 20:59:04 +00:00
|
|
|
{"set-locally", SUB_PROP_FLAG(co->is_set_locally)},
|
2014-11-13 17:00:07 +00:00
|
|
|
{"default-value", *opt, def},
|
|
|
|
{"min", SUB_PROP_DOUBLE(opt->min),
|
|
|
|
.unavailable = !(has_minmax && (opt->flags & M_OPT_MIN))},
|
|
|
|
{"max", SUB_PROP_DOUBLE(opt->max),
|
|
|
|
.unavailable = !(has_minmax && (opt->flags & M_OPT_MAX))},
|
|
|
|
{"choices", .type = {.type = CONF_TYPE_STRING_LIST},
|
|
|
|
.value = {.string_list = choices}, .unavailable = !choices},
|
2014-11-07 15:33:41 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2014-11-08 09:19:17 +00:00
|
|
|
struct m_property_action_arg next_ka = *ka;
|
|
|
|
next_ka.key = rem;
|
2014-11-13 17:00:07 +00:00
|
|
|
int r = m_property_read_sub(props, M_PROPERTY_KEY_ACTION, &next_ka);
|
|
|
|
talloc_free(choices);
|
|
|
|
return r;
|
2014-11-07 15:33:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2014-08-01 23:35:32 +00:00
|
|
|
static const struct m_property mp_properties[];
|
|
|
|
|
|
|
|
static int mp_property_list(void *ctx, struct m_property *prop,
|
|
|
|
int action, void *arg)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
char **list = NULL;
|
|
|
|
int num = 0;
|
|
|
|
for (int n = 0; mp_properties[n].name; n++) {
|
|
|
|
MP_TARRAY_APPEND(NULL, list, num,
|
|
|
|
talloc_strdup(NULL, mp_properties[n].name));
|
|
|
|
}
|
|
|
|
MP_TARRAY_APPEND(NULL, list, num, NULL);
|
|
|
|
*(char ***)arg = list;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-04-14 22:22:51 +00:00
|
|
|
// Redirect a property name to another
|
|
|
|
#define M_PROPERTY_ALIAS(name, real_property) \
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{(name), mp_property_alias, .priv = (real_property)}
|
2014-02-15 15:42:48 +00:00
|
|
|
|
2015-05-22 18:01:12 +00:00
|
|
|
#define M_PROPERTY_DEPRECATED_ALIAS(name, real_property) \
|
|
|
|
{(name), mp_property_deprecated_alias, .priv = (real_property)}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// All properties available in MPlayer.
|
|
|
|
/** \ingroup Properties
|
|
|
|
*/
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
static const struct m_property mp_properties[] = {
|
2007-02-21 00:49:24 +00:00
|
|
|
// General
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"osd-level", mp_property_generic_option},
|
|
|
|
{"osd-scale", property_osd_helper},
|
|
|
|
{"loop", mp_property_generic_option},
|
|
|
|
{"loop-file", mp_property_generic_option},
|
|
|
|
{"speed", mp_property_playback_speed},
|
2015-08-10 16:40:16 +00:00
|
|
|
{"audio-speed-correction", mp_property_av_speed_correction, .priv = "a"},
|
|
|
|
{"video-speed-correction", mp_property_av_speed_correction, .priv = "v"},
|
2015-08-10 16:43:25 +00:00
|
|
|
{"display-sync-active", mp_property_display_sync_active},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"filename", mp_property_filename},
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
{"stream-open-filename", mp_property_stream_open_filename},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"file-size", mp_property_file_size},
|
|
|
|
{"path", mp_property_path},
|
|
|
|
{"media-title", mp_property_media_title},
|
|
|
|
{"stream-path", mp_property_stream_path},
|
|
|
|
{"stream-capture", mp_property_stream_capture},
|
|
|
|
{"demuxer", mp_property_demuxer},
|
2015-01-23 14:59:06 +00:00
|
|
|
{"file-format", mp_property_file_format},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"stream-pos", mp_property_stream_pos},
|
|
|
|
{"stream-end", mp_property_stream_end},
|
2015-05-22 18:02:47 +00:00
|
|
|
{"duration", mp_property_duration},
|
|
|
|
M_PROPERTY_DEPRECATED_ALIAS("length", "duration"),
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"avsync", mp_property_avsync},
|
|
|
|
{"total-avsync-change", mp_property_total_avsync_change},
|
|
|
|
{"drop-frame-count", mp_property_drop_frame_cnt},
|
2015-10-30 13:05:41 +00:00
|
|
|
{"mistimed-frame-count", mp_property_mistimed_frame_count},
|
2015-11-13 21:48:32 +00:00
|
|
|
{"vsync-ratio", mp_property_vsync_ratio},
|
video: add VO framedropping mode
This mostly uses the same idea as with vo_vdpau.c, but much simplified.
On X11, it tries to get the display framerate with XF86VM, and limits
the frequency of new video frames against it. Note that this is an old
extension, and is confirmed not to work correctly with multi-monitor
setups. But we're using it because it was already around (it is also
used by vo_vdpau).
This attempts to predict the next vsync event by using the time of the
last frame and the display FPS. Even if that goes completely wrong,
the results are still relatively good.
On other systems, or if the X11 code doesn't return a display FPS, a
framerate of 1000 is assumed. This is infinite for all practical
purposes, and means that only frames which are definitely too late are
dropped. This probably has worse results, but is still useful.
"--framedrop=yes" is basically replaced with "--framedrop=decoder". The
old framedropping mode is kept around, and should perhaps be improved.
Dropping on the decoder level is still useful if decoding itself is too
slow.
2014-08-15 21:33:33 +00:00
|
|
|
{"vo-drop-frame-count", mp_property_vo_drop_frame_count},
|
2015-11-13 21:41:41 +00:00
|
|
|
{"vo-delayed-frame-count", mp_property_vo_delayed_frame_count},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"percent-pos", mp_property_percent_pos},
|
|
|
|
{"time-start", mp_property_time_start},
|
|
|
|
{"time-pos", mp_property_time_pos},
|
|
|
|
{"time-remaining", mp_property_remaining},
|
|
|
|
{"playtime-remaining", mp_property_playtime_remaining},
|
2014-06-29 17:27:46 +00:00
|
|
|
{"playback-time", mp_property_playback_time},
|
2014-07-14 23:49:02 +00:00
|
|
|
{"disc-title", mp_property_disc_title},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"chapter", mp_property_chapter},
|
|
|
|
{"edition", mp_property_edition},
|
2014-07-14 23:49:02 +00:00
|
|
|
{"disc-titles", mp_property_disc_titles},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"chapters", mp_property_chapters},
|
|
|
|
{"editions", mp_property_editions},
|
2014-07-14 23:49:02 +00:00
|
|
|
{"angle", mp_property_angle},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"metadata", mp_property_metadata},
|
2014-12-29 22:03:39 +00:00
|
|
|
{"filtered-metadata", mp_property_filtered_metadata},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"chapter-metadata", mp_property_chapter_metadata},
|
2015-09-11 21:04:02 +00:00
|
|
|
{"vf-metadata", mp_property_filter_metadata, .priv = "vf"},
|
|
|
|
{"af-metadata", mp_property_filter_metadata, .priv = "af"},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"pause", mp_property_pause},
|
|
|
|
{"core-idle", mp_property_core_idle},
|
|
|
|
{"eof-reached", mp_property_eof_reached},
|
2014-08-07 22:13:27 +00:00
|
|
|
{"seeking", mp_property_seeking},
|
2014-10-21 11:32:30 +00:00
|
|
|
{"playback-abort", mp_property_playback_abort},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"cache", mp_property_cache},
|
2014-07-01 22:14:30 +00:00
|
|
|
{"cache-free", mp_property_cache_free},
|
|
|
|
{"cache-used", mp_property_cache_used},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"cache-size", mp_property_cache_size},
|
2014-07-31 02:25:39 +00:00
|
|
|
{"cache-idle", mp_property_cache_idle},
|
2014-08-28 15:48:31 +00:00
|
|
|
{"demuxer-cache-duration", mp_property_demuxer_cache_duration},
|
2015-04-20 21:47:13 +00:00
|
|
|
{"demuxer-cache-time", mp_property_demuxer_cache_time},
|
2014-08-28 15:48:31 +00:00
|
|
|
{"demuxer-cache-idle", mp_property_demuxer_cache_idle},
|
2014-10-07 20:07:07 +00:00
|
|
|
{"cache-buffering-state", mp_property_cache_buffering},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"paused-for-cache", mp_property_paused_for_cache},
|
|
|
|
{"hr-seek", mp_property_generic_option},
|
|
|
|
{"clock", mp_property_clock},
|
|
|
|
{"seekable", mp_property_seekable},
|
2015-01-26 12:46:33 +00:00
|
|
|
{"partially-seekable", mp_property_partially_seekable},
|
2014-12-10 13:42:57 +00:00
|
|
|
{"idle", mp_property_idle},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
|
|
|
|
{"chapter-list", mp_property_list_chapters},
|
|
|
|
{"track-list", property_list_tracks},
|
|
|
|
{"edition-list", property_list_editions},
|
2014-12-13 19:25:31 +00:00
|
|
|
{"disc-title-list", mp_property_list_disc_titles},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
|
|
|
|
{"playlist", mp_property_playlist},
|
|
|
|
{"playlist-pos", mp_property_playlist_pos},
|
2014-02-15 15:54:55 +00:00
|
|
|
M_PROPERTY_ALIAS("playlist-count", "playlist/count"),
|
2013-05-15 00:17:47 +00:00
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
// Audio
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"volume", mp_property_volume},
|
2014-08-29 07:48:45 +00:00
|
|
|
{"mute", mp_property_mute},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"audio-delay", mp_property_audio_delay},
|
2015-05-22 18:05:04 +00:00
|
|
|
{"audio-codec-name", mp_property_audio_codec_name},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"audio-codec", mp_property_audio_codec},
|
2015-05-22 18:23:47 +00:00
|
|
|
{"audio-params", mp_property_audio_params},
|
|
|
|
{"audio-out-params", mp_property_audio_out_params},
|
2015-05-22 18:28:20 +00:00
|
|
|
M_PROPERTY_DEPRECATED_ALIAS("audio-samplerate", "audio-params/samplerate"),
|
|
|
|
M_PROPERTY_DEPRECATED_ALIAS("audio-channels", "audio-params/channel-count"),
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"aid", mp_property_audio},
|
|
|
|
{"balance", mp_property_balance},
|
|
|
|
{"volume-restore-data", mp_property_volrestore},
|
2014-10-27 11:16:32 +00:00
|
|
|
{"audio-device", mp_property_audio_device},
|
2014-10-10 17:46:21 +00:00
|
|
|
{"audio-device-list", mp_property_audio_devices},
|
2015-02-02 16:35:31 +00:00
|
|
|
{"current-ao", mp_property_ao},
|
2015-02-02 22:01:11 +00:00
|
|
|
{"audio-out-detected-device", mp_property_ao_detected_device},
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
// Video
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"fullscreen", mp_property_fullscreen},
|
|
|
|
{"deinterlace", mp_property_deinterlace},
|
2014-10-19 23:47:56 +00:00
|
|
|
{"field-dominance", mp_property_generic_option},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"ontop", mp_property_ontop},
|
|
|
|
{"border", mp_property_border},
|
2015-01-16 22:38:47 +00:00
|
|
|
{"on-all-workspaces", mp_property_all_workspaces},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"framedrop", mp_property_framedrop},
|
|
|
|
{"gamma", mp_property_video_color},
|
|
|
|
{"brightness", mp_property_video_color},
|
|
|
|
{"contrast", mp_property_video_color},
|
|
|
|
{"saturation", mp_property_video_color},
|
|
|
|
{"hue", mp_property_video_color},
|
2015-09-29 19:12:26 +00:00
|
|
|
{"video-output-levels", mp_property_video_color,
|
|
|
|
.priv = (void *)"output-levels"},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"panscan", panscan_property_helper},
|
|
|
|
{"video-zoom", panscan_property_helper},
|
|
|
|
{"video-align-x", panscan_property_helper},
|
|
|
|
{"video-align-y", panscan_property_helper},
|
|
|
|
{"video-pan-x", panscan_property_helper},
|
|
|
|
{"video-pan-y", panscan_property_helper},
|
|
|
|
{"video-unscaled", panscan_property_helper},
|
|
|
|
{"video-out-params", mp_property_vo_imgparams},
|
|
|
|
{"video-params", mp_property_vd_imgparams},
|
|
|
|
{"video-format", mp_property_video_format},
|
2015-11-22 17:54:22 +00:00
|
|
|
{"video-frame-info", mp_property_video_frame_info},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"video-codec", mp_property_video_codec},
|
2014-02-15 15:42:48 +00:00
|
|
|
M_PROPERTY_ALIAS("dwidth", "video-out-params/dw"),
|
|
|
|
M_PROPERTY_ALIAS("dheight", "video-out-params/dh"),
|
|
|
|
M_PROPERTY_ALIAS("width", "video-params/w"),
|
|
|
|
M_PROPERTY_ALIAS("height", "video-params/h"),
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"window-scale", mp_property_window_scale},
|
2014-10-24 13:34:53 +00:00
|
|
|
{"vo-configured", mp_property_vo_configured},
|
2015-02-02 16:35:31 +00:00
|
|
|
{"current-vo", mp_property_vo},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"fps", mp_property_fps},
|
|
|
|
{"estimated-vf-fps", mp_property_vf_fps},
|
|
|
|
{"video-aspect", mp_property_aspect},
|
|
|
|
{"vid", mp_property_video},
|
|
|
|
{"program", mp_property_program},
|
|
|
|
{"hwdec", mp_property_hwdec},
|
2015-05-25 19:44:48 +00:00
|
|
|
{"hwdec-active", mp_property_hwdec_active},
|
|
|
|
{"hwdec-detected", mp_property_detected_hwdec},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
|
2014-08-19 19:19:38 +00:00
|
|
|
{"estimated-frame-count", mp_property_frame_count},
|
|
|
|
{"estimated-frame-number", mp_property_frame_number},
|
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"osd-width", mp_property_osd_w},
|
|
|
|
{"osd-height", mp_property_osd_h},
|
|
|
|
{"osd-par", mp_property_osd_par},
|
2013-09-30 20:25:34 +00:00
|
|
|
|
2014-09-17 22:12:59 +00:00
|
|
|
{"osd-sym-cc", mp_property_osd_sym},
|
2014-09-17 22:49:55 +00:00
|
|
|
{"osd-ass-cc", mp_property_osd_ass},
|
2014-09-17 22:12:59 +00:00
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
// Subs
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"sid", mp_property_sub},
|
|
|
|
{"secondary-sid", mp_property_sub2},
|
|
|
|
{"sub-delay", mp_property_sub_delay},
|
|
|
|
{"sub-pos", mp_property_sub_pos},
|
|
|
|
{"sub-visibility", property_osd_helper},
|
|
|
|
{"sub-forced-only", property_osd_helper},
|
|
|
|
{"sub-scale", property_osd_helper},
|
2015-02-16 19:04:15 +00:00
|
|
|
{"sub-use-margins", property_osd_helper},
|
|
|
|
{"ass-force-margins", property_osd_helper},
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"ass-vsfilter-aspect-compat", property_osd_helper},
|
|
|
|
{"ass-style-override", property_osd_helper},
|
2007-02-21 00:49:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"vf", mp_property_vf},
|
|
|
|
{"af", mp_property_af},
|
|
|
|
|
2014-10-21 21:34:56 +00:00
|
|
|
{"video-rotate", video_simple_refresh_property},
|
2014-10-21 11:28:28 +00:00
|
|
|
|
2014-11-17 23:09:42 +00:00
|
|
|
{"ab-loop-a", mp_property_ab_loop},
|
|
|
|
{"ab-loop-b", mp_property_ab_loop},
|
|
|
|
|
2015-04-20 18:52:16 +00:00
|
|
|
#define PROPERTY_BITRATE(name, old, type) \
|
|
|
|
{name, mp_property_packet_bitrate, (void *)(uintptr_t)((type)|(old?0x100:0))}
|
|
|
|
PROPERTY_BITRATE("packet-video-bitrate", true, STREAM_VIDEO),
|
|
|
|
PROPERTY_BITRATE("packet-audio-bitrate", true, STREAM_AUDIO),
|
|
|
|
PROPERTY_BITRATE("packet-sub-bitrate", true, STREAM_SUB),
|
|
|
|
|
|
|
|
PROPERTY_BITRATE("video-bitrate", false, STREAM_VIDEO),
|
|
|
|
PROPERTY_BITRATE("audio-bitrate", false, STREAM_AUDIO),
|
|
|
|
PROPERTY_BITRATE("sub-bitrate", false, STREAM_SUB),
|
2014-12-12 00:00:58 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
#define PROPERTY_TV_COLOR(name, type) \
|
|
|
|
{name, mp_property_tv_color, (void *)(intptr_t)type}
|
|
|
|
PROPERTY_TV_COLOR("tv-brightness", TV_COLOR_BRIGHTNESS),
|
|
|
|
PROPERTY_TV_COLOR("tv-contrast", TV_COLOR_CONTRAST),
|
|
|
|
PROPERTY_TV_COLOR("tv-saturation", TV_COLOR_SATURATION),
|
|
|
|
PROPERTY_TV_COLOR("tv-hue", TV_COLOR_HUE),
|
|
|
|
{"tv-freq", mp_property_tv_freq},
|
|
|
|
{"tv-norm", mp_property_tv_norm},
|
|
|
|
{"tv-scan", mp_property_tv_scan},
|
|
|
|
{"tv-channel", mp_property_tv_channel},
|
|
|
|
{"dvb-channel", mp_property_dvb_channel},
|
2012-08-09 23:30:53 +00:00
|
|
|
|
2014-10-21 11:41:19 +00:00
|
|
|
{"cursor-autohide", mp_property_cursor_autohide},
|
|
|
|
|
2014-10-21 11:16:48 +00:00
|
|
|
#define TRACK_FF(name, type) \
|
|
|
|
{name, property_switch_track_ff, (void *)(intptr_t)type}
|
|
|
|
TRACK_FF("ff-vid", STREAM_VIDEO),
|
|
|
|
TRACK_FF("ff-aid", STREAM_AUDIO),
|
|
|
|
TRACK_FF("ff-sid", STREAM_SUB),
|
|
|
|
|
2014-11-02 19:48:45 +00:00
|
|
|
{"window-minimized", mp_property_win_minimized},
|
2014-11-06 02:16:32 +00:00
|
|
|
{"display-names", mp_property_display_names},
|
2015-03-10 13:50:56 +00:00
|
|
|
{"display-fps", mp_property_display_fps},
|
2015-11-25 21:07:56 +00:00
|
|
|
{"estimated-display-fps", mp_property_estimated_display_fps},
|
|
|
|
{"vsync-jitter", mp_property_vsync_jitter},
|
2014-11-02 19:48:45 +00:00
|
|
|
|
2015-03-24 21:00:01 +00:00
|
|
|
{"working-directory", mp_property_cwd},
|
|
|
|
|
2015-05-23 13:26:55 +00:00
|
|
|
{"protocol-list", mp_property_protocols},
|
|
|
|
|
2014-11-02 16:44:24 +00:00
|
|
|
{"mpv-version", mp_property_version},
|
2014-11-13 15:18:40 +00:00
|
|
|
{"mpv-configuration", mp_property_configuration},
|
2014-11-02 16:44:24 +00:00
|
|
|
|
command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)
This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:
int (*)(const m_option_t*, int, void*, void*)
but the actual function signatures were:
int (*)(m_option_t*, int, void*, MPContext *)
Two arguments were mismatched.
This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 00:11:39 +00:00
|
|
|
{"options", mp_property_options},
|
2014-10-15 20:39:33 +00:00
|
|
|
{"file-local-options", mp_property_local_options},
|
2014-11-13 16:27:31 +00:00
|
|
|
{"option-info", mp_property_option_info},
|
2014-08-01 23:35:32 +00:00
|
|
|
{"property-list", mp_property_list},
|
2013-07-25 21:36:01 +00:00
|
|
|
|
2015-03-30 21:52:28 +00:00
|
|
|
// compatibility
|
|
|
|
M_PROPERTY_ALIAS("video", "vid"),
|
|
|
|
M_PROPERTY_ALIAS("audio", "aid"),
|
|
|
|
M_PROPERTY_ALIAS("sub", "sid"),
|
|
|
|
M_PROPERTY_ALIAS("colormatrix", "video-params/colormatrix"),
|
|
|
|
M_PROPERTY_ALIAS("colormatrix-input-range", "video-params/colorlevels"),
|
|
|
|
M_PROPERTY_ALIAS("colormatrix-primaries", "video-params/primaries"),
|
2015-03-31 02:50:49 +00:00
|
|
|
M_PROPERTY_ALIAS("colormatrix-gamma", "video-params/gamma"),
|
2015-03-30 21:52:28 +00:00
|
|
|
|
2015-05-22 18:05:04 +00:00
|
|
|
M_PROPERTY_DEPRECATED_ALIAS("audio-format", "audio-codec-name"),
|
|
|
|
|
2012-08-09 23:30:53 +00:00
|
|
|
{0},
|
2007-02-21 00:49:24 +00:00
|
|
|
};
|
|
|
|
|
2014-04-05 21:54:21 +00:00
|
|
|
// Each entry describes which properties an event (possibly) changes.
|
2014-06-10 21:56:05 +00:00
|
|
|
#define E(x, ...) [x] = (const char*const[]){__VA_ARGS__, NULL}
|
|
|
|
static const char *const *const mp_event_property_change[] = {
|
2014-04-05 21:54:21 +00:00
|
|
|
E(MPV_EVENT_START_FILE, "*"),
|
|
|
|
E(MPV_EVENT_END_FILE, "*"),
|
|
|
|
E(MPV_EVENT_FILE_LOADED, "*"),
|
2015-02-01 17:25:12 +00:00
|
|
|
E(MP_EVENT_CHANGE_ALL, "*"),
|
2014-04-05 21:54:21 +00:00
|
|
|
E(MPV_EVENT_TRACKS_CHANGED, "track-list"),
|
|
|
|
E(MPV_EVENT_TRACK_SWITCHED, "vid", "video", "aid", "audio", "sid", "sub",
|
|
|
|
"secondary-sid"),
|
|
|
|
E(MPV_EVENT_IDLE, "*"),
|
2014-04-14 20:19:07 +00:00
|
|
|
E(MPV_EVENT_PAUSE, "pause", "paused-on-cache", "core-idle", "eof-reached"),
|
|
|
|
E(MPV_EVENT_UNPAUSE, "pause", "paused-on-cache", "core-idle", "eof-reached"),
|
2014-04-05 21:54:21 +00:00
|
|
|
E(MPV_EVENT_TICK, "time-pos", "stream-pos", "stream-time-pos", "avsync",
|
2014-10-18 22:49:37 +00:00
|
|
|
"percent-pos", "time-remaining", "playtime-remaining", "playback-time",
|
2015-02-27 11:23:29 +00:00
|
|
|
"estimated-vf-fps", "drop-frame-count", "vo-drop-frame-count",
|
2015-08-10 16:43:25 +00:00
|
|
|
"total-avsync-change", "audio-speed-correction", "video-speed-correction",
|
2015-11-25 21:07:56 +00:00
|
|
|
"vo-delayed-frame-count", "mistimed-frame-count", "vsync-ratio",
|
|
|
|
"estimated-display-fps", "vsync-jitter"),
|
2014-04-05 21:54:21 +00:00
|
|
|
E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params",
|
|
|
|
"video-format", "video-codec", "video-bitrate", "dwidth", "dheight",
|
2015-02-02 21:43:05 +00:00
|
|
|
"width", "height", "fps", "aspect", "vo-configured", "current-vo",
|
2015-03-30 21:52:28 +00:00
|
|
|
"detected-hwdec", "colormatrix", "colormatrix-input-range",
|
2015-08-04 16:02:59 +00:00
|
|
|
"colormatrix-output-range", "colormatrix-primaries", "video-aspect"),
|
2014-04-05 21:54:21 +00:00
|
|
|
E(MPV_EVENT_AUDIO_RECONFIG, "audio-format", "audio-codec", "audio-bitrate",
|
2015-02-01 17:21:48 +00:00
|
|
|
"samplerate", "channels", "audio", "volume", "mute", "balance",
|
2015-05-22 18:23:47 +00:00
|
|
|
"volume-restore-data", "current-ao", "audio-codec-name", "audio-params",
|
|
|
|
"audio-out-params"),
|
2015-12-24 16:36:02 +00:00
|
|
|
E(MPV_EVENT_SEEK, "seeking", "core-idle", "eof-reached"),
|
|
|
|
E(MPV_EVENT_PLAYBACK_RESTART, "seeking", "core-idle", "eof-reached"),
|
2015-03-15 14:41:01 +00:00
|
|
|
E(MPV_EVENT_METADATA_UPDATE, "metadata", "filtered-metadata", "media-title"),
|
2014-04-27 20:28:07 +00:00
|
|
|
E(MPV_EVENT_CHAPTER_CHANGE, "chapter", "chapter-metadata"),
|
2014-08-28 15:48:31 +00:00
|
|
|
E(MP_EVENT_CACHE_UPDATE, "cache", "cache-free", "cache-used", "cache-idle",
|
2015-04-20 21:47:13 +00:00
|
|
|
"demuxer-cache-duration", "demuxer-cache-idle", "paused-for-cache",
|
|
|
|
"demuxer-cache-time"),
|
2014-11-02 19:26:51 +00:00
|
|
|
E(MP_EVENT_WIN_RESIZE, "window-scale"),
|
2015-06-28 16:10:17 +00:00
|
|
|
E(MP_EVENT_WIN_STATE, "window-minimized", "display-names", "display-fps", "fullscreen"),
|
2014-04-05 21:54:21 +00:00
|
|
|
};
|
|
|
|
#undef E
|
|
|
|
|
2015-06-09 16:05:12 +00:00
|
|
|
// If there is no prefix, return length+1 (avoids matching full name as prefix).
|
2014-08-01 23:39:28 +00:00
|
|
|
static int prefix_len(const char *p)
|
|
|
|
{
|
|
|
|
const char *end = strchr(p, '/');
|
2015-06-09 16:05:12 +00:00
|
|
|
return end ? end - p : strlen(p) + 1;
|
2014-08-01 23:39:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool match_property(const char *a, const char *b)
|
|
|
|
{
|
|
|
|
if (strcmp(a, "*") == 0)
|
|
|
|
return true;
|
|
|
|
int len_a = prefix_len(a);
|
|
|
|
int len_b = prefix_len(b);
|
|
|
|
return strncmp(a, b, MPMIN(len_a, len_b)) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return a bitset of events which change the property.
|
|
|
|
uint64_t mp_get_property_event_mask(const char *name)
|
|
|
|
{
|
|
|
|
uint64_t mask = 0;
|
|
|
|
for (int n = 0; n < MP_ARRAY_SIZE(mp_event_property_change); n++) {
|
|
|
|
const char *const *const list = mp_event_property_change[n];
|
|
|
|
for (int i = 0; list && list[i]; i++) {
|
|
|
|
if (match_property(list[i], name))
|
|
|
|
mask |= 1ULL << n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return an ID for the property. It might not be unique, but is good enough
|
|
|
|
// for property change handling. Return -1 if property unknown.
|
|
|
|
int mp_get_property_id(const char *name)
|
|
|
|
{
|
|
|
|
for (int n = 0; mp_properties[n].name; n++) {
|
|
|
|
if (match_property(mp_properties[n].name, name))
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-04-08 19:24:14 +00:00
|
|
|
static bool is_property_set(int action, void *val)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
|
|
|
case M_PROPERTY_SWITCH:
|
|
|
|
case M_PROPERTY_SET_STRING:
|
|
|
|
case M_PROPERTY_SET_NODE:
|
|
|
|
return true;
|
|
|
|
case M_PROPERTY_KEY_ACTION: {
|
|
|
|
struct m_property_action_arg *key = val;
|
|
|
|
return is_property_set(key->action, key->arg);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-21 10:19:59 +00:00
|
|
|
int mp_property_do(const char *name, int action, void *val,
|
|
|
|
struct MPContext *ctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2014-04-08 19:24:14 +00:00
|
|
|
int r = m_property_do(ctx->log, mp_properties, name, action, val, ctx);
|
|
|
|
if (r == M_PROPERTY_OK && is_property_set(action, val))
|
|
|
|
mp_notify_property(ctx, (char *)name);
|
|
|
|
return r;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2013-09-20 21:33:38 +00:00
|
|
|
char *mp_property_expand_string(struct MPContext *mpctx, const char *str)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
|
|
|
return m_properties_expand_string(mp_properties, str, mpctx);
|
|
|
|
}
|
|
|
|
|
2014-02-20 13:46:23 +00:00
|
|
|
// Before expanding properties, parse C-style escapes like "\n"
|
|
|
|
char *mp_property_expand_escaped_string(struct MPContext *mpctx, const char *str)
|
|
|
|
{
|
|
|
|
void *tmp = talloc_new(NULL);
|
|
|
|
bstr strb = bstr0(str);
|
|
|
|
bstr dst = {0};
|
|
|
|
while (strb.len) {
|
|
|
|
if (!mp_append_escaped_string(tmp, &dst, &strb)) {
|
|
|
|
talloc_free(tmp);
|
|
|
|
return talloc_strdup(NULL, "(broken escape sequences)");
|
|
|
|
}
|
|
|
|
// pass " through literally
|
|
|
|
if (!bstr_eatstart0(&strb, "\""))
|
|
|
|
break;
|
|
|
|
bstr_xappend(tmp, &dst, bstr0("\""));
|
|
|
|
}
|
|
|
|
char *r = mp_property_expand_string(mpctx, dst.start);
|
|
|
|
talloc_free(tmp);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-12-21 18:36:33 +00:00
|
|
|
void property_print_help(struct mp_log *log)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-12-21 18:36:33 +00:00
|
|
|
m_properties_print_help_list(log, mp_properties);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-19 01:17:30 +00:00
|
|
|
/* List of default ways to show a property on OSD.
|
|
|
|
*
|
2012-09-25 01:24:38 +00:00
|
|
|
* If osd_progbar is set, a bar showing the current position between min/max
|
|
|
|
* values of the property is shown. In this case osd_msg is only used for
|
|
|
|
* terminal output if there is no video; it'll be a label shown together with
|
|
|
|
* percentage.
|
2009-09-19 01:17:30 +00:00
|
|
|
*/
|
2014-06-10 21:56:05 +00:00
|
|
|
static const struct property_osd_display {
|
2012-09-25 01:24:38 +00:00
|
|
|
// property name
|
2009-09-19 01:17:30 +00:00
|
|
|
const char *name;
|
2012-09-25 01:24:38 +00:00
|
|
|
// name used on OSD
|
|
|
|
const char *osd_name;
|
|
|
|
// progressbar type
|
|
|
|
int osd_progbar;
|
|
|
|
// Needs special ways to display the new value (seeks are delayed)
|
|
|
|
int seek_msg, seek_bar;
|
2013-09-20 21:33:38 +00:00
|
|
|
// Free-form message (if NULL, osd_name or the property name is used)
|
|
|
|
const char *msg;
|
2009-09-19 01:17:30 +00:00
|
|
|
} property_osd_display[] = {
|
|
|
|
// general
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "loop", "Loop" },
|
2012-09-25 01:24:38 +00:00
|
|
|
{ "chapter", .seek_msg = OSD_SEEK_INFO_CHAPTER_TEXT,
|
|
|
|
.seek_bar = OSD_SEEK_INFO_BAR },
|
|
|
|
{ "edition", .seek_msg = OSD_SEEK_INFO_EDITION },
|
|
|
|
{ "hr-seek", "hr-seek" },
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "speed", "Speed" },
|
|
|
|
{ "clock", "Clock" },
|
2009-09-19 01:17:30 +00:00
|
|
|
// audio
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "volume", "Volume",
|
2014-10-11 19:34:15 +00:00
|
|
|
.msg = "Volume: ${?volume:${volume}% ${?mute==yes:(Muted)}}${!volume:${volume}}",
|
2014-09-21 13:55:22 +00:00
|
|
|
.osd_progbar = OSD_VOLUME },
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "mute", "Mute" },
|
|
|
|
{ "audio-delay", "A-V delay" },
|
|
|
|
{ "audio", "Audio" },
|
|
|
|
{ "balance", "Balance", .osd_progbar = OSD_BALANCE },
|
2009-09-19 01:17:30 +00:00
|
|
|
// video
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "panscan", "Panscan", .osd_progbar = OSD_PANSCAN },
|
|
|
|
{ "ontop", "Stay on top" },
|
|
|
|
{ "border", "Border" },
|
|
|
|
{ "framedrop", "Framedrop" },
|
|
|
|
{ "deinterlace", "Deinterlace" },
|
2014-02-03 21:00:34 +00:00
|
|
|
{ "colormatrix",
|
|
|
|
.msg = "YUV colormatrix:\n${colormatrix}" },
|
|
|
|
{ "colormatrix-input-range",
|
|
|
|
.msg = "YUV input range:\n${colormatrix-input-range}" },
|
|
|
|
{ "colormatrix-output-range",
|
|
|
|
.msg = "RGB output range:\n${colormatrix-output-range}" },
|
2014-03-26 13:03:24 +00:00
|
|
|
{ "colormatrix-primaries",
|
|
|
|
.msg = "Colorspace primaries:\n${colormatrix-primaries}", },
|
2015-03-31 02:50:49 +00:00
|
|
|
{ "colormatrix-gamma",
|
|
|
|
.msg = "Colorspace gamma:\n${colormatrix-gamma}", },
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "gamma", "Gamma", .osd_progbar = OSD_BRIGHTNESS },
|
|
|
|
{ "brightness", "Brightness", .osd_progbar = OSD_BRIGHTNESS },
|
|
|
|
{ "contrast", "Contrast", .osd_progbar = OSD_CONTRAST },
|
|
|
|
{ "saturation", "Saturation", .osd_progbar = OSD_SATURATION },
|
|
|
|
{ "hue", "Hue", .osd_progbar = OSD_HUE },
|
|
|
|
{ "angle", "Angle" },
|
2009-09-19 01:17:30 +00:00
|
|
|
// subs
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "sub", "Subtitles" },
|
2013-12-24 16:46:14 +00:00
|
|
|
{ "secondary-sid", "Secondary subtitles" },
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "sub-pos", "Sub position" },
|
2014-01-17 21:34:47 +00:00
|
|
|
{ "sub-delay", "Sub delay" },
|
2015-01-29 19:28:39 +00:00
|
|
|
{ "sub-visibility", .msg = "Subtitles ${!sub-visibility==yes:hidden}"
|
|
|
|
"${?sub-visibility==yes:visible${?sub==no: (but no subtitles selected)}}" },
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "sub-forced-only", "Forced sub only" },
|
|
|
|
{ "sub-scale", "Sub Scale"},
|
|
|
|
{ "ass-vsfilter-aspect-compat", "Subtitle VSFilter aspect compat"},
|
|
|
|
{ "ass-style-override", "ASS subtitle style override"},
|
2014-02-21 12:18:50 +00:00
|
|
|
{ "vf", "Video filters", .msg = "Video filters:\n${vf}"},
|
|
|
|
{ "af", "Audio filters", .msg = "Audio filters:\n${af}"},
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "tv-brightness", "Brightness", .osd_progbar = OSD_BRIGHTNESS },
|
|
|
|
{ "tv-hue", "Hue", .osd_progbar = OSD_HUE},
|
|
|
|
{ "tv-saturation", "Saturation", .osd_progbar = OSD_SATURATION },
|
|
|
|
{ "tv-contrast", "Contrast", .osd_progbar = OSD_CONTRAST },
|
2015-08-09 21:55:10 +00:00
|
|
|
{ "ab-loop-a", "A-B loop start"},
|
|
|
|
{ "ab-loop-b", .msg = "A-B loop: ${ab-loop-a} - ${ab-loop-b}"},
|
2015-02-16 20:35:13 +00:00
|
|
|
{ "audio-device", "Audio device"},
|
2014-09-21 21:54:29 +00:00
|
|
|
// By default, don't display the following properties on OSD
|
|
|
|
{ "pause", NULL },
|
|
|
|
{ "fullscreen", NULL },
|
2012-09-25 01:24:38 +00:00
|
|
|
{0}
|
2009-09-19 01:17:30 +00:00
|
|
|
};
|
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
static void show_property_osd(MPContext *mpctx, const char *name, int osd_mode)
|
2009-09-19 01:17:30 +00:00
|
|
|
{
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2014-09-21 21:54:29 +00:00
|
|
|
struct property_osd_display disp = { .name = name, .osd_name = name };
|
2009-09-19 01:17:30 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
if (!osd_mode)
|
|
|
|
return;
|
2012-09-25 01:24:38 +00:00
|
|
|
|
2009-09-19 01:17:30 +00:00
|
|
|
// look for the command
|
2014-09-21 21:40:45 +00:00
|
|
|
for (const struct property_osd_display *p = property_osd_display; p->name; p++)
|
|
|
|
{
|
2014-02-21 12:18:50 +00:00
|
|
|
if (!strcmp(p->name, name)) {
|
2014-09-21 21:40:45 +00:00
|
|
|
disp = *p;
|
2009-09-19 01:17:30 +00:00
|
|
|
break;
|
2012-09-25 01:24:38 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-20 21:33:38 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
if (osd_mode == MP_ON_OSD_AUTO) {
|
|
|
|
osd_mode =
|
|
|
|
((disp.msg || disp.osd_name || disp.seek_msg) ? MP_ON_OSD_MSG : 0) |
|
|
|
|
((disp.osd_progbar || disp.seek_bar) ? MP_ON_OSD_BAR : 0);
|
2012-09-25 01:24:38 +00:00
|
|
|
}
|
2009-09-19 01:17:30 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
if (!disp.osd_progbar)
|
|
|
|
disp.osd_progbar = ' ';
|
|
|
|
|
|
|
|
if (!disp.osd_name)
|
|
|
|
disp.osd_name = name;
|
|
|
|
|
|
|
|
if (disp.seek_msg || disp.seek_bar) {
|
2012-09-25 01:24:38 +00:00
|
|
|
mpctx->add_osd_seek_info |=
|
2014-09-21 21:40:45 +00:00
|
|
|
(osd_mode & MP_ON_OSD_MSG ? disp.seek_msg : 0) |
|
|
|
|
(osd_mode & MP_ON_OSD_BAR ? disp.seek_bar : 0);
|
2012-09-25 01:24:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-08 21:53:11 +00:00
|
|
|
struct m_option prop = {0};
|
2014-09-21 21:40:45 +00:00
|
|
|
mp_property_do(name, M_PROPERTY_GET_TYPE, &prop, mpctx);
|
|
|
|
if ((osd_mode & MP_ON_OSD_BAR) && (prop.flags & CONF_RANGE) == CONF_RANGE) {
|
2012-09-21 12:05:52 +00:00
|
|
|
if (prop.type == CONF_TYPE_INT) {
|
2014-06-08 21:52:58 +00:00
|
|
|
int n = prop.min;
|
|
|
|
mp_property_do(name, M_PROPERTY_GET_NEUTRAL, &n, mpctx);
|
2012-09-21 12:05:52 +00:00
|
|
|
int i;
|
2014-09-21 21:40:45 +00:00
|
|
|
if (mp_property_do(name, M_PROPERTY_GET, &i, mpctx) > 0)
|
|
|
|
set_osd_bar(mpctx, disp.osd_progbar, prop.min, prop.max, n, i);
|
2012-09-21 12:05:52 +00:00
|
|
|
} else if (prop.type == CONF_TYPE_FLOAT) {
|
2014-06-08 21:52:58 +00:00
|
|
|
float n = prop.min;
|
|
|
|
mp_property_do(name, M_PROPERTY_GET_NEUTRAL, &n, mpctx);
|
2009-09-19 01:17:30 +00:00
|
|
|
float f;
|
2014-09-21 21:40:45 +00:00
|
|
|
if (mp_property_do(name, M_PROPERTY_GET, &f, mpctx) > 0)
|
|
|
|
set_osd_bar(mpctx, disp.osd_progbar, prop.min, prop.max, n, f);
|
2009-09-19 01:17:30 +00:00
|
|
|
}
|
2013-09-20 21:33:38 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
if (osd_mode & MP_ON_OSD_MSG) {
|
|
|
|
void *tmp = talloc_new(NULL);
|
2013-09-20 21:33:38 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
const char *msg = disp.msg;
|
|
|
|
if (!msg)
|
|
|
|
msg = talloc_asprintf(tmp, "%s: ${%s}", disp.osd_name, name);
|
2013-09-20 21:33:38 +00:00
|
|
|
|
2014-09-21 21:40:45 +00:00
|
|
|
char *osd_msg = talloc_steal(tmp, mp_property_expand_string(mpctx, msg));
|
|
|
|
|
|
|
|
if (osd_msg && osd_msg[0])
|
|
|
|
set_osd_msg(mpctx, 1, opts->osd_duration, "%s", osd_msg);
|
|
|
|
|
|
|
|
talloc_free(tmp);
|
|
|
|
}
|
2009-09-19 01:17:30 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-07-22 12:43:58 +00:00
|
|
|
static bool reinit_filters(MPContext *mpctx, enum stream_type mediatype)
|
|
|
|
{
|
|
|
|
switch (mediatype) {
|
|
|
|
case STREAM_VIDEO:
|
|
|
|
return reinit_video_filters(mpctx) >= 0;
|
|
|
|
case STREAM_AUDIO:
|
|
|
|
return reinit_audio_filters(mpctx) >= 0;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-10 21:56:05 +00:00
|
|
|
static const char *const filter_opt[STREAM_TYPE_COUNT] = {
|
2013-08-03 11:38:40 +00:00
|
|
|
[STREAM_VIDEO] = "vf",
|
|
|
|
[STREAM_AUDIO] = "af",
|
|
|
|
};
|
|
|
|
|
|
|
|
static int set_filters(struct MPContext *mpctx, enum stream_type mediatype,
|
|
|
|
struct m_obj_settings *new_chain)
|
2013-05-18 09:44:17 +00:00
|
|
|
{
|
2013-08-03 11:38:40 +00:00
|
|
|
bstr option = bstr0(filter_opt[mediatype]);
|
|
|
|
struct m_config_option *co = m_config_get_co(mpctx->mconfig, option);
|
|
|
|
if (!co)
|
|
|
|
return -1;
|
2013-07-22 12:43:58 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
struct m_obj_settings **list = co->data;
|
|
|
|
struct m_obj_settings *old_settings = *list;
|
|
|
|
*list = NULL;
|
|
|
|
m_option_copy(co->opt, list, &new_chain);
|
|
|
|
|
|
|
|
bool success = reinit_filters(mpctx, mediatype);
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
m_option_free(co->opt, &old_settings);
|
2014-06-01 01:41:43 +00:00
|
|
|
mp_notify_property(mpctx, filter_opt[mediatype]);
|
2013-08-03 11:38:40 +00:00
|
|
|
} else {
|
|
|
|
m_option_free(co->opt, list);
|
|
|
|
*list = old_settings;
|
|
|
|
reinit_filters(mpctx, mediatype);
|
2013-07-22 12:43:58 +00:00
|
|
|
}
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
if (mediatype == STREAM_VIDEO)
|
|
|
|
mp_force_video_refresh(mpctx);
|
|
|
|
|
|
|
|
return success ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2015-07-21 19:54:15 +00:00
|
|
|
static int edit_filters(struct MPContext *mpctx, struct mp_log *log,
|
|
|
|
enum stream_type mediatype,
|
2013-08-03 11:38:40 +00:00
|
|
|
const char *cmd, const char *arg)
|
|
|
|
{
|
|
|
|
bstr option = bstr0(filter_opt[mediatype]);
|
|
|
|
struct m_config_option *co = m_config_get_co(mpctx->mconfig, option);
|
|
|
|
if (!co)
|
|
|
|
return -1;
|
|
|
|
|
2013-05-18 09:44:17 +00:00
|
|
|
// The option parser is used to modify the filter list itself.
|
|
|
|
char optname[20];
|
2013-08-03 11:38:40 +00:00
|
|
|
snprintf(optname, sizeof(optname), "%.*s-%s", BSTR_P(option), cmd);
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
struct m_obj_settings *new_chain = NULL;
|
|
|
|
m_option_copy(co->opt, &new_chain, co->data);
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2015-07-21 19:54:15 +00:00
|
|
|
int r = m_option_parse(log, co->opt, bstr0(optname), bstr0(arg), &new_chain);
|
2013-08-03 11:38:40 +00:00
|
|
|
if (r >= 0)
|
|
|
|
r = set_filters(mpctx, mediatype, new_chain);
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
m_option_free(co->opt, &new_chain);
|
2013-05-18 09:44:17 +00:00
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
return r >= 0 ? 0 : -1;
|
2013-05-18 09:44:17 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 11:54:02 +00:00
|
|
|
static int edit_filters_osd(struct MPContext *mpctx, enum stream_type mediatype,
|
|
|
|
const char *cmd, const char *arg, bool on_osd)
|
|
|
|
{
|
2015-07-21 19:54:15 +00:00
|
|
|
int r = edit_filters(mpctx, mpctx->log, mediatype, cmd, arg);
|
2013-08-03 11:54:02 +00:00
|
|
|
if (on_osd) {
|
|
|
|
if (r >= 0) {
|
|
|
|
const char *prop = filter_opt[mediatype];
|
|
|
|
show_property_osd(mpctx, prop, MP_ON_OSD_MSG);
|
|
|
|
} else {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, 1, mpctx->opts->osd_duration,
|
2013-08-03 11:54:02 +00:00
|
|
|
"Changing filters failed!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-07-25 12:22:40 +00:00
|
|
|
static void recreate_overlays(struct MPContext *mpctx)
|
2013-09-30 20:27:37 +00:00
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2014-07-25 12:22:40 +00:00
|
|
|
struct sub_bitmaps *new = &cmd->overlay_osd[0];
|
|
|
|
if (new == cmd->overlay_osd_current)
|
|
|
|
new += 1; // pick the unused one
|
|
|
|
new->format = SUBBITMAP_RGBA;
|
2015-03-18 11:33:14 +00:00
|
|
|
new->change_id = 1;
|
2014-07-25 12:22:40 +00:00
|
|
|
// overlay array can have unused entries, but parts list must be "packed"
|
|
|
|
new->num_parts = 0;
|
|
|
|
for (int n = 0; n < cmd->num_overlays; n++) {
|
2014-10-02 23:22:07 +00:00
|
|
|
struct overlay *o = &cmd->overlays[n];
|
|
|
|
if (o->osd.bitmap)
|
|
|
|
MP_TARRAY_APPEND(cmd, new->parts, new->num_parts, o->osd);
|
2014-07-25 12:22:40 +00:00
|
|
|
}
|
|
|
|
cmd->overlay_osd_current = new;
|
|
|
|
osd_set_external2(mpctx->osd, cmd->overlay_osd_current);
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 23:22:07 +00:00
|
|
|
// Set overlay with the given ID to the contents as described by "new".
|
|
|
|
static void replace_overlay(struct MPContext *mpctx, int id, struct overlay *new)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
assert(id >= 0);
|
|
|
|
if (id >= cmd->num_overlays) {
|
|
|
|
MP_TARRAY_GROW(cmd, cmd->overlays, id);
|
|
|
|
while (cmd->num_overlays <= id)
|
|
|
|
cmd->overlays[cmd->num_overlays++] = (struct overlay){0};
|
|
|
|
}
|
|
|
|
|
|
|
|
struct overlay *ptr = &cmd->overlays[id];
|
|
|
|
struct overlay old = *ptr;
|
|
|
|
|
|
|
|
if (!ptr->osd.bitmap && !new->osd.bitmap)
|
|
|
|
return; // don't need to recreate or unmap
|
|
|
|
|
|
|
|
*ptr = *new;
|
|
|
|
recreate_overlays(mpctx);
|
|
|
|
|
|
|
|
// Do this afterwards, so we never unmap while the OSD is using it.
|
2014-12-26 16:43:59 +00:00
|
|
|
if (old.map_start && old.map_size)
|
|
|
|
munmap(old.map_start, old.map_size);
|
2014-10-02 23:22:07 +00:00
|
|
|
}
|
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
static int overlay_add(struct MPContext *mpctx, int id, int x, int y,
|
|
|
|
char *file, int offset, char *fmt, int w, int h,
|
|
|
|
int stride)
|
|
|
|
{
|
2014-01-18 00:19:20 +00:00
|
|
|
int r = -1;
|
2013-09-30 20:27:37 +00:00
|
|
|
if (strcmp(fmt, "bgra") != 0) {
|
|
|
|
MP_ERR(mpctx, "overlay_add: unsupported OSD format '%s'\n", fmt);
|
2014-01-18 00:19:20 +00:00
|
|
|
goto error;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
2014-07-25 12:22:40 +00:00
|
|
|
if (id < 0 || id >= 64) { // arbitrary upper limit
|
2013-09-30 20:27:37 +00:00
|
|
|
MP_ERR(mpctx, "overlay_add: invalid id %d\n", id);
|
2014-01-18 00:19:20 +00:00
|
|
|
goto error;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
2014-10-02 23:22:07 +00:00
|
|
|
if (w < 0 || h < 0 || stride < w * 4 || (stride % 4)) {
|
|
|
|
MP_ERR(mpctx, "overlay_add: inconsistent parameters\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
struct overlay overlay = {
|
|
|
|
.osd = {
|
|
|
|
.stride = stride,
|
|
|
|
.x = x, .y = y,
|
|
|
|
.w = w, .h = h,
|
|
|
|
.dw = w, .dh = h,
|
|
|
|
},
|
|
|
|
};
|
2013-09-30 20:27:37 +00:00
|
|
|
int fd = -1;
|
|
|
|
bool close_fd = true;
|
2014-12-26 16:43:59 +00:00
|
|
|
void *p = NULL;
|
2013-09-30 20:27:37 +00:00
|
|
|
if (file[0] == '@') {
|
|
|
|
char *end;
|
|
|
|
fd = strtol(&file[1], &end, 10);
|
|
|
|
if (!file[1] || end[0])
|
|
|
|
fd = -1;
|
|
|
|
close_fd = false;
|
2014-10-02 23:24:48 +00:00
|
|
|
} else if (file[0] == '&') {
|
|
|
|
char *end;
|
|
|
|
unsigned long long addr = strtoull(&file[1], &end, 0);
|
|
|
|
if (!file[1] || end[0])
|
|
|
|
addr = 0;
|
|
|
|
p = (void *)(uintptr_t)addr;
|
2013-09-30 20:27:37 +00:00
|
|
|
} else {
|
2013-11-30 21:40:51 +00:00
|
|
|
fd = open(file, O_RDONLY | O_BINARY | O_CLOEXEC);
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
2014-10-02 23:22:07 +00:00
|
|
|
if (fd >= 0) {
|
2014-12-26 16:43:59 +00:00
|
|
|
overlay.map_size = offset + h * stride;
|
|
|
|
void *m = mmap(NULL, overlay.map_size, PROT_READ, MAP_SHARED, fd, 0);
|
2014-10-02 23:22:07 +00:00
|
|
|
if (close_fd)
|
|
|
|
close(fd);
|
2014-12-26 16:43:59 +00:00
|
|
|
if (m && m != MAP_FAILED) {
|
|
|
|
overlay.map_start = m;
|
|
|
|
p = m;
|
|
|
|
}
|
2014-10-02 23:22:07 +00:00
|
|
|
}
|
2014-12-26 16:43:59 +00:00
|
|
|
if (!p) {
|
2013-09-30 20:27:37 +00:00
|
|
|
MP_ERR(mpctx, "overlay_add: could not open or map '%s'\n", file);
|
2014-01-18 00:19:20 +00:00
|
|
|
goto error;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
2014-12-26 16:43:59 +00:00
|
|
|
overlay.osd.bitmap = (char *)p + offset;
|
2014-10-02 23:22:07 +00:00
|
|
|
replace_overlay(mpctx, id, &overlay);
|
2014-01-18 00:19:20 +00:00
|
|
|
r = 0;
|
|
|
|
error:
|
|
|
|
return r;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void overlay_remove(struct MPContext *mpctx, int id)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2014-10-02 23:22:07 +00:00
|
|
|
if (id >= 0 && id < cmd->num_overlays)
|
|
|
|
replace_overlay(mpctx, id, &(struct overlay){0});
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void overlay_uninit(struct MPContext *mpctx)
|
|
|
|
{
|
2014-07-25 12:22:40 +00:00
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2014-01-18 16:59:34 +00:00
|
|
|
if (!mpctx->osd)
|
|
|
|
return;
|
2014-07-25 12:22:40 +00:00
|
|
|
for (int id = 0; id < cmd->num_overlays; id++)
|
2013-09-30 20:27:37 +00:00
|
|
|
overlay_remove(mpctx, id);
|
2014-01-18 00:19:20 +00:00
|
|
|
osd_set_external2(mpctx->osd, NULL);
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
|
2013-11-29 23:18:24 +00:00
|
|
|
struct cycle_counter {
|
|
|
|
char **args;
|
|
|
|
int counter;
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool stringlist_equals(char **l1, char **l2)
|
|
|
|
{
|
|
|
|
assert(l1 && l2);
|
|
|
|
for (int i = 0; ; i++) {
|
|
|
|
if (!l1[i] && !l2[i])
|
|
|
|
return true;
|
|
|
|
if (!l1[i] || !l2[i])
|
|
|
|
return false;
|
|
|
|
if (strcmp(l1[i], l2[i]) != 0)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static char **stringlist_dup(void *talloc_ctx, char **list)
|
|
|
|
{
|
|
|
|
int num = 0;
|
|
|
|
char **res = NULL;
|
|
|
|
for (int i = 0; list && list[i]; i++)
|
|
|
|
MP_TARRAY_APPEND(talloc_ctx, res, num, talloc_strdup(talloc_ctx, list[i]));
|
|
|
|
MP_TARRAY_APPEND(talloc_ctx, res, num, NULL);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int *get_cmd_cycle_counter(struct MPContext *mpctx, char **args)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
for (int n = 0; n < cmd->num_cycle_counters; n++) {
|
|
|
|
struct cycle_counter *ctr = &cmd->cycle_counters[n];
|
|
|
|
if (stringlist_equals(ctr->args, args))
|
|
|
|
return &ctr->counter;
|
|
|
|
}
|
2014-10-21 21:55:32 +00:00
|
|
|
struct cycle_counter ctr = {stringlist_dup(cmd, args), -1};
|
2013-11-29 23:18:24 +00:00
|
|
|
MP_TARRAY_APPEND(cmd, cmd->cycle_counters, cmd->num_cycle_counters, ctr);
|
|
|
|
return &cmd->cycle_counters[cmd->num_cycle_counters - 1].counter;
|
|
|
|
}
|
|
|
|
|
2013-10-31 22:23:38 +00:00
|
|
|
static int mp_property_multiply(char *property, double f, struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
union m_option_value val = {0};
|
|
|
|
struct m_option opt = {0};
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = mp_property_do(property, M_PROPERTY_GET_TYPE, &opt, mpctx);
|
|
|
|
if (r != M_PROPERTY_OK)
|
|
|
|
return r;
|
|
|
|
assert(opt.type);
|
|
|
|
|
|
|
|
if (!opt.type->multiply)
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
r = mp_property_do(property, M_PROPERTY_GET, &val, mpctx);
|
|
|
|
if (r != M_PROPERTY_OK)
|
|
|
|
return r;
|
|
|
|
opt.type->multiply(&opt, &val, f);
|
|
|
|
r = mp_property_do(property, M_PROPERTY_SET, &val, mpctx);
|
|
|
|
m_option_free(&opt, &val);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-10-23 11:11:41 +00:00
|
|
|
static struct track *find_track_with_url(struct MPContext *mpctx, int type,
|
|
|
|
const char *url)
|
|
|
|
{
|
|
|
|
for (int n = 0; n < mpctx->num_tracks; n++) {
|
|
|
|
struct track *track = mpctx->tracks[n];
|
|
|
|
if (track && track->type == type && track->is_external &&
|
|
|
|
strcmp(track->external_filename, url) == 0)
|
|
|
|
return track;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-10-27 23:33:52 +00:00
|
|
|
// Whether this property should react to key events generated by auto-repeat.
|
|
|
|
static bool check_property_autorepeat(char *property, struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct m_option prop = {0};
|
|
|
|
if (mp_property_do(property, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// This is a heuristic at best.
|
|
|
|
if (prop.type == &m_option_type_flag || prop.type == &m_option_type_choice)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-20 21:11:03 +00:00
|
|
|
static struct mpv_node *add_map_entry(struct mpv_node *dst, const char *key)
|
|
|
|
{
|
|
|
|
struct mpv_node_list *list = dst->u.list;
|
|
|
|
assert(dst->format == MPV_FORMAT_NODE_MAP && dst->u.list);
|
|
|
|
MP_TARRAY_GROW(list, list->values, list->num);
|
|
|
|
MP_TARRAY_GROW(list, list->keys, list->num);
|
|
|
|
list->keys[list->num] = talloc_strdup(list, key);
|
|
|
|
return &list->values[list->num++];
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ADD_MAP_INT(dst, name, i) (*add_map_entry(dst, name) = \
|
|
|
|
(struct mpv_node){ .format = MPV_FORMAT_INT64, .u.int64 = (i) });
|
|
|
|
|
|
|
|
#define ADD_MAP_CSTR(dst, name, s) (*add_map_entry(dst, name) = \
|
|
|
|
(struct mpv_node){ .format = MPV_FORMAT_STRING, .u.string = (s) });
|
|
|
|
|
2015-04-20 21:00:12 +00:00
|
|
|
int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *res)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-12-01 01:07:32 +00:00
|
|
|
struct command_ctx *cmdctx = mpctx->command_ctx;
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2009-03-29 23:06:58 +00:00
|
|
|
int osd_duration = opts->osd_duration;
|
2013-12-15 22:35:36 +00:00
|
|
|
int on_osd = cmd->flags & MP_ON_OSD_FLAGS;
|
|
|
|
bool auto_osd = on_osd == MP_ON_OSD_AUTO;
|
|
|
|
bool msg_osd = auto_osd || (on_osd & MP_ON_OSD_MSG);
|
|
|
|
bool bar_osd = auto_osd || (on_osd & MP_ON_OSD_BAR);
|
2013-10-02 19:05:04 +00:00
|
|
|
bool msg_or_nobar_osd = msg_osd && !(auto_osd && opts->osd_bar_visible);
|
2012-09-25 01:24:38 +00:00
|
|
|
int osdl = msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
|
2013-05-18 10:56:22 +00:00
|
|
|
|
2014-10-24 11:42:02 +00:00
|
|
|
mp_cmd_dump(mpctx->log, MSGL_V, "Run command:", cmd);
|
2014-10-23 12:40:38 +00:00
|
|
|
|
2013-12-15 22:35:36 +00:00
|
|
|
if (cmd->flags & MP_EXPAND_PROPERTIES) {
|
2013-05-18 10:56:22 +00:00
|
|
|
for (int n = 0; n < cmd->nargs; n++) {
|
2013-11-28 18:04:16 +00:00
|
|
|
if (cmd->args[n].type->type == CONF_TYPE_STRING) {
|
2014-02-23 16:43:38 +00:00
|
|
|
char *s = mp_property_expand_string(mpctx, cmd->args[n].v.s);
|
|
|
|
if (!s)
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2014-02-23 16:43:38 +00:00
|
|
|
talloc_free(cmd->args[n].v.s);
|
|
|
|
cmd->args[n].v.s = s;
|
2013-05-18 10:56:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
switch (cmd->id) {
|
|
|
|
case MP_CMD_SEEK: {
|
2013-07-25 16:08:57 +00:00
|
|
|
double v = cmd->args[0].v.d * cmd->scale;
|
2015-03-04 16:21:02 +00:00
|
|
|
int abs = cmd->args[1].v.i & 3;
|
2015-03-04 16:21:05 +00:00
|
|
|
enum seek_precision precision = MPSEEK_DEFAULT;
|
|
|
|
switch (((cmd->args[2].v.i | cmd->args[1].v.i) >> 3) & 3) {
|
|
|
|
case 1: precision = MPSEEK_KEYFRAME; break;
|
|
|
|
case 2: precision = MPSEEK_EXACT; break;
|
2015-03-04 16:21:02 +00:00
|
|
|
}
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return -1;
|
2013-12-01 01:07:32 +00:00
|
|
|
mark_seek(mpctx);
|
2015-05-20 11:26:36 +00:00
|
|
|
switch (abs) {
|
|
|
|
case 0: { // Relative seek
|
|
|
|
queue_seek(mpctx, MPSEEK_RELATIVE, v, precision, false);
|
|
|
|
set_osd_function(mpctx, (v > 0) ? OSD_FFW : OSD_REW);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: { // Absolute seek by percentage
|
|
|
|
double ratio = v / 100.0;
|
|
|
|
double cur_pos = get_current_pos_ratio(mpctx, false);
|
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR, ratio, precision, false);
|
|
|
|
set_osd_function(mpctx, cur_pos < ratio ? OSD_FFW : OSD_REW);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: { // Absolute seek to a timestamp in seconds
|
2015-03-04 16:21:05 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, v, precision, false);
|
2012-11-20 16:20:45 +00:00
|
|
|
set_osd_function(mpctx,
|
|
|
|
v > get_current_time(mpctx) ? OSD_FFW : OSD_REW);
|
2015-05-20 11:26:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3: { // Relative seek by percentage
|
2015-05-18 20:56:56 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR,
|
|
|
|
get_current_pos_ratio(mpctx, false) + v / 100.0,
|
|
|
|
precision, false);
|
|
|
|
set_osd_function(mpctx, v > 0 ? OSD_FFW : OSD_REW);
|
2015-05-20 11:26:36 +00:00
|
|
|
break;
|
|
|
|
}}
|
2012-09-25 01:24:38 +00:00
|
|
|
if (bar_osd)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
|
2013-10-02 19:05:04 +00:00
|
|
|
if (msg_or_nobar_osd)
|
2012-09-25 01:24:38 +00:00
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-12-01 01:07:32 +00:00
|
|
|
case MP_CMD_REVERT_SEEK: {
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return -1;
|
2013-12-01 01:07:32 +00:00
|
|
|
double oldpts = cmdctx->last_seek_pts;
|
2014-12-17 21:56:45 +00:00
|
|
|
if (cmdctx->marked_pts != MP_NOPTS_VALUE)
|
|
|
|
oldpts = cmdctx->marked_pts;
|
|
|
|
if (cmd->args[0].v.i == 1) {
|
|
|
|
cmdctx->marked_pts = get_current_time(mpctx);
|
|
|
|
} else if (oldpts != MP_NOPTS_VALUE) {
|
2013-12-01 01:07:32 +00:00
|
|
|
cmdctx->last_seek_pts = get_current_time(mpctx);
|
2014-12-17 21:56:45 +00:00
|
|
|
cmdctx->marked_pts = MP_NOPTS_VALUE;
|
2015-03-04 16:21:05 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, oldpts, MPSEEK_EXACT, false);
|
2013-12-01 01:07:32 +00:00
|
|
|
set_osd_function(mpctx, OSD_REW);
|
|
|
|
if (bar_osd)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
|
|
|
|
if (msg_or_nobar_osd)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
|
2014-06-01 01:41:46 +00:00
|
|
|
} else {
|
|
|
|
return -1;
|
2013-12-01 01:07:32 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-09-09 00:08:08 +00:00
|
|
|
case MP_CMD_SET: {
|
2012-09-22 06:04:08 +00:00
|
|
|
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_SET_STRING,
|
2011-08-07 01:45:40 +00:00
|
|
|
cmd->args[1].v.s, mpctx);
|
2013-02-16 20:37:00 +00:00
|
|
|
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
|
2013-12-15 22:35:36 +00:00
|
|
|
show_property_osd(mpctx, cmd->args[0].v.s, on_osd);
|
2013-02-16 20:37:00 +00:00
|
|
|
} else if (r == M_PROPERTY_UNKNOWN) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2013-10-12 16:42:42 +00:00
|
|
|
"Unknown property: '%s'", cmd->args[0].v.s);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2013-02-16 20:37:00 +00:00
|
|
|
} else if (r <= 0) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2013-10-12 16:42:42 +00:00
|
|
|
"Failed to set property '%s' to '%s'",
|
|
|
|
cmd->args[0].v.s, cmd->args[1].v.s);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2013-02-16 20:37:00 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-09-22 04:15:36 +00:00
|
|
|
case MP_CMD_ADD:
|
|
|
|
case MP_CMD_CYCLE:
|
|
|
|
{
|
2015-09-10 12:15:12 +00:00
|
|
|
char *property = cmd->args[0].v.s;
|
2012-09-22 04:15:36 +00:00
|
|
|
struct m_property_switch_arg s = {
|
2015-09-10 12:15:12 +00:00
|
|
|
.inc = cmd->args[1].v.d * cmd->scale,
|
2012-09-22 04:15:36 +00:00
|
|
|
.wrap = cmd->id == MP_CMD_CYCLE,
|
|
|
|
};
|
2013-10-27 23:33:52 +00:00
|
|
|
if (cmd->repeated && !check_property_autorepeat(property, mpctx)) {
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_VERBOSE(mpctx, "Dropping command '%.*s' from auto-repeated key.\n",
|
|
|
|
BSTR_P(cmd->original));
|
2013-10-27 23:33:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
int r = mp_property_do(property, M_PROPERTY_SWITCH, &s, mpctx);
|
2013-02-16 20:37:00 +00:00
|
|
|
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
|
2013-12-15 22:35:36 +00:00
|
|
|
show_property_osd(mpctx, property, on_osd);
|
2013-02-16 20:37:00 +00:00
|
|
|
} else if (r == M_PROPERTY_UNKNOWN) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2013-10-27 23:33:52 +00:00
|
|
|
"Unknown property: '%s'", property);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2013-02-16 20:37:00 +00:00
|
|
|
} else if (r <= 0) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2013-10-12 16:42:42 +00:00
|
|
|
"Failed to increment property '%s' by %g",
|
2013-10-27 23:33:52 +00:00
|
|
|
property, s.inc);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2013-02-16 20:37:00 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2013-10-31 22:23:38 +00:00
|
|
|
case MP_CMD_MULTIPLY: {
|
|
|
|
char *property = cmd->args[0].v.s;
|
|
|
|
double f = cmd->args[1].v.d;
|
|
|
|
int r = mp_property_multiply(property, f, mpctx);
|
|
|
|
|
|
|
|
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
|
2013-12-15 22:35:36 +00:00
|
|
|
show_property_osd(mpctx, property, on_osd);
|
2013-10-31 22:23:38 +00:00
|
|
|
} else if (r == M_PROPERTY_UNKNOWN) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2013-10-31 22:23:38 +00:00
|
|
|
"Unknown property: '%s'", property);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2013-10-31 22:23:38 +00:00
|
|
|
} else if (r <= 0) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2013-10-31 22:23:38 +00:00
|
|
|
"Failed to multiply property '%s' by %g", property, f);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2013-10-31 22:23:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-29 23:18:24 +00:00
|
|
|
case MP_CMD_CYCLE_VALUES: {
|
|
|
|
char *args[MP_CMD_MAX_ARGS + 1] = {0};
|
|
|
|
for (int n = 0; n < cmd->nargs; n++)
|
|
|
|
args[n] = cmd->args[n].v.s;
|
|
|
|
int first = 1, dir = 1;
|
|
|
|
if (strcmp(args[0], "!reverse") == 0) {
|
|
|
|
first += 1;
|
|
|
|
dir = -1;
|
|
|
|
}
|
|
|
|
int *ptr = get_cmd_cycle_counter(mpctx, &args[first - 1]);
|
|
|
|
int count = cmd->nargs - first;
|
|
|
|
if (ptr && count > 0) {
|
2014-10-21 21:55:32 +00:00
|
|
|
*ptr = *ptr < 0 ? (dir > 0 ? 0 : -1) : *ptr + dir;
|
2013-11-29 23:18:24 +00:00
|
|
|
if (*ptr >= count)
|
|
|
|
*ptr = 0;
|
|
|
|
if (*ptr < 0)
|
|
|
|
*ptr = count - 1;
|
|
|
|
char *property = args[first - 1];
|
2014-10-21 21:55:32 +00:00
|
|
|
char *value = args[first + *ptr];
|
2013-11-29 23:18:24 +00:00
|
|
|
int r = mp_property_do(property, M_PROPERTY_SET_STRING, value, mpctx);
|
|
|
|
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
|
2013-12-15 22:35:36 +00:00
|
|
|
show_property_osd(mpctx, property, on_osd);
|
2013-11-29 23:18:24 +00:00
|
|
|
} else if (r == M_PROPERTY_UNKNOWN) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2013-11-29 23:18:24 +00:00
|
|
|
"Unknown property: '%s'", property);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2013-11-29 23:18:24 +00:00
|
|
|
} else if (r <= 0) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2013-11-29 23:18:24 +00:00
|
|
|
"Failed to set property '%s' to '%s'",
|
|
|
|
property, value);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2013-11-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_FRAME_STEP:
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return -1;
|
2014-11-23 14:30:36 +00:00
|
|
|
if (cmd->is_up_down) {
|
|
|
|
if (cmd->is_up) {
|
|
|
|
if (mpctx->step_frames < 1)
|
|
|
|
pause_player(mpctx);
|
|
|
|
} else {
|
|
|
|
if (cmd->repeated) {
|
|
|
|
unpause_player(mpctx);
|
|
|
|
} else {
|
|
|
|
add_step_frame(mpctx, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
add_step_frame(mpctx, 1);
|
|
|
|
}
|
core: add backstep support
Allows stepping back one frame via the frame_back_step inout command,
bound to "," by default.
This uses the precise seeking facility, and a perfect frame index built
on the fly. The index is built during playback and precise seeking, and
contains (as of this commit) the last 100 displayed or skipped frames.
This index is used to find the PTS of the previous frame, which is then
used as target for a precise seek. If no PTS is found, the core attempts
to do a seek before the current frame, and skip decoded frames until the
current frame is reached; this will create a sufficient index and the
normal backstep algorithm can be applied.
This can be rather slow. The worst case for backstepping is about the
same as the worst case for precise seeking if the previous frame can be
deduced from the index. If not, the worst case will be twice as slow.
There's also some minor danger that the index is incorrect in case
framedropping is involved. For framedropping due to --framedrop, this
problem is ignored (use of --framedrop is discouraged anyway). For
framedropping during precise seeking (done to make it faster), we try
to not add frames to the index that are produced when this can happen.
I'm not sure how well that works (or if the logic is sane), and it's
sure to break with some video filters. In the worst case, backstepping
might silently skip frames if you backstep after a user-initiated
precise seek. (Precise seeks to do indexing are not affected.)
Likewise, video filters that somehow change timing of frames and do not
do this in a deterministic way (i.e. if you seek to a position, frames
with different timings are produced than when the position is reached
during normal playback) will make backstepping silently jump to the
wrong frame. Enabling/disabling filters during playback (like for
example deinterlacing) will have similar bad effects.
2013-04-24 17:31:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MP_CMD_FRAME_BACK_STEP:
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return -1;
|
core: add backstep support
Allows stepping back one frame via the frame_back_step inout command,
bound to "," by default.
This uses the precise seeking facility, and a perfect frame index built
on the fly. The index is built during playback and precise seeking, and
contains (as of this commit) the last 100 displayed or skipped frames.
This index is used to find the PTS of the previous frame, which is then
used as target for a precise seek. If no PTS is found, the core attempts
to do a seek before the current frame, and skip decoded frames until the
current frame is reached; this will create a sufficient index and the
normal backstep algorithm can be applied.
This can be rather slow. The worst case for backstepping is about the
same as the worst case for precise seeking if the previous frame can be
deduced from the index. If not, the worst case will be twice as slow.
There's also some minor danger that the index is incorrect in case
framedropping is involved. For framedropping due to --framedrop, this
problem is ignored (use of --framedrop is discouraged anyway). For
framedropping during precise seeking (done to make it faster), we try
to not add frames to the index that are produced when this can happen.
I'm not sure how well that works (or if the logic is sane), and it's
sure to break with some video filters. In the worst case, backstepping
might silently skip frames if you backstep after a user-initiated
precise seek. (Precise seeks to do indexing are not affected.)
Likewise, video filters that somehow change timing of frames and do not
do this in a deterministic way (i.e. if you seek to a position, frames
with different timings are produced than when the position is reached
during normal playback) will make backstepping silently jump to the
wrong frame. Enabling/disabling filters during playback (like for
example deinterlacing) will have similar bad effects.
2013-04-24 17:31:48 +00:00
|
|
|
add_step_frame(mpctx, -1);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_QUIT:
|
2014-05-22 19:28:20 +00:00
|
|
|
case MP_CMD_QUIT_WATCH_LATER:
|
2014-10-10 12:44:22 +00:00
|
|
|
if (cmd->id == MP_CMD_QUIT_WATCH_LATER || opts->position_save_on_quit)
|
2014-05-22 19:28:20 +00:00
|
|
|
mp_write_watch_later_conf(mpctx);
|
2012-08-04 01:46:11 +00:00
|
|
|
mpctx->stop_play = PT_QUIT;
|
2013-08-02 08:32:38 +00:00
|
|
|
mpctx->quit_custom_rc = cmd->args[0].v.i;
|
|
|
|
mpctx->has_quit_custom_rc = true;
|
2012-08-04 01:46:11 +00:00
|
|
|
break;
|
2010-05-03 23:34:38 +00:00
|
|
|
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
case MP_CMD_PLAYLIST_NEXT:
|
|
|
|
case MP_CMD_PLAYLIST_PREV:
|
|
|
|
{
|
|
|
|
int dir = cmd->id == MP_CMD_PLAYLIST_PREV ? -1 : +1;
|
|
|
|
int force = cmd->args[0].v.i;
|
2011-08-07 01:45:40 +00:00
|
|
|
|
mplayer: attempt to skip playlist entries which can't be played
This is for situations when repeated attempts at playing a playlist
entry failed, and playlist navigation becomes impossible due to that.
For example, it wasn't possible to skip backwards past an unplayable
playlist entry:
mpv file1.mkv doesntexist.mkv file3.mkv
You couldn't skip back to file1.mkv from file3.mkv. When running a
single "playlist_prev" command, doesntexist.mkv would be played, which
would fail to load. As reaction to the failure to load it, the next file
would be played, which is file3.mkv.
To make this even worse, the file could successfully load, but run only
for a split second. So just loading successfully isn't good enough.
Attempt to solve this by marking problematic playlist entries as failed,
and by having playlist_prev skip past such playlist entries. We define
failure as not being able to play more than 3 seconds (or failing to
initialize to begin with). (The 3 seconds are in real time, not file
duration.)
"playlist_prev force" still exhibits the old behavior.
Additionally, use the same mechanism to prevent pointless infinite
reloading if none of the files on the playlist exist. (See github issue
All in all, this is a heuristic, and later adjustments might be
necessary.
Note: forward skips (playlist_next) are not affected at all. (Except for
the interaction with --loop.)
2013-09-15 03:03:37 +00:00
|
|
|
struct playlist_entry *e = mp_next_file(mpctx, dir, force);
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
if (!e && !force)
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2013-11-03 05:06:45 +00:00
|
|
|
mp_set_playlist_entry(mpctx, e);
|
2014-11-11 21:07:16 +00:00
|
|
|
if (on_osd & MP_ON_OSD_MSG)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_CURRENT_FILE;
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_SUB_STEP:
|
2013-12-24 16:46:14 +00:00
|
|
|
case MP_CMD_SUB_SEEK: {
|
2015-05-26 19:42:34 +00:00
|
|
|
if (!mpctx->playback_initialized)
|
2014-09-01 19:44:54 +00:00
|
|
|
return -1;
|
2015-11-17 00:54:02 +00:00
|
|
|
struct dec_sub *sub = mpctx->d_sub[0];
|
2014-11-05 17:47:12 +00:00
|
|
|
double refpts = get_current_time(mpctx);
|
2015-11-17 00:54:02 +00:00
|
|
|
if (sub && refpts != MP_NOPTS_VALUE) {
|
2013-06-28 23:34:11 +00:00
|
|
|
double a[2];
|
2015-11-16 22:15:59 +00:00
|
|
|
a[0] = refpts - opts->sub_delay;
|
2013-06-28 23:34:11 +00:00
|
|
|
a[1] = cmd->args[0].v.i;
|
2015-11-17 00:54:02 +00:00
|
|
|
if (sub_control(sub, SD_CTRL_SUB_STEP, a) > 0) {
|
2013-10-02 19:05:04 +00:00
|
|
|
if (cmd->id == MP_CMD_SUB_STEP) {
|
2014-01-06 16:38:10 +00:00
|
|
|
opts->sub_delay -= a[0];
|
2013-10-02 19:05:04 +00:00
|
|
|
osd_changed_all(mpctx->osd);
|
2014-09-21 22:08:19 +00:00
|
|
|
show_property_osd(mpctx, "sub-delay", on_osd);
|
2013-10-02 19:05:04 +00:00
|
|
|
} else {
|
2013-10-07 15:16:03 +00:00
|
|
|
// We can easily get stuck by failing to seek to the video
|
|
|
|
// frame which actually shows the sub first (because video
|
|
|
|
// frame PTS and sub PTS rarely match exactly). Add some
|
|
|
|
// rounding for the mess of it.
|
|
|
|
a[0] += 0.01 * (a[1] > 0 ? 1 : -1);
|
2013-12-01 01:07:32 +00:00
|
|
|
mark_seek(mpctx);
|
2015-03-04 16:21:05 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_RELATIVE, a[0], MPSEEK_EXACT, false);
|
2013-10-02 19:05:04 +00:00
|
|
|
set_osd_function(mpctx, (a[0] > 0) ? OSD_FFW : OSD_REW);
|
|
|
|
if (bar_osd)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
|
|
|
|
if (msg_or_nobar_osd)
|
|
|
|
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_TEXT;
|
|
|
|
}
|
2012-09-01 17:49:04 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-12-24 16:46:14 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_OSD: {
|
|
|
|
int v = cmd->args[0].v.i;
|
2014-09-21 22:25:59 +00:00
|
|
|
if (opts->osd_level > MAX_OSD_LEVEL)
|
|
|
|
opts->osd_level = MAX_OSD_LEVEL;
|
2011-08-07 01:45:40 +00:00
|
|
|
if (v < 0)
|
2014-09-21 22:25:59 +00:00
|
|
|
opts->osd_level = (opts->osd_level + 1) % (MAX_OSD_LEVEL + 1);
|
2011-08-07 01:45:40 +00:00
|
|
|
else
|
2014-09-21 22:25:59 +00:00
|
|
|
opts->osd_level = MPCLAMP(v, 0, MAX_OSD_LEVEL);
|
2014-10-03 01:37:27 +00:00
|
|
|
if (opts->osd_level > 0 && (on_osd & MP_ON_OSD_MSG))
|
2014-09-21 22:25:59 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "OSD level: %d", opts->osd_level);
|
2014-10-03 01:37:27 +00:00
|
|
|
if (opts->osd_level == 0)
|
2014-09-26 11:52:55 +00:00
|
|
|
set_osd_msg(mpctx, 0, 0, "");
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-10-11 00:24:13 +00:00
|
|
|
case MP_CMD_PRINT_TEXT: {
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_INFO(mpctx, "%s\n", cmd->args[0].v.s);
|
2012-10-11 00:24:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-09-15 00:04:57 +00:00
|
|
|
case MP_CMD_SHOW_TEXT: {
|
2013-05-18 10:56:22 +00:00
|
|
|
// if no argument supplied use default osd_duration, else <arg> ms.
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, cmd->args[2].v.i,
|
2013-05-18 10:56:22 +00:00
|
|
|
(cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
|
|
|
|
"%s", cmd->args[0].v.s);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_LOADFILE: {
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
char *filename = cmd->args[0].v.s;
|
2014-07-22 22:20:53 +00:00
|
|
|
int append = cmd->args[1].v.i;
|
2010-05-03 23:34:38 +00:00
|
|
|
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
if (!append)
|
|
|
|
playlist_clear(mpctx->playlist);
|
|
|
|
|
2014-02-22 06:28:05 +00:00
|
|
|
struct playlist_entry *entry = playlist_entry_new(filename);
|
|
|
|
if (cmd->args[2].v.str_list) {
|
|
|
|
char **pairs = cmd->args[2].v.str_list;
|
|
|
|
for (int i = 0; pairs[i] && pairs[i + 1]; i += 2) {
|
|
|
|
playlist_entry_add_param(entry, bstr0(pairs[i]),
|
|
|
|
bstr0(pairs[i + 1]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
playlist_add(mpctx->playlist, entry);
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
|
2014-10-10 12:44:22 +00:00
|
|
|
if (!append || (append == 2 && !mpctx->playlist->current)) {
|
|
|
|
if (opts->position_save_on_quit) // requested in issue #1148
|
|
|
|
mp_write_watch_later_conf(mpctx);
|
2014-10-27 20:50:40 +00:00
|
|
|
mp_set_playlist_entry(mpctx, entry);
|
2014-10-10 12:44:22 +00:00
|
|
|
}
|
2014-11-08 22:03:04 +00:00
|
|
|
mp_notify_property(mpctx, "playlist");
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_LOADLIST: {
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
char *filename = cmd->args[0].v.s;
|
|
|
|
bool append = cmd->args[1].v.i;
|
2013-12-21 19:15:47 +00:00
|
|
|
struct playlist *pl = playlist_parse_file(filename, mpctx->global);
|
2013-04-10 15:16:49 +00:00
|
|
|
if (pl) {
|
2014-12-29 21:08:22 +00:00
|
|
|
prepare_playlist(mpctx, pl);
|
|
|
|
struct playlist_entry *new = pl->current;
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
if (!append)
|
|
|
|
playlist_clear(mpctx->playlist);
|
2014-07-24 17:30:24 +00:00
|
|
|
playlist_append_entries(mpctx->playlist, pl);
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
talloc_free(pl);
|
|
|
|
|
2014-12-29 21:08:22 +00:00
|
|
|
if (!append && mpctx->playlist->first)
|
|
|
|
mp_set_playlist_entry(mpctx, new ? new : mpctx->playlist->first);
|
|
|
|
|
2014-11-08 22:03:04 +00:00
|
|
|
mp_notify_property(mpctx, "playlist");
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
} else {
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_ERR(mpctx, "Unable to load playlist %s.\n", filename);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
case MP_CMD_PLAYLIST_CLEAR: {
|
|
|
|
// Supposed to clear the playlist, except the currently played item.
|
|
|
|
if (mpctx->playlist->current_was_replaced)
|
|
|
|
mpctx->playlist->current = NULL;
|
|
|
|
while (mpctx->playlist->first) {
|
|
|
|
struct playlist_entry *e = mpctx->playlist->first;
|
|
|
|
if (e == mpctx->playlist->current) {
|
|
|
|
e = e->next;
|
|
|
|
if (!e)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
playlist_remove(mpctx->playlist, e);
|
|
|
|
}
|
2014-11-08 22:03:04 +00:00
|
|
|
mp_notify_property(mpctx, "playlist");
|
2012-02-10 18:03:24 +00:00
|
|
|
break;
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
}
|
2012-02-10 18:03:24 +00:00
|
|
|
|
2013-07-02 11:17:50 +00:00
|
|
|
case MP_CMD_PLAYLIST_REMOVE: {
|
|
|
|
struct playlist_entry *e = playlist_entry_from_index(mpctx->playlist,
|
|
|
|
cmd->args[0].v.i);
|
2013-11-28 18:13:48 +00:00
|
|
|
if (cmd->args[0].v.i < 0)
|
|
|
|
e = mpctx->playlist->current;
|
2014-06-01 01:41:46 +00:00
|
|
|
if (!e)
|
|
|
|
return -1;
|
|
|
|
// Can't play a removed entry
|
2015-07-08 19:31:31 +00:00
|
|
|
if (mpctx->playlist->current == e && !mpctx->stop_play)
|
2014-06-01 01:41:46 +00:00
|
|
|
mpctx->stop_play = PT_CURRENT_ENTRY;
|
|
|
|
playlist_remove(mpctx->playlist, e);
|
2014-11-08 22:03:04 +00:00
|
|
|
mp_notify_property(mpctx, "playlist");
|
2013-07-02 11:17:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case MP_CMD_PLAYLIST_MOVE: {
|
|
|
|
struct playlist_entry *e1 = playlist_entry_from_index(mpctx->playlist,
|
|
|
|
cmd->args[0].v.i);
|
|
|
|
struct playlist_entry *e2 = playlist_entry_from_index(mpctx->playlist,
|
|
|
|
cmd->args[1].v.i);
|
2014-06-01 01:41:46 +00:00
|
|
|
if (!e1)
|
|
|
|
return -1;
|
|
|
|
playlist_move(mpctx->playlist, e1, e2);
|
2014-11-08 22:03:04 +00:00
|
|
|
mp_notify_property(mpctx, "playlist");
|
2013-07-02 11:17:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-05-17 19:16:10 +00:00
|
|
|
case MP_CMD_PLAYLIST_SHUFFLE: {
|
|
|
|
playlist_shuffle(mpctx->playlist);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_STOP:
|
2014-10-10 13:13:04 +00:00
|
|
|
playlist_clear(mpctx->playlist);
|
2015-10-06 16:18:13 +00:00
|
|
|
if (mpctx->stop_play != PT_QUIT)
|
2015-07-08 19:31:31 +00:00
|
|
|
mpctx->stop_play = PT_STOP;
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2012-09-15 00:04:57 +00:00
|
|
|
case MP_CMD_SHOW_PROGRESS:
|
2012-09-25 01:24:38 +00:00
|
|
|
mpctx->add_osd_seek_info |=
|
|
|
|
(msg_osd ? OSD_SEEK_INFO_TEXT : 0) |
|
|
|
|
(bar_osd ? OSD_SEEK_INFO_BAR : 0);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2010-04-09 19:20:52 +00:00
|
|
|
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
case MP_CMD_TV_LAST_CHANNEL: {
|
2014-09-01 19:44:54 +00:00
|
|
|
if (!mpctx->demuxer)
|
|
|
|
return -1;
|
|
|
|
demux_stream_control(mpctx->demuxer, STREAM_CTRL_TV_LAST_CHAN, NULL);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.
Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.
In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.
Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.
Mostly untested, due to lack of hardware.
2014-06-09 21:38:28 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2015-02-03 08:15:14 +00:00
|
|
|
case MP_CMD_SUB_ADD:
|
|
|
|
case MP_CMD_AUDIO_ADD: {
|
2014-10-20 21:33:46 +00:00
|
|
|
if (!mpctx->playing)
|
2014-09-01 19:44:54 +00:00
|
|
|
return -1;
|
2015-02-03 08:15:14 +00:00
|
|
|
int type = cmd->id == MP_CMD_SUB_ADD ? STREAM_SUB : STREAM_AUDIO;
|
2014-10-23 11:11:41 +00:00
|
|
|
if (cmd->args[1].v.i == 2) {
|
2015-06-03 19:34:46 +00:00
|
|
|
struct track *t = find_track_with_url(mpctx, type, cmd->args[0].v.s);
|
2015-02-03 08:15:14 +00:00
|
|
|
if (t) {
|
2015-05-26 12:01:23 +00:00
|
|
|
mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
|
2014-10-23 11:11:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2015-02-03 08:15:14 +00:00
|
|
|
struct track *t = mp_add_external_file(mpctx, cmd->args[0].v.s, type);
|
|
|
|
if (!t)
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2014-11-27 17:57:18 +00:00
|
|
|
if (cmd->args[1].v.i == 1) {
|
2015-02-03 08:15:14 +00:00
|
|
|
t->no_default = true;
|
2014-11-27 17:57:18 +00:00
|
|
|
} else {
|
2015-05-26 12:01:23 +00:00
|
|
|
mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION);
|
2014-10-20 21:55:29 +00:00
|
|
|
}
|
|
|
|
char *title = cmd->args[2].v.s;
|
|
|
|
if (title && title[0])
|
2015-02-03 08:15:14 +00:00
|
|
|
t->title = talloc_strdup(t, title);
|
2014-10-20 21:55:29 +00:00
|
|
|
char *lang = cmd->args[3].v.s;
|
|
|
|
if (lang && lang[0])
|
2015-02-03 08:15:14 +00:00
|
|
|
t->lang = talloc_strdup(t, lang);
|
2015-06-03 19:34:46 +00:00
|
|
|
if (mpctx->playback_initialized)
|
2015-06-03 19:50:37 +00:00
|
|
|
print_track_list(mpctx, "Track added:");
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2014-02-13 12:30:07 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2015-02-03 08:15:14 +00:00
|
|
|
case MP_CMD_SUB_REMOVE:
|
|
|
|
case MP_CMD_AUDIO_REMOVE: {
|
|
|
|
int type = cmd->id == MP_CMD_SUB_REMOVE ? STREAM_SUB : STREAM_AUDIO;
|
|
|
|
struct track *t = mp_track_by_tid(mpctx, type, cmd->args[0].v.i);
|
|
|
|
if (!t)
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2015-02-03 08:15:14 +00:00
|
|
|
mp_remove_track(mpctx, t);
|
2015-06-03 19:34:46 +00:00
|
|
|
if (mpctx->playback_initialized)
|
2015-06-03 19:50:37 +00:00
|
|
|
print_track_list(mpctx, "Track removed:");
|
2012-11-15 19:26:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-03 08:15:14 +00:00
|
|
|
case MP_CMD_SUB_RELOAD:
|
|
|
|
case MP_CMD_AUDIO_RELOAD: {
|
|
|
|
int type = cmd->id == MP_CMD_SUB_RELOAD ? STREAM_SUB : STREAM_AUDIO;
|
|
|
|
struct track *t = mp_track_by_tid(mpctx, type, cmd->args[0].v.i);
|
2015-04-28 20:06:22 +00:00
|
|
|
struct track *nt = NULL;
|
2015-02-03 08:15:14 +00:00
|
|
|
if (t && t->is_external && t->external_filename) {
|
2015-04-28 20:06:22 +00:00
|
|
|
char *filename = talloc_strdup(NULL, t->external_filename);
|
|
|
|
mp_remove_track(mpctx, t);
|
|
|
|
nt = mp_add_external_file(mpctx, filename, type);
|
|
|
|
talloc_free(filename);
|
|
|
|
}
|
|
|
|
if (nt) {
|
2015-05-26 12:01:23 +00:00
|
|
|
mp_switch_track(mpctx, nt->type, nt, 0);
|
2015-06-03 19:50:37 +00:00
|
|
|
print_track_list(mpctx, "Reloaded:");
|
2015-04-28 20:06:22 +00:00
|
|
|
return 0;
|
2012-11-15 19:26:52 +00:00
|
|
|
}
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2012-11-15 19:26:52 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 21:06:41 +00:00
|
|
|
case MP_CMD_RESCAN_EXTERNAL_FILES: {
|
|
|
|
if (!mpctx->playing)
|
|
|
|
return -1;
|
|
|
|
autoload_external_files(mpctx);
|
|
|
|
if (cmd->args[0].v.i) {
|
|
|
|
// somewhat fuzzy and not ideal
|
2015-05-22 19:00:24 +00:00
|
|
|
struct track *a = select_default_track(mpctx, 0, STREAM_AUDIO);
|
2015-02-16 21:06:41 +00:00
|
|
|
if (a && a->is_external)
|
2015-05-26 12:01:23 +00:00
|
|
|
mp_switch_track(mpctx, STREAM_AUDIO, a, 0);
|
2015-05-22 19:00:24 +00:00
|
|
|
struct track *s = select_default_track(mpctx, 0, STREAM_SUB);
|
2015-02-16 21:06:41 +00:00
|
|
|
if (s && s->is_external)
|
2015-05-26 12:01:23 +00:00
|
|
|
mp_switch_track(mpctx, STREAM_SUB, s, 0);
|
2015-04-28 20:04:37 +00:00
|
|
|
|
2015-06-03 19:34:46 +00:00
|
|
|
if (mpctx->playback_initialized)
|
2015-06-03 19:50:37 +00:00
|
|
|
print_track_list(mpctx, "Track list:\n");
|
2015-02-16 21:06:41 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-03-04 16:21:02 +00:00
|
|
|
case MP_CMD_SCREENSHOT: {
|
|
|
|
int mode = cmd->args[0].v.i & 3;
|
|
|
|
int freq = (cmd->args[0].v.i | cmd->args[1].v.i) >> 3;
|
|
|
|
screenshot_request(mpctx, mode, freq, msg_osd);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2015-03-04 16:21:02 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2013-07-08 18:34:26 +00:00
|
|
|
case MP_CMD_SCREENSHOT_TO_FILE:
|
|
|
|
screenshot_to_file(mpctx, cmd->args[0].v.s, cmd->args[1].v.i, msg_osd);
|
|
|
|
break;
|
|
|
|
|
2015-04-20 21:11:03 +00:00
|
|
|
case MP_CMD_SCREENSHOT_RAW: {
|
|
|
|
if (!res)
|
|
|
|
return -1;
|
|
|
|
struct mp_image *img = screenshot_get_rgb(mpctx, cmd->args[0].v.i);
|
|
|
|
if (!img)
|
|
|
|
return -1;
|
|
|
|
struct mpv_node_list *info = talloc_zero(NULL, struct mpv_node_list);
|
|
|
|
talloc_steal(info, img);
|
|
|
|
*res = (mpv_node){ .format = MPV_FORMAT_NODE_MAP, .u.list = info };
|
|
|
|
ADD_MAP_INT(res, "w", img->w);
|
|
|
|
ADD_MAP_INT(res, "h", img->h);
|
|
|
|
ADD_MAP_INT(res, "stride", img->stride[0]);
|
|
|
|
ADD_MAP_CSTR(res, "format", "bgr0");
|
|
|
|
struct mpv_byte_array *ba = talloc_ptrtype(info, ba);
|
|
|
|
*ba = (struct mpv_byte_array){
|
|
|
|
.data = img->planes[0],
|
|
|
|
.size = img->stride[0] * img->h,
|
|
|
|
};
|
|
|
|
*add_map_entry(res, "data") =
|
|
|
|
(struct mpv_node){.format = MPV_FORMAT_BYTE_ARRAY, .u.ba = ba,};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-29 22:36:44 +00:00
|
|
|
case MP_CMD_RUN: {
|
|
|
|
char *args[MP_CMD_MAX_ARGS + 1] = {0};
|
|
|
|
for (int n = 0; n < cmd->nargs; n++)
|
|
|
|
args[n] = cmd->args[n].v.s;
|
2015-04-15 20:43:02 +00:00
|
|
|
mp_subprocess_detached(mpctx->log, args);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2013-11-29 22:36:44 +00:00
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2013-06-22 23:28:28 +00:00
|
|
|
case MP_CMD_ENABLE_INPUT_SECTION:
|
2015-08-05 22:31:47 +00:00
|
|
|
mp_input_enable_section(mpctx->input, cmd->args[0].v.s, cmd->args[1].v.i);
|
2013-06-22 23:28:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MP_CMD_DISABLE_INPUT_SECTION:
|
|
|
|
mp_input_disable_section(mpctx->input, cmd->args[0].v.s);
|
|
|
|
break;
|
|
|
|
|
2015-08-05 21:55:16 +00:00
|
|
|
case MP_CMD_DEFINE_INPUT_SECTION:
|
|
|
|
mp_input_define_section(mpctx->input, cmd->args[0].v.s, "<api>",
|
|
|
|
cmd->args[1].v.s, !!cmd->args[2].v.i);
|
|
|
|
break;
|
|
|
|
|
2014-11-18 20:33:15 +00:00
|
|
|
case MP_CMD_AB_LOOP: {
|
|
|
|
double now = get_current_time(mpctx);
|
|
|
|
int r = 0;
|
|
|
|
if (opts->ab_loop[0] == MP_NOPTS_VALUE) {
|
|
|
|
r = mp_property_do("ab-loop-a", M_PROPERTY_SET, &now, mpctx);
|
|
|
|
show_property_osd(mpctx, "ab-loop-a", on_osd);
|
|
|
|
} else if (opts->ab_loop[1] == MP_NOPTS_VALUE) {
|
|
|
|
r = mp_property_do("ab-loop-b", M_PROPERTY_SET, &now, mpctx);
|
|
|
|
show_property_osd(mpctx, "ab-loop-b", on_osd);
|
|
|
|
} else {
|
|
|
|
now = MP_NOPTS_VALUE;
|
|
|
|
r = mp_property_do("ab-loop-a", M_PROPERTY_SET, &now, mpctx);
|
|
|
|
r = mp_property_do("ab-loop-b", M_PROPERTY_SET, &now, mpctx);
|
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Clear A-B loop");
|
|
|
|
}
|
|
|
|
return r > 0;
|
|
|
|
}
|
|
|
|
|
2014-11-20 21:41:50 +00:00
|
|
|
case MP_CMD_DROP_BUFFERS: {
|
|
|
|
reset_audio_state(mpctx);
|
|
|
|
reset_video_state(mpctx);
|
|
|
|
|
|
|
|
if (mpctx->demuxer)
|
|
|
|
demux_flush(mpctx->demuxer);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-07-31 23:06:59 +00:00
|
|
|
case MP_CMD_VO_CMDLINE:
|
|
|
|
if (mpctx->video_out) {
|
|
|
|
char *s = cmd->args[0].v.s;
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_INFO(mpctx, "Setting vo cmd line to '%s'.\n", s);
|
2012-07-31 23:06:59 +00:00
|
|
|
if (vo_control(mpctx->video_out, VOCTRL_SET_COMMAND_LINE, s) > 0) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "vo='%s'", s);
|
2012-07-31 23:06:59 +00:00
|
|
|
} else {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "Failed!");
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2012-07-31 23:06:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-10-27 10:52:42 +00:00
|
|
|
case MP_CMD_AO_RELOAD:
|
|
|
|
reload_audio_output(mpctx);
|
|
|
|
break;
|
|
|
|
|
2013-07-22 12:43:58 +00:00
|
|
|
case MP_CMD_AF:
|
2014-06-01 01:41:46 +00:00
|
|
|
return edit_filters_osd(mpctx, STREAM_AUDIO, cmd->args[0].v.s,
|
|
|
|
cmd->args[1].v.s, msg_osd);
|
2013-07-22 12:43:58 +00:00
|
|
|
|
2013-05-18 09:44:17 +00:00
|
|
|
case MP_CMD_VF:
|
2014-06-01 01:41:46 +00:00
|
|
|
return edit_filters_osd(mpctx, STREAM_VIDEO, cmd->args[0].v.s,
|
|
|
|
cmd->args[1].v.s, msg_osd);
|
2010-10-17 15:54:55 +00:00
|
|
|
|
2014-11-23 14:08:49 +00:00
|
|
|
case MP_CMD_SCRIPT_BINDING: {
|
|
|
|
mpv_event_client_message event = {0};
|
|
|
|
char *name = cmd->args[0].v.s;
|
|
|
|
if (!name || !name[0])
|
|
|
|
return -1;
|
|
|
|
char *sep = strchr(name, '/');
|
|
|
|
char *target = NULL;
|
|
|
|
char space[MAX_CLIENT_NAME];
|
2014-12-10 17:28:09 +00:00
|
|
|
if (sep) {
|
2014-11-23 14:08:49 +00:00
|
|
|
snprintf(space, sizeof(space), "%.*s", (int)(sep - name), name);
|
|
|
|
target = space;
|
|
|
|
name = sep + 1;
|
|
|
|
}
|
|
|
|
char state[3] = {'p', cmd->is_mouse_button ? 'm' : '-'};
|
|
|
|
if (cmd->is_up_down)
|
|
|
|
state[0] = cmd->repeated ? 'r' : (cmd->is_up ? 'u' : 'd');
|
2015-12-23 18:10:38 +00:00
|
|
|
event.num_args = 4;
|
|
|
|
event.args = (const char*[4]){"key-binding", name, state, cmd->key_name};
|
2014-11-23 14:08:49 +00:00
|
|
|
if (mp_client_send_event_dup(mpctx, target,
|
|
|
|
MPV_EVENT_CLIENT_MESSAGE, &event) < 0)
|
2014-02-10 20:03:59 +00:00
|
|
|
{
|
|
|
|
MP_VERBOSE(mpctx, "Can't find script '%s' when handling input.\n",
|
2014-11-23 14:08:49 +00:00
|
|
|
target ? target : "-");
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-02-10 20:03:59 +00:00
|
|
|
}
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
|
2014-03-17 17:26:56 +00:00
|
|
|
case MP_CMD_SCRIPT_MESSAGE_TO: {
|
2014-02-17 01:33:47 +00:00
|
|
|
mpv_event_client_message *event = talloc_ptrtype(NULL, event);
|
|
|
|
*event = (mpv_event_client_message){0};
|
|
|
|
for (int n = 1; n < cmd->nargs; n++) {
|
|
|
|
MP_TARRAY_APPEND(event, event->args, event->num_args,
|
2014-08-11 11:00:57 +00:00
|
|
|
talloc_strdup(event, cmd->args[n].v.s));
|
2014-02-17 01:33:47 +00:00
|
|
|
}
|
|
|
|
if (mp_client_send_event(mpctx, cmd->args[0].v.s,
|
|
|
|
MPV_EVENT_CLIENT_MESSAGE, event) < 0)
|
|
|
|
{
|
|
|
|
MP_VERBOSE(mpctx, "Can't find script '%s' for %s.\n",
|
|
|
|
cmd->args[0].v.s, cmd->name);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2014-02-17 01:33:47 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-03-17 17:26:56 +00:00
|
|
|
case MP_CMD_SCRIPT_MESSAGE: {
|
|
|
|
const char *args[MP_CMD_MAX_ARGS];
|
|
|
|
mpv_event_client_message event = {.args = args};
|
|
|
|
for (int n = 0; n < cmd->nargs; n++)
|
|
|
|
event.args[event.num_args++] = cmd->args[n].v.s;
|
|
|
|
mp_client_broadcast_event(mpctx, MPV_EVENT_CLIENT_MESSAGE, &event);
|
|
|
|
break;
|
|
|
|
}
|
2014-02-17 01:33:47 +00:00
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
case MP_CMD_OVERLAY_ADD:
|
|
|
|
overlay_add(mpctx,
|
|
|
|
cmd->args[0].v.i, cmd->args[1].v.i, cmd->args[2].v.i,
|
|
|
|
cmd->args[3].v.s, cmd->args[4].v.i, cmd->args[5].v.s,
|
|
|
|
cmd->args[6].v.i, cmd->args[7].v.i, cmd->args[8].v.i);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MP_CMD_OVERLAY_REMOVE:
|
|
|
|
overlay_remove(mpctx, cmd->args[0].v.i);
|
|
|
|
break;
|
|
|
|
|
2013-07-08 17:27:45 +00:00
|
|
|
case MP_CMD_COMMAND_LIST: {
|
|
|
|
for (struct mp_cmd *sub = cmd->args[0].v.p; sub; sub = sub->queue_next)
|
2015-04-20 21:00:12 +00:00
|
|
|
run_command(mpctx, sub, NULL);
|
2013-07-08 17:27:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-08-30 00:30:17 +00:00
|
|
|
case MP_CMD_IGNORE:
|
|
|
|
break;
|
|
|
|
|
2014-05-26 16:11:02 +00:00
|
|
|
case MP_CMD_WRITE_WATCH_LATER_CONFIG: {
|
|
|
|
mp_write_watch_later_conf(mpctx);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
case MP_CMD_HOOK_ADD:
|
|
|
|
if (!cmd->sender) {
|
|
|
|
MP_ERR(mpctx, "Can be used from client API only.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
mp_hook_add(mpctx, cmd->sender, cmd->args[0].v.s, cmd->args[1].v.i,
|
|
|
|
cmd->args[2].v.i);
|
|
|
|
break;
|
|
|
|
case MP_CMD_HOOK_ACK:
|
|
|
|
if (!cmd->sender) {
|
|
|
|
MP_ERR(mpctx, "Can be used from client API only.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
mp_hook_run(mpctx, cmd->sender, cmd->args[0].v.s);
|
|
|
|
break;
|
|
|
|
|
2015-01-23 20:45:13 +00:00
|
|
|
case MP_CMD_MOUSE: {
|
|
|
|
const int x = cmd->args[0].v.i, y = cmd->args[1].v.i;
|
|
|
|
int button = cmd->args[2].v.i;
|
|
|
|
if (button == -1) {// no button
|
|
|
|
mp_input_set_mouse_pos(mpctx->input, x, y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (button < 0 || button >= 20) {// invalid button
|
|
|
|
MP_ERR(mpctx, "%d is not a valid mouse button number.\n", button);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
const bool dbc = cmd->args[3].v.i;
|
|
|
|
button += dbc ? MP_MOUSE_BASE_DBL : MP_MOUSE_BASE;
|
|
|
|
mp_input_set_mouse_pos(mpctx->input, x, y);
|
|
|
|
mp_input_put_key(mpctx->input, button);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-06-10 23:56:56 +00:00
|
|
|
case MP_CMD_KEYPRESS:
|
|
|
|
case MP_CMD_KEYDOWN: {
|
|
|
|
const char *key_name = cmd->args[0].v.s;
|
|
|
|
int code = mp_input_get_key_from_name(key_name);
|
|
|
|
if (code < 0) {
|
|
|
|
MP_ERR(mpctx, "%s is not a valid input name.\n", key_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (cmd->id == MP_CMD_KEYDOWN)
|
|
|
|
code |= MP_KEY_STATE_DOWN;
|
|
|
|
|
|
|
|
mp_input_put_key(mpctx->input, code);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case MP_CMD_KEYUP: {
|
|
|
|
const char *key_name = cmd->args[0].v.s;
|
|
|
|
if (key_name[0] == '\0') {
|
|
|
|
mp_input_put_key(mpctx->input, MP_INPUT_RELEASE_ALL);
|
|
|
|
} else {
|
|
|
|
int code = mp_input_get_key_from_name(key_name);
|
|
|
|
if (code < 0) {
|
|
|
|
MP_ERR(mpctx, "%s is not a valid input name.\n", key_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
mp_input_put_key(mpctx->input, code | MP_KEY_STATE_UP);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
default:
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_VERBOSE(mpctx, "Received unknown cmd %s\n", cmd->name);
|
2014-06-01 01:41:46 +00:00
|
|
|
return -1;
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2014-06-01 01:41:46 +00:00
|
|
|
return 0;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
void command_uninit(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
overlay_uninit(mpctx);
|
2015-02-12 15:53:56 +00:00
|
|
|
ao_hotplug_destroy(mpctx->command_ctx->hotplug);
|
2013-09-30 20:27:37 +00:00
|
|
|
talloc_free(mpctx->command_ctx);
|
|
|
|
mpctx->command_ctx = NULL;
|
|
|
|
}
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
|
|
|
|
void command_init(struct MPContext *mpctx)
|
|
|
|
{
|
2013-12-01 01:07:32 +00:00
|
|
|
mpctx->command_ctx = talloc(NULL, struct command_ctx);
|
|
|
|
*mpctx->command_ctx = (struct command_ctx){
|
|
|
|
.last_seek_pts = MP_NOPTS_VALUE,
|
2014-11-17 23:09:42 +00:00
|
|
|
.prev_pts = MP_NOPTS_VALUE,
|
2013-12-01 01:07:32 +00:00
|
|
|
};
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
}
|
|
|
|
|
2014-11-17 23:09:42 +00:00
|
|
|
static void command_event(struct MPContext *mpctx, int event, void *arg)
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
{
|
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
2014-11-17 23:09:42 +00:00
|
|
|
|
2014-12-17 21:56:45 +00:00
|
|
|
if (event == MPV_EVENT_START_FILE) {
|
2014-02-10 20:01:35 +00:00
|
|
|
ctx->last_seek_pts = MP_NOPTS_VALUE;
|
2014-12-17 21:56:45 +00:00
|
|
|
ctx->marked_pts = MP_NOPTS_VALUE;
|
|
|
|
}
|
2014-02-10 20:01:35 +00:00
|
|
|
|
2014-12-10 13:42:57 +00:00
|
|
|
if (event == MPV_EVENT_SEEK)
|
2014-11-17 23:09:42 +00:00
|
|
|
ctx->prev_pts = MP_NOPTS_VALUE;
|
2014-12-10 13:42:57 +00:00
|
|
|
if (event == MPV_EVENT_IDLE)
|
|
|
|
ctx->is_idle = true;
|
|
|
|
if (event == MPV_EVENT_START_FILE)
|
|
|
|
ctx->is_idle = false;
|
2014-12-10 16:52:21 +00:00
|
|
|
if (event == MPV_EVENT_END_FILE || event == MPV_EVENT_FILE_LOADED) {
|
|
|
|
// Update chapters - does nothing if something else is visible.
|
|
|
|
set_osd_bar_chapters(mpctx, OSD_BAR_SEEK);
|
|
|
|
}
|
2015-02-14 14:13:58 +00:00
|
|
|
}
|
|
|
|
|
2015-06-16 21:11:14 +00:00
|
|
|
void handle_ab_loop(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
|
|
|
struct MPOpts *opts = mpctx->opts;
|
|
|
|
|
|
|
|
double now = mpctx->restart_complete ? mpctx->playback_pts : MP_NOPTS_VALUE;
|
|
|
|
if (now != MP_NOPTS_VALUE && opts->ab_loop[0] != MP_NOPTS_VALUE &&
|
|
|
|
opts->ab_loop[1] != MP_NOPTS_VALUE)
|
|
|
|
{
|
|
|
|
if (ctx->prev_pts >= opts->ab_loop[0] &&
|
|
|
|
ctx->prev_pts < opts->ab_loop[1] &&
|
|
|
|
(now >= opts->ab_loop[1] || mpctx->stop_play == AT_END_OF_FILE))
|
|
|
|
{
|
|
|
|
mark_seek(mpctx);
|
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, opts->ab_loop[0],
|
|
|
|
MPSEEK_EXACT, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctx->prev_pts = now;
|
|
|
|
}
|
|
|
|
|
2015-02-14 14:13:58 +00:00
|
|
|
void handle_command_updates(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct command_ctx *ctx = mpctx->command_ctx;
|
2015-02-12 15:53:56 +00:00
|
|
|
|
|
|
|
// This is a bit messy: ao_hotplug wakes up the player, and then we have
|
|
|
|
// to recheck the state. Then the client(s) will read the property.
|
2015-02-14 11:43:55 +00:00
|
|
|
if (ctx->hotplug && ao_hotplug_check_update(ctx->hotplug)) {
|
2015-02-12 15:53:56 +00:00
|
|
|
mp_notify_property(mpctx, "audio-device-list");
|
2015-02-14 11:43:55 +00:00
|
|
|
mp_notify_property(mpctx, "audio-out-detected-device");
|
|
|
|
}
|
2014-11-17 23:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mp_notify(struct MPContext *mpctx, int event, void *arg)
|
|
|
|
{
|
|
|
|
command_event(mpctx, event, arg);
|
|
|
|
|
2014-08-01 23:39:28 +00:00
|
|
|
mp_client_broadcast_event(mpctx, event, arg);
|
2014-04-05 21:54:21 +00:00
|
|
|
}
|
|
|
|
|
2014-06-01 01:41:36 +00:00
|
|
|
void mp_notify_property(struct MPContext *mpctx, const char *property)
|
2014-04-05 21:54:21 +00:00
|
|
|
{
|
2014-08-01 23:39:28 +00:00
|
|
|
mp_client_property_change(mpctx, property);
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
}
|