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>
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
2009-04-02 02:00:22 +00:00
|
|
|
#include "talloc.h"
|
2008-03-28 01:07:59 +00:00
|
|
|
#include "command.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "input/input.h"
|
|
|
|
#include "stream/stream.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "demux/demux.h"
|
|
|
|
#include "demux/stheader.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "mplayer.h"
|
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
|
|
|
#include "playlist.h"
|
|
|
|
#include "playlist_parser.h"
|
2011-01-26 17:40:52 +00:00
|
|
|
#include "sub/sub.h"
|
2011-01-16 18:03:08 +00:00
|
|
|
#include "sub/dec_sub.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/m_option.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "m_property.h"
|
2010-12-18 06:02:48 +00:00
|
|
|
#include "m_config.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/filter/vf.h"
|
|
|
|
#include "video/decode/vd.h"
|
2008-04-23 06:49:25 +00:00
|
|
|
#include "mp_osd.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/out/vo.h"
|
|
|
|
#include "video/csputils.h"
|
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
|
|
|
#include "playlist.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "audio/mixer.h"
|
|
|
|
#include "audio/out/ao.h"
|
|
|
|
#include "core/mp_common.h"
|
|
|
|
#include "audio/filter/af.h"
|
|
|
|
#include "video/decode/dec_video.h"
|
|
|
|
#include "audio/decode/dec_audio.h"
|
2011-01-26 17:40:52 +00:00
|
|
|
#include "sub/spudec.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/path.h"
|
2011-01-26 17:40:52 +00:00
|
|
|
#include "sub/ass_mp.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "stream/tv.h"
|
|
|
|
#include "stream/stream_radio.h"
|
2007-05-08 12:20:46 +00:00
|
|
|
#include "stream/pvr.h"
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_DVBIN
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "stream/dvbin.h"
|
|
|
|
#endif
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_DVDREAD
|
2007-02-21 00:49:24 +00:00
|
|
|
#include "stream/stream_dvd.h"
|
|
|
|
#endif
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/m_struct.h"
|
2011-10-06 18:46:01 +00:00
|
|
|
#include "screenshot.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/mp_core.h"
|
2007-08-25 16:03:02 +00:00
|
|
|
#include "mp_fifo.h"
|
2008-02-29 17:44:54 +00:00
|
|
|
#include "libavutil/avstring.h"
|
2007-02-21 00:49:24 +00:00
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2008-04-20 20:29:28 +00:00
|
|
|
static void rescale_input_coordinates(struct MPContext *mpctx, int ix, int iy,
|
|
|
|
double *dx, double *dy)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
2008-04-20 23:18:28 +00:00
|
|
|
struct MPOpts *opts = &mpctx->opts;
|
2008-04-20 20:29:28 +00:00
|
|
|
struct vo *vo = mpctx->video_out;
|
2007-02-21 00:49:24 +00:00
|
|
|
//remove the borders, if any, and rescale to the range [0,1],[0,1]
|
2010-05-03 23:34:38 +00:00
|
|
|
if (vo_fs) { //we are in full-screen mode
|
2011-08-07 01:45:40 +00:00
|
|
|
if (opts->vo_screenwidth > vo->dwidth)
|
|
|
|
// there are borders along the x axis
|
2010-05-07 19:02:47 +00:00
|
|
|
ix -= (opts->vo_screenwidth - vo->dwidth) / 2;
|
2011-08-07 01:45:40 +00:00
|
|
|
if (opts->vo_screenheight > vo->dheight)
|
|
|
|
// there are borders along the y axis (usual way)
|
2010-05-07 19:02:47 +00:00
|
|
|
iy -= (opts->vo_screenheight - vo->dheight) / 2;
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2010-05-07 19:02:47 +00:00
|
|
|
if (ix < 0 || ix > vo->dwidth) {
|
2010-05-03 23:34:38 +00:00
|
|
|
*dx = *dy = -1.0;
|
|
|
|
return;
|
|
|
|
} //we are on one of the borders
|
2010-05-07 19:02:47 +00:00
|
|
|
if (iy < 0 || iy > vo->dheight) {
|
2010-05-03 23:34:38 +00:00
|
|
|
*dx = *dy = -1.0;
|
|
|
|
return;
|
|
|
|
} //we are on one of the borders
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 20:29:28 +00:00
|
|
|
*dx = (double) ix / (double) vo->dwidth;
|
|
|
|
*dy = (double) iy / (double) vo->dheight;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_V,
|
2010-05-07 19:02:47 +00:00
|
|
|
"\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
|
|
|
|
*dx, *dy, opts->vo_screenwidth, opts->vo_screenheight, vo->dwidth,
|
|
|
|
vo->dheight, vo_fs);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2008-04-21 03:55:23 +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: {
|
2010-05-07 19:02:47 +00:00
|
|
|
opts->playback_speed = *(float *) 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;
|
2010-11-26 20:52:35 +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;
|
|
|
|
char *f = (char *)mp_basename(mpctx->filename);
|
|
|
|
return m_property_strdup_ro(prop, action, arg, (*f) ? f : mpctx->filename);
|
|
|
|
}
|
|
|
|
|
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;
|
2012-10-30 18:32:57 +00:00
|
|
|
if (name && name[0]) {
|
|
|
|
return m_property_strdup_ro(prop, action, arg, name);
|
|
|
|
} else {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2012-09-18 13:31:46 +00:00
|
|
|
return m_property_double_ro(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
|
|
|
|
2012-09-18 13:31:46 +00:00
|
|
|
return m_property_double_ro(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)
|
|
|
|
{
|
|
|
|
if (!mpctx->sh_audio || !mpctx->sh_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
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) {
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_SET: ;
|
|
|
|
int pos = *(int *)arg;
|
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, 0);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(int *)arg = get_percent_pos(mpctx);
|
|
|
|
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;
|
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
switch (action) {
|
2007-05-31 13:07:52 +00:00
|
|
|
case M_PROPERTY_SET:
|
2011-08-07 01:45:40 +00:00
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, 0);
|
2007-05-31 13:07:52 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(double *)arg = get_current_time(mpctx);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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: {
|
2012-09-25 01:24:38 +00:00
|
|
|
char *chapter_name = chapter_display_name(mpctx, chapter);
|
2007-12-14 08:33:11 +00:00
|
|
|
if (!chapter_name)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
*(char **) arg = chapter_name;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_SET: ;
|
|
|
|
int step_all = *(int *)arg - chapter;
|
2007-12-14 08:33:11 +00:00
|
|
|
chapter += step_all;
|
2012-09-18 18:07:24 +00:00
|
|
|
double next_pts = 0;
|
|
|
|
queue_seek(mpctx, MPSEEK_NONE, 0, 0);
|
|
|
|
chapter = seek_chapter(mpctx, chapter, &next_pts);
|
|
|
|
if (chapter >= 0) {
|
|
|
|
if (next_pts > -1.0)
|
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, next_pts, 0);
|
|
|
|
} else if (step_all > 0)
|
|
|
|
mpctx->stop_play = PT_NEXT_ENTRY;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-08-25 23:19:42 +00:00
|
|
|
static int mp_property_edition(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct MPOpts *opts = &mpctx->opts;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
if (!demuxer)
|
2011-12-31 12:20:08 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-08-25 23:19:42 +00:00
|
|
|
int num_titles = 0;
|
|
|
|
stream_control(demuxer->stream, STREAM_CTRL_GET_NUM_TITLES, &num_titles);
|
|
|
|
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) {
|
|
|
|
struct sh_video *sh_video = demuxer->video->sh;
|
|
|
|
if (sh_video)
|
|
|
|
resync_video_stream(sh_video);
|
|
|
|
|
|
|
|
struct sh_audio *sh_audio = demuxer->audio->sh;
|
|
|
|
if (sh_audio)
|
|
|
|
resync_audio_stream(sh_audio);
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-05-29 22:14:41 +00:00
|
|
|
/// Demuxer meta data
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_metadata(m_option_t *prop, int action, void *arg,
|
2011-08-07 01:45:40 +00:00
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
2012-08-19 16:07:06 +00:00
|
|
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
|
|
|
if (!demuxer)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
|
2008-04-26 13:35:40 +00:00
|
|
|
static const m_option_t key_type =
|
2011-08-07 01:45:40 +00:00
|
|
|
{
|
|
|
|
"metadata", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL
|
|
|
|
};
|
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;
|
|
|
|
m_option_copy(prop, &slist, &demuxer->info);
|
|
|
|
*(char ***)arg = slist;
|
2007-05-29 22:14:41 +00:00
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 18:07:24 +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;
|
2012-09-21 10:19:59 +00:00
|
|
|
char *meta = demux_info_get(demuxer, ka->key);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case 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;
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(int *)arg = mpctx->paused;
|
|
|
|
return M_PROPERTY_OK;
|
2008-11-29 06:09:57 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
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
|
|
|
|
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
|
|
|
{
|
|
|
|
|
|
|
|
if (!mpctx->sh_audio)
|
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:
|
2010-05-03 23:34:38 +00:00
|
|
|
mixer_getbothvolume(&mpctx->mixer, arg);
|
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_SET:
|
2010-05-03 23:34:38 +00:00
|
|
|
mixer_setvolume(&mpctx->mixer, *(float *) arg, *(float *) arg);
|
|
|
|
return M_PROPERTY_OK;
|
2012-09-22 04:15:36 +00:00
|
|
|
case M_PROPERTY_SWITCH: {
|
|
|
|
struct m_property_switch_arg *sarg = arg;
|
|
|
|
if (sarg->inc <= 0)
|
2010-05-03 23:34:38 +00:00
|
|
|
mixer_decvolume(&mpctx->mixer);
|
|
|
|
else
|
|
|
|
mixer_incvolume(&mpctx->mixer);
|
|
|
|
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
|
|
|
{
|
|
|
|
|
|
|
|
if (!mpctx->sh_audio)
|
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:
|
2012-04-09 14:39:01 +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:
|
|
|
|
*(int *)arg = mixer_getmute(&mpctx->mixer);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/// 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
|
|
|
{
|
|
|
|
if (!(mpctx->sh_audio && mpctx->sh_video))
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-10-30 18:44:09 +00:00
|
|
|
float delay = 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:
|
2012-10-30 18:44:09 +00:00
|
|
|
audio_delay = *(float *)arg;
|
|
|
|
mpctx->delay -= 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
|
|
|
{
|
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
|
|
|
const char *c = mpctx->sh_audio ? mpctx->sh_audio->gsh->codec : NULL;
|
|
|
|
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
|
|
|
{
|
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
|
|
|
const char *c = mpctx->sh_audio ? mpctx->sh_audio->gsh->decoder_desc : NULL;
|
|
|
|
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
|
|
|
{
|
|
|
|
if (!mpctx->sh_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:
|
|
|
|
*(char **)arg = format_bitrate(mpctx->sh_audio->i_bps);
|
|
|
|
return M_PROPERTY_OK;
|
2012-09-18 18:07:24 +00:00
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(int *)arg = mpctx->sh_audio->i_bps;
|
|
|
|
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
|
|
|
{
|
|
|
|
if (!mpctx->sh_audio)
|
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:
|
2011-08-07 01:45:40 +00:00
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d kHz",
|
|
|
|
mpctx->sh_audio->samplerate / 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:
|
|
|
|
*(int *)arg = mpctx->sh_audio->samplerate;
|
|
|
|
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
|
|
|
{
|
|
|
|
if (!mpctx->sh_audio)
|
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:
|
2010-05-03 23:34:38 +00:00
|
|
|
switch (mpctx->sh_audio->channels) {
|
|
|
|
case 1:
|
2011-07-03 17:04:21 +00:00
|
|
|
*(char **) arg = talloc_strdup(NULL, "mono");
|
2010-05-03 23:34:38 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2011-07-03 17:04:21 +00:00
|
|
|
*(char **) arg = talloc_strdup(NULL, "stereo");
|
2010-05-03 23:34:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-07-03 17:04:21 +00:00
|
|
|
*(char **) arg = talloc_asprintf(NULL, "%d channels",
|
|
|
|
mpctx->sh_audio->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:
|
|
|
|
*(int *)arg = mpctx->sh_audio->channels;
|
|
|
|
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:
|
2010-05-03 23:34:38 +00:00
|
|
|
mixer_getbalance(&mpctx->mixer, arg);
|
|
|
|
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;
|
|
|
|
mixer_getbalance(&mpctx->mixer, &bal);
|
|
|
|
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:
|
2011-08-07 01:45:40 +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;
|
|
|
|
}
|
|
|
|
|
2012-08-19 16:01:30 +00:00
|
|
|
static struct track* track_next(struct MPContext *mpctx, enum stream_type type,
|
|
|
|
int direction, struct track *track)
|
|
|
|
{
|
|
|
|
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];
|
|
|
|
if (cur->type == type) {
|
|
|
|
if (cur == track) {
|
|
|
|
seen = true;
|
|
|
|
} else {
|
|
|
|
if (seen && !next) {
|
|
|
|
next = cur;
|
|
|
|
} else if (!seen || !track) {
|
|
|
|
prev = cur;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return direction > 0 ? next : prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int property_switch_track(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx, 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;
|
2012-08-19 16:01:30 +00:00
|
|
|
struct track *track = mpctx->current_track[type];
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2012-08-19 16:01:30 +00:00
|
|
|
*(int *) arg = track ? track->user_tid : -1;
|
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)
|
2012-08-19 16:01:30 +00:00
|
|
|
lang = mp_gtext("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;
|
2012-09-18 12:00:08 +00:00
|
|
|
mp_switch_track(mpctx, type,
|
2012-09-22 04:15:36 +00:00
|
|
|
track_next(mpctx, 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:
|
|
|
|
mp_switch_track(mpctx, type, mp_track_by_tid(mpctx, type, *(int *)arg));
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
default:
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
2012-08-19 16:01:30 +00:00
|
|
|
}
|
2007-02-21 00:49:24 +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)
|
|
|
|
{
|
|
|
|
return property_switch_track(prop, action, arg, mpctx, 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
|
|
|
{
|
2012-08-19 16:01:30 +00:00
|
|
|
return property_switch_track(prop, action, arg, mpctx, 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) {
|
2011-08-07 01:45:40 +00:00
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_ERR,
|
|
|
|
"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_AUDIO,
|
|
|
|
find_track_by_demuxer_id(mpctx, STREAM_AUDIO, prog.aid));
|
|
|
|
mp_switch_track(mpctx, STREAM_VIDEO,
|
|
|
|
find_track_by_demuxer_id(mpctx, STREAM_VIDEO, prog.vid));
|
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)
|
2008-04-25 02:04:41 +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;
|
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_fs == !!*(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, VOCTRL_FULLSCREEN, 0);
|
2009-03-20 00:56:49 +00:00
|
|
|
mpctx->opts.fullscreen = vo_fs;
|
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
|
|
|
}
|
|
|
|
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_deinterlace(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
|
|
|
{
|
|
|
|
if (!mpctx->sh_video || !mpctx->sh_video->vfilter)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-10-28 19:59:15 +00:00
|
|
|
vf_instance_t *vf = mpctx->sh_video->vfilter;
|
|
|
|
int enabled = 0;
|
|
|
|
if (vf->control(vf, VFCTRL_GET_DEINTERLACE, &enabled) != CONTROL_OK)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_GET:
|
2012-10-28 19:59:15 +00:00
|
|
|
*(int *)arg = !!enabled;
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_OK;
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_SET:
|
2010-05-03 23:34:38 +00:00
|
|
|
vf->control(vf, VFCTRL_SET_DEINTERLACE, arg);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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 colormatrix_property_helper(m_option_t *prop, int action,
|
2011-08-07 01:45:40 +00:00
|
|
|
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) {
|
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
|
|
|
if (mpctx->sh_video)
|
|
|
|
set_video_colorspace(mpctx->sh_video);
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
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
|
|
|
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)
|
|
|
|
return colormatrix_property_helper(prop, action, arg, 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
|
|
|
struct MPOpts *opts = &mpctx->opts;
|
2012-09-21 11:46:58 +00:00
|
|
|
struct mp_csp_details actual = { .format = -1 };
|
|
|
|
char *req_csp = mp_csp_names[opts->requested_colorspace];
|
|
|
|
char *real_csp = NULL;
|
|
|
|
if (mpctx->sh_video) {
|
|
|
|
struct vf_instance *vf = mpctx->sh_video->vfilter;
|
|
|
|
if (vf->control(vf, VFCTRL_GET_YUV_COLORSPACE, &actual) == true) {
|
|
|
|
real_csp = mp_csp_names[actual.format];
|
|
|
|
} else {
|
|
|
|
real_csp = "Unknown";
|
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:46:58 +00:00
|
|
|
}
|
|
|
|
char *res;
|
|
|
|
if (opts->requested_colorspace == MP_CSP_AUTO && real_csp) {
|
|
|
|
// Caveat: doesn't handle the case when the autodetected colorspace
|
|
|
|
// is different from the actual colorspace as used by the
|
|
|
|
// VO - the OSD will display the VO colorspace without
|
|
|
|
// indication that it doesn't match the requested colorspace.
|
|
|
|
res = talloc_asprintf(NULL, "Auto (%s)", real_csp);
|
|
|
|
} else if (opts->requested_colorspace == actual.format || !real_csp) {
|
|
|
|
res = talloc_strdup(NULL, req_csp);
|
|
|
|
} else
|
|
|
|
res = talloc_asprintf(NULL, mp_gtext("%s, but %s used"),
|
|
|
|
req_csp, real_csp);
|
|
|
|
*(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 levels_property_helper(int offset, m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
2012-09-21 11:07:22 +00:00
|
|
|
if (action != M_PROPERTY_PRINT)
|
|
|
|
return colormatrix_property_helper(prop, action, arg, mpctx);
|
|
|
|
|
2012-09-21 12:05:52 +00:00
|
|
|
struct m_option opt = {0};
|
2012-09-21 11:07:22 +00:00
|
|
|
mp_property_generic_option(prop, M_PROPERTY_GET_TYPE, &opt, mpctx);
|
2012-09-21 12:05:52 +00:00
|
|
|
assert(opt.type);
|
2012-09-21 11:07:22 +00:00
|
|
|
|
|
|
|
int requested = 0;
|
|
|
|
mp_property_generic_option(prop, M_PROPERTY_GET, &requested, mpctx);
|
|
|
|
|
|
|
|
struct mp_csp_details actual = {0};
|
|
|
|
int actual_level = -1;
|
2012-09-21 12:05:52 +00:00
|
|
|
char *req_level = m_option_print(&opt, &requested);
|
2012-09-21 11:07:22 +00:00
|
|
|
char *real_level = NULL;
|
|
|
|
if (mpctx->sh_video) {
|
|
|
|
struct vf_instance *vf = mpctx->sh_video->vfilter;
|
|
|
|
if (vf->control(vf, VFCTRL_GET_YUV_COLORSPACE, &actual) == true) {
|
|
|
|
actual_level = *(enum mp_csp_levels *)(((char *)&actual) + offset);
|
2012-09-21 12:05:52 +00:00
|
|
|
real_level = m_option_print(&opt, &actual_level);
|
2012-09-21 11:07:22 +00:00
|
|
|
} else {
|
|
|
|
real_level = talloc_strdup(NULL, "Unknown");
|
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
|
|
|
}
|
2009-11-15 13:21:40 +00:00
|
|
|
}
|
2012-09-21 11:07:22 +00:00
|
|
|
char *res;
|
|
|
|
if (requested == MP_CSP_LEVELS_AUTO && real_level) {
|
|
|
|
res = talloc_asprintf(NULL, "Auto (%s)", real_level);
|
|
|
|
} else if (requested == actual_level || !real_level) {
|
|
|
|
res = talloc_strdup(NULL, real_level);
|
|
|
|
} else
|
|
|
|
res = talloc_asprintf(NULL, mp_gtext("%s, but %s used"),
|
|
|
|
req_level, real_level);
|
|
|
|
talloc_free(req_level);
|
|
|
|
talloc_free(real_level);
|
|
|
|
*(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_input_range(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
|
|
|
return levels_property_helper(offsetof(struct mp_csp_details, levels_in),
|
|
|
|
prop, action, arg, mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mp_property_colormatrix_output_range(m_option_t *prop, int action,
|
|
|
|
void *arg, MPContext *mpctx)
|
|
|
|
{
|
|
|
|
return levels_property_helper(offsetof(struct mp_csp_details, levels_out),
|
|
|
|
prop, action, arg, mpctx);
|
2009-11-15 13:21:40 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Panscan (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_panscan(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-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,
|
|
|
|
&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,
|
2010-05-03 23:34:38 +00:00
|
|
|
&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,
|
2010-05-07 19:02:47 +00:00
|
|
|
void *arg, MPContext *mpctx)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
|
|
|
if (!mpctx->sh_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
|
|
|
}
|
|
|
|
|
|
|
|
/// Color settings, try to use vf/vo then fall back on TV. (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_gamma(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
|
|
|
{
|
2010-11-01 20:45:46 +00:00
|
|
|
int *gamma = (int *)((char *)&mpctx->opts + prop->offset);
|
2008-04-25 04:12:05 +00:00
|
|
|
int r, val;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
if (!mpctx->sh_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
if (gamma[0] == 1000) {
|
2010-05-03 23:34:38 +00:00
|
|
|
gamma[0] = 0;
|
|
|
|
get_video_colors(mpctx->sh_video, prop->name, gamma);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET:
|
2010-05-03 23:34:38 +00:00
|
|
|
*gamma = *(int *) arg;
|
|
|
|
r = set_video_colors(mpctx->sh_video, prop->name, *gamma);
|
|
|
|
if (r <= 0)
|
|
|
|
break;
|
|
|
|
return r;
|
2007-02-21 00:49:24 +00:00
|
|
|
case M_PROPERTY_GET:
|
2010-05-03 23:34:38 +00:00
|
|
|
if (get_video_colors(mpctx->sh_video, prop->name, &val) > 0) {
|
|
|
|
*(int *)arg = val;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
break;
|
2007-02-21 00:49:24 +00:00
|
|
|
default:
|
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
|
|
|
}
|
|
|
|
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_TV
|
2012-08-19 16:01:30 +00:00
|
|
|
if (mpctx->sh_video->gsh->demuxer->type == DEMUXER_TYPE_TV) {
|
2010-05-03 23:34:38 +00:00
|
|
|
int l = strlen(prop->name);
|
|
|
|
char tv_prop[3 + l + 1];
|
2012-09-14 23:10:59 +00:00
|
|
|
sprintf(tv_prop, "tv-%s", prop->name);
|
2010-05-03 23:34:38 +00:00
|
|
|
return mp_property_do(tv_prop, action, arg, mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// VSync (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_vsync(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-09-18 18:07:24 +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
|
|
|
{
|
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
|
|
|
const char *c = mpctx->sh_video ? mpctx->sh_video->gsh->codec : NULL;
|
|
|
|
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
|
|
|
{
|
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
|
|
|
const char *c = mpctx->sh_video ? mpctx->sh_video->gsh->decoder_desc : NULL;
|
|
|
|
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
|
|
|
{
|
|
|
|
if (!mpctx->sh_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) {
|
2012-09-18 13:31:46 +00:00
|
|
|
*(char **)arg = format_bitrate(mpctx->sh_video->i_bps);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return m_property_int_ro(prop, action, arg, mpctx->sh_video->i_bps);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Video display width (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_width(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->sh_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Video display height (RO)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_height(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->sh_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
return m_property_int_ro(prop, action, arg, mpctx->sh_video->disp_h);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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
|
|
|
{
|
|
|
|
if (!mpctx->sh_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2007-02-21 00:49:24 +00:00
|
|
|
return m_property_float_ro(prop, action, arg, mpctx->sh_video->fps);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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
|
|
|
{
|
|
|
|
if (!mpctx->sh_video)
|
2010-05-03 23:34:38 +00:00
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
2012-09-22 03:13:29 +00:00
|
|
|
switch (action) {
|
|
|
|
case M_PROPERTY_SET: {
|
|
|
|
float f = *(float *)arg;
|
|
|
|
if (f < 0.1)
|
|
|
|
f = (float)mpctx->sh_video->disp_w / mpctx->sh_video->disp_h;
|
|
|
|
mpctx->opts.movie_aspect = f;
|
|
|
|
video_reset_aspect(mpctx->sh_video);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(float *)arg = mpctx->sh_video->aspect;
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
2012-09-18 18:07:24 +00:00
|
|
|
// For subtitle related properties using the generic option bridge.
|
|
|
|
// - Fail as unavailable if no video is active
|
|
|
|
// - Trigger OSD state update when property is set
|
|
|
|
static int property_sub_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
|
|
|
{
|
2012-09-18 18:07:24 +00:00
|
|
|
if (!mpctx->sh_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (action == M_PROPERTY_SET)
|
2012-11-17 19:56:45 +00:00
|
|
|
osd_subs_changed(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
|
|
|
{
|
2012-08-19 16:01:30 +00:00
|
|
|
return property_switch_track(prop, action, arg, mpctx, 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
|
|
|
{
|
|
|
|
if (!mpctx->sh_video)
|
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:
|
|
|
|
*(char **)arg = format_delay(sub_delay);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
static int mp_property_sub_pos(m_option_t *prop, int action, void *arg,
|
|
|
|
MPContext *mpctx)
|
|
|
|
{
|
|
|
|
if (!mpctx->sh_video)
|
|
|
|
return M_PROPERTY_UNAVAILABLE;
|
|
|
|
if (action == M_PROPERTY_PRINT) {
|
|
|
|
*(char **)arg = talloc_asprintf(NULL, "%d/100", sub_pos);
|
|
|
|
return M_PROPERTY_OK;
|
|
|
|
}
|
|
|
|
return property_sub_helper(prop, action, arg, mpctx);
|
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Subtitle visibility (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_sub_visibility(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-25 18:22:39 +00:00
|
|
|
struct MPOpts *opts = &mpctx->opts;
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
if (!mpctx->sh_video)
|
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:
|
2012-09-18 18:07:24 +00:00
|
|
|
opts->sub_visibility = *(int *)arg;
|
2010-05-03 23:34:38 +00:00
|
|
|
vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
|
|
if (vo_spudec)
|
|
|
|
vo_osd_changed(OSDTYPE_SPU);
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_OK;
|
|
|
|
case M_PROPERTY_GET:
|
|
|
|
*(int *)arg = opts->sub_visibility;
|
|
|
|
return M_PROPERTY_OK;
|
2011-08-04 19:47:36 +00:00
|
|
|
}
|
2012-09-18 18:07:24 +00:00
|
|
|
return M_PROPERTY_NOT_IMPLEMENTED;
|
2011-08-04 19:47:36 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
/// Show only forced subtitles (RW)
|
2008-04-25 02:04:41 +00:00
|
|
|
static int mp_property_sub_forced_only(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
|
|
|
{
|
|
|
|
if (!vo_spudec)
|
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) {
|
|
|
|
forced_subs_only = *(int *)arg;
|
2010-05-03 23:34:38 +00:00
|
|
|
spudec_set_forced_subs_only(vo_spudec, forced_subs_only);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_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
|
|
|
|
|
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
|
|
|
|
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"),
|
|
|
|
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 },
|
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 },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "percent-pos", mp_property_percent_pos, CONF_TYPE_INT,
|
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 },
|
2007-12-14 08:33:11 +00:00
|
|
|
{ "chapter", mp_property_chapter, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_MIN, 0, 0, NULL },
|
2012-09-21 12:22:23 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("edition", mp_property_edition),
|
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 },
|
2008-01-05 14:32:39 +00:00
|
|
|
{ "angle", mp_property_angle, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
CONF_RANGE, -2, 10, NULL },
|
2007-05-29 22:14:41 +00:00
|
|
|
{ "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2008-10-01 17:05:30 +00:00
|
|
|
{ "pause", mp_property_pause, CONF_TYPE_FLAG,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_RANGE, 0, 1, NULL },
|
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"),
|
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 },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "audio", mp_property_audio, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
CONF_RANGE, -2, 65535, NULL },
|
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 },
|
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),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM_("gamma", mp_property_gamma,
|
|
|
|
.offset = offsetof(struct MPOpts, vo_gamma_gamma)),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM_("brightness", mp_property_gamma,
|
|
|
|
.offset = offsetof(struct MPOpts, vo_gamma_brightness)),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM_("contrast", mp_property_gamma,
|
|
|
|
.offset = offsetof(struct MPOpts, vo_gamma_contrast)),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM_("saturation", mp_property_gamma,
|
|
|
|
.offset = offsetof(struct MPOpts, vo_gamma_saturation)),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM_("hue", mp_property_gamma,
|
|
|
|
.offset = offsetof(struct MPOpts, vo_gamma_hue)),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("panscan", mp_property_panscan),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM_("vsync", mp_property_vsync),
|
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 },
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "width", mp_property_width, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
2007-02-21 00:49:24 +00:00
|
|
|
{ "height", mp_property_height, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
0, 0, 0, NULL },
|
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,
|
2012-09-22 03:13:29 +00:00
|
|
|
CONF_RANGE, 0, 10, NULL },
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "video", mp_property_video, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
CONF_RANGE, -2, 65535, NULL },
|
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
|
|
|
|
|
|
|
// Subs
|
|
|
|
{ "sub", mp_property_sub, CONF_TYPE_INT,
|
2011-08-07 01:45:40 +00:00
|
|
|
M_OPT_MIN, -1, 0, NULL },
|
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),
|
2012-09-14 23:10:59 +00:00
|
|
|
{ "sub-visibility", mp_property_sub_visibility, 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("sub-forced-only", mp_property_sub_forced_only),
|
2012-11-17 19:56:45 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("sub-scale", property_sub_helper),
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_ASS
|
2012-09-18 18:07:24 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("ass-use-margins", property_sub_helper),
|
|
|
|
M_OPTION_PROPERTY_CUSTOM("ass-vsfilter-aspect-compat", property_sub_helper),
|
2012-10-11 00:23:29 +00:00
|
|
|
M_OPTION_PROPERTY_CUSTOM("ass-style-override", property_sub_helper),
|
2008-01-23 21:18:32 +00:00
|
|
|
#endif
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_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
|
|
|
|
|
|
|
{0},
|
2007-02-21 00:49:24 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
{
|
2007-05-29 21:49:39 +00:00
|
|
|
return m_property_do(mp_properties, name, action, val, ctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
|
commands: change property expansion format string
This affects property format strings like they are used in the
"show_text" input command, for --playing-msg, and other places.
To quote the documentation comment on m_properties_expand_string():
${NAME} is expanded to the value of property NAME.
If NAME starts with '=', use the raw value of the property.
${NAME:STR} expands to the property, or STR if the property is not
available.
${?NAME:STR} expands to STR if the property is available.
${!NAME:STR} expands to STR if the property is not available.
STR is recursively expanded using the same rules.
"$$" can be used to escape "$", and "$}" to escape "}".
"$>" disables parsing of "$" for the rest of the string.
Most importantly, "?(property:str)" becomes "${?property:str}".
Make the simple fallback case easier, e.g. "${property:fallback}"
instead of "${property}?(!property:fallback)".
Add the ability to escape the format meta characters. "$" is used for
escaping, because escaping with "\" is taken by the commands parser in
the layer below. "$>" can be used to disable interpretation of format
strings (of course escapes by the commands parser can't be canceled).
By default, properties which are unavailable or don't exist are turned
into a string signaling the status (e.g. "(unavailable)"), instead of
an empty string. If an empty string is desired, this has to be done
explicitly: "${property:}" (the fallback part is an empty string). Raw
properties still return an empty string on error.
m_properties_expand_string() now returns a talloc'ed pointer, instead of
a malloc'ed one.
2012-09-23 21:00:54 +00:00
|
|
|
char *mp_property_expand_string(struct MPContext *mpctx, char *str)
|
2007-02-21 00:49:24 +00:00
|
|
|
{
|
|
|
|
return m_properties_expand_string(mp_properties, str, mpctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void property_print_help(void)
|
|
|
|
{
|
|
|
|
m_properties_print_help_list(mp_properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
// osd msg id if it must be shared
|
2009-09-19 01:17:30 +00:00
|
|
|
int osd_id;
|
2012-09-25 01:24:38 +00:00
|
|
|
// Needs special ways to display the new value (seeks are delayed)
|
|
|
|
int seek_msg, seek_bar;
|
2009-09-19 01:17:30 +00:00
|
|
|
} property_osd_display[] = {
|
|
|
|
// general
|
2012-09-25 01:24:38 +00:00
|
|
|
{ "loop", _("Loop") },
|
|
|
|
{ "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" },
|
|
|
|
{ "speed", _("Speed") },
|
2009-09-19 01:17:30 +00:00
|
|
|
// audio
|
2012-09-06 05:58:28 +00:00
|
|
|
{ "volume", _("Volume"), .osd_progbar = OSD_VOLUME },
|
2012-09-25 01:24:38 +00:00
|
|
|
{ "mute", _("Mute") },
|
|
|
|
{ "audio-delay", _("A-V delay") },
|
|
|
|
{ "audio", _("Audio") },
|
2012-09-06 05:58:28 +00:00
|
|
|
{ "balance", _("Balance"), .osd_progbar = OSD_BALANCE },
|
2009-09-19 01:17:30 +00:00
|
|
|
// video
|
2012-09-06 05:58:28 +00:00
|
|
|
{ "panscan", _("Panscan"), .osd_progbar = OSD_PANSCAN },
|
2012-09-25 01:24:38 +00:00
|
|
|
{ "ontop", _("Stay on top") },
|
|
|
|
{ "border", _("Border") },
|
|
|
|
{ "framedrop", _("Framedrop") },
|
|
|
|
{ "deinterlace", _("Deinterlace") },
|
|
|
|
{ "colormatrix", _("YUV colormatrix") },
|
|
|
|
{ "colormatrix-input-range", _("YUV input range") },
|
|
|
|
{ "colormatrix-output-range", _("RGB output range") },
|
2012-09-06 05:58:28 +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 },
|
2012-09-25 01:24:38 +00:00
|
|
|
{ "vsync", _("VSync") },
|
|
|
|
{ "angle", _("Angle") },
|
2009-09-19 01:17:30 +00:00
|
|
|
// subs
|
2012-09-25 01:24:38 +00:00
|
|
|
{ "sub", _("Subtitles") },
|
|
|
|
{ "sub-pos", _("Sub position") },
|
|
|
|
{ "sub-delay", _("Sub delay"), .osd_id = OSD_MSG_SUB_DELAY },
|
|
|
|
{ "sub-visibility", _("Subtitles") },
|
|
|
|
{ "sub-forced-only", _("Forced sub only") },
|
|
|
|
{ "sub-scale", _("Sub Scale")},
|
|
|
|
{ "ass-vsfilter-aspect-compat", _("Subtitle VSFilter aspect compat")},
|
2012-10-11 00:23:29 +00:00
|
|
|
{ "ass-style-override", _("ASS subtitle style override")},
|
2009-09-19 01:17:30 +00:00
|
|
|
#ifdef CONFIG_TV
|
2012-09-14 23:10:59 +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
|
|
|
};
|
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
static void show_property_osd(MPContext *mpctx, const char *pname,
|
|
|
|
enum mp_on_osd osd_mode)
|
2009-09-19 01:17:30 +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;
|
|
|
|
|
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;
|
|
|
|
osd_name = p->seek_msg ? "" : mp_gtext(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
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
if (osd_mode != MP_ON_OSD_AUTO) {
|
|
|
|
osd_name = osd_name ? osd_name : prop.name;
|
|
|
|
if (!(osd_mode & MP_ON_OSD_MSG))
|
|
|
|
osd_name = NULL;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2012-09-25 01:24:38 +00:00
|
|
|
return;
|
2009-09-19 01:17:30 +00:00
|
|
|
}
|
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
if (osd_name) {
|
2013-02-16 20:37:00 +00:00
|
|
|
char *val = NULL;
|
|
|
|
int r = mp_property_do(prop.name, M_PROPERTY_PRINT, &val, mpctx);
|
|
|
|
if (r == M_PROPERTY_UNAVAILABLE) {
|
|
|
|
set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, opts->osd_duration,
|
|
|
|
"%s: (unavailable)", osd_name);
|
|
|
|
} else if (r >= 0 && val) {
|
2012-09-25 01:24:38 +00:00
|
|
|
int osd_id = 0;
|
|
|
|
if (p) {
|
|
|
|
int index = p - property_osd_display;
|
|
|
|
osd_id = p->osd_id ? p->osd_id : OSD_MSG_PROPERTY + index;
|
|
|
|
}
|
|
|
|
set_osd_tmsg(mpctx, osd_id, 1, opts->osd_duration,
|
|
|
|
"%s: %s", osd_name, val);
|
2011-07-03 17:04:21 +00:00
|
|
|
talloc_free(val);
|
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";
|
|
|
|
}
|
|
|
|
|
2011-10-23 03:26:30 +00:00
|
|
|
static void show_chapters_on_osd(MPContext *mpctx)
|
|
|
|
{
|
|
|
|
int count = get_chapter_count(mpctx);
|
2012-08-19 16:07:06 +00:00
|
|
|
int cur = mpctx->num_sources ? get_current_chapter(mpctx) : -1;
|
2011-10-23 03:26:30 +00:00
|
|
|
char *res = NULL;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if (count < 1) {
|
|
|
|
res = talloc_asprintf_append(res, "No chapters.");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (n = 0; n < count; n++) {
|
|
|
|
char *name = chapter_display_name(mpctx, n);
|
|
|
|
double t = chapter_start_time(mpctx, n);
|
2012-09-01 19:59:13 +00:00
|
|
|
char* time = mp_format_time(t, false);
|
2011-10-23 03:26:30 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-08-04 01:50:23 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, "%s", res);
|
2011-10-23 03:26:30 +00:00
|
|
|
talloc_free(res);
|
|
|
|
}
|
|
|
|
|
2012-08-19 16:01:30 +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;
|
|
|
|
}
|
|
|
|
|
2011-10-24 00:41:17 +00:00
|
|
|
static void show_tracks_on_osd(MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct MPOpts *opts = &mpctx->opts;
|
2012-08-03 10:24:55 +00:00
|
|
|
char *res = NULL;
|
2011-10-24 00:41:17 +00:00
|
|
|
|
2012-08-19 16:01:30 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
bool selected = mpctx->current_track[track->type] == track;
|
|
|
|
res = talloc_asprintf_append(res, "%s: ", track_type_name(track->type));
|
|
|
|
if (selected)
|
|
|
|
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) ");
|
|
|
|
if (selected)
|
|
|
|
res = talloc_asprintf_append(res, "<");
|
2011-10-24 00:41:17 +00:00
|
|
|
res = talloc_asprintf_append(res, "\n");
|
2012-08-19 16:01:30 +00:00
|
|
|
}
|
|
|
|
|
2012-08-03 10:24:55 +00:00
|
|
|
res = talloc_asprintf_append(res, "\n");
|
|
|
|
}
|
|
|
|
|
2012-08-25 23:19:42 +00:00
|
|
|
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);
|
|
|
|
|
2012-08-04 01:50:23 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, opts->osd_duration, "%s", res);
|
2011-10-24 00:41:17 +00:00
|
|
|
talloc_free(res);
|
|
|
|
}
|
|
|
|
|
2013-02-06 20:38:53 +00:00
|
|
|
static void show_playlist_on_osd(MPContext *mpctx)
|
|
|
|
{
|
|
|
|
struct MPOpts *opts = &mpctx->opts;
|
|
|
|
char *res = 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, opts->osd_duration, "%s", res);
|
|
|
|
talloc_free(res);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2008-04-21 03:55:23 +00:00
|
|
|
struct MPOpts *opts = &mpctx->opts;
|
2011-08-07 01:45:40 +00:00
|
|
|
sh_audio_t *const sh_audio = mpctx->sh_audio;
|
|
|
|
sh_video_t *const sh_video = mpctx->sh_video;
|
2009-03-29 23:06:58 +00:00
|
|
|
int osd_duration = opts->osd_duration;
|
2012-09-25 01:24:38 +00:00
|
|
|
bool auto_osd = cmd->on_osd == MP_ON_OSD_AUTO;
|
|
|
|
bool msg_osd = auto_osd || (cmd->on_osd & MP_ON_OSD_MSG);
|
|
|
|
bool bar_osd = auto_osd || (cmd->on_osd & MP_ON_OSD_BAR);
|
|
|
|
int osdl = msg_osd ? 1 : OSD_LEVEL_INVISIBLE;
|
2011-08-07 01:45:40 +00:00
|
|
|
switch (cmd->id) {
|
|
|
|
case MP_CMD_SEEK: {
|
2013-02-24 20:16:23 +00:00
|
|
|
double v = cmd->args[0].v.d;
|
2013-02-24 15:06:27 +00:00
|
|
|
int abs = cmd->args[1].v.i;
|
|
|
|
int exact = cmd->args[2].v.i;
|
2011-08-07 01:45:40 +00:00
|
|
|
if (abs == 2) { // Absolute seek to a timestamp in seconds
|
|
|
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, v, exact);
|
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 */
|
|
|
|
queue_seek(mpctx, MPSEEK_FACTOR, v / 100.0, exact);
|
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 {
|
|
|
|
queue_seek(mpctx, MPSEEK_RELATIVE, v, exact);
|
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-02-16 20:17:59 +00:00
|
|
|
if (msg_osd && !(auto_osd && opts->osd_bar_visible))
|
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
|
|
|
|
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) {
|
|
|
|
show_property_osd(mpctx, cmd->args[0].v.s, cmd->on_osd);
|
|
|
|
} else if (r == M_PROPERTY_UNKNOWN) {
|
2011-08-07 01:45:40 +00:00
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
|
|
|
"Unknown property: '%s'\n", cmd->args[0].v.s);
|
2013-02-16 20:37:00 +00:00
|
|
|
} else if (r <= 0) {
|
2011-08-07 01:45:40 +00:00
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
|
|
|
"Failed to set property '%s' to '%s'.\n",
|
|
|
|
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,
|
|
|
|
};
|
2012-09-18 12:00:08 +00:00
|
|
|
if (cmd->args[1].v.f)
|
2012-09-22 04:15:36 +00:00
|
|
|
s.inc = cmd->args[1].v.f;
|
2012-09-18 12:00:08 +00:00
|
|
|
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_SWITCH, &s, mpctx);
|
2013-02-16 20:37:00 +00:00
|
|
|
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
|
|
|
|
show_property_osd(mpctx, cmd->args[0].v.s, cmd->on_osd);
|
|
|
|
} else if (r == M_PROPERTY_UNKNOWN) {
|
2011-08-07 01:45:40 +00:00
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
|
|
|
"Unknown property: '%s'\n", cmd->args[0].v.s);
|
2013-02-16 20:37:00 +00:00
|
|
|
} else if (r <= 0) {
|
2011-08-07 01:45:40 +00:00
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
2012-09-18 15:13:05 +00:00
|
|
|
"Failed to increment property '%s' by %g.\n",
|
2012-09-22 04:15:36 +00:00
|
|
|
cmd->args[0].v.s, 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
|
|
|
|
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) {
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
|
|
|
"Failed to get value of property '%s'.\n",
|
|
|
|
cmd->args[0].v.s);
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "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
|
|
|
}
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_%s=%s\n",
|
|
|
|
cmd->args[0].v.s, tmp);
|
|
|
|
talloc_free(tmp);
|
|
|
|
break;
|
|
|
|
}
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2012-09-14 23:48:27 +00:00
|
|
|
case MP_CMD_SPEED_MULT: {
|
2011-08-07 01:45:40 +00:00
|
|
|
float v = cmd->args[0].v.f;
|
2012-09-14 23:48:27 +00:00
|
|
|
v *= mpctx->opts.playback_speed;
|
2011-08-07 01:45:40 +00:00
|
|
|
mp_property_do("speed", M_PROPERTY_SET, &v, mpctx);
|
2012-09-25 01:24:38 +00:00
|
|
|
show_property_osd(mpctx, "speed", cmd->on_osd);
|
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_FRAME_STEP:
|
|
|
|
add_step_frame(mpctx);
|
|
|
|
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-02-24 15:06:27 +00:00
|
|
|
mpctx->quit_player_rc = cmd->args[0].v.i;
|
2012-08-04 01:46:11 +00:00
|
|
|
break;
|
2010-05-03 23:34:38 +00:00
|
|
|
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 19:33:26 +00:00
|
|
|
case MP_CMD_PLAYLIST_NEXT:
|
|
|
|
case MP_CMD_PLAYLIST_PREV:
|
|
|
|
{
|
|
|
|
int dir = cmd->id == MP_CMD_PLAYLIST_PREV ? -1 : +1;
|
|
|
|
int force = cmd->args[0].v.i;
|
2011-08-07 01:45:40 +00:00
|
|
|
|
2013-02-03 13:54:28 +00:00
|
|
|
struct playlist_entry *e = mp_next_file(mpctx, dir);
|
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:
|
|
|
|
if (sh_video) {
|
|
|
|
int movement = cmd->args[0].v.i;
|
2012-08-19 16:01:30 +00:00
|
|
|
struct track *track = mpctx->current_track[STREAM_SUB];
|
2012-09-01 17:49:04 +00:00
|
|
|
bool available = false;
|
|
|
|
if (track && track->subdata) {
|
|
|
|
available = true;
|
2012-08-19 16:01:30 +00:00
|
|
|
step_sub(track->subdata, mpctx->video_pts, movement);
|
2012-09-01 17:49:04 +00:00
|
|
|
}
|
|
|
|
#ifdef CONFIG_ASS
|
|
|
|
struct ass_track *ass_track = sub_get_ass_track(mpctx->osd);
|
|
|
|
if (ass_track) {
|
|
|
|
available = true;
|
|
|
|
sub_delay += ass_step_sub(ass_track,
|
|
|
|
(mpctx->video_pts + sub_delay) * 1000 + .5, movement) / 1000.;
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
#endif
|
2012-09-01 17:49:04 +00:00
|
|
|
if (available)
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, osdl, osd_duration,
|
2012-09-01 17:49:04 +00:00
|
|
|
"Sub delay: %d ms", ROUND(sub_delay * 1000));
|
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_OSD: {
|
|
|
|
int v = cmd->args[0].v.i;
|
|
|
|
int max = (opts->term_osd
|
|
|
|
&& !sh_video) ? MAX_TERM_OSD_LEVEL : MAX_OSD_LEVEL;
|
|
|
|
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)
|
2012-08-04 01:50:23 +00:00
|
|
|
set_osd_tmsg(mpctx, OSD_MSG_OSD_STATUS, 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
|
|
|
else
|
2012-08-04 01:50:23 +00:00
|
|
|
rm_osd_msg(mpctx, OSD_MSG_OSD_STATUS);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-10-11 00:24:13 +00:00
|
|
|
case MP_CMD_PRINT_TEXT: {
|
|
|
|
char *txt = mp_property_expand_string(mpctx, cmd->args[0].v.s);
|
|
|
|
if (txt) {
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "%s\n", txt);
|
|
|
|
talloc_free(txt);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-09-15 00:04:57 +00:00
|
|
|
case MP_CMD_SHOW_TEXT: {
|
commands: change property expansion format string
This affects property format strings like they are used in the
"show_text" input command, for --playing-msg, and other places.
To quote the documentation comment on m_properties_expand_string():
${NAME} is expanded to the value of property NAME.
If NAME starts with '=', use the raw value of the property.
${NAME:STR} expands to the property, or STR if the property is not
available.
${?NAME:STR} expands to STR if the property is available.
${!NAME:STR} expands to STR if the property is not available.
STR is recursively expanded using the same rules.
"$$" can be used to escape "$", and "$}" to escape "}".
"$>" disables parsing of "$" for the rest of the string.
Most importantly, "?(property:str)" becomes "${?property:str}".
Make the simple fallback case easier, e.g. "${property:fallback}"
instead of "${property}?(!property:fallback)".
Add the ability to escape the format meta characters. "$" is used for
escaping, because escaping with "\" is taken by the commands parser in
the layer below. "$>" can be used to disable interpretation of format
strings (of course escapes by the commands parser can't be canceled).
By default, properties which are unavailable or don't exist are turned
into a string signaling the status (e.g. "(unavailable)"), instead of
an empty string. If an empty string is desired, this has to be done
explicitly: "${property:}" (the fallback part is an empty string). Raw
properties still return an empty string on error.
m_properties_expand_string() now returns a talloc'ed pointer, instead of
a malloc'ed one.
2012-09-23 21:00:54 +00:00
|
|
|
char *txt = mp_property_expand_string(mpctx, cmd->args[0].v.s);
|
2011-08-07 01:45:40 +00:00
|
|
|
if (txt) {
|
commands: change property expansion format string
This affects property format strings like they are used in the
"show_text" input command, for --playing-msg, and other places.
To quote the documentation comment on m_properties_expand_string():
${NAME} is expanded to the value of property NAME.
If NAME starts with '=', use the raw value of the property.
${NAME:STR} expands to the property, or STR if the property is not
available.
${?NAME:STR} expands to STR if the property is available.
${!NAME:STR} expands to STR if the property is not available.
STR is recursively expanded using the same rules.
"$$" can be used to escape "$", and "$}" to escape "}".
"$>" disables parsing of "$" for the rest of the string.
Most importantly, "?(property:str)" becomes "${?property:str}".
Make the simple fallback case easier, e.g. "${property:fallback}"
instead of "${property}?(!property:fallback)".
Add the ability to escape the format meta characters. "$" is used for
escaping, because escaping with "\" is taken by the commands parser in
the layer below. "$>" can be used to disable interpretation of format
strings (of course escapes by the commands parser can't be canceled).
By default, properties which are unavailable or don't exist are turned
into a string signaling the status (e.g. "(unavailable)"), instead of
an empty string. If an empty string is desired, this has to be done
explicitly: "${property:}" (the fallback part is an empty string). Raw
properties still return an empty string on error.
m_properties_expand_string() now returns a talloc'ed pointer, instead of
a malloc'ed one.
2012-09-23 21:00:54 +00:00
|
|
|
// if no argument supplied use default osd_duration, else <arg> ms.
|
2012-08-04 01:50:23 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TEXT, cmd->args[2].v.i,
|
2012-09-15 00:04:57 +00:00
|
|
|
(cmd->args[1].v.i < 0 ? osd_duration : cmd->args[1].v.i),
|
2011-08-08 08:07:17 +00:00
|
|
|
"%s", txt);
|
commands: change property expansion format string
This affects property format strings like they are used in the
"show_text" input command, for --playing-msg, and other places.
To quote the documentation comment on m_properties_expand_string():
${NAME} is expanded to the value of property NAME.
If NAME starts with '=', use the raw value of the property.
${NAME:STR} expands to the property, or STR if the property is not
available.
${?NAME:STR} expands to STR if the property is available.
${!NAME:STR} expands to STR if the property is not available.
STR is recursively expanded using the same rules.
"$$" can be used to escape "$", and "$}" to escape "}".
"$>" disables parsing of "$" for the rest of the string.
Most importantly, "?(property:str)" becomes "${?property:str}".
Make the simple fallback case easier, e.g. "${property:fallback}"
instead of "${property}?(!property:fallback)".
Add the ability to escape the format meta characters. "$" is used for
escaping, because escaping with "\" is taken by the commands parser in
the layer below. "$>" can be used to disable interpretation of format
strings (of course escapes by the commands parser can't be canceled).
By default, properties which are unavailable or don't exist are turned
into a string signaling the status (e.g. "(unavailable)"), instead of
an empty string. If an empty string is desired, this has to be done
explicitly: "${property:}" (the fallback part is an empty string). Raw
properties still return an empty string on error.
m_properties_expand_string() now returns a talloc'ed pointer, instead of
a malloc'ed one.
2012-09-23 21:00:54 +00:00
|
|
|
talloc_free(txt);
|
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));
|
|
|
|
|
|
|
|
if (!append) {
|
|
|
|
mpctx->playlist->current = mpctx->playlist->first;
|
|
|
|
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_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;
|
|
|
|
struct playlist *pl = playlist_parse_file(filename);
|
|
|
|
if (!pl) {
|
|
|
|
if (!append)
|
|
|
|
playlist_clear(mpctx->playlist);
|
|
|
|
playlist_transfer_entries(mpctx->playlist, pl);
|
|
|
|
talloc_free(pl);
|
|
|
|
|
|
|
|
if (!append)
|
|
|
|
mpctx->stop_play = PT_NEXT_ENTRY;
|
|
|
|
} else {
|
2011-08-07 01:45:40 +00:00
|
|
|
mp_tmsg(MSGT_CPLAYER, MSGL_ERR,
|
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
|
|
|
"\nUnable 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
|
|
|
|
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
|
|
|
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_RADIO
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_RADIO_STEP_CHANNEL:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (mpctx->stream && mpctx->stream->type == STREAMTYPE_RADIO) {
|
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
|
|
|
radio_step_channel(mpctx->stream, RADIO_CHANNEL_HIGHER);
|
2011-08-07 01:45:40 +00:00
|
|
|
else
|
2012-08-19 16:07:06 +00:00
|
|
|
radio_step_channel(mpctx->stream, RADIO_CHANNEL_LOWER);
|
|
|
|
if (radio_get_channel_name(mpctx->stream)) {
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_tmsg(OSD_MSG_RADIO_CHANNEL, osdl, osd_duration,
|
2011-08-07 01:45:40 +00:00
|
|
|
"Channel: %s",
|
2012-08-19 16:07:06 +00:00
|
|
|
radio_get_channel_name(mpctx->stream));
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
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_RADIO_SET_CHANNEL:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (mpctx->stream && mpctx->stream->type == STREAMTYPE_RADIO) {
|
|
|
|
radio_set_channel(mpctx->stream, cmd->args[0].v.s);
|
|
|
|
if (radio_get_channel_name(mpctx->stream)) {
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_tmsg(OSD_MSG_RADIO_CHANNEL, osdl, osd_duration,
|
2011-08-07 01:45:40 +00:00
|
|
|
"Channel: %s",
|
2012-08-19 16:07:06 +00:00
|
|
|
radio_get_channel_name(mpctx->stream));
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
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_RADIO_SET_FREQ:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (mpctx->stream && mpctx->stream->type == STREAMTYPE_RADIO)
|
|
|
|
radio_set_freq(mpctx->stream, cmd->args[0].v.f);
|
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_RADIO_STEP_FREQ:
|
2012-08-19 16:07:06 +00:00
|
|
|
if (mpctx->stream && mpctx->stream->type == STREAMTYPE_RADIO)
|
|
|
|
radio_step_freq(mpctx->stream, cmd->args[0].v.f);
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2007-02-21 00:49:24 +00:00
|
|
|
#endif
|
|
|
|
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_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);
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_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));
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 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));
|
|
|
|
}
|
2008-08-03 15:21:40 +00:00
|
|
|
#endif /* CONFIG_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);
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_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));
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 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));
|
|
|
|
}
|
2008-08-03 15:21:40 +00:00
|
|
|
#endif /* CONFIG_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) {
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration,
|
2011-08-07 01:45:40 +00:00
|
|
|
"Channel: %s", tv_channel_current->name);
|
|
|
|
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
|
|
}
|
|
|
|
}
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_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);
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 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));
|
|
|
|
}
|
2008-08-03 15:21:40 +00:00
|
|
|
#endif /* CONFIG_PVR */
|
|
|
|
#ifdef CONFIG_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)) {
|
|
|
|
mpctx->stop_play = PT_NEXT_ENTRY;
|
|
|
|
mpctx->dvbin_reopen = 1;
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2008-08-03 15:21:40 +00:00
|
|
|
#endif /* CONFIG_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) {
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration,
|
2011-08-07 01:45:40 +00:00
|
|
|
"Channel: %s", tv_channel_current->name);
|
|
|
|
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_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);
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 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));
|
|
|
|
}
|
2008-08-03 15:21:40 +00:00
|
|
|
#endif /* CONFIG_PVR */
|
2011-08-07 01:45:40 +00:00
|
|
|
break;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_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)) {
|
|
|
|
mpctx->stop_play = PT_NEXT_ENTRY;
|
|
|
|
mpctx->dvbin_reopen = 1;
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
|
|
|
break;
|
2008-08-03 15:21:40 +00:00
|
|
|
#endif /* CONFIG_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) {
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration,
|
2011-08-07 01:45:40 +00:00
|
|
|
"Channel: %s", tv_channel_current->name);
|
|
|
|
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
2010-05-03 23:34:38 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_PVR
|
2011-08-07 01:45:40 +00:00
|
|
|
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
|
|
|
pvr_set_lastchannel(mpctx->stream);
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 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));
|
|
|
|
}
|
2008-08-03 15:21:40 +00:00
|
|
|
#endif /* CONFIG_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;
|
2009-11-07 12:31:05 +00:00
|
|
|
#endif /* CONFIG_TV */
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2012-11-15 19:26:52 +00:00
|
|
|
case MP_CMD_SUB_ADD:
|
2011-08-07 01:45:40 +00:00
|
|
|
if (sh_video) {
|
2012-11-15 19:26:52 +00:00
|
|
|
mp_add_subtitles(mpctx, cmd->args[0].v.s, sh_video->fps, 0);
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
|
|
|
break;
|
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);
|
|
|
|
if (sh_video && sub && sub->is_external && sub->external_filename)
|
|
|
|
{
|
|
|
|
struct track *nsub = mp_add_subtitles(mpctx, sub->external_filename,
|
|
|
|
sh_video->fps, 0);
|
|
|
|
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:52:47 +00:00
|
|
|
screenshot_request(mpctx, cmd->args[0].v.i, cmd->args[1].v.i,
|
|
|
|
!!(cmd->on_osd & MP_ON_OSD_MSG));
|
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_RUN:
|
2007-02-21 00:49:24 +00:00
|
|
|
#ifndef __MINGW32__
|
2011-08-07 01:45:40 +00:00
|
|
|
if (!fork()) {
|
commands: change property expansion format string
This affects property format strings like they are used in the
"show_text" input command, for --playing-msg, and other places.
To quote the documentation comment on m_properties_expand_string():
${NAME} is expanded to the value of property NAME.
If NAME starts with '=', use the raw value of the property.
${NAME:STR} expands to the property, or STR if the property is not
available.
${?NAME:STR} expands to STR if the property is available.
${!NAME:STR} expands to STR if the property is not available.
STR is recursively expanded using the same rules.
"$$" can be used to escape "$", and "$}" to escape "}".
"$>" disables parsing of "$" for the rest of the string.
Most importantly, "?(property:str)" becomes "${?property:str}".
Make the simple fallback case easier, e.g. "${property:fallback}"
instead of "${property}?(!property:fallback)".
Add the ability to escape the format meta characters. "$" is used for
escaping, because escaping with "\" is taken by the commands parser in
the layer below. "$>" can be used to disable interpretation of format
strings (of course escapes by the commands parser can't be canceled).
By default, properties which are unavailable or don't exist are turned
into a string signaling the status (e.g. "(unavailable)"), instead of
an empty string. If an empty string is desired, this has to be done
explicitly: "${property:}" (the fallback part is an empty string). Raw
properties still return an empty string on error.
m_properties_expand_string() now returns a talloc'ed pointer, instead of
a malloc'ed one.
2012-09-23 21:00:54 +00:00
|
|
|
char *s = mp_property_expand_string(mpctx, cmd->args[0].v.s);
|
|
|
|
if (s) {
|
|
|
|
execl("/bin/sh", "sh", "-c", s, NULL);
|
|
|
|
talloc_free(s);
|
2012-08-12 17:57:35 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
#endif
|
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_KEYDOWN_EVENTS:
|
|
|
|
mplayer_put_key(mpctx->key_fifo, cmd->args[0].v.i);
|
|
|
|
break;
|
2010-05-03 23:34:38 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_SET_MOUSE_POS: {
|
|
|
|
int pointer_x, pointer_y;
|
|
|
|
double dx, dy;
|
|
|
|
pointer_x = cmd->args[0].v.i;
|
|
|
|
pointer_y = cmd->args[1].v.i;
|
|
|
|
rescale_input_coordinates(mpctx, pointer_x, pointer_y, &dx, &dy);
|
|
|
|
break;
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-07-31 23:06:59 +00:00
|
|
|
case MP_CMD_VO_CMDLINE:
|
|
|
|
if (mpctx->video_out) {
|
|
|
|
char *s = cmd->args[0].v.s;
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Setting vo cmd line to '%s'.\n",
|
|
|
|
s);
|
|
|
|
if (vo_control(mpctx->video_out, VOCTRL_SET_COMMAND_LINE, s) > 0) {
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, "vo='%s'", s);
|
2012-07-31 23:06:59 +00:00
|
|
|
} else {
|
2012-09-09 00:08:08 +00:00
|
|
|
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, "Failed!");
|
2012-07-31 23:06:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-04-11 18:59:19 +00:00
|
|
|
case MP_CMD_AF_SWITCH:
|
2011-08-07 01:45:40 +00:00
|
|
|
if (sh_audio) {
|
2010-04-11 18:59:19 +00:00
|
|
|
af_uninit(mpctx->mixer.afilter);
|
|
|
|
af_init(mpctx->mixer.afilter);
|
|
|
|
}
|
|
|
|
case MP_CMD_AF_ADD:
|
2011-08-07 01:45:40 +00:00
|
|
|
case MP_CMD_AF_DEL: {
|
2010-04-11 18:59:19 +00:00
|
|
|
if (!sh_audio)
|
|
|
|
break;
|
2011-08-07 01:45:40 +00:00
|
|
|
char *af_args = strdup(cmd->args[0].v.s);
|
2013-01-13 15:13:13 +00:00
|
|
|
bstr af_commands = bstr0(af_args);
|
2012-11-01 11:23:48 +00:00
|
|
|
struct af_instance *af;
|
2013-01-13 15:13:13 +00:00
|
|
|
while (af_commands.len) {
|
|
|
|
bstr af_command;
|
|
|
|
bstr_split_tok(af_commands, ",", &af_command, &af_commands);
|
|
|
|
char *af_command0 = bstrdup0(NULL, af_command);
|
2011-08-07 01:45:40 +00:00
|
|
|
if (cmd->id == MP_CMD_AF_DEL) {
|
2013-01-13 15:13:13 +00:00
|
|
|
af = af_get(mpctx->mixer.afilter, af_command0);
|
2011-08-07 01:45:40 +00:00
|
|
|
if (af != NULL)
|
|
|
|
af_remove(mpctx->mixer.afilter, af);
|
|
|
|
} else
|
2013-01-13 15:13:13 +00:00
|
|
|
af_add(mpctx->mixer.afilter, af_command0);
|
|
|
|
talloc_free(af_command0);
|
2010-04-11 18:59:19 +00:00
|
|
|
}
|
2011-08-07 01:45:40 +00:00
|
|
|
reinit_audio_chain(mpctx);
|
|
|
|
free(af_args);
|
2010-04-11 18:59:19 +00:00
|
|
|
break;
|
2011-08-07 01:45:40 +00:00
|
|
|
}
|
2010-04-11 18:59:19 +00:00
|
|
|
case MP_CMD_AF_CLR:
|
|
|
|
if (!sh_audio)
|
|
|
|
break;
|
|
|
|
af_uninit(mpctx->mixer.afilter);
|
|
|
|
af_init(mpctx->mixer.afilter);
|
2010-11-26 20:52:35 +00:00
|
|
|
reinit_audio_chain(mpctx);
|
2010-04-11 18:59:19 +00:00
|
|
|
break;
|
2010-10-17 15:54:55 +00:00
|
|
|
case MP_CMD_AF_CMDLINE:
|
|
|
|
if (sh_audio) {
|
2012-11-01 11:23:48 +00:00
|
|
|
struct af_instance *af = af_get(sh_audio->afilter, cmd->args[0].v.s);
|
2010-10-17 15:54:55 +00:00
|
|
|
if (!af) {
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
|
|
|
"Filter '%s' not found in chain.\n", cmd->args[0].v.s);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
af->control(af, AF_CONTROL_COMMAND_LINE, cmd->args[1].v.s);
|
|
|
|
af_reinit(sh_audio->afilter, af);
|
|
|
|
}
|
|
|
|
break;
|
2011-10-23 03:26:30 +00:00
|
|
|
case MP_CMD_SHOW_CHAPTERS:
|
|
|
|
show_chapters_on_osd(mpctx);
|
|
|
|
break;
|
2011-10-24 00:41:17 +00:00
|
|
|
case MP_CMD_SHOW_TRACKS:
|
|
|
|
show_tracks_on_osd(mpctx);
|
|
|
|
break;
|
2013-02-06 20:38:53 +00:00
|
|
|
case MP_CMD_SHOW_PLAYLIST:
|
|
|
|
show_playlist_on_osd(mpctx);
|
|
|
|
break;
|
2010-10-17 15:54:55 +00:00
|
|
|
|
2011-08-07 01:45:40 +00:00
|
|
|
default:
|
|
|
|
mp_msg(MSGT_CPLAYER, MSGL_V,
|
|
|
|
"Received unknown cmd %s\n", cmd->name);
|
|
|
|
}
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
switch (cmd->pausing) {
|
2010-05-03 23:34:38 +00:00
|
|
|
case 1: // "pausing"
|
2008-11-29 06:09:57 +00:00
|
|
|
pause_player(mpctx);
|
2010-05-03 23:34:38 +00:00
|
|
|
break;
|
|
|
|
case 3: // "pausing_toggle"
|
2008-11-29 06:09:57 +00:00
|
|
|
if (mpctx->paused)
|
|
|
|
unpause_player(mpctx);
|
|
|
|
else
|
|
|
|
pause_player(mpctx);
|
2010-05-03 23:34:38 +00:00
|
|
|
break;
|
2007-02-21 00:49:24 +00:00
|
|
|
}
|
|
|
|
}
|