1.1.2
by Reinhard Tartler
Import upstream version 2.0-134-g84d8671 |
1 |
/*
|
2 |
* This file is part of MPlayer.
|
|
3 |
*
|
|
4 |
* MPlayer is free software; you can redistribute it and/or modify
|
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
6 |
* the Free Software Foundation; either version 2 of the License, or
|
|
7 |
* (at your option) any later version.
|
|
8 |
*
|
|
9 |
* MPlayer is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License along
|
|
15 |
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
16 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
17 |
*/
|
|
18 |
||
19 |
#ifndef MPLAYER_MP_CORE_H
|
|
20 |
#define MPLAYER_MP_CORE_H
|
|
21 |
||
22 |
#include <stdbool.h> |
|
23 |
||
24 |
#include "options.h" |
|
25 |
#include "mixer.h" |
|
26 |
#include "sub/subreader.h" |
|
27 |
#include "sub/find_subfiles.h" |
|
28 |
||
29 |
// definitions used internally by the core player code
|
|
30 |
||
31 |
#define INITIALIZED_VO 1
|
|
32 |
#define INITIALIZED_AO 2
|
|
33 |
||
34 |
#define INITIALIZED_GETCH2 8
|
|
35 |
#define INITIALIZED_SPUDEC 32
|
|
36 |
#define INITIALIZED_STREAM 64
|
|
37 |
#define INITIALIZED_VOBSUB 256
|
|
38 |
#define INITIALIZED_DEMUXER 512
|
|
39 |
#define INITIALIZED_ACODEC 1024
|
|
40 |
#define INITIALIZED_VCODEC 2048
|
|
41 |
#define INITIALIZED_SUB 4096
|
|
42 |
#define INITIALIZED_ALL 0xFFFF
|
|
43 |
||
44 |
||
45 |
#define SUB_SOURCE_SUBS 0
|
|
46 |
#define SUB_SOURCE_VOBSUB 1
|
|
47 |
#define SUB_SOURCE_DEMUX 2
|
|
48 |
#define SUB_SOURCES 3
|
|
49 |
||
50 |
||
51 |
enum stop_play_reason { |
|
52 |
KEEP_PLAYING = 0, // must be 0, numeric values of others do not matter |
|
53 |
AT_END_OF_FILE, |
|
54 |
PT_NEXT_ENTRY, |
|
55 |
PT_PREV_ENTRY, |
|
56 |
PT_NEXT_SRC, |
|
57 |
PT_PREV_SRC, |
|
58 |
PT_UP_NEXT, |
|
59 |
PT_UP_PREV, |
|
60 |
PT_STOP, |
|
61 |
};
|
|
62 |
||
63 |
enum exit_reason { |
|
64 |
EXIT_NONE, |
|
65 |
EXIT_QUIT, |
|
66 |
EXIT_EOF, |
|
67 |
EXIT_ERROR
|
|
68 |
};
|
|
69 |
||
70 |
struct content_source { |
|
71 |
struct stream *stream; |
|
72 |
struct demuxer *demuxer; |
|
73 |
};
|
|
74 |
||
75 |
struct timeline_part { |
|
76 |
double start; |
|
77 |
double source_start; |
|
78 |
struct content_source *source; |
|
79 |
};
|
|
80 |
||
81 |
struct chapter { |
|
82 |
double start; |
|
83 |
char *name; |
|
84 |
};
|
|
85 |
||
86 |
typedef struct MPContext { |
|
87 |
struct MPOpts opts; |
|
88 |
struct m_config *mconfig; |
|
89 |
struct vo_x11_state *x11_state; |
|
90 |
struct mp_fifo *key_fifo; |
|
91 |
struct input_ctx *input; |
|
92 |
struct osd_state *osd; |
|
93 |
struct sub_data *subdata; // current sub_data style subtitles if any |
|
94 |
// last sub_data style sub line if any, used by log_sub() only
|
|
95 |
struct subtitle *vo_sub_last; |
|
96 |
||
97 |
bool add_osd_seek_info; |
|
98 |
// if nonzero, hide current OSD contents when GetTimerMS() reaches this
|
|
99 |
unsigned int osd_show_percentage_until; |
|
100 |
unsigned int osd_visible; |
|
101 |
||
102 |
int osd_function; |
|
103 |
struct play_tree *playtree; |
|
104 |
struct play_tree_iter *playtree_iter; |
|
105 |
char *filename; // currently playing file |
|
106 |
enum stop_play_reason stop_play; |
|
107 |
int play_tree_step; |
|
108 |
unsigned int initialized_flags; // which subsystems have been initialized |
|
109 |
||
110 |
struct content_source *sources; |
|
111 |
int num_sources; |
|
112 |
struct timeline_part *timeline; |
|
113 |
int num_timeline_parts; |
|
114 |
int timeline_part; |
|
115 |
struct chapter *chapters; |
|
116 |
int num_chapters; |
|
117 |
double video_offset; |
|
118 |
||
119 |
struct stream *stream; |
|
120 |
struct demuxer *demuxer; |
|
121 |
struct sh_audio *sh_audio; |
|
122 |
struct sh_video *sh_video; |
|
123 |
struct demux_stream *d_audio; |
|
124 |
struct demux_stream *d_video; |
|
125 |
struct demux_stream *d_sub; |
|
126 |
mixer_t mixer; |
|
127 |
struct ao *ao; |
|
128 |
struct vo *video_out; |
|
129 |
||
130 |
/* We're starting playback from scratch or after a seek. Show first
|
|
131 |
* video frame immediately and reinitialize sync. */
|
|
132 |
bool restart_playback; |
|
133 |
/* After playback restart (above) or audio stream change, adjust audio
|
|
134 |
* stream by cutting samples or adding silence at the beginning to make
|
|
135 |
* audio playback position match video position. */
|
|
136 |
bool syncing_audio; |
|
137 |
bool hrseek_active; |
|
138 |
bool hrseek_framedrop; |
|
139 |
double hrseek_pts; |
|
140 |
// AV sync: the next frame should be shown when the audio out has this
|
|
141 |
// much (in seconds) buffered data left. Increased when more data is
|
|
142 |
// written to the ao, decreased when moving to the next frame.
|
|
143 |
// In the audio-only case used as a timer since the last seek
|
|
144 |
// by the audio CPU usage meter.
|
|
145 |
double delay; |
|
146 |
// AV sync: time until next frame should be shown
|
|
147 |
float time_frame; |
|
148 |
// How long the last vo flip() call took. Used to adjust timing with
|
|
149 |
// the goal of making flip() calls finish (rather than start) at the
|
|
150 |
// specified time.
|
|
151 |
float last_vo_flip_duration; |
|
152 |
// How much video timing has been changed to make it match the audio
|
|
153 |
// timeline. Used for status line information only.
|
|
154 |
double total_avsync_change; |
|
155 |
// A-V sync difference when last frame was displayed. Kept to display
|
|
156 |
// the same value if the status line is updated at a time where no new
|
|
157 |
// video frame is shown.
|
|
158 |
double last_av_difference; |
|
159 |
/* timestamp of video frame currently visible on screen
|
|
160 |
* (or at least queued to be flipped by VO) */
|
|
161 |
double video_pts; |
|
1.1.3
by Reinhard Tartler
Import upstream version 2.0-426-gc32b3ed |
162 |
double last_seek_pts; |
1.1.2
by Reinhard Tartler
Import upstream version 2.0-134-g84d8671 |
163 |
|
164 |
// used to prevent hanging in some error cases
|
|
165 |
unsigned int start_timestamp; |
|
166 |
||
167 |
// Timestamp from the last time some timing functions read the
|
|
168 |
// current time, in (occasionally wrapping) microseconds. Used
|
|
169 |
// to turn a new time value to a delta from last time.
|
|
170 |
unsigned int last_time; |
|
171 |
||
172 |
// Used to communicate the parameters of a seek between parts
|
|
173 |
struct seek_params { |
|
174 |
enum seek_type { |
|
175 |
MPSEEK_NONE, MPSEEK_RELATIVE, MPSEEK_ABSOLUTE, MPSEEK_FACTOR |
|
176 |
} type; |
|
177 |
double amount; |
|
178 |
int exact; // -1 = disable, 0 = default, 1 = enable |
|
179 |
// currently not set by commands, only used internally by seek()
|
|
180 |
int direction; // -1 = backward, 0 = default, 1 = forward |
|
181 |
} seek; |
|
182 |
||
183 |
/* Heuristic for relative chapter seeks: keep track which chapter
|
|
184 |
* the user wanted to go to, even if we aren't exactly within the
|
|
185 |
* boundaries of that chapter due to an inaccurate seek. */
|
|
186 |
int last_chapter_seek; |
|
187 |
double last_chapter_pts; |
|
188 |
||
189 |
float begin_skip; ///< start time of the current skip while on edlout mode |
|
190 |
// audio is muted if either EDL or user activates mute
|
|
191 |
short edl_muted; ///< Stores whether EDL is currently in muted mode. |
|
192 |
short user_muted; ///< Stores whether user wanted muted mode. |
|
193 |
||
194 |
int global_sub_size; // this encompasses all subtitle sources |
|
195 |
int global_sub_pos; // this encompasses all subtitle sources |
|
196 |
int set_of_sub_pos; |
|
197 |
int set_of_sub_size; |
|
198 |
int sub_counts[SUB_SOURCES]; |
|
199 |
// set_of_ass_tracks[i] contains subtitles from set_of_subtitles[i]
|
|
200 |
// parsed by libass or NULL if format unsupported
|
|
201 |
struct ass_track *set_of_ass_tracks[MAX_SUBTITLE_FILES]; |
|
202 |
sub_data* set_of_subtitles[MAX_SUBTITLE_FILES]; |
|
203 |
bool track_was_native_ass[MAX_SUBTITLE_FILES]; |
|
1.1.3
by Reinhard Tartler
Import upstream version 2.0-426-gc32b3ed |
204 |
struct ass_library *ass_library; |
1.1.2
by Reinhard Tartler
Import upstream version 2.0-134-g84d8671 |
205 |
|
206 |
int file_format; |
|
207 |
||
208 |
int last_dvb_step; |
|
209 |
int dvbin_reopen; |
|
210 |
||
211 |
int paused; |
|
212 |
// step this many frames, then pause
|
|
213 |
int step_frames; |
|
214 |
||
215 |
// Set after showing warning about decoding being too slow for realtime
|
|
216 |
// playback rate. Used to avoid showing it multiple times.
|
|
217 |
bool drop_message_shown; |
|
218 |
||
1.1.3
by Reinhard Tartler
Import upstream version 2.0-426-gc32b3ed |
219 |
struct screenshot_ctx *screenshot_ctx; |
220 |
||
1.1.2
by Reinhard Tartler
Import upstream version 2.0-134-g84d8671 |
221 |
#ifdef CONFIG_DVDNAV
|
222 |
struct mp_image *nav_smpi; ///< last decoded dvdnav video image |
|
223 |
unsigned char *nav_buffer; ///< last read dvdnav video frame |
|
224 |
unsigned char *nav_start; ///< pointer to last read video buffer |
|
225 |
int nav_in_size; ///< last read size |
|
226 |
#endif
|
|
227 |
} MPContext; |
|
228 |
||
229 |
||
1.1.3
by Reinhard Tartler
Import upstream version 2.0-426-gc32b3ed |
230 |
// should not be global
|
1.1.2
by Reinhard Tartler
Import upstream version 2.0-134-g84d8671 |
231 |
extern FILE *edl_fd; |
232 |
// These appear in options list
|
|
233 |
extern int forced_subs_only; |
|
234 |
||
235 |
void uninit_player(struct MPContext *mpctx, unsigned int mask); |
|
236 |
void reinit_audio_chain(struct MPContext *mpctx); |
|
237 |
void init_vo_spudec(struct MPContext *mpctx); |
|
238 |
double playing_audio_pts(struct MPContext *mpctx); |
|
239 |
void exit_player_with_rc(struct MPContext *mpctx, enum exit_reason how, int rc); |
|
240 |
void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr); |
|
241 |
int reinit_video_chain(struct MPContext *mpctx); |
|
242 |
void pause_player(struct MPContext *mpctx); |
|
243 |
void unpause_player(struct MPContext *mpctx); |
|
244 |
void add_step_frame(struct MPContext *mpctx); |
|
245 |
void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount, |
|
246 |
int exact); |
|
1.1.3
by Reinhard Tartler
Import upstream version 2.0-426-gc32b3ed |
247 |
int seek_chapter(struct MPContext *mpctx, int chapter, double *seek_pts); |
1.1.2
by Reinhard Tartler
Import upstream version 2.0-134-g84d8671 |
248 |
double get_time_length(struct MPContext *mpctx); |
249 |
double get_current_time(struct MPContext *mpctx); |
|
250 |
int get_percent_pos(struct MPContext *mpctx); |
|
251 |
int get_current_chapter(struct MPContext *mpctx); |
|
252 |
char *chapter_display_name(struct MPContext *mpctx, int chapter); |
|
1.1.3
by Reinhard Tartler
Import upstream version 2.0-426-gc32b3ed |
253 |
char *chapter_name(struct MPContext *mpctx, int chapter); |
254 |
double chapter_start_time(struct MPContext *mpctx, int chapter); |
|
255 |
int get_chapter_count(struct MPContext *mpctx); |
|
1.1.2
by Reinhard Tartler
Import upstream version 2.0-134-g84d8671 |
256 |
void update_subtitles(struct MPContext *mpctx, double refpts, |
257 |
double sub_offset, bool reset); |
|
258 |
||
259 |
||
260 |
// timeline/tl_matroska.c
|
|
261 |
void build_ordered_chapter_timeline(struct MPContext *mpctx); |
|
262 |
// timeline/tl_edl.c
|
|
263 |
void build_edl_timeline(struct MPContext *mpctx); |
|
264 |
||
265 |
#endif /* MPLAYER_MP_CORE_H */ |