Remove trailing whitespace from most files
[mplayer/glamo.git] / mp_core.h
blob5b3f9543661d284bc1b7cda6c7b3b94dfd33c190
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 struct content_source {
51 struct stream *stream;
52 struct demuxer *demuxer;
55 struct timeline_part {
56 double start;
57 double source_start;
58 struct content_source *source;
61 struct chapter {
62 double start;
63 char *name;
66 typedef struct MPContext {
67 struct MPOpts opts;
68 struct m_config *mconfig;
69 struct vo_x11_state *x11_state;
70 struct mp_fifo *key_fifo;
71 struct input_ctx *input;
72 struct osd_state *osd;
74 bool add_osd_seek_info;
75 // if nonzero, hide current OSD contents when GetTimerMS() reaches this
76 unsigned int osd_show_percentage_until;
77 unsigned int osd_visible;
79 int osd_function;
80 const ao_functions_t *audio_out;
81 struct play_tree *playtree;
82 struct play_tree_iter *playtree_iter;
83 char *filename; // currently playing file
84 enum stop_play_reason stop_play;
85 int play_tree_step;
86 unsigned int initialized_flags; // which subsystems have been initialized
88 struct content_source *sources;
89 int num_sources;
90 struct timeline_part *timeline;
91 int num_timeline_parts;
92 int timeline_part;
93 struct chapter *chapters;
94 int num_chapters;
95 double video_offset;
97 struct stream *stream;
98 struct demuxer *demuxer;
99 struct sh_audio *sh_audio;
100 struct sh_video *sh_video;
101 struct demux_stream *d_audio;
102 struct demux_stream *d_video;
103 struct demux_stream *d_sub;
104 mixer_t mixer;
105 struct vo *video_out;
106 // Frames buffered in the vo ready to flip. Currently always 0 or 1.
107 // This is really a vo variable but currently there's no suitable vo
108 // struct.
109 int num_buffered_frames;
111 // Show a video frame as quickly as possible without trying to adjust
112 // for AV sync. Used when starting a file or after seeking.
113 bool update_video_immediately;
114 // AV sync: the next frame should be shown when the audio out has this
115 // much (in seconds) buffered data left. Increased when more data is
116 // written to the ao, decreased when moving to the next frame.
117 // In the audio-only case used as a timer since the last seek
118 // by the audio CPU usage meter.
119 double delay;
120 // AV sync: time until next frame should be shown
121 float time_frame;
122 // How long the last vo flip() call took. Used to adjust timing with
123 // the goal of making flip() calls finish (rather than start) at the
124 // specified time.
125 float last_vo_flip_duration;
126 // How much video timing has been changed to make it match the audio
127 // timeline. Used for status line information only.
128 double total_avsync_change;
129 // A-V sync difference when last frame was displayed. Kept to display
130 // the same value if the status line is updated at a time where no new
131 // video frame is shown.
132 double last_av_difference;
134 // Timestamp from the last time some timing functions read the
135 // current time, in (occasionally wrapping) microseconds. Used
136 // to turn a new time value to a delta from last time.
137 unsigned int last_time;
139 // Used to communicate the parameters of a seek between parts
140 double rel_seek_secs;
141 int abs_seek_pos;
143 float begin_skip; ///< start time of the current skip while on edlout mode
144 // audio is muted if either EDL or user activates mute
145 short edl_muted; ///< Stores whether EDL is currently in muted mode.
146 short user_muted; ///< Stores whether user wanted muted mode.
148 int global_sub_size; // this encompasses all subtitle sources
149 int global_sub_pos; // this encompasses all subtitle sources
150 int set_of_sub_pos;
151 int set_of_sub_size;
152 int global_sub_indices[SUB_SOURCES];
153 // set_of_ass_tracks[i] contains subtitles from set_of_subtitles[i]
154 // parsed by libass or NULL if format unsupported
155 struct ass_track_s *set_of_ass_tracks[MAX_SUBTITLE_FILES];
156 sub_data* set_of_subtitles[MAX_SUBTITLE_FILES];
158 int file_format;
160 int last_dvb_step;
161 int dvbin_reopen;
163 int paused;
164 // step this many frames, then pause
165 int step_frames;
167 // Set after showing warning about decoding being too slow for realtime
168 // playback rate. Used to avoid showing it multiple times.
169 bool drop_message_shown;
171 #ifdef CONFIG_DVDNAV
172 struct mp_image *nav_smpi; ///< last decoded dvdnav video image
173 unsigned char *nav_buffer; ///< last read dvdnav video frame
174 unsigned char *nav_start; ///< pointer to last read video buffer
175 int nav_in_size; ///< last read size
176 #endif
177 } MPContext;
180 // Most of these should not be globals
181 extern FILE *edl_fd;
182 extern int file_filter;
183 // These appear in options list
184 extern int forced_subs_only;
186 struct ao_data;
187 int build_afilter_chain(struct MPContext *mpctx, struct sh_audio *sh_audio, struct ao_data *ao_data);
188 void uninit_player(struct MPContext *mpctx, unsigned int mask);
189 void reinit_audio_chain(struct MPContext *mpctx);
190 void init_vo_spudec(struct MPContext *mpctx);
191 double playing_audio_pts(struct MPContext *mpctx);
192 void exit_player_with_rc(struct MPContext *mpctx, exit_reason_t how, int rc);
193 void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr);
194 int reinit_video_chain(struct MPContext *mpctx);
195 void pause_player(struct MPContext *mpctx);
196 void unpause_player(struct MPContext *mpctx);
197 void add_step_frame(struct MPContext *mpctx);
198 int seek_chapter(struct MPContext *mpctx, int chapter, double *seek_pts,
199 char **chapter_name);
200 int get_current_chapter(struct MPContext *mpctx);
201 char *chapter_display_name(struct MPContext *mpctx, int chapter);
203 #endif /* MPLAYER_MP_CORE_H */