2010-01-30 23:24:23 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* 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
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
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>
|
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"
|
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 00:40:26 +00:00
|
|
|
#include "stream/resolve/resolve.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/playlist.h"
|
|
|
|
#include "common/playlist_parser.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"
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "stream/tv.h"
|
2007-05-08 12:20:46 +00:00
|
|
|
#include "stream/pvr.h"
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_DVBIN
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "stream/dvbin.h"
|
|
|
|
#endif
|
2011-10-06 18:46:01 +00:00
|
|
|
#include "screenshot.h"
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_SYS_MMAN_H
|
2013-09-30 20:27:37 +00:00
|
|
|
#include <sys/mman.h>
|
|
|
|
#endif
|
2013-12-07 18:26:05 +00:00
|
|
|
#ifndef __MINGW32__
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#endif
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-11-30 21:40:51 +00:00
|
|
|
#include "osdep/io.h"
|
|
|
|
|
2013-12-17 00:08:53 +00:00
|
|
|
#include "core.h"
|
2013-12-17 00:15:48 +00:00
|
|
|
#include "lua.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 {
|
2013-12-01 01:07:32 +00:00
|
|
|
double last_seek_time;
|
|
|
|
double last_seek_pts;
|
|
|
|
|
2013-11-29 23:18:24 +00:00
|
|
|
struct cycle_counter *cycle_counters;
|
|
|
|
int num_cycle_counters;
|
|
|
|
|
2013-09-30 20:27:37 +00:00
|
|
|
#define OVERLAY_MAX_ID 64
|
|
|
|
void *overlay_map[OVERLAY_MAX_ID];
|
2014-01-18 00:19:20 +00:00
|
|
|
struct sub_bitmaps external2;
|
2013-09-30 20:27:37 +00:00
|
|
|
};
|
|
|
|
|
2013-09-20 13:09:29 +00:00
|
|
|
static int edit_filters(struct MPContext *mpctx, enum stream_type mediatype,
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-09-18 13:31:46 +00:00
|
|
|
static char *format_bitrate(int rate)
|
|
|
|
{
|
|
|
|
return talloc_asprintf(NULL, "%d kbps", rate * 8 / 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *format_delay(double time)
|
|
|
|
{
|
|
|
|
return talloc_asprintf(NULL, "%d ms", ROUND(time * 1000));
|
|
|
|
}
|
|
|
|
|
2012-09-18 18:07:24 +00:00
|
|
|
// Property-option bridge.
|
2010-12-18 06:02:48 +00:00
|
|
|
static int mp_property_generic_option(struct m_option *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
|
|
|
char *optname = prop->priv;
|
2012-09-18 18:07:24 +00:00
|
|
|
struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
|
|
|
|
bstr0(optname));
|
|
|
|
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)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_playback_speed(m_option_t *prop, int action,
|
2010-05-07 19:02:47 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2012-09-25 01:24:38 +00:00
|
|
|
double orig_speed = opts->playback_speed;
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET: {
|
2013-08-04 21:56:20 +00:00
|
|
|
opts->playback_speed = *(double *) arg;
|
2011-12-06 00:46:37 +00:00
|
|
|
// Adjust time until next frame flip for nosound mode
|
|
|
|
mpctx->time_frame *= orig_speed / opts->playback_speed;
|
2013-11-23 20:22:17 +00:00
|
|
|
if (mpctx->d_audio)
|
2013-04-03 23:19:29 +00:00
|
|
|
reinit_audio_chain(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:
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "x %6.2f", orig_speed);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// filename with path (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_path(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2012-10-13 15:09:35 +00:00
|
|
|
if (!mpctx->filename)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-10-14 21:08:39 +00:00
|
|
|
return m_property_strdup_ro(prop, action, arg, mpctx->filename);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 18:32:57 +00:00
|
|
|
static int mp_property_filename(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
int r = m_property_strdup_ro(prop, action, arg, f[0] ? f : filename);
|
|
|
|
talloc_free(filename);
|
|
|
|
return r;
|
2012-10-30 18:32:57 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 15:09:35 +00:00
|
|
|
static int mp_property_media_title(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2012-10-30 18:32:57 +00:00
|
|
|
char *name = NULL;
|
2012-10-13 15:09:35 +00:00
|
|
|
if (mpctx->resolve_result)
|
|
|
|
name = mpctx->resolve_result->title;
|
2013-05-15 13:06:21 +00:00
|
|
|
if (name && name[0])
|
2012-10-30 18:32:57 +00:00
|
|
|
return m_property_strdup_ro(prop, action, arg, name);
|
2013-05-15 13:06:21 +00:00
|
|
|
if (mpctx->master_demuxer) {
|
|
|
|
name = demux_info_get(mpctx->master_demuxer, "title");
|
|
|
|
if (name && name[0])
|
|
|
|
return m_property_strdup_ro(prop, action, arg, name);
|
2012-10-30 18:32:57 +00:00
|
|
|
}
|
2013-05-15 13:06:21 +00:00
|
|
|
return mp_property_filename(prop, action, arg, mpctx);
|
2012-10-13 15:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_stream_path(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct stream *stream = mpctx->stream;
|
|
|
|
if (!stream || !stream->url)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-10-14 21:08:39 +00:00
|
|
|
return m_property_strdup_ro(prop, action, arg, stream->url);
|
2012-10-13 15:09:35 +00:00
|
|
|
}
|
|
|
|
|
2013-05-11 20:19:33 +00:00
|
|
|
static int mp_property_stream_capture(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
|
|
|
if (!mpctx->stream)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
if (action == M_PROPERTY_SET) {
|
|
|
|
char *filename = *(char **)arg;
|
|
|
|
stream_set_capture_file(mpctx->stream, filename);
|
|
|
|
// fall through to mp_property_generic_option
|
|
|
|
}
|
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Demuxer name (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_demuxer(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
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;
|
2012-10-14 21:08:39 +00:00
|
|
|
return m_property_strdup_ro(prop, action, arg, demuxer->desc->name);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Position in the stream (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_stream_pos(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
struct stream *stream = mpctx->stream;
|
|
|
|
if (!stream)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2012-09-18 09:48:50 +00:00
|
|
|
*(int64_t *) arg = stream_tell(stream);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_SET:
|
2012-09-18 09:48:50 +00:00
|
|
|
stream_seek(stream, *(int64_t *) arg);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Stream start offset (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_stream_start(m_option_t *prop, int action,
|
2010-05-07 19:02:47 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
struct stream *stream = mpctx->stream;
|
|
|
|
if (!stream)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-10-14 21:08:39 +00:00
|
|
|
return m_property_int64_ro(prop, action, arg, stream->start_pos);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Stream end offset (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_stream_end(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
struct stream *stream = mpctx->stream;
|
|
|
|
if (!stream)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-10-14 21:08:39 +00:00
|
|
|
return m_property_int64_ro(prop, action, arg, stream->end_pos);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Stream length (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_stream_length(m_option_t *prop, int action,
|
2010-05-07 19:02:47 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
struct stream *stream = mpctx->stream;
|
|
|
|
if (!stream)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-10-14 21:08:39 +00:00
|
|
|
return m_property_int64_ro(prop, action, arg,
|
|
|
|
stream->end_pos - stream->start_pos);
|
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.
|
|
|
|
static int property_time(m_option_t *prop, int action, void *arg, double time)
|
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(double *)arg = time;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
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:
|
|
|
|
*(struct m_option *)ka->arg = *prop;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2010-07-25 09:06:37 +00:00
|
|
|
/// Current stream position in seconds (RO)
|
|
|
|
static int mp_property_stream_time_pos(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
struct demuxer *demuxer = mpctx->demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
double pts = demuxer->stream_pts;
|
|
|
|
if (pts == MP_NOPTS_VALUE)
|
2010-07-25 09:06:37 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2013-07-25 22:18:05 +00:00
|
|
|
return property_time(prop, action, arg, pts);
|
2010-07-25 09:06:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Media length in seconds (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_length(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
|
|
|
double len;
|
|
|
|
|
2012-08-19 16:07:06 +00:00
|
|
|
if (!(int) (len = get_time_length(mpctx)))
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-07-25 22:18:05 +00:00
|
|
|
return property_time(prop, action, arg, len);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2012-11-16 19:10:05 +00:00
|
|
|
static int mp_property_avsync(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
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;
|
2013-10-02 18:43:13 +00:00
|
|
|
if (mpctx->last_av_difference == MP_NOPTS_VALUE)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-11-16 19:10:05 +00:00
|
|
|
return m_property_double_ro(prop, action, arg, mpctx->last_av_difference);
|
|
|
|
}
|
|
|
|
|
2007-05-31 13:07:52 +00:00
|
|
|
/// Current position in percent (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_percent_pos(m_option_t *prop, int action,
|
2011-08-07 01:45:40 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
if (!mpctx->num_sources)
|
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;
|
player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:
1. If there's a queued seek, stop accepting non-seek commands, and delay
them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
trying to decode and display the first video frame), stop accepting
seek commands (and in fact all commands that were queued after the
first seek command). This logic is disabled if seeking started longer
than 300ms ago. (To avoid starvation.)
I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.
The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.
One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).
Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 21:29:50 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, 0, 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
|
|
|
}
|
2013-06-28 20:28:21 +00:00
|
|
|
case M_PROPERTY_PRINT:
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d", get_percent_pos(mpctx));
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-05-31 13:07:52 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-05-31 13:07:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Current position in seconds (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_time_pos(m_option_t *prop, int action,
|
2011-08-07 01:45:40 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
if (!mpctx->num_sources)
|
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) {
|
player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:
1. If there's a queued seek, stop accepting non-seek commands, and delay
them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
trying to decode and display the first video frame), stop accepting
seek commands (and in fact all commands that were queued after the
first seek command). This logic is disabled if seeking started longer
than 300ms ago. (To avoid starvation.)
I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.
The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.
One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).
Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 21:29:50 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, 0, true);
|
2007-05-31 13:07:52 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2013-07-25 22:18:05 +00:00
|
|
|
return property_time(prop, 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);
|
2013-05-10 13:20:40 +00:00
|
|
|
double pos = get_current_time(mpctx);
|
|
|
|
double start = get_start_time(mpctx);
|
|
|
|
|
2013-12-16 19:12:53 +00:00
|
|
|
*remaining = len - (pos - start);
|
|
|
|
|
2013-12-17 12:49:11 +00:00
|
|
|
return len > 0;
|
2013-12-16 14:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_remaining(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
2013-12-16 19:12:53 +00:00
|
|
|
double remaining;
|
|
|
|
if (!time_remaining(mpctx, &remaining))
|
2013-12-16 14:55:36 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return property_time(prop, action, arg, remaining);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_playtime_remaining(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
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;
|
|
|
|
|
2013-12-16 14:55:36 +00:00
|
|
|
double speed = mpctx->opts->playback_speed;
|
|
|
|
return property_time(prop, action, arg, remaining / speed);
|
2013-05-10 13:20:40 +00:00
|
|
|
}
|
|
|
|
|
2007-12-14 08:33:11 +00:00
|
|
|
/// Current chapter (RW)
|
|
|
|
static int mp_property_chapter(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
int chapter = get_current_chapter(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;
|
|
|
|
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;
|
|
|
|
step_all = ROUND(sarg->inc);
|
|
|
|
// 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
|
|
|
|
if (current_chapter_start >= 0 &&
|
|
|
|
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;
|
2013-05-03 22:36:53 +00:00
|
|
|
if (chapter >= get_chapter_count(mpctx) && step_all > 0) {
|
2012-09-18 18:07:24 +00:00
|
|
|
mpctx->stop_play = PT_NEXT_ENTRY;
|
2013-05-03 22:36:53 +00:00
|
|
|
} else {
|
|
|
|
mp_seek_chapter(mpctx, chapter);
|
|
|
|
}
|
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)},
|
|
|
|
{"time", CONF_TYPE_TIME, {.time = time}},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
int r = m_property_read_sub(props, action, arg);
|
|
|
|
talloc_free(name);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-05-15 00:17:47 +00:00
|
|
|
static int mp_property_list_chapters(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2014-02-15 15:55:40 +00:00
|
|
|
int count = get_chapter_count(mpctx);
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2013-05-15 00:17:47 +00:00
|
|
|
int cur = mpctx->num_sources ? get_current_chapter(mpctx) : -1;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-08-25 23:19:42 +00:00
|
|
|
static int mp_property_edition(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
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;
|
|
|
|
mpctx->stop_play = PT_RESTART;
|
|
|
|
}
|
|
|
|
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 = {
|
|
|
|
.name = prop->name,
|
|
|
|
.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
|
|
|
}
|
|
|
|
|
2013-06-27 16:21:07 +00:00
|
|
|
static struct mp_resolve_src *find_source(struct mp_resolve_result *res,
|
2013-09-10 14:38:34 +00:00
|
|
|
char *encid, char *url)
|
2013-06-27 16:21:07 +00:00
|
|
|
{
|
|
|
|
if (res->num_srcs == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
int src = 0;
|
|
|
|
for (int n = 0; n < res->num_srcs; n++) {
|
2013-09-10 14:38:34 +00:00
|
|
|
char *s_url = res->srcs[n]->url;
|
|
|
|
char *s_encid = res->srcs[n]->encid;
|
|
|
|
if (url && s_url && strcmp(url, s_url) == 0) {
|
2013-06-27 16:21:07 +00:00
|
|
|
src = n;
|
|
|
|
break;
|
|
|
|
}
|
2013-09-10 14:38:34 +00:00
|
|
|
// Prefer source URL if possible; so continue in case encid isn't unique
|
|
|
|
if (encid && s_encid && strcmp(encid, s_encid) == 0)
|
|
|
|
src = n;
|
2013-06-27 16:21:07 +00:00
|
|
|
}
|
|
|
|
return res->srcs[src];
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_quvi_format(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2013-09-10 14:38:34 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2013-06-27 16:21:07 +00:00
|
|
|
struct mp_resolve_result *res = mpctx->resolve_result;
|
|
|
|
if (!res || !res->num_srcs)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2013-09-10 14:38:34 +00:00
|
|
|
struct mp_resolve_src *cur = find_source(res, opts->quvi_format, res->url);
|
2013-06-27 16:21:07 +00:00
|
|
|
if (!cur)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(char **)arg = talloc_strdup(NULL, cur->encid);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
mpctx->stop_play = PT_RESTART;
|
2013-09-10 14:50:19 +00:00
|
|
|
// Make it restart at the same position. This will have disastrous
|
|
|
|
// consequences if the stream is not arbitrarily seekable, but whatever.
|
|
|
|
m_config_backup_opt(mpctx->mconfig, "start");
|
|
|
|
opts->play_start = (struct m_rel_time) {
|
|
|
|
.type = REL_TIME_ABSOLUTE,
|
|
|
|
.pos = get_current_time(mpctx),
|
|
|
|
};
|
2013-06-27 16:21:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_SWITCH: {
|
|
|
|
struct m_property_switch_arg *sarg = arg;
|
|
|
|
int pos = 0;
|
|
|
|
for (int n = 0; n < res->num_srcs; n++) {
|
|
|
|
if (res->srcs[n] == cur) {
|
|
|
|
pos = n;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos += sarg->inc;
|
|
|
|
if (pos < 0 || pos >= res->num_srcs) {
|
|
|
|
if (sarg->wrap) {
|
|
|
|
pos = (res->num_srcs + pos) % res->num_srcs;
|
|
|
|
} else {
|
|
|
|
pos = av_clip(pos, 0, res->num_srcs);
|
|
|
|
}
|
|
|
|
}
|
2013-07-22 22:45:23 +00:00
|
|
|
char *fmt = res->srcs[pos]->encid;
|
|
|
|
return mp_property_quvi_format(prop, M_PROPERTY_SET, &fmt, mpctx);
|
2013-06-27 16:21:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
|
|
|
}
|
|
|
|
|
2011-12-31 12:20:08 +00:00
|
|
|
/// Number of titles in file
|
|
|
|
static int mp_property_titles(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
2013-09-10 13:39:05 +00:00
|
|
|
unsigned int num_titles;
|
|
|
|
if (!demuxer || stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_TITLES,
|
|
|
|
&num_titles) < 1)
|
2011-12-31 12:20:08 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-08-25 23:19:42 +00:00
|
|
|
return m_property_int_ro(prop, action, arg, num_titles);
|
2011-12-31 12:20:08 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 21:17:01 +00:00
|
|
|
/// Number of chapters in file
|
|
|
|
static int mp_property_chapters(m_option_t *prop, int action, void *arg,
|
2011-08-07 01:45:40 +00:00
|
|
|
MPContext *mpctx)
|
2008-09-26 21:17:01 +00:00
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
if (!mpctx->num_sources)
|
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);
|
|
|
|
return m_property_int_ro(prop, action, arg, count);
|
2008-09-26 21:17:01 +00:00
|
|
|
}
|
|
|
|
|
2012-08-25 23:19:42 +00:00
|
|
|
static int mp_property_editions(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (demuxer->num_editions <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_int_ro(prop, action, arg, demuxer->num_editions);
|
|
|
|
}
|
|
|
|
|
2008-01-05 14:32:39 +00:00
|
|
|
/// Current dvd angle (RW)
|
|
|
|
static int mp_property_angle(m_option_t *prop, int action, void *arg,
|
2011-08-07 01:45:40 +00:00
|
|
|
MPContext *mpctx)
|
2008-01-05 14:32:39 +00:00
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
2008-08-04 13:33:22 +00:00
|
|
|
int angle = -1;
|
2008-01-05 14:32:39 +00:00
|
|
|
int angles;
|
|
|
|
|
2012-08-19 16:07:06 +00:00
|
|
|
if (demuxer)
|
|
|
|
angle = demuxer_get_current_angle(demuxer);
|
2008-01-05 14:32:39 +00:00
|
|
|
if (angle < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-08-19 16:07:06 +00:00
|
|
|
angles = demuxer_angles_count(demuxer);
|
2008-01-05 14:32:39 +00:00
|
|
|
if (angles <= 1)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(int *) arg = angle;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_PRINT: {
|
2011-07-03 17:04:21 +00:00
|
|
|
*(char **) arg = talloc_asprintf(NULL, "%d/%d", angle, angles);
|
2008-01-05 14:32:39 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_SET:
|
2012-09-18 18:07:24 +00:00
|
|
|
angle = demuxer_set_angle(demuxer, *(int *)arg);
|
|
|
|
if (angle >= 0) {
|
2013-11-23 20:36:20 +00:00
|
|
|
if (mpctx->d_video)
|
2013-11-27 19:54:07 +00:00
|
|
|
video_reset_decoding(mpctx->d_video);
|
2012-09-18 18:07:24 +00:00
|
|
|
|
2013-11-23 20:22:17 +00:00
|
|
|
if (mpctx->d_audio)
|
2013-11-27 19:54:07 +00:00
|
|
|
audio_reset_decoding(mpctx->d_audio);
|
2012-09-18 18:07:24 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_OK;
|
2013-05-05 17:09:44 +00:00
|
|
|
case M_PROPERTY_GET_TYPE: {
|
|
|
|
struct m_option opt = {
|
|
|
|
.name = prop->name,
|
|
|
|
.type = CONF_TYPE_INT,
|
|
|
|
.flags = CONF_RANGE,
|
|
|
|
.min = 1,
|
|
|
|
.max = angles,
|
|
|
|
};
|
|
|
|
*(struct m_option *)arg = opt;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2010-04-23 17:14:59 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2008-01-05 14:32:39 +00:00
|
|
|
}
|
|
|
|
|
2013-09-08 04:32:48 +00:00
|
|
|
static int tag_property(m_option_t *prop, int action, void *arg,
|
|
|
|
struct mp_tags *tags)
|
2011-08-07 01:45:40 +00:00
|
|
|
{
|
2008-04-26 13:35:40 +00:00
|
|
|
static const m_option_t key_type =
|
2011-08-07 01:45:40 +00:00
|
|
|
{
|
2013-09-08 04:32:48 +00:00
|
|
|
"tags", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL
|
2011-08-07 01:45:40 +00:00
|
|
|
};
|
2007-05-29 22:14:41 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
switch (action) {
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
char **slist = NULL;
|
2013-09-08 04:32:48 +00:00
|
|
|
int num = 0;
|
|
|
|
for (int n = 0; n < tags->num_keys; n++) {
|
2014-02-12 20:59:26 +00:00
|
|
|
MP_TARRAY_APPEND(NULL, slist, num, talloc_strdup(NULL, tags->keys[n]));
|
|
|
|
MP_TARRAY_APPEND(NULL, slist, num, talloc_strdup(NULL, tags->values[n]));
|
2013-09-08 04:32:48 +00:00
|
|
|
}
|
|
|
|
MP_TARRAY_APPEND(NULL, slist, num, NULL);
|
2012-09-18 18:07:24 +00:00
|
|
|
*(char ***)arg = slist;
|
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
|
|
|
}
|
|
|
|
*(char **)arg = res;
|
2013-06-11 10:18:36 +00:00
|
|
|
return res ? M_PROPERTY_OK : M_PROPERTY_UNAVAILABLE;
|
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;
|
2013-09-08 04:32:48 +00:00
|
|
|
char *meta = mp_tags_get_str(tags, ka->key);
|
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:
|
2012-09-21 12:05:52 +00:00
|
|
|
*(struct m_option *)ka->arg = key_type;
|
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
|
|
|
|
static int mp_property_metadata(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
return tag_property(prop, action, arg, demuxer->metadata);
|
|
|
|
}
|
|
|
|
|
2013-09-08 05:42:05 +00:00
|
|
|
static int mp_property_chapter_metadata(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
int chapter = get_current_chapter(mpctx);
|
|
|
|
if (!demuxer || chapter < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
|
|
|
assert(chapter < demuxer->num_chapters);
|
|
|
|
|
|
|
|
return tag_property(prop, action, arg, demuxer->chapters[chapter].metadata);
|
|
|
|
}
|
|
|
|
|
2008-11-29 06:09:57 +00:00
|
|
|
static int mp_property_pause(m_option_t *prop, int action, void *arg,
|
|
|
|
void *ctx)
|
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) {
|
2008-11-29 06:09:57 +00:00
|
|
|
pause_player(mpctx);
|
2012-09-18 12:00:08 +00:00
|
|
|
} else {
|
|
|
|
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
|
|
|
}
|
2013-04-25 18:38:22 +00:00
|
|
|
return mp_property_generic_option(prop, action, arg, ctx);
|
2008-10-01 17:05:30 +00:00
|
|
|
}
|
|
|
|
|
2013-02-17 19:24:59 +00:00
|
|
|
static int mp_property_cache(m_option_t *prop, int action, void *arg,
|
|
|
|
void *ctx)
|
|
|
|
{
|
|
|
|
MPContext *mpctx = ctx;
|
|
|
|
int cache = mp_get_cache_percent(mpctx);
|
|
|
|
if (cache < 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
return m_property_int_ro(prop, action, arg, cache);
|
|
|
|
}
|
2007-05-29 22:14:41 +00:00
|
|
|
|
2013-06-04 11:33:01 +00:00
|
|
|
static int mp_property_clock(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
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))
|
2013-06-04 11:33:01 +00:00
|
|
|
return m_property_strdup_ro(prop, action, arg, outstr);
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Volume (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_volume(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
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;
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_SET:
|
2013-10-12 16:28:02 +00:00
|
|
|
if (!mixer_audio_initialized(mpctx->mixer))
|
|
|
|
return M_PROPERTY_ERROR;
|
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: {
|
2013-10-12 16:28:02 +00:00
|
|
|
if (!mixer_audio_initialized(mpctx->mixer))
|
|
|
|
return M_PROPERTY_ERROR;
|
2012-09-22 04:15:36 +00:00
|
|
|
struct m_property_switch_arg *sarg = arg;
|
|
|
|
if (sarg->inc <= 0)
|
2013-09-19 12:33:26 +00:00
|
|
|
mixer_decvolume(mpctx->mixer);
|
2010-05-03 23:34:38 +00:00
|
|
|
else
|
2013-09-19 12:33:26 +00:00
|
|
|
mixer_incvolume(mpctx->mixer);
|
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)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_mute(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
2013-10-12 16:28:02 +00:00
|
|
|
if (!mixer_audio_initialized(mpctx->mixer))
|
|
|
|
return M_PROPERTY_ERROR;
|
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;
|
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
|
|
|
}
|
|
|
|
|
2013-09-19 12:32:47 +00:00
|
|
|
static int mp_property_volrestore(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Audio delay (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_audio_delay(m_option_t *prop, int action,
|
2010-05-07 19:02:47 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
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:
|
2013-07-27 19:24:54 +00:00
|
|
|
mpctx->audio_delay = mpctx->opts->audio_delay = *(float *)arg;
|
2014-01-06 17:51:02 +00:00
|
|
|
mpctx->delay += mpctx->audio_delay - delay;
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2012-10-30 18:44:09 +00:00
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Audio codec tag (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_audio_format(m_option_t *prop, int action,
|
2010-05-07 19:02:47 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-11-23 20:22:17 +00:00
|
|
|
const char *c = mpctx->d_audio ? mpctx->d_audio->header->codec : NULL;
|
core: redo how codecs are mapped, remove codecs.conf
Use codec names instead of FourCCs to identify codecs. Rewrite how
codecs are selected and initialized. Now each decoder exports a list
of decoders (and the codec it supports) via add_decoders(). The order
matters, and the first decoder for a given decoder is preferred over
the other decoders. E.g. all ad_mpg123 decoders are preferred over
ad_lavc, because it comes first in the mpcodecs_ad_drivers array.
Likewise, decoders within ad_lavc that are enumerated first by
libavcodec (using av_codec_next()) are preferred. (This is actually
critical to select h264 software decoding by default instead of vdpau.
libavcodec and ffmpeg/avconv use the same method to select decoders by
default, so we hope this is sane.)
The codec names follow libavcodec's codec names as defined by
AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders
have names different from the canonical codec name. The AVCodecDescriptor
API is relatively new, so we need a compatibility layer for older
libavcodec versions for codec names that are referenced internally,
and which are different from the decoder name. (Add a configure check
for that, because checking versions is getting way too messy.)
demux/codec_tags.c is generated from the former codecs.conf (minus
"special" decoders like vdpau, and excluding the mappings that are the
same as the mappings libavformat's exported RIFF tables). It contains
all the mappings from FourCCs to codec name. This is needed for
demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the
codec as determined by libavformat, while the other demuxers have to do
this on their own, using the mp_set_audio/video_codec_from_tag()
functions. Note that the sh_audio/video->format members don't uniquely
identify the codec anymore, and sh->codec takes over this role.
Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which
provide cover the functionality of the removed switched.
Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure
container/video combinations (e.g. the sample Film_200_zygo_pro.mov)
are played flipped. ffplay/avplay doesn't handle this properly either,
so we don't care and blame ffmeg/libav instead.
2013-02-09 14:15:19 +00:00
|
|
|
return m_property_strdup_ro(prop, action, arg, c);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 22:14:41 +00:00
|
|
|
/// Audio codec name (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_audio_codec(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
2007-05-29 22:14:41 +00:00
|
|
|
{
|
2013-11-23 20:22:17 +00:00
|
|
|
const char *c = mpctx->d_audio ? mpctx->d_audio->decoder_desc : NULL;
|
core: redo how codecs are mapped, remove codecs.conf
Use codec names instead of FourCCs to identify codecs. Rewrite how
codecs are selected and initialized. Now each decoder exports a list
of decoders (and the codec it supports) via add_decoders(). The order
matters, and the first decoder for a given decoder is preferred over
the other decoders. E.g. all ad_mpg123 decoders are preferred over
ad_lavc, because it comes first in the mpcodecs_ad_drivers array.
Likewise, decoders within ad_lavc that are enumerated first by
libavcodec (using av_codec_next()) are preferred. (This is actually
critical to select h264 software decoding by default instead of vdpau.
libavcodec and ffmpeg/avconv use the same method to select decoders by
default, so we hope this is sane.)
The codec names follow libavcodec's codec names as defined by
AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders
have names different from the canonical codec name. The AVCodecDescriptor
API is relatively new, so we need a compatibility layer for older
libavcodec versions for codec names that are referenced internally,
and which are different from the decoder name. (Add a configure check
for that, because checking versions is getting way too messy.)
demux/codec_tags.c is generated from the former codecs.conf (minus
"special" decoders like vdpau, and excluding the mappings that are the
same as the mappings libavformat's exported RIFF tables). It contains
all the mappings from FourCCs to codec name. This is needed for
demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the
codec as determined by libavformat, while the other demuxers have to do
this on their own, using the mp_set_audio/video_codec_from_tag()
functions. Note that the sh_audio/video->format members don't uniquely
identify the codec anymore, and sh->codec takes over this role.
Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which
provide cover the functionality of the removed switched.
Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure
container/video combinations (e.g. the sample Film_200_zygo_pro.mov)
are played flipped. ffplay/avplay doesn't handle this properly either,
so we don't care and blame ffmeg/libav instead.
2013-02-09 14:15:19 +00:00
|
|
|
return m_property_strdup_ro(prop, action, arg, c);
|
2007-05-29 22:14:41 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Audio bitrate (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_audio_bitrate(m_option_t *prop, int action,
|
2010-05-07 19:02:47 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-11-23 20:22:17 +00:00
|
|
|
if (!mpctx->d_audio)
|
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-11-23 20:22:17 +00:00
|
|
|
*(char **)arg = format_bitrate(mpctx->d_audio->i_bps);
|
2012-09-18 13:31:46 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_GET:
|
2013-11-23 20:22:17 +00:00
|
|
|
*(int *)arg = mpctx->d_audio->i_bps;
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 13:31:46 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Samplerate (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_samplerate(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-11-23 20:25:05 +00:00
|
|
|
struct mp_audio fmt = {0};
|
|
|
|
if (mpctx->d_audio)
|
|
|
|
mp_audio_buffer_get_format(mpctx->d_audio->decode_buffer, &fmt);
|
|
|
|
if (!fmt.rate)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2011-08-07 01:45:40 +00:00
|
|
|
switch (action) {
|
2007-05-30 06:53:06 +00:00
|
|
|
case M_PROPERTY_PRINT:
|
2013-11-23 20:25:05 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d kHz", fmt.rate / 1000);
|
2007-05-30 06:53:06 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_GET:
|
2013-11-23 20:25:05 +00:00
|
|
|
*(int *)arg = fmt.rate;
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-05-30 06:53:06 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Number of channels (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_channels(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-11-23 20:25:05 +00:00
|
|
|
struct mp_audio fmt = {0};
|
|
|
|
if (mpctx->d_audio)
|
|
|
|
mp_audio_buffer_get_format(mpctx->d_audio->decode_buffer, &fmt);
|
|
|
|
if (!fmt.channels.num)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_PRINT:
|
2013-11-23 20:25:05 +00:00
|
|
|
*(char **) arg = mp_chmap_to_str(&fmt.channels);
|
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-11-23 20:25:05 +00:00
|
|
|
*(int *)arg = fmt.channels.num;
|
2012-09-18 18:07:24 +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
|
|
|
}
|
|
|
|
|
2007-06-20 02:26:20 +00:00
|
|
|
/// Balance (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_balance(m_option_t *prop, int action, void *arg,
|
2011-08-07 01:45:40 +00:00
|
|
|
MPContext *mpctx)
|
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;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int property_switch_track(m_option_t *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
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
if (!mpctx->num_sources)
|
2009-12-27 14:06:47 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
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:
|
2013-04-14 22:22:51 +00:00
|
|
|
*(int *) arg = track ? track->user_tid : -2;
|
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: {
|
|
|
|
struct m_property_switch_arg *sarg = arg;
|
2013-12-24 16:46:14 +00:00
|
|
|
mp_switch_track_n(mpctx, order, type,
|
|
|
|
track_next(mpctx, order, type, sarg->inc >= 0 ? +1 : -1, track));
|
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:
|
2013-12-24 16:46:14 +00:00
|
|
|
track = mp_track_by_tid(mpctx, type, *(int *)arg);
|
|
|
|
mp_switch_track_n(mpctx, order, type, track);
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2013-04-14 22:22:51 +00:00
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
2012-08-19 16:01:30 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
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];
|
|
|
|
|
|
|
|
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},
|
|
|
|
{"albumart", SUB_PROP_FLAG(track->attached_picture)},
|
|
|
|
{"default", SUB_PROP_FLAG(track->default_track)},
|
|
|
|
{"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},
|
|
|
|
{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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int property_list_tracks(m_option_t *prop, int action, void *arg,
|
2013-07-22 22:45:23 +00:00
|
|
|
MPContext *mpctx)
|
2013-05-15 00:17:47 +00:00
|
|
|
{
|
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)
|
|
|
|
static int mp_property_audio(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2013-12-24 16:46:14 +00:00
|
|
|
return property_switch_track(prop, action, arg, mpctx, 0, STREAM_AUDIO);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Selected video id (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_video(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-12-24 16:46:14 +00:00
|
|
|
return property_switch_track(prop, action, arg, mpctx, 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;
|
|
|
|
}
|
|
|
|
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_program(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
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,
|
|
|
|
find_track_by_demuxer_id(mpctx, STREAM_VIDEO, prog.vid));
|
2013-04-14 19:32:34 +00:00
|
|
|
mp_switch_track(mpctx, STREAM_AUDIO,
|
|
|
|
find_track_by_demuxer_id(mpctx, STREAM_AUDIO, prog.aid));
|
|
|
|
mp_switch_track(mpctx, STREAM_SUB,
|
|
|
|
find_track_by_demuxer_id(mpctx, STREAM_VIDEO, prog.sid));
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Fullscreen state (RW)
|
2013-03-04 16:40:21 +00:00
|
|
|
static int mp_property_fullscreen(m_option_t *prop,
|
|
|
|
int action,
|
|
|
|
void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
|
|
|
if (!mpctx->video_out)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-04-12 12:34:46 +00:00
|
|
|
struct mp_vo_opts *opts = mpctx->video_out->opts;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-09-18 18:07:24 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2013-07-18 12:05:39 +00:00
|
|
|
int val = *(int *)arg;
|
|
|
|
opts->fullscreen = val;
|
2010-05-07 19:02:47 +00:00
|
|
|
if (mpctx->video_out->config_ok)
|
|
|
|
vo_control(mpctx->video_out, VOCTRL_FULLSCREEN, 0);
|
2013-07-18 12:05:39 +00:00
|
|
|
return opts->fullscreen == val ? M_PROPERTY_OK : M_PROPERTY_ERROR;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
2007-02-21 00:49:24 +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
|
|
|
#define VF_DEINTERLACE_LABEL "deinterlace"
|
|
|
|
|
2013-09-20 13:09:29 +00:00
|
|
|
static const char *deint_filters[] = {
|
|
|
|
"yadif",
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_VAAPI_VPP
|
2013-09-20 13:55:13 +00:00
|
|
|
"vavpp",
|
|
|
|
#endif
|
2013-09-20 13:09:29 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static int probe_deint_filters(struct MPContext *mpctx, const char *cmd)
|
|
|
|
{
|
|
|
|
for (int n = 0; deint_filters[n]; n++) {
|
|
|
|
char filter[80];
|
|
|
|
// add a label so that removing the filter is easier
|
|
|
|
snprintf(filter, sizeof(filter), "@%s:%s", VF_DEINTERLACE_LABEL,
|
|
|
|
deint_filters[n]);
|
|
|
|
if (edit_filters(mpctx, STREAM_VIDEO, cmd, filter) >= 0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_deinterlacing(struct MPContext *mpctx, bool enable)
|
|
|
|
{
|
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)
|
2013-09-20 13:09:29 +00:00
|
|
|
edit_filters(mpctx, STREAM_VIDEO, "del", "@" 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
|
|
|
} 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)
|
2013-09-20 14:48:08 +00:00
|
|
|
probe_deint_filters(mpctx, "pre");
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_deinterlace(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
2013-11-23 20:36:20 +00:00
|
|
|
if (!mpctx->d_video || !mpctx->d_video->vfilter)
|
2012-10-28 19:59:15 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
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;
|
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
|
|
|
}
|
|
|
|
|
2013-07-16 21:22:55 +00:00
|
|
|
// Generic option + requires hard refresh to make changes take effect.
|
|
|
|
static int video_refresh_property_helper(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
2009-11-15 13:21:40 +00:00
|
|
|
{
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
int r = mp_property_generic_option(prop, action, arg, mpctx);
|
2012-09-18 18:07:24 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2013-11-23 20:36:20 +00:00
|
|
|
if (mpctx->d_video) {
|
2013-07-16 21:22:55 +00:00
|
|
|
reinit_video_filters(mpctx);
|
|
|
|
mp_force_video_refresh(mpctx);
|
|
|
|
}
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
2009-11-15 13:21:40 +00:00
|
|
|
|
2014-02-03 21:00:34 +00:00
|
|
|
static void append_csp(char **ptr, const char *name, const char *const *names,
|
|
|
|
int value)
|
|
|
|
{
|
|
|
|
const char *cspname = names[value];
|
|
|
|
if (name[0] == '*') {
|
|
|
|
name++;
|
|
|
|
} else if (value == 0) {
|
|
|
|
cspname = "unknown";
|
|
|
|
}
|
|
|
|
*ptr = talloc_asprintf_append(*ptr, "%s: %s\n", name, cspname);
|
|
|
|
}
|
|
|
|
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
static int mp_property_colormatrix(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2012-09-21 11:46:58 +00:00
|
|
|
if (action != M_PROPERTY_PRINT)
|
2013-07-16 21:22:55 +00:00
|
|
|
return video_refresh_property_helper(prop, action, arg, mpctx);
|
2012-09-21 11:46:58 +00:00
|
|
|
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2013-07-16 21:22:55 +00:00
|
|
|
|
|
|
|
struct mp_csp_details vo_csp = {0};
|
2013-08-24 17:37:34 +00:00
|
|
|
if (mpctx->video_out)
|
|
|
|
vo_control(mpctx->video_out, VOCTRL_GET_YUV_COLORSPACE, &vo_csp);
|
2013-07-16 21:22:55 +00:00
|
|
|
|
|
|
|
struct mp_image_params vd_csp = {0};
|
2013-11-23 20:36:20 +00:00
|
|
|
if (mpctx->d_video)
|
2013-12-10 18:07:29 +00:00
|
|
|
vd_csp = mpctx->d_video->decoder_output;
|
2013-07-16 21:22:55 +00:00
|
|
|
|
2014-02-03 21:00:34 +00:00
|
|
|
char *res = talloc_strdup(NULL, "");
|
|
|
|
append_csp(&res, "*Requested", mp_csp_names, opts->requested_colorspace);
|
|
|
|
append_csp(&res, "Video decoder", mp_csp_names, vd_csp.colorspace);
|
|
|
|
append_csp(&res, "Video output", mp_csp_names, vo_csp.format);
|
2012-09-21 11:46:58 +00:00
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
}
|
|
|
|
|
2013-07-16 21:22:55 +00:00
|
|
|
static int mp_property_colormatrix_input_range(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
{
|
2012-09-21 11:07:22 +00:00
|
|
|
if (action != M_PROPERTY_PRINT)
|
2013-07-16 21:22:55 +00:00
|
|
|
return video_refresh_property_helper(prop, action, arg, mpctx);
|
2012-09-21 11:07:22 +00:00
|
|
|
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2012-09-21 11:07:22 +00:00
|
|
|
|
2013-07-16 21:22:55 +00:00
|
|
|
struct mp_csp_details vo_csp = {0};
|
2013-08-24 17:37:34 +00:00
|
|
|
if (mpctx->video_out)
|
|
|
|
vo_control(mpctx->video_out, VOCTRL_GET_YUV_COLORSPACE, &vo_csp );
|
2013-07-16 21:22:55 +00:00
|
|
|
|
|
|
|
struct mp_image_params vd_csp = {0};
|
2013-11-23 20:36:20 +00:00
|
|
|
if (mpctx->d_video)
|
2013-12-10 18:07:29 +00:00
|
|
|
vd_csp = mpctx->d_video->decoder_output;
|
2013-07-16 21:22:55 +00:00
|
|
|
|
2014-02-03 21:00:34 +00:00
|
|
|
char *res = talloc_strdup(NULL, "");
|
|
|
|
append_csp(&res, "*Requested", mp_csp_levels_names,
|
|
|
|
opts->requested_input_range);
|
|
|
|
append_csp(&res, "Video decoder", mp_csp_levels_names, vd_csp.colorlevels);
|
|
|
|
append_csp(&res, "Video output", mp_csp_levels_names, vo_csp.levels_in);
|
2012-09-21 11:07:22 +00:00
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
video, options: implement better YUV->RGB conversion control
Rewrite control of the colorspace and input/output level parameters
used in YUV-RGB conversions, replacing VO-specific suboptions with new
common options and adding configuration support to more cases.
Add new option --colormatrix which selects the colorspace the original
video is assumed to have in YUV->RGB conversions. The default
behavior changes from assuming BT.601 to colorspace autoselection
between BT.601 and BT.709 using a simple heuristic based on video
size. Add new options --colormatrix-input-range and
--colormatrix-output-range which select input YUV and output RGB range.
Disable the previously existing VO-specific colorspace and level
conversion suboptions in vo_gl and vo_vdpau. Remove the
"yuv_colorspace" property and replace it with one named "colormatrix"
and semantics matching the new option. Add new properties matching the
options for level conversion.
Colorspace selection is currently supported by vo_gl, vo_vdpau, vo_xv
and vf_scale, and all can change it at runtime (previously only
vo_vdpau and vo_xv could). vo_vdpau now uses the same conversion
matrix generation as vo_gl instead of libvdpau functionality; the main
functional difference is that the "contrast" equalizer control behaves
somewhat differently (it scales the Y component around 1/2 instead of
around 0, so that contrast 0 makes the image gray rather than black).
vo_xv does not support level conversion. vf_scale supports range
setting for input, but always outputs full-range RGB.
The value of the slave properties is the policy setting used for
conversions. This means they can be set to any value regardless of
whether the current VO supports that value or whether there currently
even is any video. Possibly separate properties could be added to
query the conversion actually used at the moment, if any.
Because the colorspace and level settings are now set with a single
VF/VO control call, the return value of that is no longer used to
signal whether all the settings are actually supported. Instead code
should set all the details it can support, and ignore the rest. The
core will use GET_YUV_COLORSPACE to check which colorspace details
have been set and which not. In other words, the return value for
SET_YUV_COLORSPACE only signals whether any kind of YUV colorspace
conversion handling exists at all, and VOs have to take care to return
the actual state with GET_YUV_COLORSPACE instead.
To be changed in later commits: add missing option documentation.
2011-10-15 21:50:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_colormatrix_output_range(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
2013-08-24 17:37:34 +00:00
|
|
|
if (action != M_PROPERTY_PRINT)
|
|
|
|
return video_refresh_property_helper(prop, action, arg, mpctx);
|
2013-07-16 21:22:55 +00:00
|
|
|
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2013-07-16 21:22:55 +00:00
|
|
|
|
|
|
|
struct mp_csp_details actual = {0};
|
2013-08-24 17:37:34 +00:00
|
|
|
if (mpctx->video_out)
|
|
|
|
vo_control(mpctx->video_out, VOCTRL_GET_YUV_COLORSPACE, &actual);
|
2013-07-16 21:22:55 +00:00
|
|
|
|
2014-02-03 21:00:34 +00:00
|
|
|
char *res = talloc_strdup(NULL, "");
|
|
|
|
append_csp(&res, "*Requested", mp_csp_levels_names,
|
|
|
|
opts->requested_output_range);
|
|
|
|
append_csp(&res, "Video output", mp_csp_levels_names, actual.levels_out);
|
2013-07-16 21:22:55 +00:00
|
|
|
*(char **)arg = res;
|
|
|
|
return M_PROPERTY_OK;
|
2009-11-15 13:21:40 +00:00
|
|
|
}
|
|
|
|
|
2013-06-14 22:15:32 +00:00
|
|
|
// Update options which are managed through VOCTRL_GET/SET_PANSCAN.
|
|
|
|
static int panscan_property_helper(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
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
|
|
|
|
2012-09-18 18:07:24 +00:00
|
|
|
int r = mp_property_generic_option(prop, action, arg, mpctx);
|
|
|
|
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
|
|
|
|
*/
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_vo_flag(m_option_t *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
|
|
|
{
|
|
|
|
|
|
|
|
if (!mpctx->video_out)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-09-18 18:07:24 +00:00
|
|
|
if (action == M_PROPERTY_SET) {
|
2010-05-03 23:34:38 +00:00
|
|
|
if (*vo_var == !!*(int *) arg)
|
|
|
|
return M_PROPERTY_OK;
|
2010-05-07 19:02:47 +00:00
|
|
|
if (mpctx->video_out->config_ok)
|
|
|
|
vo_control(mpctx->video_out, vo_ctrl, 0);
|
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 mp_property_generic_option(prop, action, arg, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Window always on top (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_ontop(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
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)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_border(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
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
|
|
|
}
|
|
|
|
|
2012-09-17 06:38:19 +00:00
|
|
|
static int mp_property_framedrop(m_option_t *prop, int action,
|
2013-03-04 16:40:21 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
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
|
|
|
|
2012-09-17 06:38:19 +00:00
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 14:23:44 +00:00
|
|
|
static int mp_property_video_color(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
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: {
|
2013-11-23 20:36:20 +00:00
|
|
|
if (video_set_colors(mpctx->d_video, prop->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:
|
2013-11-23 20:36:20 +00:00
|
|
|
if (video_get_colors(mpctx->d_video, prop->name, (int *)arg) <= 0)
|
2013-08-20 14:23:44 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
// Write new value to option variable
|
|
|
|
mp_property_generic_option(prop, M_PROPERTY_SET, arg, mpctx);
|
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2013-08-20 14:23:44 +00:00
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Video codec tag (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_video_format(m_option_t *prop, int action,
|
2010-05-07 19:02:47 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-11-23 20:36:20 +00:00
|
|
|
const char *c = mpctx->d_video ? mpctx->d_video->header->codec : NULL;
|
core: redo how codecs are mapped, remove codecs.conf
Use codec names instead of FourCCs to identify codecs. Rewrite how
codecs are selected and initialized. Now each decoder exports a list
of decoders (and the codec it supports) via add_decoders(). The order
matters, and the first decoder for a given decoder is preferred over
the other decoders. E.g. all ad_mpg123 decoders are preferred over
ad_lavc, because it comes first in the mpcodecs_ad_drivers array.
Likewise, decoders within ad_lavc that are enumerated first by
libavcodec (using av_codec_next()) are preferred. (This is actually
critical to select h264 software decoding by default instead of vdpau.
libavcodec and ffmpeg/avconv use the same method to select decoders by
default, so we hope this is sane.)
The codec names follow libavcodec's codec names as defined by
AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders
have names different from the canonical codec name. The AVCodecDescriptor
API is relatively new, so we need a compatibility layer for older
libavcodec versions for codec names that are referenced internally,
and which are different from the decoder name. (Add a configure check
for that, because checking versions is getting way too messy.)
demux/codec_tags.c is generated from the former codecs.conf (minus
"special" decoders like vdpau, and excluding the mappings that are the
same as the mappings libavformat's exported RIFF tables). It contains
all the mappings from FourCCs to codec name. This is needed for
demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the
codec as determined by libavformat, while the other demuxers have to do
this on their own, using the mp_set_audio/video_codec_from_tag()
functions. Note that the sh_audio/video->format members don't uniquely
identify the codec anymore, and sh->codec takes over this role.
Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which
provide cover the functionality of the removed switched.
Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure
container/video combinations (e.g. the sample Film_200_zygo_pro.mov)
are played flipped. ffplay/avplay doesn't handle this properly either,
so we don't care and blame ffmeg/libav instead.
2013-02-09 14:15:19 +00:00
|
|
|
return m_property_strdup_ro(prop, action, arg, c);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 22:14:41 +00:00
|
|
|
/// Video codec name (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_video_codec(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
2007-05-29 22:14:41 +00:00
|
|
|
{
|
2013-11-23 20:36:20 +00:00
|
|
|
const char *c = mpctx->d_video ? mpctx->d_video->decoder_desc : NULL;
|
core: redo how codecs are mapped, remove codecs.conf
Use codec names instead of FourCCs to identify codecs. Rewrite how
codecs are selected and initialized. Now each decoder exports a list
of decoders (and the codec it supports) via add_decoders(). The order
matters, and the first decoder for a given decoder is preferred over
the other decoders. E.g. all ad_mpg123 decoders are preferred over
ad_lavc, because it comes first in the mpcodecs_ad_drivers array.
Likewise, decoders within ad_lavc that are enumerated first by
libavcodec (using av_codec_next()) are preferred. (This is actually
critical to select h264 software decoding by default instead of vdpau.
libavcodec and ffmpeg/avconv use the same method to select decoders by
default, so we hope this is sane.)
The codec names follow libavcodec's codec names as defined by
AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders
have names different from the canonical codec name. The AVCodecDescriptor
API is relatively new, so we need a compatibility layer for older
libavcodec versions for codec names that are referenced internally,
and which are different from the decoder name. (Add a configure check
for that, because checking versions is getting way too messy.)
demux/codec_tags.c is generated from the former codecs.conf (minus
"special" decoders like vdpau, and excluding the mappings that are the
same as the mappings libavformat's exported RIFF tables). It contains
all the mappings from FourCCs to codec name. This is needed for
demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the
codec as determined by libavformat, while the other demuxers have to do
this on their own, using the mp_set_audio/video_codec_from_tag()
functions. Note that the sh_audio/video->format members don't uniquely
identify the codec anymore, and sh->codec takes over this role.
Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which
provide cover the functionality of the removed switched.
Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure
container/video combinations (e.g. the sample Film_200_zygo_pro.mov)
are played flipped. ffplay/avplay doesn't handle this properly either,
so we don't care and blame ffmeg/libav instead.
2013-02-09 14:15:19 +00:00
|
|
|
return m_property_strdup_ro(prop, action, arg, c);
|
2007-05-29 22:14:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Video bitrate (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_video_bitrate(m_option_t *prop, int action,
|
2010-05-07 19:02:47 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-11-23 20:36:20 +00:00
|
|
|
if (!mpctx->d_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-09-18 18:07:24 +00:00
|
|
|
if (action == M_PROPERTY_PRINT) {
|
2013-11-23 20:36:20 +00:00
|
|
|
*(char **)arg = format_bitrate(mpctx->d_video->i_bps);
|
2012-09-18 13:31:46 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2013-11-23 20:36:20 +00:00
|
|
|
return m_property_int_ro(prop, action, arg, mpctx->d_video->i_bps);
|
2007-02-21 00:49:24 +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
|
|
|
|
2014-02-15 15:42:48 +00:00
|
|
|
double dar = p.d_w / (double)p.d_h;
|
|
|
|
double sar = p.w / (double)p.h;
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p.imgfmt))},
|
|
|
|
{"w", SUB_PROP_INT(p.w)},
|
|
|
|
{"h", SUB_PROP_INT(p.h)},
|
|
|
|
{"dw", SUB_PROP_INT(p.d_w)},
|
|
|
|
{"dh", SUB_PROP_INT(p.d_h)},
|
|
|
|
{"aspect", SUB_PROP_FLOAT(dar)},
|
|
|
|
{"par", SUB_PROP_FLOAT(dar / sar)},
|
|
|
|
{"colormatrix", SUB_PROP_STR(mp_csp_names[p.colorspace])},
|
|
|
|
{"colorlevels", SUB_PROP_STR(mp_csp_levels_names[p.colorlevels])},
|
|
|
|
{"chroma-location", SUB_PROP_STR(mp_chroma_names[p.chroma_location])},
|
|
|
|
{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
|
|
|
}
|
|
|
|
|
2014-02-15 15:42:48 +00:00
|
|
|
static int mp_property_vo_imgparams(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
2013-03-25 20:25:11 +00:00
|
|
|
{
|
2014-02-15 15:42:48 +00:00
|
|
|
return property_imgparams(get_video_out_params(mpctx), action, arg);
|
2013-03-25 20:25:11 +00:00
|
|
|
}
|
|
|
|
|
2014-02-15 15:42:48 +00:00
|
|
|
static int mp_property_vd_imgparams(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
2013-03-25 20:25:11 +00:00
|
|
|
{
|
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;
|
|
|
|
if (vd->vf_input.imgfmt) {
|
|
|
|
return property_imgparams(vd->vf_input, action, arg);
|
|
|
|
} 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
|
|
|
}
|
|
|
|
|
2013-10-31 19:19:40 +00:00
|
|
|
static int mp_property_window_scale(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
int vid_w = params.d_w;
|
|
|
|
int vid_h = params.d_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};
|
|
|
|
if (s[0] > 0 && s[1] > 0 && vo_control(vo, VOCTRL_SET_WINDOW_SIZE, s) > 0)
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET: {
|
|
|
|
int s[2];
|
|
|
|
if (vo_control(vo, VOCTRL_GET_WINDOW_SIZE, s) <= 0 || s[0] < 1 || s[1] < 1)
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2013-09-30 20:25:34 +00:00
|
|
|
static int mp_property_osd_w(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2014-01-18 00:19:20 +00:00
|
|
|
struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd, OSDTYPE_OSD);
|
|
|
|
return m_property_int_ro(prop, action, arg, vo_res.w);
|
2013-09-30 20:25:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_osd_h(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2014-01-18 00:19:20 +00:00
|
|
|
struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd, OSDTYPE_OSD);
|
|
|
|
return m_property_int_ro(prop, action, arg, vo_res.w);
|
2013-09-30 20:25:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_osd_par(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2014-01-18 00:19:20 +00:00
|
|
|
struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd, OSDTYPE_OSD);
|
|
|
|
return m_property_double_ro(prop, action, arg, vo_res.display_par);
|
2013-09-30 20:25:34 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Video fps (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_fps(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-11-23 20:36:20 +00:00
|
|
|
if (!mpctx->d_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-11-23 20:41:40 +00:00
|
|
|
return m_property_float_ro(prop, action, arg, mpctx->d_video->fps);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Video aspect (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_aspect(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-11-23 20:36:20 +00:00
|
|
|
if (!mpctx->d_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2013-11-23 20:36:20 +00:00
|
|
|
struct dec_video *d_video = mpctx->d_video;
|
|
|
|
struct sh_video *sh_video = d_video->header->video;
|
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;
|
2013-09-15 20:03:29 +00:00
|
|
|
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: {
|
|
|
|
float aspect = -1;
|
2013-11-23 20:39:07 +00:00
|
|
|
struct mp_image_params *params = &d_video->vf_input;
|
2013-09-26 14:53:17 +00:00
|
|
|
if (params && params->d_w && params->d_h) {
|
|
|
|
aspect = (float)params->d_w / params->d_h;
|
|
|
|
} else if (sh_video->disp_w && sh_video->disp_h) {
|
|
|
|
aspect = (float)sh_video->disp_w / sh_video->disp_h;
|
|
|
|
}
|
|
|
|
if (aspect <= 0)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
*(float *)arg = aspect;
|
2012-09-22 03:13:29 +00:00
|
|
|
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
|
2013-05-14 21:14:23 +00:00
|
|
|
static int property_osd_helper(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-10-01 23:32:03 +00:00
|
|
|
if (!mpctx->video_out)
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (action == M_PROPERTY_SET)
|
2013-05-14 21:14:23 +00:00
|
|
|
osd_changed_all(mpctx->osd);
|
2012-09-18 18:07:24 +00:00
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Selected subtitles (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_sub(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2013-12-24 16:46:14 +00:00
|
|
|
return property_switch_track(prop, action, arg, mpctx, 0, STREAM_SUB);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_sub2(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
return property_switch_track(prop, action, arg, mpctx, 1, STREAM_SUB);
|
2007-11-25 04:09:04 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Subtitle delay (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_sub_delay(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
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;
|
|
|
|
}
|
2013-06-28 23:32:38 +00:00
|
|
|
return property_osd_helper(prop, action, arg, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
static int mp_property_sub_pos(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
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;
|
|
|
|
}
|
2013-05-14 21:14:23 +00:00
|
|
|
return property_osd_helper(prop, action, arg, mpctx);
|
2012-09-25 01:24:38 +00:00
|
|
|
}
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_TV
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-08-19 16:07:06 +00:00
|
|
|
static tvi_handle_t *get_tvh(struct MPContext *mpctx)
|
|
|
|
{
|
|
|
|
if (!(mpctx->master_demuxer && mpctx->master_demuxer->type == DEMUXER_TYPE_TV))
|
|
|
|
return NULL;
|
|
|
|
return mpctx->master_demuxer->priv;
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// TV color settings (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_tv_color(m_option_t *prop, int action, void *arg,
|
2010-05-07 19:02:47 +00:00
|
|
|
MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
tvi_handle_t *tvh = get_tvh(mpctx);
|
|
|
|
if (!tvh)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
2010-11-01 20:45:46 +00:00
|
|
|
return tv_set_color_options(tvh, prop->offset, *(int *) arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_GET:
|
2010-11-01 20:45:46 +00:00
|
|
|
return tv_get_color_options(tvh, prop->offset, arg);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-06-28 20:16:29 +00:00
|
|
|
static int mp_property_playlist_pos(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
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 = {
|
|
|
|
.name = prop->name,
|
|
|
|
.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;
|
|
|
|
|
|
|
|
struct m_sub_property props[] = {
|
|
|
|
{"filename", SUB_PROP_STR(e->filename)},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
return m_property_read_sub(props, action, arg);
|
2013-06-28 20:16:29 +00:00
|
|
|
}
|
|
|
|
|
2013-05-15 00:17:47 +00:00
|
|
|
static int mp_property_playlist(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
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)
|
|
|
|
{
|
|
|
|
if (mpctx->playlist->current == e) {
|
|
|
|
res = talloc_asprintf_append(res, "> %s <\n", e->filename);
|
|
|
|
} else {
|
|
|
|
res = talloc_asprintf_append(res, "%s\n", e->filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*(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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int property_filter(m_option_t *prop, int action, void *arg,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return mp_property_generic_option(prop, action, arg, mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_vf(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
return property_filter(prop, action, arg, mpctx, STREAM_VIDEO);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_af(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
return property_filter(prop, action, arg, mpctx, STREAM_AUDIO);
|
|
|
|
}
|
|
|
|
|
2013-04-14 22:22:51 +00:00
|
|
|
static int mp_property_alias(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
const char *real_property = prop->priv;
|
|
|
|
int r = mp_property_do(real_property, action, arg, mpctx);
|
|
|
|
if (action == M_PROPERTY_GET_TYPE && r >= 0) {
|
|
|
|
// Fix the property name
|
|
|
|
struct m_option *type = arg;
|
|
|
|
type->name = prop->name;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-07-25 21:36:01 +00:00
|
|
|
static int mp_property_options(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
if (action != M_PROPERTY_KEY_ACTION)
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
|
|
|
|
struct m_property_action_arg *ka = arg;
|
|
|
|
|
|
|
|
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;
|
2013-09-07 18:03:13 +00:00
|
|
|
case M_PROPERTY_SET:
|
|
|
|
if (!(mpctx->initialized_flags & INITIALIZED_PLAYBACK) &&
|
|
|
|
!(opt->opt->flags & (M_OPT_PRE_PARSE | M_OPT_GLOBAL)))
|
|
|
|
{
|
|
|
|
m_option_copy(opt->opt, opt->data, ka->arg);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_ERROR;
|
2013-07-25 21:36:01 +00:00
|
|
|
case M_PROPERTY_GET_TYPE:
|
|
|
|
*(struct m_option *)ka->arg = *opt->opt;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-09-18 18:07:24 +00:00
|
|
|
// Use option-to-property-bridge. (The property and option have the same names.)
|
|
|
|
#define M_OPTION_PROPERTY(name) \
|
2012-09-26 21:56:29 +00:00
|
|
|
{(name), mp_property_generic_option, &m_option_type_dummy, 0, 0, 0, (name)}
|
2012-09-18 18:07:24 +00:00
|
|
|
|
|
|
|
// OPTION_PROPERTY(), but with a custom property handler. The custom handler
|
|
|
|
// must let unknown operations fall back to mp_property_generic_option().
|
|
|
|
#define M_OPTION_PROPERTY_CUSTOM(name, handler) \
|
2012-09-26 21:56:29 +00:00
|
|
|
{(name), (handler), &m_option_type_dummy, 0, 0, 0, (name)}
|
2012-09-18 18:07:24 +00:00
|
|
|
#define M_OPTION_PROPERTY_CUSTOM_(name, handler, ...) \
|
2012-09-26 21:56:29 +00:00
|
|
|
{(name), (handler), &m_option_type_dummy, 0, 0, 0, (name), __VA_ARGS__}
|
2012-09-18 18:07:24 +00:00
|
|
|
|
2013-04-14 22:22:51 +00:00
|
|
|
// Redirect a property name to another
|
|
|
|
#define M_PROPERTY_ALIAS(name, real_property) \
|
|
|
|
{(name), mp_property_alias, &m_option_type_dummy, 0, 0, 0, (real_property)}
|
|
|
|
|
2014-02-15 15:42:48 +00:00
|
|
|
// A generic property; the property callback must implement M_PROPERTY_GET_TYPE.
|
|
|
|
#define M_PROPERTY(name, handler) \
|
|
|
|
{(name), handler, &m_option_type_dummy}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// All properties available in MPlayer.
|
|
|
|
/** \ingroup Properties
|
|
|
|
*/
|
2008-01-13 17:00:46 +00:00
|
|
|
static const m_option_t mp_properties[] = {
|
2007-02-21 00:49:24 +00:00
|
|
|
// General
|
2012-09-18 18:07:24 +00:00
|
|
|
M_OPTION_PROPERTY("osd-level"),
|
2013-05-14 12:10:27 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("osd-scale", property_osd_helper),
|
2012-09-18 18:07:24 +00:00
|
|
|
M_OPTION_PROPERTY("loop"),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("speed", mp_property_playback_speed),
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "filename", mp_property_filename, CONF_TYPE_STRING,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "path", mp_property_path, CONF_TYPE_STRING,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2012-10-13 15:09:35 +00:00
|
|
|
{ "media-title", mp_property_media_title, CONF_TYPE_STRING,
|
|
|
|
0, 0, 0, NULL },
|
|
|
|
{ "stream-path", mp_property_stream_path, CONF_TYPE_STRING,
|
|
|
|
0, 0, 0, NULL },
|
2013-05-11 20:19:33 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("stream-capture", mp_property_stream_capture),
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "demuxer", mp_property_demuxer, CONF_TYPE_STRING,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2012-09-18 09:48:50 +00:00
|
|
|
{ "stream-pos", mp_property_stream_pos, CONF_TYPE_INT64,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_MIN, 0, 0, NULL },
|
2012-09-18 09:48:50 +00:00
|
|
|
{ "stream-start", mp_property_stream_start, CONF_TYPE_INT64,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_MIN, 0, 0, NULL },
|
2012-09-18 09:48:50 +00:00
|
|
|
{ "stream-end", mp_property_stream_end, CONF_TYPE_INT64,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_MIN, 0, 0, NULL },
|
2012-09-18 09:48:50 +00:00
|
|
|
{ "stream-length", mp_property_stream_length, CONF_TYPE_INT64,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_MIN, 0, 0, NULL },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "stream-time-pos", mp_property_stream_time_pos, CONF_TYPE_TIME,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_MIN, 0, 0, NULL },
|
2007-05-31 13:02:51 +00:00
|
|
|
{ "length", mp_property_length, CONF_TYPE_TIME,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_MIN, 0, 0, NULL },
|
2012-11-16 19:10:05 +00:00
|
|
|
{ "avsync", mp_property_avsync, CONF_TYPE_DOUBLE },
|
2013-06-28 20:28:21 +00:00
|
|
|
{ "percent-pos", mp_property_percent_pos, CONF_TYPE_DOUBLE,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, 0, 100, NULL },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "time-pos", mp_property_time_pos, CONF_TYPE_TIME,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_MIN, 0, 0, NULL },
|
2013-05-10 13:20:40 +00:00
|
|
|
{ "time-remaining", mp_property_remaining, CONF_TYPE_TIME },
|
2013-12-16 14:55:36 +00:00
|
|
|
{ "playtime-remaining", mp_property_playtime_remaining, CONF_TYPE_TIME },
|
2007-12-14 08:33:11 +00:00
|
|
|
{ "chapter", mp_property_chapter, CONF_TYPE_INT,
|
2013-08-15 19:49:06 +00:00
|
|
|
M_OPT_MIN, -1, 0, NULL },
|
2012-09-21 12:22:23 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("edition", mp_property_edition),
|
2013-06-27 16:21:07 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("quvi-format", mp_property_quvi_format),
|
2011-12-31 12:20:08 +00:00
|
|
|
{ "titles", mp_property_titles, CONF_TYPE_INT,
|
|
|
|
0, 0, 0, NULL },
|
2008-09-26 21:17:01 +00:00
|
|
|
{ "chapters", mp_property_chapters, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2012-08-25 23:19:42 +00:00
|
|
|
{ "editions", mp_property_editions, CONF_TYPE_INT },
|
2013-05-05 17:09:44 +00:00
|
|
|
{ "angle", mp_property_angle, &m_option_type_dummy },
|
2013-09-08 05:42:05 +00:00
|
|
|
{ "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST },
|
|
|
|
{ "chapter-metadata", mp_property_chapter_metadata, CONF_TYPE_STRING_LIST },
|
2013-04-25 18:38:22 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("pause", mp_property_pause),
|
2013-02-17 19:24:59 +00:00
|
|
|
{ "cache", mp_property_cache, CONF_TYPE_INT },
|
2012-09-18 18:07:24 +00:00
|
|
|
M_OPTION_PROPERTY("pts-association-mode"),
|
|
|
|
M_OPTION_PROPERTY("hr-seek"),
|
2013-06-04 11:33:01 +00:00
|
|
|
{ "clock", mp_property_clock, CONF_TYPE_STRING,
|
|
|
|
0, 0, 0, NULL },
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2014-02-15 15:55:40 +00:00
|
|
|
M_PROPERTY("chapter-list", mp_property_list_chapters),
|
2014-02-15 15:53:11 +00:00
|
|
|
M_PROPERTY("track-list", property_list_tracks),
|
2013-06-28 20:16:29 +00:00
|
|
|
|
2014-02-15 15:54:55 +00:00
|
|
|
M_PROPERTY("playlist", mp_property_playlist),
|
2013-06-28 20:16:29 +00:00
|
|
|
{ "playlist-pos", mp_property_playlist_pos, CONF_TYPE_INT },
|
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
|
|
|
|
{ "volume", mp_property_volume, CONF_TYPE_FLOAT,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, 0, 100, NULL },
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "mute", mp_property_mute, CONF_TYPE_FLAG,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, 0, 1, NULL },
|
2012-09-18 18:07:24 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("audio-delay", mp_property_audio_delay),
|
core: redo how codecs are mapped, remove codecs.conf
Use codec names instead of FourCCs to identify codecs. Rewrite how
codecs are selected and initialized. Now each decoder exports a list
of decoders (and the codec it supports) via add_decoders(). The order
matters, and the first decoder for a given decoder is preferred over
the other decoders. E.g. all ad_mpg123 decoders are preferred over
ad_lavc, because it comes first in the mpcodecs_ad_drivers array.
Likewise, decoders within ad_lavc that are enumerated first by
libavcodec (using av_codec_next()) are preferred. (This is actually
critical to select h264 software decoding by default instead of vdpau.
libavcodec and ffmpeg/avconv use the same method to select decoders by
default, so we hope this is sane.)
The codec names follow libavcodec's codec names as defined by
AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders
have names different from the canonical codec name. The AVCodecDescriptor
API is relatively new, so we need a compatibility layer for older
libavcodec versions for codec names that are referenced internally,
and which are different from the decoder name. (Add a configure check
for that, because checking versions is getting way too messy.)
demux/codec_tags.c is generated from the former codecs.conf (minus
"special" decoders like vdpau, and excluding the mappings that are the
same as the mappings libavformat's exported RIFF tables). It contains
all the mappings from FourCCs to codec name. This is needed for
demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the
codec as determined by libavformat, while the other demuxers have to do
this on their own, using the mp_set_audio/video_codec_from_tag()
functions. Note that the sh_audio/video->format members don't uniquely
identify the codec anymore, and sh->codec takes over this role.
Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which
provide cover the functionality of the removed switched.
Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure
container/video combinations (e.g. the sample Film_200_zygo_pro.mov)
are played flipped. ffplay/avplay doesn't handle this properly either,
so we don't care and blame ffmeg/libav instead.
2013-02-09 14:15:19 +00:00
|
|
|
{ "audio-format", mp_property_audio_format, CONF_TYPE_STRING,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "audio-codec", mp_property_audio_codec, CONF_TYPE_STRING,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "audio-bitrate", mp_property_audio_bitrate, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "samplerate", mp_property_samplerate, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "channels", mp_property_channels, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2013-04-14 22:22:51 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("aid", mp_property_audio),
|
2007-06-20 02:26:20 +00:00
|
|
|
{ "balance", mp_property_balance, CONF_TYPE_FLOAT,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, -1, 1, NULL },
|
2013-09-19 12:32:47 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("volume-restore-data", mp_property_volrestore),
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
// Video
|
2012-09-18 18:07:24 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("fullscreen", mp_property_fullscreen),
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "deinterlace", mp_property_deinterlace, CONF_TYPE_FLAG,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, 0, 1, NULL },
|
2012-09-18 18:07:24 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("colormatrix", mp_property_colormatrix),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("colormatrix-input-range",
|
|
|
|
mp_property_colormatrix_input_range),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("colormatrix-output-range",
|
|
|
|
mp_property_colormatrix_output_range),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("ontop", mp_property_ontop),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("border", mp_property_border),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("framedrop", mp_property_framedrop),
|
2013-08-20 14:23:44 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("gamma", mp_property_video_color),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("brightness", mp_property_video_color),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("contrast", mp_property_video_color),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("saturation", mp_property_video_color),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("hue", mp_property_video_color),
|
2013-06-14 22:15:32 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("panscan", panscan_property_helper),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("video-zoom", panscan_property_helper),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("video-align-x", panscan_property_helper),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("video-align-y", panscan_property_helper),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("video-pan-x", panscan_property_helper),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("video-pan-y", panscan_property_helper),
|
2013-09-01 01:27:03 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("video-unscaled", panscan_property_helper),
|
2014-02-15 15:42:48 +00:00
|
|
|
M_PROPERTY("video-out-params", mp_property_vo_imgparams),
|
|
|
|
M_PROPERTY("video-params", mp_property_vd_imgparams),
|
core: redo how codecs are mapped, remove codecs.conf
Use codec names instead of FourCCs to identify codecs. Rewrite how
codecs are selected and initialized. Now each decoder exports a list
of decoders (and the codec it supports) via add_decoders(). The order
matters, and the first decoder for a given decoder is preferred over
the other decoders. E.g. all ad_mpg123 decoders are preferred over
ad_lavc, because it comes first in the mpcodecs_ad_drivers array.
Likewise, decoders within ad_lavc that are enumerated first by
libavcodec (using av_codec_next()) are preferred. (This is actually
critical to select h264 software decoding by default instead of vdpau.
libavcodec and ffmpeg/avconv use the same method to select decoders by
default, so we hope this is sane.)
The codec names follow libavcodec's codec names as defined by
AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders
have names different from the canonical codec name. The AVCodecDescriptor
API is relatively new, so we need a compatibility layer for older
libavcodec versions for codec names that are referenced internally,
and which are different from the decoder name. (Add a configure check
for that, because checking versions is getting way too messy.)
demux/codec_tags.c is generated from the former codecs.conf (minus
"special" decoders like vdpau, and excluding the mappings that are the
same as the mappings libavformat's exported RIFF tables). It contains
all the mappings from FourCCs to codec name. This is needed for
demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the
codec as determined by libavformat, while the other demuxers have to do
this on their own, using the mp_set_audio/video_codec_from_tag()
functions. Note that the sh_audio/video->format members don't uniquely
identify the codec anymore, and sh->codec takes over this role.
Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which
provide cover the functionality of the removed switched.
Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure
container/video combinations (e.g. the sample Film_200_zygo_pro.mov)
are played flipped. ffplay/avplay doesn't handle this properly either,
so we don't care and blame ffmeg/libav instead.
2013-02-09 14:15:19 +00:00
|
|
|
{ "video-format", mp_property_video_format, CONF_TYPE_STRING,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "video-codec", mp_property_video_codec, CONF_TYPE_STRING,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "video-bitrate", mp_property_video_bitrate, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
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"),
|
2013-10-31 19:19:40 +00:00
|
|
|
{ "window-scale", mp_property_window_scale, CONF_TYPE_DOUBLE,
|
|
|
|
CONF_RANGE, 0.125, 8 },
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "fps", mp_property_fps, CONF_TYPE_FLOAT,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "aspect", mp_property_aspect, CONF_TYPE_FLOAT,
|
2013-09-26 14:53:17 +00:00
|
|
|
CONF_RANGE, -1, 10, NULL },
|
2013-04-14 22:22:51 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("vid", mp_property_video),
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "program", mp_property_program, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
CONF_RANGE, -1, 65535, NULL },
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-09-30 20:25:34 +00:00
|
|
|
{ "osd-width", mp_property_osd_w, CONF_TYPE_INT },
|
|
|
|
{ "osd-height", mp_property_osd_h, CONF_TYPE_INT },
|
|
|
|
{ "osd-par", mp_property_osd_par, CONF_TYPE_DOUBLE },
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
// Subs
|
2013-04-14 22:22:51 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("sid", mp_property_sub),
|
2013-12-24 16:46:14 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("secondary-sid", mp_property_sub2),
|
2012-09-18 18:07:24 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("sub-delay", mp_property_sub_delay),
|
2012-09-25 01:24:38 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("sub-pos", mp_property_sub_pos),
|
2013-04-28 23:39:50 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("sub-visibility", property_osd_helper),
|
sub: add sd_spu.c to wrap spudec, cleanup mplayer.c
This unifies the subtitle rendering path. Now all subtitle rendering
goes through sd_ass.c/sd_lavc.c/sd_spu.c.
Before that commit, the spudec.h functions were used directly in
mplayer.c, which introduced many special cases. Add sd_spu.c, which is
just a small wrapper connecting the new subtitle render API with the
dusty old vobsub decoder in spudec.c.
One detail that changes is that we always pass the palette as extra
data, instead of passing the libdvdread palette as pointer to spudec
directly. This is a bit roundabout, but actually makes the code simpler
and more elegant: the difference between DVD and non-DVD dvdsubs is
reduced.
Ideally, we would just delete spudec.c and use libavcodec's DVD sub
decoder. However, DVD playback with demux_mpg produces packets
incompatible to lavc. There are incompatibilities the other way around
as well: packets from libavformat's vobsub demuxer are incompatible to
spudec.c. So we define a new subtitle codec name for demux_mpg subs,
"dvd_subtitle_mpg", which only sd_spu can decode.
There is actually code in spudec.c to "assemble" fragments into complete
packets, but using the whole spudec.c is easier than trying to move this
code into demux_mpg to fix subtitle packets.
As additional complication, Libav 9.x can't decode DVD subs correctly,
so use sd_spu in that case as well.
2013-04-28 23:13:22 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("sub-forced-only", property_osd_helper),
|
2013-05-14 21:14:23 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("sub-scale", property_osd_helper),
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_LIBASS
|
2013-05-14 21:14:23 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("ass-use-margins", property_osd_helper),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("ass-vsfilter-aspect-compat", property_osd_helper),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("ass-style-override", property_osd_helper),
|
2008-01-23 21:18:32 +00:00
|
|
|
#endif
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-08-03 11:41:38 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("vf*", mp_property_vf),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("af*", mp_property_af),
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_TV
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "tv-brightness", mp_property_tv_color, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, -100, 100, .offset = TV_COLOR_BRIGHTNESS },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "tv-contrast", mp_property_tv_color, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, -100, 100, .offset = TV_COLOR_CONTRAST },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "tv-saturation", mp_property_tv_color, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, -100, 100, .offset = TV_COLOR_SATURATION },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "tv-hue", mp_property_tv_color, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, -100, 100, .offset = TV_COLOR_HUE },
|
2007-02-21 00:49:24 +00:00
|
|
|
#endif
|
2012-08-09 23:30:53 +00:00
|
|
|
|
2013-04-14 22:22:51 +00:00
|
|
|
M_PROPERTY_ALIAS("video", "vid"),
|
|
|
|
M_PROPERTY_ALIAS("audio", "aid"),
|
|
|
|
M_PROPERTY_ALIAS("sub", "sid"),
|
|
|
|
|
2013-07-25 21:36:01 +00:00
|
|
|
{ "options", mp_property_options, &m_option_type_dummy },
|
|
|
|
|
2012-08-09 23:30:53 +00:00
|
|
|
{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
|
|
|
const struct m_option *mp_get_property_list(void)
|
|
|
|
{
|
|
|
|
return mp_properties;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2013-12-21 18:36:33 +00:00
|
|
|
return m_property_do(ctx->log, mp_properties, name, action, val, ctx);
|
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);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
|
|
|
static 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;
|
|
|
|
// Extra free-from message (just for volume)
|
|
|
|
const char *extra_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 },
|
|
|
|
{ "pts-association-mode", "PTS association mode" },
|
|
|
|
{ "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",
|
2013-09-20 22:08:38 +00:00
|
|
|
.extra_msg = "${?mute==yes:(Muted)}", .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}" },
|
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" },
|
2013-12-18 16:12:07 +00:00
|
|
|
{ "sub-visibility", "Subtitles" },
|
|
|
|
{ "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"},
|
|
|
|
{ "vf*", "Video filters", .msg = "Video filters:\n${vf}"},
|
|
|
|
{ "af*", "Audio filters", .msg = "Audio filters:\n${af}"},
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_TV
|
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 },
|
2009-09-19 01:17:30 +00:00
|
|
|
#endif
|
2012-09-25 01:24:38 +00:00
|
|
|
{0}
|
2009-09-19 01:17:30 +00:00
|
|
|
};
|
|
|
|
|
2013-12-15 22:35:36 +00:00
|
|
|
static void show_property_osd(MPContext *mpctx, const char *pname, int osd_mode)
|
2009-09-19 01:17:30 +00:00
|
|
|
{
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts = mpctx->opts;
|
2012-09-21 12:05:52 +00:00
|
|
|
struct m_option prop = {0};
|
2009-09-19 01:17:30 +00:00
|
|
|
struct property_osd_display *p;
|
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
if (mp_property_do(pname, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int osd_progbar = 0;
|
|
|
|
const char *osd_name = NULL;
|
2013-09-20 21:33:38 +00:00
|
|
|
const char *msg = NULL;
|
|
|
|
const char *extra_msg = NULL;
|
2012-09-25 01:24:38 +00:00
|
|
|
|
2009-09-19 01:17:30 +00:00
|
|
|
// look for the command
|
2012-09-25 01:24:38 +00:00
|
|
|
for (p = property_osd_display; p->name; p++) {
|
|
|
|
if (!strcmp(p->name, prop.name)) {
|
|
|
|
osd_progbar = p->seek_bar ? 1 : p->osd_progbar;
|
2013-12-16 19:40:02 +00:00
|
|
|
osd_name = p->seek_msg ? "" : p->osd_name;
|
2009-09-19 01:17:30 +00:00
|
|
|
break;
|
2012-09-25 01:24:38 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-19 01:17:30 +00:00
|
|
|
if (!p->name)
|
2012-09-25 01:24:38 +00:00
|
|
|
p = NULL;
|
2009-09-19 01:17:30 +00:00
|
|
|
|
2013-09-20 21:33:38 +00:00
|
|
|
if (p) {
|
|
|
|
msg = p->msg;
|
|
|
|
extra_msg = p->extra_msg;
|
|
|
|
}
|
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
if (osd_mode != MP_ON_OSD_AUTO) {
|
|
|
|
osd_name = osd_name ? osd_name : prop.name;
|
2013-09-20 21:33:38 +00:00
|
|
|
if (!(osd_mode & MP_ON_OSD_MSG)) {
|
2012-09-25 01:24:38 +00:00
|
|
|
osd_name = NULL;
|
2013-09-20 21:33:38 +00:00
|
|
|
msg = NULL;
|
|
|
|
extra_msg = NULL;
|
|
|
|
}
|
2012-09-25 01:24:38 +00:00
|
|
|
osd_progbar = osd_progbar ? osd_progbar : ' ';
|
|
|
|
if (!(osd_mode & MP_ON_OSD_BAR))
|
|
|
|
osd_progbar = 0;
|
|
|
|
}
|
2009-09-19 01:17:30 +00:00
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
if (p && (p->seek_msg || p->seek_bar)) {
|
|
|
|
mpctx->add_osd_seek_info |=
|
|
|
|
(osd_name ? p->seek_msg : 0) | (osd_progbar ? p->seek_bar : 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-24 19:19:33 +00:00
|
|
|
void *tmp = talloc_new(NULL);
|
|
|
|
|
|
|
|
if (!msg && osd_name)
|
|
|
|
msg = talloc_asprintf(tmp, "%s: ${%s}", osd_name, prop.name);
|
2013-09-20 21:33:38 +00:00
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
if (osd_progbar && (prop.flags & CONF_RANGE) == CONF_RANGE) {
|
2013-02-16 20:37:00 +00:00
|
|
|
bool ok = false;
|
2012-09-21 12:05:52 +00:00
|
|
|
if (prop.type == CONF_TYPE_INT) {
|
|
|
|
int i;
|
2013-02-16 20:37:00 +00:00
|
|
|
ok = mp_property_do(prop.name, M_PROPERTY_GET, &i, mpctx) > 0;
|
|
|
|
if (ok)
|
|
|
|
set_osd_bar(mpctx, osd_progbar, osd_name, prop.min, prop.max, i);
|
2012-09-21 12:05:52 +00:00
|
|
|
} else if (prop.type == CONF_TYPE_FLOAT) {
|
2009-09-19 01:17:30 +00:00
|
|
|
float f;
|
2013-02-16 20:37:00 +00:00
|
|
|
ok = mp_property_do(prop.name, M_PROPERTY_GET, &f, mpctx) > 0;
|
|
|
|
if (ok)
|
|
|
|
set_osd_bar(mpctx, osd_progbar, osd_name, prop.min, prop.max, f);
|
2009-09-19 01:17:30 +00:00
|
|
|
}
|
2013-02-16 20:37:00 +00:00
|
|
|
if (ok && osd_mode == MP_ON_OSD_AUTO && opts->osd_bar_visible)
|
2013-09-20 21:33:38 +00:00
|
|
|
msg = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *osd_msg = NULL;
|
|
|
|
if (msg)
|
|
|
|
osd_msg = talloc_steal(tmp, mp_property_expand_string(mpctx, msg));
|
|
|
|
if (extra_msg) {
|
|
|
|
char *t = talloc_steal(tmp, mp_property_expand_string(mpctx, extra_msg));
|
|
|
|
osd_msg = talloc_asprintf(tmp, "%s%s%s", osd_msg ? osd_msg : "",
|
|
|
|
osd_msg && osd_msg[0] ? " " : "", t);
|
|
|
|
}
|
|
|
|
|
2014-01-17 21:34:47 +00:00
|
|
|
if (osd_msg && osd_msg[0])
|
|
|
|
set_osd_msg(mpctx, 1, opts->osd_duration, "%s", osd_msg);
|
2013-09-20 21:33:38 +00:00
|
|
|
|
|
|
|
talloc_free(tmp);
|
2009-09-19 01:17:30 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2009-12-27 13:56:51 +00:00
|
|
|
static const char *property_error_string(int error_value)
|
|
|
|
{
|
|
|
|
switch (error_value) {
|
|
|
|
case M_PROPERTY_ERROR:
|
|
|
|
return "ERROR";
|
|
|
|
case M_PROPERTY_UNAVAILABLE:
|
|
|
|
return "PROPERTY_UNAVAILABLE";
|
|
|
|
case M_PROPERTY_NOT_IMPLEMENTED:
|
|
|
|
return "NOT_IMPLEMENTED";
|
|
|
|
case M_PROPERTY_UNKNOWN:
|
|
|
|
return "PROPERTY_UNKNOWN";
|
|
|
|
}
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-08-03 11:38:40 +00:00
|
|
|
static const char *filter_opt[STREAM_TYPE_COUNT] = {
|
|
|
|
[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);
|
|
|
|
} 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int edit_filters(struct MPContext *mpctx, enum stream_type mediatype,
|
|
|
|
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
|
|
|
|
2013-12-21 18:45:42 +00:00
|
|
|
int r = m_option_parse(mpctx->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)
|
|
|
|
{
|
|
|
|
int r = edit_filters(mpctx, mediatype, cmd, arg);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_SYS_MMAN_H
|
2013-09-30 20:27:37 +00:00
|
|
|
|
|
|
|
static int ext2_sub_find(struct MPContext *mpctx, int id)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2014-01-18 00:19:20 +00:00
|
|
|
struct sub_bitmaps *sub = &cmd->external2;
|
2013-09-30 20:27:37 +00:00
|
|
|
void *p = NULL;
|
|
|
|
if (id >= 0 && id < OVERLAY_MAX_ID)
|
|
|
|
p = cmd->overlay_map[id];
|
|
|
|
if (sub && p) {
|
|
|
|
for (int n = 0; n < sub->num_parts; n++) {
|
|
|
|
if (sub->parts[n].bitmap == p)
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ext2_sub_alloc(struct MPContext *mpctx)
|
|
|
|
{
|
2014-01-18 00:19:20 +00:00
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
|
|
|
struct sub_bitmaps *sub = &cmd->external2;
|
2013-09-30 20:27:37 +00:00
|
|
|
struct sub_bitmap b = {0};
|
2014-01-18 00:19:20 +00:00
|
|
|
MP_TARRAY_APPEND(cmd, sub->parts, sub->num_parts, b);
|
2013-09-30 20:27:37 +00:00
|
|
|
return sub->num_parts - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
struct command_ctx *cmd = mpctx->command_ctx;
|
2014-01-18 00:19:20 +00:00
|
|
|
int r = -1;
|
|
|
|
// Temporarily unmap them to avoid race condition with concurrent access.
|
|
|
|
osd_set_external2(mpctx->osd, NULL);
|
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
|
|
|
}
|
|
|
|
if (id < 0 || id >= OVERLAY_MAX_ID) {
|
|
|
|
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
|
|
|
}
|
|
|
|
int fd = -1;
|
|
|
|
bool close_fd = true;
|
|
|
|
if (file[0] == '@') {
|
|
|
|
char *end;
|
|
|
|
fd = strtol(&file[1], &end, 10);
|
|
|
|
if (!file[1] || end[0])
|
|
|
|
fd = -1;
|
|
|
|
close_fd = false;
|
|
|
|
} 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
|
|
|
}
|
|
|
|
void *p = mmap(NULL, h * stride, PROT_READ, MAP_SHARED, fd, offset);
|
|
|
|
if (fd >= 0 && close_fd)
|
|
|
|
close(fd);
|
|
|
|
if (!p) {
|
|
|
|
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
|
|
|
}
|
|
|
|
int index = ext2_sub_find(mpctx, id);
|
|
|
|
if (index < 0)
|
|
|
|
index = ext2_sub_alloc(mpctx);
|
|
|
|
if (index < 0) {
|
|
|
|
munmap(p, h * stride);
|
2014-01-18 00:19:20 +00:00
|
|
|
goto error;
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
cmd->overlay_map[id] = p;
|
2014-01-18 00:19:20 +00:00
|
|
|
cmd->external2.parts[index] = (struct sub_bitmap) {
|
2013-09-30 20:27:37 +00:00
|
|
|
.bitmap = p,
|
|
|
|
.stride = stride,
|
|
|
|
.x = x, .y = y,
|
|
|
|
.w = w, .h = h,
|
|
|
|
.dw = w, .dh = h,
|
|
|
|
};
|
2014-01-18 00:19:20 +00:00
|
|
|
cmd->external2.bitmap_id = cmd->external2.bitmap_pos_id = 1;
|
|
|
|
cmd->external2.format = SUBBITMAP_RGBA;
|
|
|
|
r = 0;
|
|
|
|
error:
|
|
|
|
osd_set_external2(mpctx->osd, &cmd->external2);
|
|
|
|
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-01-18 00:19:20 +00:00
|
|
|
osd_set_external2(mpctx->osd, NULL);
|
2013-09-30 20:27:37 +00:00
|
|
|
int index = ext2_sub_find(mpctx, id);
|
|
|
|
if (index >= 0) {
|
2014-01-18 00:19:20 +00:00
|
|
|
struct sub_bitmaps *sub = &cmd->external2;
|
2013-09-30 20:27:37 +00:00
|
|
|
struct sub_bitmap *part = &sub->parts[index];
|
|
|
|
munmap(part->bitmap, part->h * part->stride);
|
|
|
|
MP_TARRAY_REMOVE_AT(sub->parts, sub->num_parts, index);
|
|
|
|
cmd->overlay_map[id] = NULL;
|
|
|
|
sub->bitmap_id = sub->bitmap_pos_id = 1;
|
|
|
|
}
|
2014-01-18 00:19:20 +00:00
|
|
|
osd_set_external2(mpctx->osd, &cmd->external2);
|
2013-09-30 20:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void overlay_uninit(struct MPContext *mpctx)
|
|
|
|
{
|
2014-01-18 16:59:34 +00:00
|
|
|
if (!mpctx->osd)
|
|
|
|
return;
|
2013-09-30 20:27:37 +00:00
|
|
|
for (int id = 0; id < OVERLAY_MAX_ID; id++)
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static void overlay_uninit(struct MPContext *mpctx){}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
struct cycle_counter ctr = {stringlist_dup(cmd, args), 0};
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-11-30 01:19:46 +00:00
|
|
|
void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
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
|
|
|
|
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) {
|
2013-05-18 10:56:22 +00:00
|
|
|
cmd->args[n].v.s =
|
|
|
|
mp_property_expand_string(mpctx, cmd->args[n].v.s);
|
|
|
|
if (!cmd->args[n].v.s)
|
|
|
|
return;
|
|
|
|
talloc_steal(cmd, cmd->args[n].v.s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2013-02-24 15:06:27 +00:00
|
|
|
int abs = cmd->args[1].v.i;
|
|
|
|
int exact = cmd->args[2].v.i;
|
2013-12-01 01:07:32 +00:00
|
|
|
mark_seek(mpctx);
|
2011-08-07 01:45:40 +00:00
|
|
|
if (abs == 2) { // Absolute seek to a timestamp in seconds
|
player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:
1. If there's a queued seek, stop accepting non-seek commands, and delay
them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
trying to decode and display the first video frame), stop accepting
seek commands (and in fact all commands that were queued after the
first seek command). This logic is disabled if seeking started longer
than 300ms ago. (To avoid starvation.)
I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.
The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.
One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).
Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 21:29:50 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, v, exact, false);
|
2012-11-20 16:20:45 +00:00
|
|
|
set_osd_function(mpctx,
|
|
|
|
v > get_current_time(mpctx) ? OSD_FFW : OSD_REW);
|
2011-08-07 01:45:40 +00:00
|
|
|
} else if (abs) { /* Absolute seek by percentage */
|
player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:
1. If there's a queued seek, stop accepting non-seek commands, and delay
them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
trying to decode and display the first video frame), stop accepting
seek commands (and in fact all commands that were queued after the
first seek command). This logic is disabled if seeking started longer
than 300ms ago. (To avoid starvation.)
I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.
The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.
One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).
Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 21:29:50 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR, v / 100.0, exact, false);
|
2012-11-20 16:20:45 +00:00
|
|
|
set_osd_function(mpctx, OSD_FFW); // Direction isn't set correctly
|
2011-08-07 01:45:40 +00:00
|
|
|
} else {
|
player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:
1. If there's a queued seek, stop accepting non-seek commands, and delay
them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
trying to decode and display the first video frame), stop accepting
seek commands (and in fact all commands that were queued after the
first seek command). This logic is disabled if seeking started longer
than 300ms ago. (To avoid starvation.)
I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.
The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.
One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).
Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 21:29:50 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_RELATIVE, v, exact, false);
|
2012-11-20 16:20:45 +00:00
|
|
|
set_osd_function(mpctx, (v > 0) ? OSD_FFW : OSD_REW);
|
2012-09-09 00:08:08 +00:00
|
|
|
}
|
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: {
|
|
|
|
double oldpts = cmdctx->last_seek_pts;
|
|
|
|
if (oldpts != MP_NOPTS_VALUE) {
|
|
|
|
cmdctx->last_seek_pts = get_current_time(mpctx);
|
player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:
1. If there's a queued seek, stop accepting non-seek commands, and delay
them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
trying to decode and display the first video frame), stop accepting
seek commands (and in fact all commands that were queued after the
first seek command). This logic is disabled if seeking started longer
than 300ms ago. (To avoid starvation.)
I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.
The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.
One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).
Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 21:29:50 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, oldpts, 1, 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;
|
|
|
|
}
|
|
|
|
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);
|
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);
|
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:
|
|
|
|
{
|
|
|
|
struct m_property_switch_arg s = {
|
|
|
|
.inc = 1,
|
|
|
|
.wrap = cmd->id == MP_CMD_CYCLE,
|
|
|
|
};
|
2013-08-04 21:56:20 +00:00
|
|
|
if (cmd->args[1].v.d)
|
2013-07-25 16:08:57 +00:00
|
|
|
s.inc = cmd->args[1].v.d * cmd->scale;
|
2013-10-27 23:33:52 +00:00
|
|
|
char *property = cmd->args[0].v.s;
|
|
|
|
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);
|
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);
|
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);
|
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
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) {
|
|
|
|
int next = *ptr;
|
|
|
|
*ptr += dir;
|
|
|
|
if (*ptr >= count)
|
|
|
|
*ptr = 0;
|
|
|
|
if (*ptr < 0)
|
|
|
|
*ptr = count - 1;
|
|
|
|
char *property = args[first - 1];
|
|
|
|
char *value = args[first + next];
|
|
|
|
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);
|
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_GET_PROPERTY: {
|
|
|
|
char *tmp;
|
2012-09-22 06:04:08 +00:00
|
|
|
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_GET_STRING,
|
2011-08-07 01:45:40 +00:00
|
|
|
&tmp, mpctx);
|
|
|
|
if (r <= 0) {
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_WARN(mpctx, "Failed to get value of property '%s'.\n",
|
|
|
|
cmd->args[0].v.s);
|
|
|
|
MP_INFO(mpctx, "ANS_ERROR=%s\n", property_error_string(r));
|
2010-05-03 23:34:38 +00:00
|
|
|
break;
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2013-12-19 20:28:55 +00:00
|
|
|
MP_INFO(mpctx, "ANS_%s=%s\n", cmd->args[0].v.s, tmp);
|
2011-08-07 01:45:40 +00:00
|
|
|
talloc_free(tmp);
|
|
|
|
break;
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_FRAME_STEP:
|
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);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MP_CMD_FRAME_BACK_STEP:
|
|
|
|
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:
|
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
|
|
|
|
core: add playback resume feature (manual/opt-in)
A "watch later" command is now mapped to Shift+Q. This quits the player
and stores the playback state in a config file in ~/.mpv/watch_later/.
When calling the player with the same file again, playback is resumed
at that time position.
It's also possible to make mpv save playback state always on quit with
the --save-position-on-quit option. Likewise, resuming can be disabled
with the --no-resume-playback option.
This also attempts to save some playback parameters, like fullscreen
state or track selection. This will unconditionally override config
settings and command line options (which is probably not what you would
expect, but in general nobody will really care about this). Some things
are not backed up, because that would cause various problems. Additional
subtitle files, video filters, etc. are not stored because that would be
too hard and fragile. Volume/mute state are not stored because it would
mess up if the system mixer is used, or if the system mixer was
readjusted in the meantime.
Basically, the tradeoff between perfect state restoration and
complexity/fragility makes it not worth to attempt to implement
it perfectly, even if the result is a little bit inconsistent.
2013-05-05 17:37:29 +00:00
|
|
|
case MP_CMD_QUIT_WATCH_LATER:
|
|
|
|
mp_write_watch_later_conf(mpctx);
|
|
|
|
mpctx->stop_play = PT_QUIT;
|
|
|
|
mpctx->quit_player_rc = 0;
|
|
|
|
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
|
|
|
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)
|
|
|
|
break;
|
|
|
|
mpctx->playlist->current = e;
|
|
|
|
mpctx->playlist->current_was_replaced = false;
|
|
|
|
mpctx->stop_play = PT_CURRENT_ENTRY;
|
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: {
|
2014-01-18 00:19:20 +00:00
|
|
|
struct osd_sub_state state;
|
|
|
|
osd_get_sub(mpctx->osd, OSDTYPE_SUB, &state);
|
|
|
|
if (state.dec_sub) {
|
2013-06-28 23:34:11 +00:00
|
|
|
double a[2];
|
2014-01-18 00:19:20 +00:00
|
|
|
a[0] = mpctx->video_pts - state.video_offset - opts->sub_delay;
|
2013-06-28 23:34:11 +00:00
|
|
|
a[1] = cmd->args[0].v.i;
|
2014-01-18 00:19:20 +00:00
|
|
|
if (sub_control(state.dec_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-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2013-10-02 19:05:04 +00:00
|
|
|
"Sub delay: %d ms", ROUND(opts->sub_delay * 1000));
|
|
|
|
} 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);
|
player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:
1. If there's a queued seek, stop accepting non-seek commands, and delay
them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
trying to decode and display the first video frame), stop accepting
seek commands (and in fact all commands that were queued after the
first seek command). This logic is disabled if seeking started longer
than 300ms ago. (To avoid starvation.)
I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.
The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.
One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).
Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 21:29:50 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_RELATIVE, a[0], 1, 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;
|
2013-10-01 23:32:03 +00:00
|
|
|
int max = (opts->term_osd && !mpctx->video_out) ? MAX_TERM_OSD_LEVEL
|
|
|
|
: MAX_OSD_LEVEL;
|
2011-08-07 01:45:40 +00:00
|
|
|
if (opts->osd_level > max)
|
|
|
|
opts->osd_level = max;
|
|
|
|
if (v < 0)
|
|
|
|
opts->osd_level = (opts->osd_level + 1) % (max + 1);
|
|
|
|
else
|
|
|
|
opts->osd_level = v > max ? max : v;
|
2012-09-25 01:24:38 +00:00
|
|
|
if (msg_osd && opts->osd_level <= 1)
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, 0, osd_duration,
|
2012-11-20 13:00:12 +00:00
|
|
|
"OSD: %s", opts->osd_level ? "yes" : "no");
|
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;
|
|
|
|
bool 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);
|
|
|
|
|
|
|
|
playlist_add(mpctx->playlist, playlist_entry_new(filename));
|
|
|
|
|
2013-06-28 20:16:29 +00:00
|
|
|
if (!append)
|
|
|
|
mp_set_playlist_entry(mpctx, mpctx->playlist->first);
|
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) {
|
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);
|
|
|
|
playlist_transfer_entries(mpctx->playlist, pl);
|
|
|
|
talloc_free(pl);
|
|
|
|
|
2013-09-04 14:08:36 +00:00
|
|
|
if (!append && mpctx->playlist->first) {
|
2013-09-22 01:04:57 +00:00
|
|
|
struct playlist_entry *e =
|
2013-12-21 19:45:19 +00:00
|
|
|
mp_check_playlist_resume(mpctx, mpctx->playlist);
|
2013-09-04 14:08:36 +00:00
|
|
|
mp_set_playlist_entry(mpctx, e ? e : mpctx->playlist->first);
|
|
|
|
}
|
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);
|
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);
|
|
|
|
}
|
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;
|
2013-07-02 11:17:50 +00:00
|
|
|
if (e) {
|
|
|
|
// Can't play a removed entry
|
|
|
|
if (mpctx->playlist->current == e)
|
|
|
|
mpctx->stop_play = PT_CURRENT_ENTRY;
|
|
|
|
playlist_remove(mpctx->playlist, e);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
if (e1) {
|
|
|
|
playlist_move(mpctx->playlist, e1, e2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_STOP:
|
|
|
|
// Go back to the starting point.
|
|
|
|
mpctx->stop_play = PT_STOP;
|
|
|
|
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
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_TV
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_TV_START_SCAN:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (get_tvh(mpctx))
|
|
|
|
tv_start_scan(get_tvh(mpctx), 1);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
|
|
|
case MP_CMD_TV_SET_FREQ:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (get_tvh(mpctx))
|
|
|
|
tv_set_freq(get_tvh(mpctx), cmd->args[0].v.f * 16.0);
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_PVR
|
2011-08-07 01:45:40 +00:00
|
|
|
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
|
|
|
pvr_set_freq(mpctx->stream, ROUND(cmd->args[0].v.f));
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
|
2011-08-07 01:45:40 +00:00
|
|
|
pvr_get_current_channelname(mpctx->stream),
|
|
|
|
pvr_get_current_stationname(mpctx->stream));
|
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#endif /* HAVE_PVR */
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_TV_STEP_FREQ:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (get_tvh(mpctx))
|
|
|
|
tv_step_freq(get_tvh(mpctx), cmd->args[0].v.f * 16.0);
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_PVR
|
2011-08-07 01:45:40 +00:00
|
|
|
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
|
|
|
pvr_force_freq_step(mpctx->stream, ROUND(cmd->args[0].v.f));
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "%s: f %d",
|
2011-08-07 01:45:40 +00:00
|
|
|
pvr_get_current_channelname(mpctx->stream),
|
|
|
|
pvr_get_current_frequency(mpctx->stream));
|
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#endif /* HAVE_PVR */
|
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_TV_SET_NORM:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (get_tvh(mpctx))
|
|
|
|
tv_set_norm(get_tvh(mpctx), 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_TV_STEP_CHANNEL:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (get_tvh(mpctx)) {
|
2011-08-07 01:45:40 +00:00
|
|
|
int v = cmd->args[0].v.i;
|
|
|
|
if (v > 0) {
|
2012-08-19 16:07:06 +00:00
|
|
|
tv_step_channel(get_tvh(mpctx), TV_CHANNEL_HIGHER);
|
2011-08-07 01:45:40 +00:00
|
|
|
} else {
|
2012-08-19 16:07:06 +00:00
|
|
|
tv_step_channel(get_tvh(mpctx), TV_CHANNEL_LOWER);
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
|
|
|
if (tv_channel_list) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2011-08-07 01:45:40 +00:00
|
|
|
"Channel: %s", tv_channel_current->name);
|
|
|
|
}
|
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_PVR
|
2011-08-07 01:45:40 +00:00
|
|
|
else if (mpctx->stream &&
|
|
|
|
mpctx->stream->type == STREAMTYPE_PVR) {
|
|
|
|
pvr_set_channel_step(mpctx->stream, cmd->args[0].v.i);
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
|
2011-08-07 01:45:40 +00:00
|
|
|
pvr_get_current_channelname(mpctx->stream),
|
|
|
|
pvr_get_current_stationname(mpctx->stream));
|
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#endif /* HAVE_PVR */
|
|
|
|
#if HAVE_DVBIN
|
2011-08-07 01:45:40 +00:00
|
|
|
if (mpctx->stream->type == STREAMTYPE_DVB) {
|
|
|
|
int dir;
|
|
|
|
int v = cmd->args[0].v.i;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
mpctx->last_dvb_step = v;
|
|
|
|
if (v > 0)
|
|
|
|
dir = DVB_CHANNEL_HIGHER;
|
|
|
|
else
|
|
|
|
dir = DVB_CHANNEL_LOWER;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
if (dvb_step_channel(mpctx->stream, dir)) {
|
Add prelimimary (basic, possibly broken) dvdnav support
This readds a more or less completely new dvdnav implementation, though
it's based on the code from before commit 41fbcee. Note that this is
rather basic, and might be broken or not quite usable in many cases.
Most importantly, navigation highlights are not correctly implemented.
This would require changes in the FFmpeg dvdsub decoder (to apply a
different internal CLUT), so supporting it is not really possible right
now. And in fact, I don't think I ever want to support it, because it's
a very small gain for a lot of work. Instead, mpv will display fake
highlights, which are an approximate bounding box around the real
highlights.
Some things like mouse input or switching audio/subtitles stream using
the dvdnav VM are not supported.
Might be quite fragile on transitions: if dvdnav initiates a transition,
and doesn't give us enough mpeg data to initialize video playback, the
player will just quit.
This is added only because some users seem to want it. I don't intend to
make mpv a good DVD player, so the very basic minimum will have to do.
How about you just convert your DVD to proper video files?
2013-12-12 00:44:28 +00:00
|
|
|
mpctx->stop_play = PT_RELOAD_DEMUXER;
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#endif /* HAVE_DVBIN */
|
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_TV_SET_CHANNEL:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (get_tvh(mpctx)) {
|
|
|
|
tv_set_channel(get_tvh(mpctx), cmd->args[0].v.s);
|
2011-08-07 01:45:40 +00:00
|
|
|
if (tv_channel_list) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2011-08-07 01:45:40 +00:00
|
|
|
"Channel: %s", tv_channel_current->name);
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_PVR
|
2011-08-07 01:45:40 +00:00
|
|
|
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
|
|
|
pvr_set_channel(mpctx->stream, cmd->args[0].v.s);
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
|
2011-08-07 01:45:40 +00:00
|
|
|
pvr_get_current_channelname(mpctx->stream),
|
|
|
|
pvr_get_current_stationname(mpctx->stream));
|
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#endif /* HAVE_PVR */
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_DVBIN
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_DVB_SET_CHANNEL:
|
|
|
|
if (mpctx->stream->type == STREAMTYPE_DVB) {
|
|
|
|
mpctx->last_dvb_step = 1;
|
|
|
|
|
|
|
|
if (dvb_set_channel(mpctx->stream, cmd->args[1].v.i,
|
|
|
|
cmd->args[0].v.i)) {
|
Add prelimimary (basic, possibly broken) dvdnav support
This readds a more or less completely new dvdnav implementation, though
it's based on the code from before commit 41fbcee. Note that this is
rather basic, and might be broken or not quite usable in many cases.
Most importantly, navigation highlights are not correctly implemented.
This would require changes in the FFmpeg dvdsub decoder (to apply a
different internal CLUT), so supporting it is not really possible right
now. And in fact, I don't think I ever want to support it, because it's
a very small gain for a lot of work. Instead, mpv will display fake
highlights, which are an approximate bounding box around the real
highlights.
Some things like mouse input or switching audio/subtitles stream using
the dvdnav VM are not supported.
Might be quite fragile on transitions: if dvdnav initiates a transition,
and doesn't give us enough mpeg data to initialize video playback, the
player will just quit.
This is added only because some users seem to want it. I don't intend to
make mpv a good DVD player, so the very basic minimum will have to do.
How about you just convert your DVD to proper video files?
2013-12-12 00:44:28 +00:00
|
|
|
mpctx->stop_play = PT_RELOAD_DEMUXER;
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-07-16 11:28:28 +00:00
|
|
|
#endif /* HAVE_DVBIN */
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_TV_LAST_CHANNEL:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (get_tvh(mpctx)) {
|
|
|
|
tv_last_channel(get_tvh(mpctx));
|
2011-08-07 01:45:40 +00:00
|
|
|
if (tv_channel_list) {
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration,
|
2011-08-07 01:45:40 +00:00
|
|
|
"Channel: %s", tv_channel_current->name);
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_PVR
|
2011-08-07 01:45:40 +00:00
|
|
|
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
|
|
|
pvr_set_lastchannel(mpctx->stream);
|
2014-01-17 21:34:47 +00:00
|
|
|
set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
|
2011-08-07 01:45:40 +00:00
|
|
|
pvr_get_current_channelname(mpctx->stream),
|
|
|
|
pvr_get_current_stationname(mpctx->stream));
|
|
|
|
}
|
2013-07-16 11:28:28 +00:00
|
|
|
#endif /* HAVE_PVR */
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_TV_STEP_NORM:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (get_tvh(mpctx))
|
|
|
|
tv_step_norm(get_tvh(mpctx));
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_TV_STEP_CHANNEL_LIST:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (get_tvh(mpctx))
|
|
|
|
tv_step_chanlist(get_tvh(mpctx));
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2013-07-16 11:28:28 +00:00
|
|
|
#endif /* HAVE_TV */
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2014-02-13 12:30:07 +00:00
|
|
|
case MP_CMD_SUB_ADD: {
|
|
|
|
struct track *sub = mp_add_subtitles(mpctx, cmd->args[0].v.s);
|
|
|
|
if (sub)
|
|
|
|
mp_switch_track(mpctx, sub->type, sub);
|
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
|
|
|
|
2012-11-15 19:26:52 +00:00
|
|
|
case MP_CMD_SUB_REMOVE: {
|
|
|
|
struct track *sub = mp_track_by_tid(mpctx, STREAM_SUB, cmd->args[0].v.i);
|
|
|
|
if (sub)
|
|
|
|
mp_remove_track(mpctx, sub);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case MP_CMD_SUB_RELOAD: {
|
|
|
|
struct track *sub = mp_track_by_tid(mpctx, STREAM_SUB, cmd->args[0].v.i);
|
2013-10-01 23:32:03 +00:00
|
|
|
if (sub && sub->is_external && sub->external_filename) {
|
2013-09-07 18:19:57 +00:00
|
|
|
struct track *nsub = mp_add_subtitles(mpctx, sub->external_filename);
|
2012-11-15 19:26:52 +00:00
|
|
|
if (nsub) {
|
|
|
|
mp_remove_track(mpctx, sub);
|
|
|
|
mp_switch_track(mpctx, nsub->type, nsub);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_SCREENSHOT:
|
2013-02-24 21:54:14 +00:00
|
|
|
screenshot_request(mpctx, cmd->args[0].v.i, cmd->args[1].v.i, msg_osd);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
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;
|
|
|
|
|
2013-11-29 22:36:44 +00:00
|
|
|
case MP_CMD_RUN: {
|
2007-02-21 00:49:24 +00:00
|
|
|
#ifndef __MINGW32__
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
mp_msg_flush_status_line(mpctx->global);
|
2013-11-29 22:36:44 +00:00
|
|
|
char *args[MP_CMD_MAX_ARGS + 1] = {0};
|
|
|
|
for (int n = 0; n < cmd->nargs; n++)
|
|
|
|
args[n] = cmd->args[n].v.s;
|
2013-11-30 21:47:17 +00:00
|
|
|
pid_t child = fork();
|
|
|
|
if (child == 0) {
|
|
|
|
// Fork twice; the second process will be made child of pid 1 as
|
|
|
|
// soon as the first process exists, and we don't have to care
|
|
|
|
// about having to wait for the second process to terminate.
|
|
|
|
if (fork() == 0) {
|
|
|
|
execvp(args[0], args);
|
2014-01-05 19:11:01 +00:00
|
|
|
// mp_msg() is not safe to be called from a forked process.
|
|
|
|
char s[] = "Executing program failed.\n";
|
|
|
|
write(2, s, sizeof(s) - 1);
|
|
|
|
_exit(1);
|
2013-11-30 21:47:17 +00:00
|
|
|
}
|
|
|
|
_exit(0);
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2013-11-30 21:47:17 +00:00
|
|
|
int st;
|
|
|
|
while (child != -1 && waitpid(child, &st, 0) < 0 && errno == EINTR) {}
|
2007-02-21 00:49:24 +00:00
|
|
|
#endif
|
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:
|
|
|
|
mp_input_enable_section(mpctx->input, cmd->args[0].v.s,
|
|
|
|
cmd->args[1].v.i == 1 ? MP_INPUT_EXCLUSIVE : 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MP_CMD_DISABLE_INPUT_SECTION:
|
|
|
|
mp_input_disable_section(mpctx->input, cmd->args[0].v.s);
|
|
|
|
break;
|
|
|
|
|
Add prelimimary (basic, possibly broken) dvdnav support
This readds a more or less completely new dvdnav implementation, though
it's based on the code from before commit 41fbcee. Note that this is
rather basic, and might be broken or not quite usable in many cases.
Most importantly, navigation highlights are not correctly implemented.
This would require changes in the FFmpeg dvdsub decoder (to apply a
different internal CLUT), so supporting it is not really possible right
now. And in fact, I don't think I ever want to support it, because it's
a very small gain for a lot of work. Instead, mpv will display fake
highlights, which are an approximate bounding box around the real
highlights.
Some things like mouse input or switching audio/subtitles stream using
the dvdnav VM are not supported.
Might be quite fragile on transitions: if dvdnav initiates a transition,
and doesn't give us enough mpeg data to initialize video playback, the
player will just quit.
This is added only because some users seem to want it. I don't intend to
make mpv a good DVD player, so the very basic minimum will have to do.
How about you just convert your DVD to proper video files?
2013-12-12 00:44:28 +00:00
|
|
|
case MP_CMD_DVDNAV:
|
|
|
|
mp_nav_user_input(mpctx, cmd->args[0].v.s);
|
|
|
|
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!");
|
2012-07-31 23:06:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-07-22 12:43:58 +00:00
|
|
|
case MP_CMD_AF:
|
2013-08-03 11:54:02 +00:00
|
|
|
edit_filters_osd(mpctx, STREAM_AUDIO, cmd->args[0].v.s,
|
|
|
|
cmd->args[1].v.s, msg_osd);
|
2010-10-17 15:54:55 +00:00
|
|
|
break;
|
2013-07-22 12:43:58 +00:00
|
|
|
|
2013-05-18 09:44:17 +00:00
|
|
|
case MP_CMD_VF:
|
2013-08-03 11:54:02 +00:00
|
|
|
edit_filters_osd(mpctx, STREAM_VIDEO, cmd->args[0].v.s,
|
|
|
|
cmd->args[1].v.s, msg_osd);
|
2013-05-18 09:44:17 +00:00
|
|
|
break;
|
2010-10-17 15:54:55 +00:00
|
|
|
|
2014-02-10 20:03:59 +00:00
|
|
|
case MP_CMD_SCRIPT_DISPATCH: {
|
|
|
|
mpv_event_script_input_dispatch *event = talloc_ptrtype(NULL, event);
|
|
|
|
*event = (mpv_event_script_input_dispatch){
|
|
|
|
.arg0 = cmd->args[1].v.i,
|
|
|
|
.type = cmd->key_up_follows ? "keyup_follows" : "press",
|
|
|
|
};
|
|
|
|
if (mp_client_send_event(mpctx, cmd->args[0].v.s,
|
|
|
|
MPV_EVENT_SCRIPT_INPUT_DISPATCH, event) < 0)
|
|
|
|
{
|
|
|
|
MP_VERBOSE(mpctx, "Can't find script '%s' when handling input.\n",
|
|
|
|
cmd->args[0].v.s);
|
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-02-17 01:33:47 +00:00
|
|
|
case MP_CMD_SCRIPT_MESSAGE: {
|
|
|
|
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,
|
|
|
|
cmd->args[n].v.s);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
#if HAVE_SYS_MMAN_H
|
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;
|
|
|
|
#endif
|
|
|
|
|
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)
|
|
|
|
run_command(mpctx, sub);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-08-30 00:30:17 +00:00
|
|
|
case MP_CMD_IGNORE:
|
|
|
|
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);
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-12-15 22:35:36 +00:00
|
|
|
if (cmd->flags & MP_PAUSING)
|
2008-11-29 06:09:57 +00:00
|
|
|
pause_player(mpctx);
|
2013-12-15 22:35:36 +00:00
|
|
|
if (cmd->flags & MP_PAUSING_TOGGLE) {
|
2013-04-25 18:38:22 +00:00
|
|
|
if (opts->pause)
|
2008-11-29 06:09:57 +00:00
|
|
|
unpause_player(mpctx);
|
|
|
|
else
|
|
|
|
pause_player(mpctx);
|
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);
|
|
|
|
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,
|
|
|
|
};
|
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-02-10 20:01:35 +00:00
|
|
|
void mp_notify(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-02-10 20:01:35 +00:00
|
|
|
if (event == MPV_EVENT_START_FILE)
|
|
|
|
ctx->last_seek_pts = MP_NOPTS_VALUE;
|
|
|
|
|
|
|
|
mp_client_broadcast_event(mpctx, event, 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
|
|
|
}
|