Merge svn changes up to r30195
[mplayer/glamo.git] / mp_core.h
bloba5c7e70c8aac8fa40af32c7e3172bfe8fe795058
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
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;
107 // Show a video frame as quickly as possible without trying to adjust
108 // for AV sync. Used when starting a file or after seeking.
109 bool update_video_immediately;
110 // AV sync: the next frame should be shown when the audio out has this
111 // much (in seconds) buffered data left. Increased when more data is
112 // written to the ao, decreased when moving to the next frame.
113 // In the audio-only case used as a timer since the last seek
114 // by the audio CPU usage meter.
115 double delay;
116 // AV sync: time until next frame should be shown
117 float time_frame;
118 // How long the last vo flip() call took. Used to adjust timing with
119 // the goal of making flip() calls finish (rather than start) at the
120 // specified time.
121 float last_vo_flip_duration;
122 // How much video timing has been changed to make it match the audio
123 // timeline. Used for status line information only.
124 double total_avsync_change;
125 // A-V sync difference when last frame was displayed. Kept to display
126 // the same value if the status line is updated at a time where no new
127 // video frame is shown.
128 double last_av_difference;
130 // Timestamp from the last time some timing functions read the
131 // current time, in (occasionally wrapping) microseconds. Used
132 // to turn a new time value to a delta from last time.
133 unsigned int last_time;
135 // Used to communicate the parameters of a seek between parts
136 double rel_seek_secs;
137 int abs_seek_pos;
139 float begin_skip; ///< start time of the current skip while on edlout mode
140 // audio is muted if either EDL or user activates mute
141 short edl_muted; ///< Stores whether EDL is currently in muted mode.
142 short user_muted; ///< Stores whether user wanted muted mode.
144 int global_sub_size; // this encompasses all subtitle sources
145 int global_sub_pos; // this encompasses all subtitle sources
146 int set_of_sub_pos;
147 int set_of_sub_size;
148 int global_sub_indices[SUB_SOURCES];
149 // set_of_ass_tracks[i] contains subtitles from set_of_subtitles[i]
150 // parsed by libass or NULL if format unsupported
151 struct ass_track *set_of_ass_tracks[MAX_SUBTITLE_FILES];
152 sub_data* set_of_subtitles[MAX_SUBTITLE_FILES];
154 int file_format;
156 int last_dvb_step;
157 int dvbin_reopen;
159 int paused;
160 // step this many frames, then pause
161 int step_frames;
163 // Set after showing warning about decoding being too slow for realtime
164 // playback rate. Used to avoid showing it multiple times.
165 bool drop_message_shown;
167 #ifdef CONFIG_DVDNAV
168 struct mp_image *nav_smpi; ///< last decoded dvdnav video image
169 unsigned char *nav_buffer; ///< last read dvdnav video frame
170 unsigned char *nav_start; ///< pointer to last read video buffer
171 int nav_in_size; ///< last read size
172 #endif
173 } MPContext;
176 // Most of these should not be globals
177 extern FILE *edl_fd;
178 extern int file_filter;
179 // These appear in options list
180 extern int forced_subs_only;
182 struct ao_data;
183 int build_afilter_chain(struct MPContext *mpctx, struct sh_audio *sh_audio, struct ao_data *ao_data);
184 void uninit_player(struct MPContext *mpctx, unsigned int mask);
185 void reinit_audio_chain(struct MPContext *mpctx);
186 void init_vo_spudec(struct MPContext *mpctx);
187 double playing_audio_pts(struct MPContext *mpctx);
188 void exit_player_with_rc(struct MPContext *mpctx, exit_reason_t how, int rc);
189 void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr);
190 int reinit_video_chain(struct MPContext *mpctx);
191 void pause_player(struct MPContext *mpctx);
192 void unpause_player(struct MPContext *mpctx);
193 void add_step_frame(struct MPContext *mpctx);
194 int seek_chapter(struct MPContext *mpctx, int chapter, double *seek_pts,
195 char **chapter_name);
196 int get_current_chapter(struct MPContext *mpctx);
197 char *chapter_display_name(struct MPContext *mpctx, int chapter);
199 #endif /* MPLAYER_MP_CORE_H */