2 * This file is part of MPlayer.
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.
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.
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.
19 #ifndef MPLAYER_MP_CORE_H
20 #define MPLAYER_MP_CORE_H
26 #include "subreader.h"
28 // definitions used internally by the core player code
30 #define INITIALIZED_VO 1
31 #define INITIALIZED_AO 2
33 #define INITIALIZED_GETCH2 8
34 #define INITIALIZED_SPUDEC 32
35 #define INITIALIZED_STREAM 64
36 #define INITIALIZED_VOBSUB 256
37 #define INITIALIZED_DEMUXER 512
38 #define INITIALIZED_ACODEC 1024
39 #define INITIALIZED_VCODEC 2048
40 #define INITIALIZED_ALL 0xFFFF
43 #define SUB_SOURCE_SUBS 0
44 #define SUB_SOURCE_VOBSUB 1
45 #define SUB_SOURCE_DEMUX 2
49 enum stop_play_reason
{
50 KEEP_PLAYING
= 0, // must be 0, numeric values of others do not matter
68 struct content_source
{
69 struct stream
*stream
;
70 struct demuxer
*demuxer
;
73 struct timeline_part
{
76 struct content_source
*source
;
84 typedef struct MPContext
{
86 struct m_config
*mconfig
;
87 struct vo_x11_state
*x11_state
;
88 struct mp_fifo
*key_fifo
;
89 struct input_ctx
*input
;
90 struct osd_state
*osd
;
92 bool add_osd_seek_info
;
93 // if nonzero, hide current OSD contents when GetTimerMS() reaches this
94 unsigned int osd_show_percentage_until
;
95 unsigned int osd_visible
;
98 const ao_functions_t
*audio_out
;
99 struct play_tree
*playtree
;
100 struct play_tree_iter
*playtree_iter
;
101 char *filename
; // currently playing file
102 enum stop_play_reason stop_play
;
104 unsigned int initialized_flags
; // which subsystems have been initialized
106 struct content_source
*sources
;
108 struct timeline_part
*timeline
;
109 int num_timeline_parts
;
111 struct chapter
*chapters
;
115 struct stream
*stream
;
116 struct demuxer
*demuxer
;
117 struct sh_audio
*sh_audio
;
118 struct sh_video
*sh_video
;
119 struct demux_stream
*d_audio
;
120 struct demux_stream
*d_video
;
121 struct demux_stream
*d_sub
;
123 struct vo
*video_out
;
125 // Show a video frame as quickly as possible without trying to adjust
126 // for AV sync. Used when starting a file or after seeking.
127 bool update_video_immediately
;
128 // AV sync: the next frame should be shown when the audio out has this
129 // much (in seconds) buffered data left. Increased when more data is
130 // written to the ao, decreased when moving to the next frame.
131 // In the audio-only case used as a timer since the last seek
132 // by the audio CPU usage meter.
134 // AV sync: time until next frame should be shown
136 // How long the last vo flip() call took. Used to adjust timing with
137 // the goal of making flip() calls finish (rather than start) at the
139 float last_vo_flip_duration
;
140 // How much video timing has been changed to make it match the audio
141 // timeline. Used for status line information only.
142 double total_avsync_change
;
143 // A-V sync difference when last frame was displayed. Kept to display
144 // the same value if the status line is updated at a time where no new
145 // video frame is shown.
146 double last_av_difference
;
148 // Timestamp from the last time some timing functions read the
149 // current time, in (occasionally wrapping) microseconds. Used
150 // to turn a new time value to a delta from last time.
151 unsigned int last_time
;
153 // Used to communicate the parameters of a seek between parts
154 double rel_seek_secs
;
157 /* Heuristic for relative chapter seeks: keep track which chapter
158 * the user wanted to go to, even if we aren't exactly within the
159 * boundaries of that chapter due to an inaccurate seek. */
160 int last_chapter_seek
;
161 double last_chapter_pts
;
163 float begin_skip
; ///< start time of the current skip while on edlout mode
164 // audio is muted if either EDL or user activates mute
165 short edl_muted
; ///< Stores whether EDL is currently in muted mode.
166 short user_muted
; ///< Stores whether user wanted muted mode.
168 int global_sub_size
; // this encompasses all subtitle sources
169 int global_sub_pos
; // this encompasses all subtitle sources
172 int global_sub_indices
[SUB_SOURCES
];
173 // set_of_ass_tracks[i] contains subtitles from set_of_subtitles[i]
174 // parsed by libass or NULL if format unsupported
175 struct ass_track
*set_of_ass_tracks
[MAX_SUBTITLE_FILES
];
176 sub_data
* set_of_subtitles
[MAX_SUBTITLE_FILES
];
184 // step this many frames, then pause
187 // Set after showing warning about decoding being too slow for realtime
188 // playback rate. Used to avoid showing it multiple times.
189 bool drop_message_shown
;
192 struct mp_image
*nav_smpi
; ///< last decoded dvdnav video image
193 unsigned char *nav_buffer
; ///< last read dvdnav video frame
194 unsigned char *nav_start
; ///< pointer to last read video buffer
195 int nav_in_size
; ///< last read size
200 // Most of these should not be globals
202 extern int file_filter
;
203 // These appear in options list
204 extern int forced_subs_only
;
207 int build_afilter_chain(struct MPContext
*mpctx
, struct sh_audio
*sh_audio
, struct ao_data
*ao_data
);
208 void uninit_player(struct MPContext
*mpctx
, unsigned int mask
);
209 void reinit_audio_chain(struct MPContext
*mpctx
);
210 void init_vo_spudec(struct MPContext
*mpctx
);
211 double playing_audio_pts(struct MPContext
*mpctx
);
212 void exit_player_with_rc(struct MPContext
*mpctx
, enum exit_reason how
, int rc
);
213 void add_subtitles(struct MPContext
*mpctx
, char *filename
, float fps
, int noerr
);
214 int reinit_video_chain(struct MPContext
*mpctx
);
215 void pause_player(struct MPContext
*mpctx
);
216 void unpause_player(struct MPContext
*mpctx
);
217 void add_step_frame(struct MPContext
*mpctx
);
218 int seek_chapter(struct MPContext
*mpctx
, int chapter
, double *seek_pts
,
219 char **chapter_name
);
220 int get_current_chapter(struct MPContext
*mpctx
);
221 char *chapter_display_name(struct MPContext
*mpctx
, int chapter
);
223 #endif /* MPLAYER_MP_CORE_H */