core: Clean up OSD seek info logic
[mplayer.git] / mp_core.h
blob13c8f149f08b9c0e5583b0e7f881b4e00db7d4b5
1 #ifndef MPLAYER_MP_CORE_H
2 #define MPLAYER_MP_CORE_H
4 #include <stdbool.h>
6 #include "options.h"
7 #include "mixer.h"
8 #include "subreader.h"
10 // definitions used internally by the core player code
12 #define INITIALIZED_VO 1
13 #define INITIALIZED_AO 2
14 #define INITIALIZED_GUI 4
15 #define INITIALIZED_GETCH2 8
16 #define INITIALIZED_SPUDEC 32
17 #define INITIALIZED_STREAM 64
18 #define INITIALIZED_VOBSUB 256
19 #define INITIALIZED_DEMUXER 512
20 #define INITIALIZED_ACODEC 1024
21 #define INITIALIZED_VCODEC 2048
22 #define INITIALIZED_ALL 0xFFFF
25 #define SUB_SOURCE_SUBS 0
26 #define SUB_SOURCE_VOBSUB 1
27 #define SUB_SOURCE_DEMUX 2
28 #define SUB_SOURCES 3
31 enum stop_play_reason {
32 KEEP_PLAYING = 0, // must be 0, numeric values of others do not matter
33 AT_END_OF_FILE,
34 PT_NEXT_ENTRY,
35 PT_PREV_ENTRY,
36 PT_NEXT_SRC,
37 PT_PREV_SRC,
38 PT_UP_NEXT,
39 PT_UP_PREV,
40 PT_STOP,
43 typedef enum {
44 EXIT_NONE,
45 EXIT_QUIT,
46 EXIT_EOF,
47 EXIT_ERROR
48 } exit_reason_t;
50 typedef struct MPContext {
51 struct MPOpts opts;
52 struct m_config *mconfig;
53 struct vo_x11_state *x11_state;
54 struct mp_fifo *key_fifo;
55 struct input_ctx *input;
56 struct osd_state *osd;
58 bool add_osd_seek_info;
59 // if nonzero, hide current OSD contents when GetTimerMS() reaches this
60 unsigned int osd_show_percentage_until;
61 unsigned int osd_visible;
63 int osd_function;
64 const ao_functions_t *audio_out;
65 struct play_tree *playtree;
66 struct play_tree_iter *playtree_iter;
67 char *filename; // currently playing file
68 enum stop_play_reason stop_play;
69 int play_tree_step;
70 unsigned int initialized_flags; // which subsystems have been initialized
72 struct stream *stream;
73 struct demuxer *demuxer;
74 struct sh_audio *sh_audio;
75 struct sh_video *sh_video;
76 struct demux_stream *d_audio;
77 struct demux_stream *d_video;
78 struct demux_stream *d_sub;
79 mixer_t mixer;
80 struct vo *video_out;
81 // Frames buffered in the vo ready to flip. Currently always 0 or 1.
82 // This is really a vo variable but currently there's no suitable vo
83 // struct.
84 int num_buffered_frames;
86 // Show a video frame as quickly as possible without trying to adjust
87 // for AV sync. Used when starting a file or after seeking.
88 bool update_video_immediately;
89 // AV sync: the next frame should be shown when the audio out has this
90 // much (in seconds) buffered data left. Increased when more data is
91 // written to the ao, decreased when moving to the next frame.
92 // In the audio-only case used as a timer since the last seek
93 // by the audio CPU usage meter.
94 double delay;
95 // AV sync: time until next frame should be shown
96 float time_frame;
97 // How long the last vo flip() call took. Used to adjust timing with
98 // the goal of making flip() calls finish (rather than start) at the
99 // specified time.
100 float last_vo_flip_duration;
101 // How much video timing has been changed to make it match the audio
102 // timeline. Used for status line information only.
103 double total_avsync_change;
104 // A-V sync difference when last frame was displayed. Kept to display
105 // the same value if the status line is updated at a time where no new
106 // video frame is shown.
107 double last_av_difference;
109 // Timestamp from the last time some timing functions read the
110 // current time, in (occasionally wrapping) microseconds. Used
111 // to turn a new time value to a delta from last time.
112 unsigned int last_time;
114 // Used to communicate the parameters of a seek between parts
115 float rel_seek_secs;
116 int abs_seek_pos;
118 float begin_skip; ///< start time of the current skip while on edlout mode
119 // audio is muted if either EDL or user activates mute
120 short edl_muted; ///< Stores whether EDL is currently in muted mode.
121 short user_muted; ///< Stores whether user wanted muted mode.
123 int global_sub_size; // this encompasses all subtitle sources
124 int global_sub_pos; // this encompasses all subtitle sources
125 int set_of_sub_pos;
126 int set_of_sub_size;
127 int global_sub_indices[SUB_SOURCES];
128 // set_of_ass_tracks[i] contains subtitles from set_of_subtitles[i]
129 // parsed by libass or NULL if format unsupported
130 struct ass_track_s *set_of_ass_tracks[MAX_SUBTITLE_FILES];
131 sub_data* set_of_subtitles[MAX_SUBTITLE_FILES];
133 int file_format;
135 int last_dvb_step;
136 int dvbin_reopen;
138 int paused;
139 // step this many frames, then pause
140 int step_frames;
142 // Set after showing warning about decoding being too slow for realtime
143 // playback rate. Used to avoid showing it multiple times.
144 bool drop_message_shown;
146 #ifdef CONFIG_DVDNAV
147 struct mp_image *nav_smpi; ///< last decoded dvdnav video image
148 unsigned char *nav_buffer; ///< last read dvdnav video frame
149 unsigned char *nav_start; ///< pointer to last read video buffer
150 int nav_in_size; ///< last read size
151 #endif
152 } MPContext;
155 // Most of these should not be globals
156 extern FILE *edl_fd;
157 extern int file_filter;
158 // These appear in options list
159 extern int forced_subs_only;
161 struct ao_data;
162 int build_afilter_chain(struct MPContext *mpctx, struct sh_audio *sh_audio, struct ao_data *ao_data);
163 void uninit_player(struct MPContext *mpctx, unsigned int mask);
164 void reinit_audio_chain(struct MPContext *mpctx);
165 void init_vo_spudec(struct MPContext *mpctx);
166 double playing_audio_pts(struct MPContext *mpctx);
167 void exit_player_with_rc(struct MPContext *mpctx, exit_reason_t how, int rc);
168 void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr);
169 int reinit_video_chain(struct MPContext *mpctx);
170 void pause_player(struct MPContext *mpctx);
171 void unpause_player(struct MPContext *mpctx);
172 void add_step_frame(struct MPContext *mpctx);
174 #endif /* MPLAYER_MP_CORE_H */