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>
|
|
|
|
|
2008-03-31 03:19:29 +00:00
|
|
|
#include "options.h"
|
2008-03-04 23:35:24 +00:00
|
|
|
#include "mixer.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"
|
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_VOBSUB 256
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
|
|
#define SUB_SOURCE_SUBS 0
|
|
|
|
#define SUB_SOURCE_VOBSUB 1
|
|
|
|
#define SUB_SOURCE_DEMUX 2
|
|
|
|
#define SUB_SOURCES 3
|
|
|
|
|
|
|
|
|
2008-08-13 05:06:26 +00:00
|
|
|
enum stop_play_reason {
|
|
|
|
KEEP_PLAYING = 0, // must be 0, numeric values of others do not matter
|
|
|
|
AT_END_OF_FILE,
|
|
|
|
PT_NEXT_ENTRY,
|
|
|
|
PT_PREV_ENTRY,
|
|
|
|
PT_NEXT_SRC,
|
|
|
|
PT_PREV_SRC,
|
|
|
|
PT_UP_NEXT,
|
|
|
|
PT_UP_PREV,
|
|
|
|
PT_STOP,
|
|
|
|
};
|
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 content_source {
|
|
|
|
struct stream *stream;
|
|
|
|
struct demuxer *demuxer;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct timeline_part {
|
|
|
|
double start;
|
|
|
|
double source_start;
|
|
|
|
struct content_source *source;
|
|
|
|
};
|
|
|
|
|
2009-04-02 02:00:22 +00:00
|
|
|
struct chapter {
|
|
|
|
double start;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
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-20 04:36:34 +00:00
|
|
|
struct vo_x11_state *x11_state;
|
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-01-06 18:48:50 +00:00
|
|
|
char *terminal_osd_text;
|
2011-01-11 15:48:45 +00:00
|
|
|
struct sub_data *subdata; // current sub_data style subtitles if any
|
|
|
|
// last sub_data style sub line if any, used by log_sub() only
|
|
|
|
struct subtitle *vo_sub_last;
|
2009-03-30 00:13:17 +00:00
|
|
|
|
|
|
|
bool add_osd_seek_info;
|
|
|
|
// if nonzero, hide current OSD contents when GetTimerMS() reaches this
|
|
|
|
unsigned int osd_show_percentage_until;
|
|
|
|
unsigned int osd_visible;
|
|
|
|
|
2007-02-21 00:49:24 +00:00
|
|
|
int osd_function;
|
2008-04-23 06:49:25 +00:00
|
|
|
struct play_tree *playtree;
|
|
|
|
struct play_tree_iter *playtree_iter;
|
2008-04-26 12:17:51 +00:00
|
|
|
char *filename; // currently playing file
|
2008-08-13 05:06:26 +00:00
|
|
|
enum stop_play_reason stop_play;
|
2007-02-21 00:49:24 +00:00
|
|
|
int play_tree_step;
|
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
|
|
|
|
2009-03-29 19:45:06 +00:00
|
|
|
struct content_source *sources;
|
|
|
|
int num_sources;
|
|
|
|
struct timeline_part *timeline;
|
|
|
|
int num_timeline_parts;
|
|
|
|
int timeline_part;
|
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;
|
2008-04-23 06:49:25 +00:00
|
|
|
struct sh_audio *sh_audio;
|
|
|
|
struct sh_video *sh_video;
|
|
|
|
struct demux_stream *d_audio;
|
|
|
|
struct demux_stream *d_video;
|
|
|
|
struct demux_stream *d_sub;
|
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;
|
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;
|
|
|
|
|
2007-02-22 20:44:48 +00:00
|
|
|
float begin_skip; ///< start time of the current skip while on edlout mode
|
2007-02-21 00:49:24 +00:00
|
|
|
|
|
|
|
int global_sub_size; // this encompasses all subtitle sources
|
|
|
|
int global_sub_pos; // this encompasses all subtitle sources
|
|
|
|
int set_of_sub_pos;
|
|
|
|
int set_of_sub_size;
|
2010-07-10 20:48:50 +00:00
|
|
|
int sub_counts[SUB_SOURCES];
|
2007-02-21 00:49:24 +00:00
|
|
|
// set_of_ass_tracks[i] contains subtitles from set_of_subtitles[i]
|
|
|
|
// parsed by libass or NULL if format unsupported
|
2009-07-28 22:11:33 +00:00
|
|
|
struct ass_track *set_of_ass_tracks[MAX_SUBTITLE_FILES];
|
2007-02-21 00:49:24 +00:00
|
|
|
sub_data* set_of_subtitles[MAX_SUBTITLE_FILES];
|
2011-01-19 18:13:48 +00:00
|
|
|
bool track_was_native_ass[MAX_SUBTITLE_FILES];
|
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-01-06 18:32:03 +00:00
|
|
|
bool status_printed;
|
|
|
|
int paused_cache_fill;
|
|
|
|
|
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;
|
|
|
|
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_DVDNAV
|
2008-04-24 02:49:44 +00:00
|
|
|
struct mp_image *nav_smpi; ///< last decoded dvdnav video image
|
2008-01-26 11:51:34 +00:00
|
|
|
unsigned char *nav_buffer; ///< last read dvdnav video frame
|
|
|
|
unsigned char *nav_start; ///< pointer to last read video buffer
|
|
|
|
int nav_in_size; ///< last read size
|
|
|
|
#endif
|
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);
|
2010-03-09 21:18:19 +00:00
|
|
|
void exit_player_with_rc(struct MPContext *mpctx, enum exit_reason how, int rc);
|
2008-04-21 03:07:22 +00:00
|
|
|
void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr);
|
|
|
|
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);
|
timeline: subs: keep subtitle tracks in source time
Timeline handling converted the pts values from demuxed subtitles to
timeline scale. Change the code to do most subtitle handling in
original subtitle source pts, and instead convert current playback
timeline pts to those units when deciding which subtitle to show.
The main functionality changes are that now demuxed subtitles which
overlap chapter boundaries are handled correctly (at least for libass
subtitles), and external subtitles are assumed to use same pts scale
as current source (this needs improvements later).
Before, a video subtitle that had a duration continuing past the end
of the chapter would continue to be shown for the original duration,
even if the chapter ended and playback switched to a position in the
source where the subtitle shouldn't exist. Now, the subtitle will
correctly end.
Before, external subtitle files were interpreted as specifying pts
values in timeline scale. Now, they're interpreted as specifying pts
values in source file time scale, for _every_ source file. This is
probably more likely to be what the user wants for the "main" source
file in case there is one, but almost certainly not quite right for
multiple source files where the same subs could be shown over
different scenes. If the user wants them to match some main source
file, it's probably still better to have incorrect extra subs for
video from some files than to have every subtitle appearing at the
wrong time. The new code makes it easier to change the interpretation
of the subtitle times, and some configurability should be added in
the future.
2012-03-20 00:54:19 +00:00
|
|
|
void update_subtitles(struct MPContext *mpctx, double refpts, bool reset);
|
2008-01-01 21:35:58 +00:00
|
|
|
|
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 */
|