2010-01-30 23:24:23 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2010-01-30 23:24:23 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or modify
|
2010-01-30 23:24:23 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2010-01-30 23:24:23 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2015-04-13 07:36:54 +00:00
|
|
|
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-30 23:24:23 +00:00
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_MP_CORE_H
|
|
|
|
#define MPLAYER_MP_CORE_H
|
2008-01-01 21:35:58 +00:00
|
|
|
|
2008-12-08 18:04:08 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2014-02-17 01:52:26 +00:00
|
|
|
#include "libmpv/client.h"
|
|
|
|
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/common.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/options.h"
|
2014-01-18 00:19:20 +00:00
|
|
|
#include "sub/osd.h"
|
2015-02-17 22:46:12 +00:00
|
|
|
#include "demux/timeline.h"
|
2008-01-30 07:21:05 +00:00
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
// definitions used internally by the core player code
|
|
|
|
|
2008-08-13 05:06:26 +00:00
|
|
|
enum stop_play_reason {
|
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
|
|
|
KEEP_PLAYING = 0, // must be 0, numeric values of others do not matter
|
mplayer: attempt to skip playlist entries which can't be played
This is for situations when repeated attempts at playing a playlist
entry failed, and playlist navigation becomes impossible due to that.
For example, it wasn't possible to skip backwards past an unplayable
playlist entry:
mpv file1.mkv doesntexist.mkv file3.mkv
You couldn't skip back to file1.mkv from file3.mkv. When running a
single "playlist_prev" command, doesntexist.mkv would be played, which
would fail to load. As reaction to the failure to load it, the next file
would be played, which is file3.mkv.
To make this even worse, the file could successfully load, but run only
for a split second. So just loading successfully isn't good enough.
Attempt to solve this by marking problematic playlist entries as failed,
and by having playlist_prev skip past such playlist entries. We define
failure as not being able to play more than 3 seconds (or failing to
initialize to begin with). (The 3 seconds are in real time, not file
duration.)
"playlist_prev force" still exhibits the old behavior.
Additionally, use the same mechanism to prevent pointless infinite
reloading if none of the files on the playlist exist. (See github issue
All in all, this is a heuristic, and later adjustments might be
necessary.
Note: forward skips (playlist_next) are not affected at all. (Except for
the interaction with --loop.)
2013-09-15 03:03:37 +00:00
|
|
|
AT_END_OF_FILE, // file has ended, prepare to play next
|
|
|
|
// also returned on unrecoverable playback errors
|
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
|
|
|
PT_NEXT_ENTRY, // prepare to play next entry in playlist
|
|
|
|
PT_CURRENT_ENTRY, // prepare to play mpctx->playlist->current
|
|
|
|
PT_STOP, // stop playback, clear playlist
|
Add prelimimary (basic, possibly broken) dvdnav support
This readds a more or less completely new dvdnav implementation, though
it's based on the code from before commit 41fbcee. Note that this is
rather basic, and might be broken or not quite usable in many cases.
Most importantly, navigation highlights are not correctly implemented.
This would require changes in the FFmpeg dvdsub decoder (to apply a
different internal CLUT), so supporting it is not really possible right
now. And in fact, I don't think I ever want to support it, because it's
a very small gain for a lot of work. Instead, mpv will display fake
highlights, which are an approximate bounding box around the real
highlights.
Some things like mouse input or switching audio/subtitles stream using
the dvdnav VM are not supported.
Might be quite fragile on transitions: if dvdnav initiates a transition,
and doesn't give us enough mpeg data to initialize video playback, the
player will just quit.
This is added only because some users seem to want it. I don't intend to
make mpv a good DVD player, so the very basic minimum will have to do.
How about you just convert your DVD to proper video files?
2013-12-12 00:44:28 +00:00
|
|
|
PT_RELOAD_DEMUXER, // restart playback, but keep stream open
|
2012-08-04 01:46:11 +00:00
|
|
|
PT_QUIT, // stop playback, quit player
|
2014-10-28 15:19:07 +00:00
|
|
|
PT_ERROR, // play next playlist entry (due to an error)
|
2008-08-13 05:06:26 +00:00
|
|
|
};
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
enum mp_osd_seek_info {
|
|
|
|
OSD_SEEK_INFO_BAR = 1,
|
|
|
|
OSD_SEEK_INFO_TEXT = 2,
|
|
|
|
OSD_SEEK_INFO_CHAPTER_TEXT = 4,
|
|
|
|
OSD_SEEK_INFO_EDITION = 8,
|
2014-11-11 21:07:16 +00:00
|
|
|
OSD_SEEK_INFO_CURRENT_FILE = 16,
|
2012-09-25 01:24:38 +00:00
|
|
|
};
|
|
|
|
|
2013-10-30 20:47:14 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
// other constants
|
|
|
|
MAX_OSD_LEVEL = 3,
|
|
|
|
OSD_LEVEL_INVISIBLE = 4,
|
|
|
|
OSD_BAR_SEEK = 256,
|
2014-07-30 21:24:08 +00:00
|
|
|
|
|
|
|
MAX_NUM_VO_PTS = 100,
|
2013-10-30 20:47:14 +00:00
|
|
|
};
|
|
|
|
|
2013-08-19 20:29:55 +00:00
|
|
|
enum seek_type {
|
|
|
|
MPSEEK_NONE = 0,
|
|
|
|
MPSEEK_RELATIVE,
|
|
|
|
MPSEEK_ABSOLUTE,
|
|
|
|
MPSEEK_FACTOR,
|
|
|
|
};
|
|
|
|
|
2015-03-04 16:21:05 +00:00
|
|
|
enum seek_precision {
|
|
|
|
MPSEEK_DEFAULT = 0,
|
|
|
|
// The following values are numerically sorted by increasing precision
|
|
|
|
MPSEEK_KEYFRAME,
|
|
|
|
MPSEEK_EXACT,
|
|
|
|
MPSEEK_VERY_EXACT,
|
|
|
|
};
|
|
|
|
|
2012-08-19 16:01:30 +00:00
|
|
|
struct track {
|
|
|
|
enum stream_type type;
|
2013-12-23 19:14:54 +00:00
|
|
|
|
|
|
|
// Currently used for decoding.
|
|
|
|
bool selected;
|
|
|
|
|
2012-08-19 16:01:30 +00:00
|
|
|
// The type specific ID, also called aid (audio), sid (subs), vid (video).
|
|
|
|
// For UI purposes only; this ID doesn't have anything to do with any
|
|
|
|
// IDs coming from demuxers or container files.
|
|
|
|
int user_tid;
|
|
|
|
|
2014-10-21 11:16:48 +00:00
|
|
|
int demuxer_id; // same as stream->demuxer_id. -1 if not set.
|
|
|
|
int ff_index; // same as stream->ff_index, or 0.
|
2012-08-19 16:01:30 +00:00
|
|
|
|
|
|
|
char *title;
|
|
|
|
bool default_track;
|
2012-12-10 17:52:06 +00:00
|
|
|
bool attached_picture;
|
2012-08-19 16:01:30 +00:00
|
|
|
char *lang;
|
|
|
|
|
|
|
|
// If this track is from an external file (e.g. subtitle file).
|
|
|
|
bool is_external;
|
2014-01-05 15:15:30 +00:00
|
|
|
bool no_default; // pretend it's not external for auto-selection
|
2012-11-15 19:26:52 +00:00
|
|
|
char *external_filename;
|
2013-04-20 21:48:26 +00:00
|
|
|
bool auto_loaded;
|
2012-08-19 16:01:30 +00:00
|
|
|
|
|
|
|
// If the track's stream changes with the timeline (ordered chapters).
|
|
|
|
bool under_timeline;
|
|
|
|
|
2014-07-20 18:02:58 +00:00
|
|
|
// Does not change with under_timeline, but it useless for most purposes.
|
|
|
|
struct sh_stream *original_stream;
|
|
|
|
|
2012-08-19 16:01:30 +00:00
|
|
|
// Value can change if under_timeline==true.
|
|
|
|
struct demuxer *demuxer;
|
2013-09-07 18:21:11 +00:00
|
|
|
// Invariant: !stream || stream->demuxer == demuxer
|
2012-08-19 16:01:30 +00:00
|
|
|
struct sh_stream *stream;
|
|
|
|
|
2013-06-01 17:43:11 +00:00
|
|
|
// For external subtitles, which are read fully on init. Do not attempt
|
|
|
|
// to read packets from them.
|
|
|
|
bool preloaded;
|
2012-08-19 16:01:30 +00:00
|
|
|
};
|
|
|
|
|
2014-07-28 18:40:43 +00:00
|
|
|
/* Note that playback can be paused, stopped, etc. at any time. While paused,
|
|
|
|
* playback restart is still active, because you want seeking to work even
|
|
|
|
* if paused.
|
|
|
|
* The main purpose of distinguishing these states is proper reinitialization
|
|
|
|
* of A/V sync.
|
|
|
|
*/
|
|
|
|
enum playback_status {
|
|
|
|
// code may compare status values numerically
|
|
|
|
STATUS_SYNCING, // seeking for a position to resume
|
|
|
|
STATUS_FILLING, // decoding more data (so you start with full buffers)
|
|
|
|
STATUS_READY, // buffers full, playback can be started any time
|
|
|
|
STATUS_PLAYING, // normal playback
|
|
|
|
STATUS_DRAINING, // decoding has ended; still playing out queued buffers
|
|
|
|
STATUS_EOF, // playback has ended, or is disabled
|
|
|
|
};
|
|
|
|
|
2013-12-24 16:46:08 +00:00
|
|
|
#define NUM_PTRACKS 2
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
typedef struct MPContext {
|
2014-02-10 20:01:35 +00:00
|
|
|
bool initialized;
|
2014-06-07 13:08:45 +00:00
|
|
|
bool autodetach;
|
2013-07-31 19:40:30 +00:00
|
|
|
struct mpv_global *global;
|
2013-07-27 19:24:54 +00:00
|
|
|
struct MPOpts *opts;
|
2013-07-31 19:40:30 +00:00
|
|
|
struct mp_log *log;
|
2008-04-26 07:44:59 +00:00
|
|
|
struct m_config *mconfig;
|
2008-04-30 04:15:52 +00:00
|
|
|
struct input_ctx *input;
|
2014-02-10 20:01:35 +00:00
|
|
|
struct mp_client_api *clients;
|
|
|
|
struct mp_dispatch_queue *dispatch;
|
stream: redo playback abort handling
This mechanism originates from MPlayer's way of dealing with blocking
network, but it's still useful. On opening and closing, mpv waits for
network synchronously, and also some obscure commands and use-cases can
lead to such blocking. In these situations, the stream is asynchronously
forced to stop by "interrupting" it.
The old design interrupting I/O was a bit broken: polling with a
callback, instead of actively interrupting it. Change the direction of
this. There is no callback anymore, and the player calls
mp_cancel_trigger() to force the stream to return.
libavformat (via stream_lavf.c) has the old broken design, and fixing it
would require fixing libavformat, which won't happen so quickly. So we
have to keep that part. But everything above the stream layer is
prepared for a better design, and more sophisticated methods than
mp_cancel_test() could be easily introduced.
There's still one problem: commands are still run in the central
playback loop, which we assume can block on I/O in the worst case.
That's not a problem yet, because we simply mark some commands as being
able to stop playback of the current file ("quit" etc.), so input.c
could abort playback as soon as such a command is queued. But there are
also commands abort playback only conditionally, and the logic for that
is in the playback core and thus "unreachable". For example,
"playlist_next" aborts playback only if there's a next file. We don't
want it to always abort playback.
As a quite ugly hack, abort playback only if at least 2 abort commands
are queued - this pretty much happens only if the core is frozen and
doesn't react to input.
2014-09-13 12:23:08 +00:00
|
|
|
struct mp_cancel *playback_abort;
|
2014-02-10 20:01:35 +00:00
|
|
|
|
|
|
|
struct mp_log *statusline;
|
2008-06-23 22:53:58 +00:00
|
|
|
struct osd_state *osd;
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
char *term_osd_text;
|
|
|
|
char *term_osd_status;
|
2014-01-17 20:55:23 +00:00
|
|
|
char *term_osd_subs;
|
player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).
This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).
Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.
Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.
Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).
Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.
The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.
In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 19:05:41 +00:00
|
|
|
char *term_osd_contents;
|
2013-11-09 23:49:13 +00:00
|
|
|
char *last_window_title;
|
2009-03-30 00:13:17 +00:00
|
|
|
|
2012-09-25 01:24:38 +00:00
|
|
|
int add_osd_seek_info; // bitfield of enum mp_osd_seek_info
|
2013-05-25 16:31:06 +00:00
|
|
|
double osd_visible; // for the osd bar only
|
2007-02-21 00:49:24 +00:00
|
|
|
int osd_function;
|
2013-05-25 16:31:06 +00:00
|
|
|
double osd_function_visible;
|
2014-09-25 19:14:00 +00:00
|
|
|
double osd_msg_visible;
|
2014-10-06 20:19:24 +00:00
|
|
|
double osd_msg_next_duration;
|
2013-05-25 16:31:06 +00:00
|
|
|
double osd_last_update;
|
2014-09-25 18:25:24 +00:00
|
|
|
bool osd_force_update;
|
2014-09-25 19:14:00 +00:00
|
|
|
char *osd_msg_text;
|
|
|
|
bool osd_show_pos;
|
2014-01-18 00:19:20 +00:00
|
|
|
struct osd_progbar_state osd_progbar;
|
2012-11-20 16:20:45 +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
|
|
|
struct playlist *playlist;
|
2014-09-08 22:38:38 +00:00
|
|
|
struct playlist_entry *playing; // currently playing file
|
2014-10-06 19:20:38 +00:00
|
|
|
char *filename; // immutable copy of playing->filename (or NULL)
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
char *stream_open_filename;
|
2008-08-13 05:06:26 +00:00
|
|
|
enum stop_play_reason stop_play;
|
2014-10-03 17:57:49 +00:00
|
|
|
bool playback_initialized; // playloop can be run/is running
|
2014-10-30 22:54:06 +00:00
|
|
|
int error_playing;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-08-04 01:46:11 +00:00
|
|
|
// Return code to use with PT_QUIT
|
2013-08-02 08:32:38 +00:00
|
|
|
int quit_custom_rc;
|
|
|
|
bool has_quit_custom_rc;
|
2014-02-25 21:34:32 +00:00
|
|
|
char **resume_defaults;
|
2012-08-04 01:46:11 +00:00
|
|
|
|
2014-10-30 22:54:06 +00:00
|
|
|
// Global file statistics
|
|
|
|
int files_played; // played without issues (even if stopped by user)
|
|
|
|
int files_errored; // played, but errors happened at one point
|
|
|
|
int files_broken; // couldn't be played at all
|
|
|
|
|
|
|
|
// Current file statistics
|
2013-09-29 19:10:36 +00:00
|
|
|
int64_t shown_vframes, shown_aframes;
|
|
|
|
|
2014-10-28 14:30:27 +00:00
|
|
|
struct stream *stream; // stream that was initially opened
|
2015-02-22 18:06:21 +00:00
|
|
|
struct demuxer **sources; // all open demuxers
|
2009-03-29 19:45:06 +00:00
|
|
|
int num_sources;
|
2012-08-19 16:01:30 +00:00
|
|
|
|
2015-02-17 22:46:12 +00:00
|
|
|
struct timeline *tl;
|
2009-03-29 19:45:06 +00:00
|
|
|
struct timeline_part *timeline;
|
|
|
|
int num_timeline_parts;
|
|
|
|
int timeline_part;
|
2014-11-02 16:20:04 +00:00
|
|
|
struct demux_chapter *chapters;
|
2009-04-02 02:00:22 +00:00
|
|
|
int num_chapters;
|
2009-03-29 19:45:06 +00:00
|
|
|
double video_offset;
|
|
|
|
|
2015-02-22 18:06:21 +00:00
|
|
|
struct demuxer *demuxer; // can change with timeline
|
2014-12-29 21:51:18 +00:00
|
|
|
struct mp_tags *filtered_tags;
|
2012-08-19 16:01:30 +00:00
|
|
|
|
|
|
|
struct track **tracks;
|
|
|
|
int num_tracks;
|
|
|
|
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
char *track_layout_hash;
|
|
|
|
|
2012-08-19 16:01:30 +00:00
|
|
|
// Selected tracks. NULL if no track selected.
|
2013-12-24 16:46:08 +00:00
|
|
|
// There can be NUM_PTRACKS of the same STREAM_TYPE selected at once.
|
|
|
|
// Currently, this is used for the secondary subtitle track only.
|
|
|
|
struct track *current_track[NUM_PTRACKS][STREAM_TYPE_COUNT];
|
2012-08-19 16:01:30 +00:00
|
|
|
|
2013-11-23 20:36:20 +00:00
|
|
|
struct dec_video *d_video;
|
2013-11-23 20:22:17 +00:00
|
|
|
struct dec_audio *d_audio;
|
2013-12-24 16:46:14 +00:00
|
|
|
struct dec_sub *d_sub[2];
|
2013-11-23 20:22:17 +00:00
|
|
|
|
2012-08-19 16:07:06 +00:00
|
|
|
// Uses: accessing metadata (consider ordered chapters case, where the main
|
|
|
|
// demuxer defines metadata), or special purpose demuxers like TV.
|
|
|
|
struct demuxer *master_demuxer;
|
2014-07-20 18:02:58 +00:00
|
|
|
struct demuxer *track_layout; // complication for ordered chapters
|
2012-08-19 16:07:06 +00:00
|
|
|
|
2013-09-19 12:33:26 +00:00
|
|
|
struct mixer *mixer;
|
2011-04-09 00:03:22 +00:00
|
|
|
struct ao *ao;
|
2014-06-08 21:54:05 +00:00
|
|
|
struct mp_audio *ao_decoder_fmt; // for weak gapless audio check
|
2014-03-07 14:24:32 +00:00
|
|
|
struct mp_audio_buffer *ao_buffer; // queued audio; passed to ao_play() later
|
|
|
|
|
2008-04-03 03:25:41 +00:00
|
|
|
struct vo *video_out;
|
video: fix and simplify video format changes and last frame display
The previous commit broke these things, and fixing them is separate in
this commit in order to reduce the volume of changes.
Move the image queue from the VO to the playback core. The image queue
is a remnant of the old way how vdpau was implemented, and increasingly
became more and more an artifact. In the end, it did only one thing:
computing the duration of the current frame. This was done by taking the
PTS difference between the current and the future frame. We keep this,
but by moving it out of the VO, we don't have to special-case format
changes anymore. This simplifies the code a lot.
Since we need the queue to compute the duration only, a queue size
larger than 2 makes no sense, and we can hardcode that.
Also change how the last frame is handled. The last frame is a bit of a
problem, because video timing works by showing one frame after another,
which makes it a special case. Make the VO provide a function to notify
us when the frame is done, instead. The frame duration is used for that.
This is not perfect. For example, changing playback speed during the
last frame doesn't update the end time. Pausing will not stop the clock
that times the last frame. But I don't think this matters for such a
corner case.
2014-08-12 21:17:35 +00:00
|
|
|
// next_frame[0] is the next frame, next_frame[1] the one after that.
|
|
|
|
struct mp_image *next_frame[2];
|
2014-12-07 01:47:09 +00:00
|
|
|
struct mp_image *saved_frame; // for hrseek_lastframe
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2014-07-28 18:40:43 +00:00
|
|
|
enum playback_status video_status, audio_status;
|
|
|
|
bool restart_complete;
|
core: completely change handling of attached picture pseudo video
Before this commit, we tried to play along with libavformat and tried
to pretend that attached pictures are video streams with a single
frame, and that the frame magically appeared at the seek position when
seeking. The playback core would then switch to a mode where the video
has ended, and the "remaining" audio is played.
This didn't work very well:
- we needed a hack in demux.c, because we tried to read more packets in
order to find the "next" video frame (libavformat doesn't tell us if
a stream has ended)
- switching the video stream didn't work, because we can't tell
libavformat to send the packet again
- seeking and resuming after was hacky (for some reason libavformat sets
the returned packet's PTS to that of the previously returned audio
packet in generic code not related to attached pictures, and this
happened to work)
- if the user did something stupid and e.g. inserted a deinterlacer by
default, a picture was never displayed, only an inactive VO window)
- same when using a command that reconfigured the VO (like switching
aspect or video filters)
- hr-seek didn't work
For this reason, handle attached pictures as separate case with a
separate video decoding function, which doesn't read packets. Also,
do not synchronize audio to video start in this case.
2013-07-11 17:23:56 +00:00
|
|
|
/* Set if audio should be timed to start with video frame after seeking,
|
|
|
|
* not set when e.g. playing cover art */
|
|
|
|
bool sync_audio_to_video;
|
2014-12-07 01:47:09 +00:00
|
|
|
bool hrseek_active; // skip all data until hrseek_pts
|
|
|
|
bool hrseek_framedrop; // allow decoder to drop frames before hrseek_pts
|
|
|
|
bool hrseek_lastframe; // drop everything until last frame reached
|
2010-12-14 23:09:47 +00:00
|
|
|
double hrseek_pts;
|
2007-03-11 06:16:14 +00:00
|
|
|
// AV sync: the next frame should be shown when the audio out has this
|
|
|
|
// much (in seconds) buffered data left. Increased when more data is
|
2014-08-25 19:28:56 +00:00
|
|
|
// written to the ao, decreased when moving to the next video frame.
|
2007-03-11 06:16:14 +00:00
|
|
|
double delay;
|
2014-08-25 19:28:56 +00:00
|
|
|
// AV sync: time in seconds until next frame should be shown
|
2013-05-25 16:31:06 +00:00
|
|
|
double time_frame;
|
2008-12-08 18:04:08 +00:00
|
|
|
// How much video timing has been changed to make it match the audio
|
|
|
|
// timeline. Used for status line information only.
|
|
|
|
double total_avsync_change;
|
2014-11-01 00:07:21 +00:00
|
|
|
// Total number of dropped frames that were dropped by decoder.
|
|
|
|
int dropped_frames_total;
|
2013-03-08 01:08:02 +00:00
|
|
|
// Number of frames dropped in a row.
|
|
|
|
int dropped_frames;
|
2008-12-08 18:04:08 +00:00
|
|
|
// A-V sync difference when last frame was displayed. Kept to display
|
|
|
|
// the same value if the status line is updated at a time where no new
|
|
|
|
// video frame is shown.
|
|
|
|
double last_av_difference;
|
2010-12-14 20:31:39 +00:00
|
|
|
/* timestamp of video frame currently visible on screen
|
|
|
|
* (or at least queued to be flipped by VO) */
|
|
|
|
double video_pts;
|
2011-07-30 22:05:17 +00:00
|
|
|
double last_seek_pts;
|
2014-08-22 13:28:05 +00:00
|
|
|
// Mostly unused; for proper audio resync on speed changes.
|
|
|
|
double video_next_pts;
|
core: add --keep-open, which doesn't close the file on EOF
The --keep-open option causes mpv not to close the current file.
Instead, it will pause, and allow the user to seek around. When
seeking beyond the end of the file, mpv does a precise seek back to
the previous last known position that produced video output.
In some corner cases, mpv might not be able to produce video output at
all, despite having created a VO. (Possibly when only 1 frame could be
decoded, but the video filter chain queues frames. Then a VO would be
created, without sending an actual video frame to the VO.) In these
cases, the VO window will not redraw, not even OSD.
Based on a patch by coax [1].
[1] http://devel.mplayer2.org/ticket/210#comment:4
2012-11-12 23:56:20 +00:00
|
|
|
// As video_pts, but is not reset when seeking away. (For the very short
|
|
|
|
// period of time until a new frame is decoded and shown.)
|
|
|
|
double last_vo_pts;
|
2013-04-03 23:18:19 +00:00
|
|
|
// Video PTS, or audio PTS if video has ended.
|
|
|
|
double playback_pts;
|
2007-03-11 06:16:14 +00:00
|
|
|
|
2014-04-27 20:28:07 +00:00
|
|
|
int last_chapter;
|
|
|
|
|
core: add backstep support
Allows stepping back one frame via the frame_back_step inout command,
bound to "," by default.
This uses the precise seeking facility, and a perfect frame index built
on the fly. The index is built during playback and precise seeking, and
contains (as of this commit) the last 100 displayed or skipped frames.
This index is used to find the PTS of the previous frame, which is then
used as target for a precise seek. If no PTS is found, the core attempts
to do a seek before the current frame, and skip decoded frames until the
current frame is reached; this will create a sufficient index and the
normal backstep algorithm can be applied.
This can be rather slow. The worst case for backstepping is about the
same as the worst case for precise seeking if the previous frame can be
deduced from the index. If not, the worst case will be twice as slow.
There's also some minor danger that the index is incorrect in case
framedropping is involved. For framedropping due to --framedrop, this
problem is ignored (use of --framedrop is discouraged anyway). For
framedropping during precise seeking (done to make it faster), we try
to not add frames to the index that are produced when this can happen.
I'm not sure how well that works (or if the logic is sane), and it's
sure to break with some video filters. In the worst case, backstepping
might silently skip frames if you backstep after a user-initiated
precise seek. (Precise seeks to do indexing are not affected.)
Likewise, video filters that somehow change timing of frames and do not
do this in a deterministic way (i.e. if you seek to a position, frames
with different timings are produced than when the position is reached
during normal playback) will make backstepping silently jump to the
wrong frame. Enabling/disabling filters during playback (like for
example deinterlacing) will have similar bad effects.
2013-04-24 17:31:48 +00:00
|
|
|
// History of video frames timestamps that were queued in the VO
|
|
|
|
// This includes even skipped frames during hr-seek
|
|
|
|
double vo_pts_history_pts[MAX_NUM_VO_PTS];
|
|
|
|
// Whether the PTS at vo_pts_history[n] is after a seek reset
|
|
|
|
uint64_t vo_pts_history_seek[MAX_NUM_VO_PTS];
|
|
|
|
uint64_t vo_pts_history_seek_ts;
|
|
|
|
uint64_t backstep_start_seek_ts;
|
|
|
|
bool backstep_active;
|
|
|
|
|
2014-07-18 13:04:46 +00:00
|
|
|
double next_heartbeat;
|
2014-03-01 20:27:37 +00:00
|
|
|
double last_idle_tick;
|
2014-07-31 02:19:41 +00:00
|
|
|
double next_cache_update;
|
2013-05-16 21:17:46 +00:00
|
|
|
|
2014-07-18 13:04:46 +00:00
|
|
|
double sleeptime; // number of seconds to sleep before next iteration
|
|
|
|
|
2013-05-25 16:31:06 +00:00
|
|
|
double mouse_timer;
|
|
|
|
unsigned int mouse_event_ts;
|
2013-09-08 00:46:19 +00:00
|
|
|
bool mouse_cursor_visible;
|
2013-05-16 21:17:46 +00:00
|
|
|
|
2010-12-14 23:02:14 +00:00
|
|
|
// used to prevent hanging in some error cases
|
2013-05-25 16:31:06 +00:00
|
|
|
double start_timestamp;
|
2007-03-11 06:16:14 +00:00
|
|
|
|
2008-04-28 09:09:31 +00:00
|
|
|
// Timestamp from the last time some timing functions read the
|
video: display last frame, drain frames on video reconfig
Until now, the player didn't care to drain frames on video reconfig.
Instead, the VO was reconfigured (i.e. resized) before the queued frames
finished displaying. This can for example be observed by passing
multiple images with different size as mf:// filename. Then the window
would resize one frame before image with the new size is displayed. With
--vo=vdpau, the effect is worse, because this VO queues more than 1
frame internally.
Fix this by explicitly draining buffered frames before video reconfig.
Raise the display time of the last frame. Otherwise, the last frame
would be shown for a very short time only. This usually doesn't matter,
but helps when playing image files. This is a byproduct of frame
draining, because normally, video timing is based on the frames queued
to the VO, and we can't do that with frames of different size or format.
So we pretend that the frame before the change is the last frame in
order to time it. This code is incorrect though: it tries to use the
framerate, which often doesn't make sense. But it's good enough to test
this code with mf://.
2013-12-10 18:33:11 +00:00
|
|
|
// current time, in microseconds.
|
|
|
|
// Used to turn a new time value to a delta from last time.
|
2013-05-25 16:31:06 +00:00
|
|
|
int64_t last_time;
|
2008-04-28 09:09:31 +00:00
|
|
|
|
2008-04-21 03:17:22 +00:00
|
|
|
// Used to communicate the parameters of a seek between parts
|
2010-12-18 08:13:45 +00:00
|
|
|
struct seek_params {
|
2013-08-19 20:29:55 +00:00
|
|
|
enum seek_type type;
|
2015-03-04 16:21:05 +00:00
|
|
|
enum seek_precision exact;
|
2010-12-18 08:13:45 +00:00
|
|
|
double amount;
|
player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:
1. If there's a queued seek, stop accepting non-seek commands, and delay
them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
trying to decode and display the first video frame), stop accepting
seek commands (and in fact all commands that were queued after the
first seek command). This logic is disabled if seeking started longer
than 300ms ago. (To avoid starvation.)
I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.
The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.
One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).
Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 21:29:50 +00:00
|
|
|
bool immediate; // disable seek delay logic
|
2010-12-18 08:13:45 +00:00
|
|
|
} seek;
|
2008-04-21 03:17:22 +00:00
|
|
|
|
2010-04-25 20:20:34 +00:00
|
|
|
/* Heuristic for relative chapter seeks: keep track which chapter
|
|
|
|
* the user wanted to go to, even if we aren't exactly within the
|
|
|
|
* boundaries of that chapter due to an inaccurate seek. */
|
|
|
|
int last_chapter_seek;
|
|
|
|
double last_chapter_pts;
|
|
|
|
|
2013-12-15 12:43:26 +00:00
|
|
|
/* Subtitle renderer. This is separate, because we want to keep fonts
|
|
|
|
* loaded across ordered chapters, instead of reloading and rescanning
|
|
|
|
* them on each transition. (Both of these objects contain this state.)
|
|
|
|
*/
|
|
|
|
struct ass_renderer *ass_renderer;
|
2011-07-22 22:55:13 +00:00
|
|
|
struct ass_library *ass_library;
|
2013-12-21 18:06:37 +00:00
|
|
|
struct mp_log *ass_log;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
int last_dvb_step;
|
|
|
|
|
2013-04-25 18:38:22 +00:00
|
|
|
bool paused;
|
2008-11-29 06:09:57 +00:00
|
|
|
// step this many frames, then pause
|
|
|
|
int step_frames;
|
2013-03-08 01:08:02 +00:00
|
|
|
// Counted down each frame, stop playback if 0 is reached. (-1 = disable)
|
|
|
|
int max_frames;
|
2013-03-25 22:44:32 +00:00
|
|
|
bool playing_msg_shown;
|
2008-01-26 11:51:34 +00:00
|
|
|
|
2013-04-25 18:38:22 +00:00
|
|
|
bool paused_for_cache;
|
2014-08-27 21:12:24 +00:00
|
|
|
double cache_stop_time, cache_wait_time;
|
2012-12-01 23:22:54 +00:00
|
|
|
|
2008-12-08 18:04:08 +00:00
|
|
|
// Set after showing warning about decoding being too slow for realtime
|
|
|
|
// playback rate. Used to avoid showing it multiple times.
|
|
|
|
bool drop_message_shown;
|
|
|
|
|
2011-10-06 18:46:01 +00:00
|
|
|
struct screenshot_ctx *screenshot_ctx;
|
Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).
This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.
One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-25 22:41:14 +00:00
|
|
|
struct command_ctx *command_ctx;
|
2012-09-14 15:51:26 +00:00
|
|
|
struct encode_lavc_context *encode_lavc_ctx;
|
2014-07-14 23:49:02 +00:00
|
|
|
struct mp_nav_state *nav_state;
|
2014-10-16 09:48:18 +00:00
|
|
|
|
2014-10-19 14:44:33 +00:00
|
|
|
struct mp_ipc_ctx *ipc_ctx;
|
2014-12-09 16:47:02 +00:00
|
|
|
|
|
|
|
struct mpv_opengl_cb_context *gl_cb_ctx;
|
2007-02-21 00:49:24 +00:00
|
|
|
} MPContext;
|
|
|
|
|
2013-10-30 20:38:30 +00:00
|
|
|
// audio.c
|
2014-07-30 21:01:55 +00:00
|
|
|
void reset_audio_state(struct MPContext *mpctx);
|
2013-10-30 20:38:30 +00:00
|
|
|
void reinit_audio_chain(struct MPContext *mpctx);
|
|
|
|
int reinit_audio_filters(struct MPContext *mpctx);
|
|
|
|
double playing_audio_pts(struct MPContext *mpctx);
|
2014-07-29 22:24:57 +00:00
|
|
|
void fill_audio_out_buffers(struct MPContext *mpctx, double endpts);
|
2013-10-30 20:38:30 +00:00
|
|
|
double written_audio_pts(struct MPContext *mpctx);
|
2013-11-08 19:02:09 +00:00
|
|
|
void clear_audio_output_buffers(struct MPContext *mpctx);
|
2014-10-02 00:49:05 +00:00
|
|
|
void set_playback_speed(struct MPContext *mpctx, double new_speed);
|
2014-10-03 17:57:49 +00:00
|
|
|
void uninit_audio_out(struct MPContext *mpctx);
|
|
|
|
void uninit_audio_chain(struct MPContext *mpctx);
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2013-10-30 20:38:30 +00:00
|
|
|
// configfiles.c
|
2014-06-26 15:56:47 +00:00
|
|
|
void mp_parse_cfgfiles(struct MPContext *mpctx);
|
2013-12-21 19:45:19 +00:00
|
|
|
void mp_load_auto_profiles(struct MPContext *mpctx);
|
2014-02-25 21:34:32 +00:00
|
|
|
void mp_get_resume_defaults(struct MPContext *mpctx);
|
2013-12-21 19:45:19 +00:00
|
|
|
void mp_load_playback_resume(struct MPContext *mpctx, const char *file);
|
2013-10-30 20:38:30 +00:00
|
|
|
void mp_write_watch_later_conf(struct MPContext *mpctx);
|
2013-12-21 19:45:19 +00:00
|
|
|
struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx,
|
|
|
|
struct playlist *playlist);
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2014-07-14 23:49:02 +00:00
|
|
|
// discnav.c
|
|
|
|
void mp_nav_init(struct MPContext *mpctx);
|
|
|
|
void mp_nav_reset(struct MPContext *mpctx);
|
|
|
|
void mp_nav_destroy(struct MPContext *mpctx);
|
|
|
|
void mp_nav_user_input(struct MPContext *mpctx, char *command);
|
|
|
|
void mp_handle_nav(struct MPContext *mpctx);
|
|
|
|
int mp_nav_in_menu(struct MPContext *mpctx);
|
2015-04-20 15:50:43 +00:00
|
|
|
bool mp_nav_mouse_on_button(struct MPContext *mpctx);
|
2014-07-14 23:49:02 +00:00
|
|
|
|
2013-10-30 20:38:30 +00:00
|
|
|
// loadfile.c
|
2008-04-21 03:07:22 +00:00
|
|
|
void uninit_player(struct MPContext *mpctx, unsigned int mask);
|
2015-02-03 08:15:14 +00:00
|
|
|
struct track *mp_add_external_file(struct MPContext *mpctx, char *filename,
|
|
|
|
enum stream_type filter);
|
2013-10-30 20:38:30 +00:00
|
|
|
void mp_switch_track(struct MPContext *mpctx, enum stream_type type,
|
|
|
|
struct track *track);
|
2013-12-24 16:46:08 +00:00
|
|
|
void mp_switch_track_n(struct MPContext *mpctx, int order,
|
|
|
|
enum stream_type type, struct track *track);
|
2013-12-23 19:14:54 +00:00
|
|
|
void mp_deselect_track(struct MPContext *mpctx, struct track *track);
|
2014-03-03 22:53:12 +00:00
|
|
|
void mp_mark_user_track_selection(struct MPContext *mpctx, int order,
|
|
|
|
enum stream_type type);
|
2013-10-30 20:38:30 +00:00
|
|
|
struct track *mp_track_by_tid(struct MPContext *mpctx, enum stream_type type,
|
|
|
|
int tid);
|
|
|
|
double timeline_set_from_time(struct MPContext *mpctx, double pts, bool *need_reset);
|
|
|
|
void add_demuxer_tracks(struct MPContext *mpctx, struct demuxer *demuxer);
|
|
|
|
bool mp_remove_track(struct MPContext *mpctx, struct track *track);
|
|
|
|
struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction,
|
|
|
|
bool force);
|
|
|
|
void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e);
|
|
|
|
void mp_play_files(struct MPContext *mpctx);
|
2014-07-16 20:40:21 +00:00
|
|
|
void update_demuxer_properties(struct MPContext *mpctx);
|
2015-04-28 20:04:37 +00:00
|
|
|
void print_track_list(struct MPContext *mpctx);
|
2014-10-03 17:57:49 +00:00
|
|
|
void reselect_demux_streams(struct MPContext *mpctx);
|
2014-12-29 21:08:22 +00:00
|
|
|
void prepare_playlist(struct MPContext *mpctx, struct playlist *pl);
|
2015-02-16 21:06:41 +00:00
|
|
|
void autoload_external_files(struct MPContext *mpctx);
|
|
|
|
struct track *select_track(struct MPContext *mpctx, enum stream_type type,
|
|
|
|
int tid, int ffid, char **langs);
|
2013-10-30 20:38:30 +00:00
|
|
|
|
|
|
|
// main.c
|
2014-02-10 20:25:22 +00:00
|
|
|
int mpv_main(int argc, char *argv[]);
|
2015-03-05 10:17:22 +00:00
|
|
|
int mp_initialize(struct MPContext *mpctx, char **argv);
|
2014-02-10 20:01:35 +00:00
|
|
|
struct MPContext *mp_create(void);
|
|
|
|
void mp_destroy(struct MPContext *mpctx);
|
2013-12-21 18:45:42 +00:00
|
|
|
void mp_print_version(struct mp_log *log, int always);
|
2015-01-03 02:01:58 +00:00
|
|
|
void wakeup_playloop(void *ctx);
|
2013-10-30 20:38:30 +00:00
|
|
|
|
|
|
|
// misc.c
|
|
|
|
double get_start_time(struct MPContext *mpctx);
|
|
|
|
double get_main_demux_pts(struct MPContext *mpctx);
|
2014-08-15 21:32:37 +00:00
|
|
|
double get_track_video_offset(struct MPContext *mpctx, struct track *track);
|
2014-03-25 01:32:24 +00:00
|
|
|
double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t);
|
2013-10-30 20:38:30 +00:00
|
|
|
double get_play_end_pts(struct MPContext *mpctx);
|
|
|
|
double get_relative_time(struct MPContext *mpctx);
|
2013-11-19 21:36:33 +00:00
|
|
|
void merge_playlist_files(struct playlist *pl);
|
2014-07-01 22:14:30 +00:00
|
|
|
float mp_get_cache_percent(struct MPContext *mpctx);
|
2013-10-30 20:38:30 +00:00
|
|
|
bool mp_get_cache_idle(struct MPContext *mpctx);
|
2013-11-09 23:49:13 +00:00
|
|
|
void update_window_title(struct MPContext *mpctx, bool force);
|
2014-10-23 16:31:43 +00:00
|
|
|
void error_on_track(struct MPContext *mpctx, struct track *track);
|
2013-10-30 20:38:30 +00:00
|
|
|
void stream_dump(struct MPContext *mpctx);
|
2015-02-20 19:06:43 +00:00
|
|
|
int mpctx_run_reentrant(struct MPContext *mpctx, void (*thread_fn)(void *arg),
|
|
|
|
void *thread_arg);
|
2014-10-06 19:20:38 +00:00
|
|
|
struct mpv_global *create_sub_global(struct MPContext *mpctx);
|
2013-10-30 20:38:30 +00:00
|
|
|
|
|
|
|
// osd.c
|
2014-09-21 21:40:45 +00:00
|
|
|
void set_osd_bar(struct MPContext *mpctx, int type,
|
2014-06-08 21:52:58 +00:00
|
|
|
double min, double max, double neutral, double val);
|
2014-09-25 19:14:00 +00:00
|
|
|
bool set_osd_msg(struct MPContext *mpctx, int level, int time,
|
2014-01-17 21:34:47 +00:00
|
|
|
const char* fmt, ...) PRINTF_ATTRIBUTE(4,5);
|
2013-10-30 20:47:14 +00:00
|
|
|
void set_osd_function(struct MPContext *mpctx, int osd_function);
|
|
|
|
void set_osd_subtitle(struct MPContext *mpctx, const char *text);
|
2014-09-17 22:12:59 +00:00
|
|
|
void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size);
|
2014-11-18 19:28:54 +00:00
|
|
|
void set_osd_bar_chapters(struct MPContext *mpctx, int type);
|
2013-10-30 20:38:30 +00:00
|
|
|
|
|
|
|
// playloop.c
|
2014-09-06 14:57:46 +00:00
|
|
|
void mp_wait_events(struct MPContext *mpctx, double sleeptime);
|
|
|
|
void mp_process_input(struct MPContext *mpctx);
|
2014-07-30 21:01:55 +00:00
|
|
|
void reset_playback_state(struct MPContext *mpctx);
|
2014-04-14 20:33:41 +00:00
|
|
|
void pause_player(struct MPContext *mpctx);
|
|
|
|
void unpause_player(struct MPContext *mpctx);
|
core: add backstep support
Allows stepping back one frame via the frame_back_step inout command,
bound to "," by default.
This uses the precise seeking facility, and a perfect frame index built
on the fly. The index is built during playback and precise seeking, and
contains (as of this commit) the last 100 displayed or skipped frames.
This index is used to find the PTS of the previous frame, which is then
used as target for a precise seek. If no PTS is found, the core attempts
to do a seek before the current frame, and skip decoded frames until the
current frame is reached; this will create a sufficient index and the
normal backstep algorithm can be applied.
This can be rather slow. The worst case for backstepping is about the
same as the worst case for precise seeking if the previous frame can be
deduced from the index. If not, the worst case will be twice as slow.
There's also some minor danger that the index is incorrect in case
framedropping is involved. For framedropping due to --framedrop, this
problem is ignored (use of --framedrop is discouraged anyway). For
framedropping during precise seeking (done to make it faster), we try
to not add frames to the index that are produced when this can happen.
I'm not sure how well that works (or if the logic is sane), and it's
sure to break with some video filters. In the worst case, backstepping
might silently skip frames if you backstep after a user-initiated
precise seek. (Precise seeks to do indexing are not affected.)
Likewise, video filters that somehow change timing of frames and do not
do this in a deterministic way (i.e. if you seek to a position, frames
with different timings are produced than when the position is reached
during normal playback) will make backstepping silently jump to the
wrong frame. Enabling/disabling filters during playback (like for
example deinterlacing) will have similar bad effects.
2013-04-24 17:31:48 +00:00
|
|
|
void add_step_frame(struct MPContext *mpctx, int dir);
|
2010-12-18 08:13:45 +00:00
|
|
|
void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
|
2015-03-04 16:21:05 +00:00
|
|
|
enum seek_precision exact, bool immediate);
|
2013-05-03 22:36:53 +00:00
|
|
|
bool mp_seek_chapter(struct MPContext *mpctx, int chapter);
|
2010-11-07 22:54:32 +00:00
|
|
|
double get_time_length(struct MPContext *mpctx);
|
|
|
|
double get_current_time(struct MPContext *mpctx);
|
2014-06-29 17:27:46 +00:00
|
|
|
double get_playback_time(struct MPContext *mpctx);
|
2010-11-07 22:54:32 +00:00
|
|
|
int get_percent_pos(struct MPContext *mpctx);
|
2013-06-20 10:15:36 +00:00
|
|
|
double get_current_pos_ratio(struct MPContext *mpctx, bool use_range);
|
2009-04-02 02:00:22 +00:00
|
|
|
int get_current_chapter(struct MPContext *mpctx);
|
|
|
|
char *chapter_display_name(struct MPContext *mpctx, int chapter);
|
2011-10-23 02:51:44 +00:00
|
|
|
char *chapter_name(struct MPContext *mpctx, int chapter);
|
|
|
|
double chapter_start_time(struct MPContext *mpctx, int chapter);
|
|
|
|
int get_chapter_count(struct MPContext *mpctx);
|
2014-10-07 20:07:07 +00:00
|
|
|
double get_cache_buffering_percentage(struct MPContext *mpctx);
|
2013-10-29 21:38:29 +00:00
|
|
|
void execute_queued_seek(struct MPContext *mpctx);
|
|
|
|
void run_playloop(struct MPContext *mpctx);
|
2014-10-06 19:20:38 +00:00
|
|
|
void mp_idle(struct MPContext *mpctx);
|
2013-10-29 21:38:29 +00:00
|
|
|
void idle_loop(struct MPContext *mpctx);
|
|
|
|
void handle_force_window(struct MPContext *mpctx, bool reconfig);
|
|
|
|
void add_frame_pts(struct MPContext *mpctx, double pts);
|
2014-12-08 16:27:07 +00:00
|
|
|
void seek_to_last_frame(struct MPContext *mpctx);
|
2011-02-14 07:34:39 +00:00
|
|
|
|
2014-05-12 23:14:07 +00:00
|
|
|
// scripting.c
|
|
|
|
struct mp_scripting {
|
|
|
|
const char *file_ext; // e.g. "lua"
|
|
|
|
int (*load)(struct mpv_handle *client, const char *filename);
|
|
|
|
};
|
|
|
|
void mp_load_scripts(struct MPContext *mpctx);
|
|
|
|
|
2013-10-30 20:38:30 +00:00
|
|
|
// sub.c
|
2014-07-30 21:01:55 +00:00
|
|
|
void reset_subtitle_state(struct MPContext *mpctx);
|
2014-10-03 17:57:49 +00:00
|
|
|
void uninit_stream_sub_decoders(struct demuxer *demuxer);
|
2013-12-24 16:46:14 +00:00
|
|
|
void reinit_subs(struct MPContext *mpctx, int order);
|
2014-10-03 17:57:49 +00:00
|
|
|
void uninit_sub(struct MPContext *mpctx, int order);
|
|
|
|
void uninit_sub_all(struct MPContext *mpctx);
|
2013-10-30 20:38:30 +00:00
|
|
|
void update_osd_msg(struct MPContext *mpctx);
|
|
|
|
void update_subtitles(struct MPContext *mpctx);
|
2014-10-03 20:32:16 +00:00
|
|
|
void uninit_sub_renderer(struct MPContext *mpctx);
|
2014-12-27 11:23:00 +00:00
|
|
|
void update_osd_sub_state(struct MPContext *mpctx, int order,
|
|
|
|
struct osd_sub_state *out_state);
|
2013-06-07 20:57:00 +00:00
|
|
|
|
2013-10-30 20:38:30 +00:00
|
|
|
// video.c
|
2014-07-30 21:01:55 +00:00
|
|
|
void reset_video_state(struct MPContext *mpctx);
|
2013-10-30 20:38:30 +00:00
|
|
|
int reinit_video_chain(struct MPContext *mpctx);
|
|
|
|
int reinit_video_filters(struct MPContext *mpctx);
|
2014-07-30 21:24:08 +00:00
|
|
|
void write_video(struct MPContext *mpctx, double endpts);
|
2013-10-30 20:38:30 +00:00
|
|
|
void mp_force_video_refresh(struct MPContext *mpctx);
|
2014-10-03 17:57:49 +00:00
|
|
|
void uninit_video_out(struct MPContext *mpctx);
|
|
|
|
void uninit_video_chain(struct MPContext *mpctx);
|
2013-10-30 20:38:30 +00:00
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_MP_CORE_H */
|