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.
|
|
|
|
*/
|
|
|
|
|
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>
|
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/options.h"
|
2011-01-26 17:40:52 +00:00
|
|
|
#include "sub/subreader.h"
|
2011-02-26 19:47:49 +00:00
|
|
|
#include "sub/find_subfiles.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "audio/mixer.h"
|
|
|
|
#include "demux/demux.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-02-14 14:23:55 +00:00
|
|
|
#define INITIALIZED_VO 1
|
|
|
|
#define INITIALIZED_AO 2
|
2009-07-07 17:35:54 +00:00
|
|
|
|
2008-02-14 14:23:55 +00:00
|
|
|
#define INITIALIZED_GETCH2 8
|
|
|
|
#define INITIALIZED_SPUDEC 32
|
|
|
|
#define INITIALIZED_STREAM 64
|
|
|
|
#define INITIALIZED_DEMUXER 512
|
|
|
|
#define INITIALIZED_ACODEC 1024
|
|
|
|
#define INITIALIZED_VCODEC 2048
|
2011-01-16 18:03:08 +00:00
|
|
|
#define INITIALIZED_SUB 4096
|
2008-02-14 14:23:55 +00:00
|
|
|
#define INITIALIZED_ALL 0xFFFF
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
AT_END_OF_FILE, // file has ended normally, prepare to play next
|
|
|
|
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
|
2012-08-25 23:19:42 +00:00
|
|
|
PT_RESTART, // restart previous file
|
2012-08-04 01:46:11 +00:00
|
|
|
PT_QUIT, // stop playback, quit player
|
2008-08-13 05:06:26 +00:00
|
|
|
};
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2010-02-14 11:02:05 +00:00
|
|
|
enum exit_reason {
|
2008-12-02 19:53:41 +00:00
|
|
|
EXIT_NONE,
|
|
|
|
EXIT_QUIT,
|
|
|
|
EXIT_EOF,
|
|
|
|
EXIT_ERROR
|
2010-02-14 11:02:05 +00:00
|
|
|
};
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2009-03-29 19:45:06 +00:00
|
|
|
struct timeline_part {
|
|
|
|
double start;
|
|
|
|
double source_start;
|
2012-08-19 15:58:58 +00:00
|
|
|
struct demuxer *source;
|
2009-03-29 19:45:06 +00:00
|
|
|
};
|
|
|
|
|
2009-04-02 02:00:22 +00:00
|
|
|
struct chapter {
|
|
|
|
double start;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2012-08-19 16:01:30 +00:00
|
|
|
struct track {
|
|
|
|
enum stream_type type;
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
// Same as stream->demuxer_id. -1 if not set.
|
|
|
|
int demuxer_id;
|
|
|
|
|
|
|
|
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;
|
2012-11-15 19:26:52 +00:00
|
|
|
char *external_filename;
|
2012-08-19 16:01:30 +00:00
|
|
|
|
|
|
|
// If the track's stream changes with the timeline (ordered chapters).
|
|
|
|
bool under_timeline;
|
|
|
|
|
|
|
|
// NULL if not backed by a demuxer (e.g. external subtitles).
|
|
|
|
// Value can change if under_timeline==true.
|
|
|
|
struct demuxer *demuxer;
|
|
|
|
// Invariant: (!demuxer && !stream) || stream->demuxer == demuxer
|
|
|
|
struct sh_stream *stream;
|
|
|
|
|
|
|
|
// NOTE: demuxer subtitles, i.e. if stream!=NULL, do not use the following
|
|
|
|
// fields. The data is stored in stream->sub this case.
|
|
|
|
|
|
|
|
// External text subtitle using libass subtitle renderer.
|
2012-08-25 18:22:39 +00:00
|
|
|
// The sh_sub is a dummy and doesn't belong to a demuxer.
|
|
|
|
struct sh_sub *sh_sub;
|
2012-08-19 16:01:30 +00:00
|
|
|
|
|
|
|
// External text subtitle using non-libass subtitle renderer.
|
|
|
|
struct sub_data *subdata;
|
|
|
|
};
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
typedef struct MPContext {
|
2008-03-31 03:19:29 +00:00
|
|
|
struct MPOpts opts;
|
2008-04-26 07:44:59 +00:00
|
|
|
struct m_config *mconfig;
|
2008-04-29 12:12:19 +00:00
|
|
|
struct mp_fifo *key_fifo;
|
2008-04-30 04:15:52 +00:00
|
|
|
struct input_ctx *input;
|
2008-06-23 22:53:58 +00:00
|
|
|
struct osd_state *osd;
|
2012-08-04 01:50:23 +00:00
|
|
|
struct mp_osd_msg *osd_msg_stack;
|
2012-01-06 18:48:50 +00:00
|
|
|
char *terminal_osd_text;
|
2012-08-19 16:01:30 +00:00
|
|
|
subtitle subs; // subtitle list used when reading subtitles from demuxer
|
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
|
2009-03-30 00:13:17 +00:00
|
|
|
unsigned int osd_visible;
|
2007-02-21 00:49:24 +00:00
|
|
|
int osd_function;
|
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;
|
2008-04-26 12:17:51 +00:00
|
|
|
char *filename; // currently playing file
|
2012-10-13 15:09:35 +00:00
|
|
|
struct mp_resolve_result *resolve_result;
|
2008-08-13 05:06:26 +00:00
|
|
|
enum stop_play_reason stop_play;
|
2008-04-26 12:31:39 +00:00
|
|
|
unsigned int initialized_flags; // which subsystems have been initialized
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2012-08-04 01:46:11 +00:00
|
|
|
// Return code to use with PT_QUIT
|
|
|
|
int quit_player_rc;
|
|
|
|
|
2012-08-19 15:58:58 +00:00
|
|
|
struct demuxer **sources;
|
2009-03-29 19:45:06 +00:00
|
|
|
int num_sources;
|
2012-08-19 16:01:30 +00:00
|
|
|
|
2009-03-29 19:45:06 +00:00
|
|
|
struct timeline_part *timeline;
|
|
|
|
int num_timeline_parts;
|
|
|
|
int timeline_part;
|
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
|
|
|
// NOTE: even if num_chapters==0, chapters being not NULL signifies presence
|
|
|
|
// of chapter metadata
|
2009-07-06 23:26:13 +00:00
|
|
|
struct chapter *chapters;
|
2009-04-02 02:00:22 +00:00
|
|
|
int num_chapters;
|
2009-03-29 19:45:06 +00:00
|
|
|
double video_offset;
|
|
|
|
|
2008-04-24 02:49:44 +00:00
|
|
|
struct stream *stream;
|
|
|
|
struct demuxer *demuxer;
|
2012-08-19 16:01:30 +00:00
|
|
|
|
|
|
|
struct track **tracks;
|
|
|
|
int num_tracks;
|
|
|
|
|
|
|
|
// Selected tracks. NULL if no track selected.
|
|
|
|
struct track *current_track[STREAM_TYPE_COUNT];
|
|
|
|
|
|
|
|
struct sh_stream *sh[STREAM_TYPE_COUNT];
|
|
|
|
struct sh_audio *sh_audio; // same as sh[STREAM_AUDIO]->audio
|
|
|
|
struct sh_video *sh_video; // same as sh[STREAM_VIDEO]->video
|
|
|
|
struct sh_sub *sh_sub; // same as sh[STREAM_SUB]->sub
|
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;
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
mixer_t mixer;
|
2011-04-09 00:03:22 +00:00
|
|
|
struct ao *ao;
|
2008-04-03 03:25:41 +00:00
|
|
|
struct vo *video_out;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
2010-11-11 10:29:14 +00:00
|
|
|
/* We're starting playback from scratch or after a seek. Show first
|
|
|
|
* video frame immediately and reinitialize sync. */
|
|
|
|
bool restart_playback;
|
2010-11-13 17:27:01 +00:00
|
|
|
/* After playback restart (above) or audio stream change, adjust audio
|
|
|
|
* stream by cutting samples or adding silence at the beginning to make
|
|
|
|
* audio playback position match video position. */
|
|
|
|
bool syncing_audio;
|
2010-12-14 23:09:47 +00:00
|
|
|
bool hrseek_active;
|
|
|
|
bool hrseek_framedrop;
|
|
|
|
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
|
|
|
|
// written to the ao, decreased when moving to the next frame.
|
|
|
|
// In the audio-only case used as a timer since the last seek
|
|
|
|
// by the audio CPU usage meter.
|
|
|
|
double delay;
|
2008-11-29 06:09:57 +00:00
|
|
|
// AV sync: time until next frame should be shown
|
|
|
|
float time_frame;
|
2008-12-08 18:04:08 +00:00
|
|
|
// How long the last vo flip() call took. Used to adjust timing with
|
|
|
|
// the goal of making flip() calls finish (rather than start) at the
|
|
|
|
// specified time.
|
|
|
|
float last_vo_flip_duration;
|
|
|
|
// How much video timing has been changed to make it match the audio
|
|
|
|
// timeline. Used for status line information only.
|
|
|
|
double total_avsync_change;
|
|
|
|
// 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;
|
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;
|
2007-03-11 06:16:14 +00:00
|
|
|
|
2010-12-14 23:02:14 +00:00
|
|
|
// used to prevent hanging in some error cases
|
|
|
|
unsigned int 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
|
|
|
|
// current time, in (occasionally wrapping) microseconds. Used
|
|
|
|
// to turn a new time value to a delta from last time.
|
|
|
|
unsigned int last_time;
|
|
|
|
|
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 {
|
|
|
|
enum seek_type {
|
|
|
|
MPSEEK_NONE, MPSEEK_RELATIVE, MPSEEK_ABSOLUTE, MPSEEK_FACTOR
|
|
|
|
} type;
|
|
|
|
double amount;
|
|
|
|
int exact; // -1 = disable, 0 = default, 1 = enable
|
|
|
|
// currently not set by commands, only used internally by seek()
|
|
|
|
int direction; // -1 = backward, 0 = default, 1 = forward
|
|
|
|
} 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;
|
|
|
|
|
2011-07-22 22:55:13 +00:00
|
|
|
struct ass_library *ass_library;
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
int file_format;
|
|
|
|
|
|
|
|
int last_dvb_step;
|
|
|
|
int dvbin_reopen;
|
|
|
|
|
2008-11-29 06:09:57 +00:00
|
|
|
int paused;
|
|
|
|
// step this many frames, then pause
|
|
|
|
int step_frames;
|
2008-01-26 11:51:34 +00:00
|
|
|
|
2012-12-01 23:22:54 +00:00
|
|
|
bool paused_for_cache;
|
|
|
|
|
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;
|
|
|
|
|
mplayer: selectively reset track selection when playing multiple files
Normally, video/audio/sub track selection is persistent across files
played in the same mplayer instance. This is wanted, because settings
should not be reset across files in general. However, if the track
layout of a file is completely different from the previous, this will
essentially select random tracks. In this case, keeping the track
selection is confusing and unwanted.
Reset the track selection to default if the track layout changes. The
track layout is determined by number of tracks, track order, default
flag, whether the track is an external subtitle, and track language.
If a track layout change is detected when playing a new file, the -sid,
-aid and -vid options are reset to "auto".
This behavior is enabled only if the user selects tracks manually (via
keybinds and the "switch_audio" slave properties etc.). If no user
interactions take place, options specified on the command line will
follow the old behavior.
2012-09-08 21:02:02 +00:00
|
|
|
char *track_layout_hash;
|
2012-09-14 15:51:26 +00:00
|
|
|
|
|
|
|
struct encode_lavc_context *encode_lavc_ctx;
|
2007-02-21 00:49:24 +00:00
|
|
|
} MPContext;
|
|
|
|
|
|
|
|
|
2011-10-25 04:05:47 +00:00
|
|
|
// should not be global
|
2007-02-21 00:49:24 +00:00
|
|
|
extern FILE *edl_fd;
|
|
|
|
// These appear in options list
|
|
|
|
extern int forced_subs_only;
|
|
|
|
|
2008-04-21 03:07:22 +00:00
|
|
|
void uninit_player(struct MPContext *mpctx, unsigned int mask);
|
|
|
|
void reinit_audio_chain(struct MPContext *mpctx);
|
|
|
|
void init_vo_spudec(struct MPContext *mpctx);
|
2008-04-21 03:55:23 +00:00
|
|
|
double playing_audio_pts(struct MPContext *mpctx);
|
2012-11-15 19:26:52 +00:00
|
|
|
struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename,
|
|
|
|
float fps, int noerr);
|
2008-04-21 03:07:22 +00:00
|
|
|
int reinit_video_chain(struct MPContext *mpctx);
|
2008-11-29 06:09:57 +00:00
|
|
|
void pause_player(struct MPContext *mpctx);
|
|
|
|
void unpause_player(struct MPContext *mpctx);
|
2008-12-01 17:53:57 +00:00
|
|
|
void add_step_frame(struct MPContext *mpctx);
|
2010-12-18 08:13:45 +00:00
|
|
|
void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
|
|
|
|
int exact);
|
2011-10-23 02:51:44 +00:00
|
|
|
int seek_chapter(struct MPContext *mpctx, int chapter, double *seek_pts);
|
2010-11-07 22:54:32 +00:00
|
|
|
double get_time_length(struct MPContext *mpctx);
|
|
|
|
double get_current_time(struct MPContext *mpctx);
|
|
|
|
int get_percent_pos(struct MPContext *mpctx);
|
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);
|
2012-08-19 16:01:30 +00:00
|
|
|
void mp_switch_track(struct MPContext *mpctx, enum stream_type type,
|
|
|
|
struct track *track);
|
|
|
|
struct track *mp_track_by_tid(struct MPContext *mpctx, enum stream_type type,
|
|
|
|
int tid);
|
2012-11-15 19:26:52 +00:00
|
|
|
bool mp_remove_track(struct MPContext *mpctx, struct track *track);
|
2013-02-03 13:54:28 +00:00
|
|
|
struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction);
|
2011-02-14 07:34:39 +00:00
|
|
|
|
|
|
|
// timeline/tl_matroska.c
|
|
|
|
void build_ordered_chapter_timeline(struct MPContext *mpctx);
|
EDL: add support for new EDL file format
The timeline code previously added to support Matroska ordered
chapters allows constructing a playback timeline from segments picked
from multiple source files. Add support for a new EDL format to make
this machinery available for use with file formats other than Matroska
and in a manner easier to use than creating files with ordered
chapters.
Unlike the old -edl option which specifies an additional file with
edits to apply to the video file given as the main argument, the new
EDL format is used by giving only the EDL file as the file to play;
that file then contains the filename(s) to use as source files where
actual video segments come from. Filename paths in the EDL file are
ignored. Currently the source files are only searched for in the
directory of the EDL file; support for a search path option will
likely be added in the future.
Format of the EDL files
The first line in the file must be "mplayer EDL file, version 2".
The rest of the lines belong to one of these classes:
1) lines specifying source files
2) empty lines
3) lines specifying timeline segments.
Lines beginning with '<' specify source files. These lines first
contain an identifier used to refer to the source file later, then the
filename separated by whitespace. The identifier must start with a
letter. Filenames that start or end with whitespace or contain
newlines are not supported.
On other lines '#' characters delimit comments. Lines that contain
only whitespace after comments have been removed are ignored.
Timeline segments must appear in the file in chronological order. Each
segment has the following information associated with it:
- duration
- output start time
- output end time (= output start time + duration)
- source id (specifies the file the content of the segment comes from)
- source start time (timestamp in the source file)
- source end time (= source start time + duration)
The output timestamps must form a continuous timeline from 0 to the
end of the last segment, such that each new segment starts from the
time the previous one ends at. Source files and times may change
arbitrarily between segments.
The general format for lines specifying timeline segments is
[output time info] source_id [source time info]
source_id must be an identifier defined on a '<' line. Both the time
info parts consists of zero or more of the following elements:
1) timestamp
2) -timestamp
3) +duration
4) *
5) -*
, where "timestamp" and "duration" are decimal numbers (computations
are done with nanosecond precision). Whitespace around "+" and "-" is
optional. 1) and 2) specify start and end time of the segment on
output or source side. 3) specifies duration; the semantics are the
same whether this appears on output or source side. 4) and 5) are
ignored on the output side (they're always implicitly assumed). On the
source side 4) specifies that the segment starts where the previous
segment _using this source_ ended; if there was no previous segment
time 0 is used. 5) specifies that the segment ends where the next
segment using this source starts.
Redundant information may be omitted. It will be filled in using the
following rules:
- output start for first segment is 0
- two of [output start, output end, duration] imply third
- two of [source start, source end, duration] imply third
- output start = output end of previous segment
- output end = output start of next segment
- if "*", source start = source end of earlier segment
- if "-*", source end = source start of a later segment
As a special rule, a last zero-duration segment without a source
specification may appear. This will produce no corresponding segment
in the resulting timeline, but can be used as syntax to specify the
end time of the timeline (with effect equal to adding -time on the
previous line).
Examples:
----- begin -----
mplayer EDL file, version 2
< id1 filename
0 id1 123
100 id1 456
200 id1 789
300
----- end -----
All segments come from the source file "filename". First segment
(output time 0-100) comes from time 123-223, second 456-556, third
789-889.
----- begin -----
mplayer EDL file, version 2
< f filename
f 60-120
f 600-660
f 30- 90
----- end -----
Play first seconds 60-120 from the file, then 600-660, then 30-90.
----- begin -----
mplayer EDL file, version 2
< id1 filename1
< id2 filename2
+10 id1 *
+10 id2 *
+10 id1 *
+10 id2 *
+10 id1 *
+10 id2 *
----- end -----
This plays time 0-10 from filename1, then 0-10 from filename1, then
10-20 from filename1, then 10-20 from filename2, then 20-30 from
filename1, then 20-30 from filename2.
----- begin -----
mplayer EDL file, version 2
< t1 filename1
< t2 filename2
t1 * +2 # segment 1
+2 t2 100 # segment 2
t1 * # segment 3
t2 *-* # segment 4
t1 3 -* # segment 5
+0.111111 t2 102.5 # segment 6
7.37 t1 5 +1 # segment 7
----- end -----
This rather pathological example illustrates the rules for filling in
implied data. All the values can be determined by recursively applying
the rules given above, and the full end result is this:
+2 0-2 t1 0-2 # segment 1
+2 2-4 t2 100-102 # segment 2
+0.758889 4-4.758889 t1 2-2.758889 # segment 3
+0.5 4.4758889-5.258889 t2 102-102.5 # segment 4
+2 5.258889-7.258889 t1 3-5 # segment 5
+0.111111 7.258889-7.37 t2 102.5-102.611111 # segment 6
+1 7.37-8.37 t1 5-6 # segment 7
2011-02-14 11:05:35 +00:00
|
|
|
// timeline/tl_edl.c
|
|
|
|
void build_edl_timeline(struct MPContext *mpctx);
|
2012-01-01 16:45:24 +00:00
|
|
|
// timeline/tl_cue.c
|
|
|
|
void build_cue_timeline(struct MPContext *mpctx);
|
2011-02-14 07:34:39 +00:00
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_MP_CORE_H */
|