Coverage Report

Created: 2026-06-13 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mpv/player/core.h
Line
Count
Source
1
/*
2
 * This file is part of mpv.
3
 *
4
 * mpv is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * mpv 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 Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with mpv.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
#ifndef MPLAYER_MP_CORE_H
19
#define MPLAYER_MP_CORE_H
20
21
#include <stdatomic.h>
22
#include <stdbool.h>
23
24
#include "audio/aframe.h"
25
#include "clipboard/clipboard.h"
26
#include "common/common.h"
27
#include "filters/f_output_chain.h"
28
#include "filters/filter.h"
29
#include "options/options.h"
30
#include "osdep/threads.h"
31
#include "sub/osd.h"
32
#include "video/mp_image.h"
33
#include "video/out/vo.h"
34
#include "osdep/als.h"
35
#include "demux/stheader.h"
36
37
// definitions used internally by the core player code
38
39
enum stop_play_reason {
40
    KEEP_PLAYING = 0,   // playback of a file is actually going on
41
                        // must be 0, numeric values of others do not matter
42
    AT_END_OF_FILE,     // file has ended, prepare to play next
43
                        // also returned on unrecoverable playback errors
44
    PT_NEXT_ENTRY,      // prepare to play next entry in playlist
45
    PT_CURRENT_ENTRY,   // prepare to play mpctx->playlist->current
46
    PT_STOP,            // stop playback / idle mode
47
    PT_QUIT,            // stop playback, quit player
48
    PT_ERROR,           // play next playlist entry (due to an error)
49
};
50
51
enum mp_osd_seek_info {
52
    OSD_SEEK_INFO_BAR           = 1,
53
    OSD_SEEK_INFO_TEXT          = 2,
54
    OSD_SEEK_INFO_CHAPTER_TEXT  = 4,
55
    OSD_SEEK_INFO_CURRENT_FILE  = 8,
56
};
57
58
59
enum {
60
    // other constants
61
    OSD_LEVEL_INVISIBLE = 4,
62
    OSD_BAR_SEEK = 256,
63
64
    MAX_NUM_VO_PTS = 100,
65
};
66
67
enum seek_type {
68
    MPSEEK_NONE = 0,
69
    MPSEEK_RELATIVE,
70
    MPSEEK_ABSOLUTE,
71
    MPSEEK_FACTOR,
72
    MPSEEK_FRAMESTEP,
73
    MPSEEK_CHAPTER,
74
};
75
76
enum seek_precision {
77
    // The following values are numerically sorted by increasing precision
78
    MPSEEK_DEFAULT = 0,
79
    MPSEEK_KEYFRAME,
80
    MPSEEK_EXACT,
81
    MPSEEK_VERY_EXACT,
82
};
83
84
enum seek_flags {
85
    MPSEEK_FLAG_DELAY = 1 << 0, // give player chance to coalesce multiple seeks
86
    MPSEEK_FLAG_NOFLUSH = 1 << 1, // keeping remaining data for seamless loops
87
};
88
89
struct seek_params {
90
    enum seek_type type;
91
    enum seek_precision exact;
92
    double amount;
93
    unsigned flags; // MPSEEK_FLAG_*
94
};
95
96
// Information about past video frames that have been sent to the VO.
97
struct frame_info {
98
    double pts;
99
    double duration;        // PTS difference to next frame
100
    double approx_duration; // possibly fixed/smoothed out duration
101
    int num_vsyncs;         // scheduled vsyncs, if using display-sync
102
};
103
104
struct track {
105
    enum stream_type type;
106
107
    // Currently used for decoding.
108
    bool selected;
109
110
    // The type specific ID, also called aid (audio), sid (subs), vid (video).
111
    // For UI purposes only; this ID doesn't have anything to do with any
112
    // IDs coming from demuxers or container files.
113
    int user_tid;
114
115
    int demuxer_id; // same as stream->demuxer_id. -1 if not set.
116
    int ff_index; // same as stream->ff_index, or 0.
117
    int hls_bitrate; // same as stream->hls_bitrate. 0 if not set.
118
119
    char *title;
120
    bool default_track, forced_track, dependent_track;
121
    bool visual_impaired_track, hearing_impaired_track;
122
    bool original_track, commentary_track;
123
    bool forced_select; // if the track was selected because it is forced
124
    bool image;
125
    bool attached_picture;
126
    char *lang;
127
128
    // If this track is from an external file (e.g. subtitle file).
129
    bool is_external;
130
    bool no_default;            // pretend it's not external for auto-selection
131
    bool no_auto_select;
132
    char *external_filename;
133
    bool auto_loaded;
134
135
    bool demuxer_ready; // if more packets should be read (subtitles only)
136
137
    struct demuxer *demuxer;
138
    // Invariant: !stream || stream->demuxer == demuxer
139
    struct sh_stream *stream;
140
141
    // Current subtitle state (or cached state if selected==false).
142
    struct dec_sub *d_sub;
143
144
    /* Heuristic for potentially redrawing subs. */
145
    bool redraw_subs;
146
147
    // Current decoding state (NULL if selected==false)
148
    struct mp_decoder_wrapper *dec;
149
150
    // Where the decoded result goes to (one of them is not NULL if active)
151
    struct vo_chain *vo_c;
152
    struct ao_chain *ao_c;
153
    struct mp_pin *sink;
154
};
155
156
// Returns true if the track belongs to the given program.
157
static inline bool track_has_program(const struct track *track, int program_id)
158
0
{
159
0
    return track->stream && sh_stream_has_program(track->stream, program_id);
160
0
}
Unexecuted instantiation: client.c:track_has_program
Unexecuted instantiation: command.c:track_has_program
Unexecuted instantiation: configfiles.c:track_has_program
Unexecuted instantiation: loadfile.c:track_has_program
Unexecuted instantiation: main.c:track_has_program
Unexecuted instantiation: misc.c:track_has_program
Unexecuted instantiation: osd.c:track_has_program
Unexecuted instantiation: playloop.c:track_has_program
Unexecuted instantiation: screenshot.c:track_has_program
Unexecuted instantiation: scripting.c:track_has_program
Unexecuted instantiation: sub.c:track_has_program
Unexecuted instantiation: video.c:track_has_program
Unexecuted instantiation: clipboard.c:track_has_program
Unexecuted instantiation: clipboard-vo.c:track_has_program
Unexecuted instantiation: stream_mpv.c:track_has_program
Unexecuted instantiation: dec_sub.c:track_has_program
Unexecuted instantiation: sd_ass.c:track_has_program
Unexecuted instantiation: sd_lavc.c:track_has_program
Unexecuted instantiation: filter_regex.c:track_has_program
Unexecuted instantiation: als-linux.c:track_has_program
Unexecuted instantiation: demux_playlist.c:track_has_program
Unexecuted instantiation: options.c:track_has_program
Unexecuted instantiation: audio.c:track_has_program
Unexecuted instantiation: external_files.c:track_has_program
Unexecuted instantiation: filter_sdh.c:track_has_program
Unexecuted instantiation: lavc_conv.c:track_has_program
Unexecuted instantiation: vf_sub.c:track_has_program
161
162
// Summarizes video filtering and output.
163
struct vo_chain {
164
    struct mp_log *log;
165
166
    struct mp_output_chain *filter;
167
168
    struct vo *vo;
169
170
    struct track *track;
171
    struct mp_pin *filter_src;
172
    struct mp_pin *dec_src;
173
174
    // - video consists of a single picture, which should be shown only once
175
    // - do not sync audio to video in any way
176
    bool is_coverart;
177
    // - video consists of sparse still images
178
    bool is_sparse;
179
    bool sparse_eof_signalled;
180
181
    bool underrun;
182
    bool underrun_signaled;
183
};
184
185
// Like vo_chain, for audio.
186
struct ao_chain {
187
    struct mp_log *log;
188
    struct MPContext *mpctx;
189
190
    bool spdif_passthrough, spdif_failed;
191
192
    struct mp_output_chain *filter;
193
194
    struct ao *ao;
195
    struct mp_async_queue *ao_queue;
196
    struct mp_filter *queue_filter;
197
    struct mp_filter *ao_filter;
198
    double ao_resume_time;
199
200
    bool out_eof;
201
    double last_out_pts;
202
203
    double start_pts;
204
    bool start_pts_known;
205
206
    bool delaying_audio_start;
207
208
    struct track *track;
209
    struct mp_pin *filter_src;
210
    struct mp_pin *dec_src;
211
212
    double delay;
213
    bool untimed_throttle;
214
215
    bool ao_underrun;   // last known AO state
216
    bool underrun;      // for cache pause logic
217
};
218
219
/* Note that playback can be paused, stopped, etc. at any time. While paused,
220
 * playback restart is still active, because you want seeking to work even
221
 * if paused.
222
 * The main purpose of distinguishing these states is proper reinitialization
223
 * of A/V sync.
224
 */
225
enum playback_status {
226
    // code may compare status values numerically
227
    STATUS_SYNCING,     // seeking for a position to resume
228
    STATUS_READY,       // buffers full, playback can be started any time
229
    STATUS_PLAYING,     // normal playback
230
    STATUS_DRAINING,    // decoding has ended; still playing out queued buffers
231
    STATUS_EOF,         // playback has ended, or is disabled
232
};
233
234
const char *mp_status_str(enum playback_status st);
235
236
extern const int num_ptracks[STREAM_TYPE_COUNT];
237
238
// Maximum of all num_ptracks[] values.
239
#define MAX_PTRACKS 2
240
241
typedef struct MPContext {
242
    bool initialized;
243
    bool is_cli;
244
    mp_thread core_thread;
245
    struct mpv_global *global;
246
    struct MPOpts *opts;
247
    struct mp_log *log;
248
    struct stats_ctx *stats;
249
    struct m_config *mconfig;
250
    struct input_ctx *input;
251
    struct mp_client_api *clients;
252
    struct mp_dispatch_queue *dispatch;
253
    struct mp_cancel *playback_abort;
254
    // Number of asynchronous tasks that still need to finish until MPContext
255
    // destruction is ok. It's implied that the async tasks call
256
    // mp_wakeup_core() each time this is decremented.
257
    // As using an atomic+wakeup would be racy, this is a normal integer, and
258
    // mp_dispatch_lock must be called to change it.
259
    int64_t outstanding_async;
260
261
    struct mp_thread_pool *thread_pool; // for coarse I/O, often during loading
262
263
    struct mp_log *statusline;
264
    struct osd_state *osd;
265
    char *term_osd_text;
266
    char *term_osd_status;
267
    char *term_osd_subs[2];
268
    char *term_osd_contents;
269
    char *term_osd_title;
270
    char *last_window_title;
271
    struct voctrl_playback_state vo_playback_state;
272
    int64_t vo_playback_state_time;
273
274
    int add_osd_seek_info; // bitfield of enum mp_osd_seek_info
275
    double osd_visible; // for the osd bar only
276
    int osd_function;
277
    double osd_function_visible;
278
    double osd_msg_visible;
279
    double osd_msg_next_duration;
280
    double osd_last_update;
281
    bool osd_force_update, osd_idle_update;
282
    char *osd_msg_text;
283
    bool osd_show_pos;
284
    struct osd_progbar_state osd_progbar;
285
286
    struct playlist *playlist;
287
    struct playlist_entry *playing; // currently playing file
288
    char *filename; // immutable copy of playing->filename (or NULL)
289
    char *stream_open_filename;
290
    char **playlist_paths; // used strictly for playlist validation
291
    int playlist_paths_len;
292
    enum stop_play_reason stop_play;
293
    bool playback_initialized; // playloop can be run/is running
294
    int error_playing;
295
296
    struct clipboard_ctx *clipboard;
297
298
    // Return code to use with PT_QUIT
299
    int quit_custom_rc;
300
    bool has_quit_custom_rc;
301
302
    // Global file statistics
303
    int files_played;       // played without issues (even if stopped by user)
304
    int files_errored;      // played, but errors happened at one point
305
    int files_broken;       // couldn't be played at all
306
307
    // Current file statistics
308
    int64_t shown_vframes, shown_aframes;
309
310
    struct demux_chapter *chapters;
311
    int num_chapters;
312
313
    struct demuxer *demuxer;
314
    struct mp_tags *filtered_tags;
315
316
    struct track **tracks;
317
    int num_tracks;
318
319
    char *track_layout_hash;
320
321
    // Selected tracks. NULL if no track selected.
322
    // There can be num_ptracks[type] of the same STREAM_TYPE selected at once.
323
    // Currently, this is used for the secondary subtitle track only.
324
    struct track *current_track[MAX_PTRACKS][STREAM_TYPE_COUNT];
325
326
    struct mp_filter *filter_root;
327
328
    struct mp_filter *lavfi;
329
    char *lavfi_graph;
330
331
    struct ao *ao;
332
    struct mp_aframe *ao_filter_fmt; // for weak gapless audio check
333
    struct ao_chain *ao_chain;
334
335
    struct vo_chain *vo_chain;
336
337
    struct vo *video_out;
338
    // next_frame[0] is the next frame, next_frame[1] the one after that.
339
    // The +1 is for adding 1 additional frame in backstep mode.
340
    struct mp_image *next_frames[VO_MAX_REQ_FRAMES + 1];
341
    int num_next_frames;
342
    struct mp_image *saved_frame;   // for hrseek_lastframe and hrseek_backstep
343
344
    enum playback_status video_status, audio_status;
345
    bool restart_complete;
346
    int play_dir;
347
    // Factors to multiply with opts->playback_speed to get the total audio or
348
    // video speed (usually 1.0, but can be set to by the sync code).
349
    double speed_factor_v, speed_factor_a;
350
    // Redundant values set from opts->playback_speed and speed_factor_*.
351
    // update_playback_speed() updates them from the other fields.
352
    double audio_speed, video_speed;
353
    bool display_sync_active;
354
    double audio_drift_compensation;
355
    double avd_filtered;
356
    // Timing error (in seconds) due to rounding on vsync boundaries
357
    double display_sync_error;
358
    // Number of mistimed frames.
359
    int mistimed_frames_total;
360
    bool hrseek_active;     // skip all data until hrseek_pts
361
    bool hrseek_lastframe;  // drop everything until last frame reached
362
    bool hrseek_backstep;   // go to frame before seek target
363
    double hrseek_pts;
364
    struct seek_params current_seek;
365
    bool ab_loop_clip;      // clip to the "b" part of an A-B loop if available
366
    // AV sync: the next frame should be shown when the audio out has this
367
    // much (in seconds) buffered data left. Increased when more data is
368
    // written to the ao, decreased when moving to the next video frame.
369
    double delay;
370
    // AV sync: time in seconds until next frame should be shown
371
    double time_frame;
372
    // How much video timing has been changed to make it match the audio
373
    // timeline. Used for status line information only.
374
    double total_avsync_change;
375
    // A-V sync difference when last frame was displayed. Kept to display
376
    // the same value if the status line is updated at a time where no new
377
    // video frame is shown.
378
    double last_av_difference;
379
    /* timestamp of video frame currently visible on screen
380
     * (or at least queued to be flipped by VO) */
381
    double video_pts;
382
    // Last seek target.
383
    double last_seek_pts;
384
    // Frame duration field from demuxer. Only used for duration of the last
385
    // video frame.
386
    double last_frame_duration;
387
    // Video PTS, or audio PTS if video has ended.
388
    double playback_pts;
389
    // For logging only.
390
    double logged_async_diff;
391
392
    int last_chapter;
393
394
    // Past timestamps etc.
395
    // The newest frame is at index 0.
396
    struct frame_info *past_frames;
397
    int num_past_frames;
398
399
    double last_idle_tick;
400
    double next_cache_update;
401
402
    double sleeptime;      // number of seconds to sleep before next iteration
403
404
    double mouse_timer;
405
    unsigned int mouse_event_ts;
406
    bool mouse_cursor_visible;
407
408
    // used to prevent hanging in some error cases
409
    double start_timestamp;
410
411
    // Timestamp from the last time some timing functions read the
412
    // current time, in nanoseconds.
413
    // Used to turn a new time value to a delta from last time.
414
    int64_t last_time;
415
416
    struct seek_params seek;
417
418
    /* Heuristic for relative chapter seeks: keep track which chapter
419
     * the user wanted to go to, even if we aren't exactly within the
420
     * boundaries of that chapter due to an inaccurate seek. */
421
    int last_chapter_seek;
422
    bool last_chapter_flag;
423
424
    bool paused;            // internal pause state
425
    bool playback_active;   // not paused, restarting, loading, unloading
426
    bool in_playloop;
427
428
    // step this many frames, then pause
429
    int step_frames;
430
    // Counted down each frame, stop playback if 0 is reached. (-1 = disable)
431
    int max_frames;
432
    bool playing_msg_shown;
433
434
    int remaining_file_loops;
435
    int remaining_ab_loops;
436
437
    bool paused_for_cache;
438
    bool demux_underrun;
439
    double cache_stop_time;
440
    int cache_buffer;
441
    double cache_update_pts;
442
443
    // Set after showing warning about decoding being too slow for realtime
444
    // playback rate. Used to avoid showing it multiple times.
445
    bool drop_message_shown;
446
447
    struct screenshot_ctx *screenshot_ctx;
448
    struct command_ctx *command_ctx;
449
    struct encode_lavc_context *encode_lavc_ctx;
450
451
    struct mp_option_callback *option_callbacks;
452
    int num_option_callbacks;
453
454
    struct mp_ipc_ctx *ipc_ctx;
455
456
    int64_t builtin_script_ids[9];
457
458
    mp_mutex abort_lock;
459
460
    // --- The following fields are protected by abort_lock
461
    struct mp_abort_entry **abort_list;
462
    int num_abort_list;
463
    bool abort_all; // during final termination
464
465
    // --- Owned by MPContext
466
    mp_thread open_thread;
467
    bool open_active; // open_thread is a valid thread handle, all setup
468
    atomic_bool open_done;
469
    // --- All fields below are immutable while open_active is true.
470
    //     Otherwise, they're owned by MPContext.
471
    struct mp_cancel *open_cancel;
472
    char *open_url;
473
    char *open_format;
474
    int open_url_flags;
475
    bool open_for_prefetch;
476
    bool demuxer_changed;
477
    // --- All fields below are owned by open_thread, unless open_done was set
478
    //     to true.
479
    struct demuxer *open_res_demuxer;
480
    int open_res_error;
481
482
    struct mp_als *als_state; // lazily initialized on first use
483
} MPContext;
484
485
// Contains information about an asynchronous work item, how it can be aborted,
486
// and when. All fields are protected by MPContext.abort_lock.
487
struct mp_abort_entry {
488
    // General conditions.
489
    bool coupled_to_playback;   // trigger when playback is terminated
490
    // Actual trigger to abort the work. Pointer immutable, owner may access
491
    // without holding the abort_lock.
492
    struct mp_cancel *cancel;
493
    // For client API.
494
    struct mpv_handle *client;  // non-NULL if done by a client API user
495
    int client_work_type;       // client API type, e.h. MPV_EVENT_COMMAND_REPLY
496
    uint64_t client_work_id;    // client API user reply_userdata value
497
                                // (only valid if client_work_type set)
498
};
499
500
// U+25CB WHITE CIRCLE
501
// U+25CF BLACK CIRCLE
502
#define WHITE_CIRCLE "\xe2\x97\x8b"
503
#define BLACK_CIRCLE "\xe2\x97\x8f"
504
505
// audio.c
506
void reset_audio_state(struct MPContext *mpctx);
507
void reinit_audio_chain(struct MPContext *mpctx);
508
int init_audio_decoder(struct MPContext *mpctx, struct track *track);
509
int reinit_audio_filters(struct MPContext *mpctx);
510
double playing_audio_pts(struct MPContext *mpctx);
511
void fill_audio_out_buffers(struct MPContext *mpctx);
512
double written_audio_pts(struct MPContext *mpctx);
513
void clear_audio_output_buffers(struct MPContext *mpctx);
514
void update_playback_speed(struct MPContext *mpctx);
515
void uninit_audio_out(struct MPContext *mpctx);
516
void uninit_audio_chain(struct MPContext *mpctx);
517
void reinit_audio_chain_src(struct MPContext *mpctx, struct track *track);
518
float audio_get_gain(struct MPContext *mpctx);
519
void audio_update_volume(struct MPContext *mpctx);
520
void reload_audio_output(struct MPContext *mpctx);
521
void audio_start_ao(struct MPContext *mpctx);
522
523
// configfiles.c
524
void mp_parse_cfgfiles(struct MPContext *mpctx);
525
void mp_load_auto_profiles(struct MPContext *mpctx);
526
bool mp_load_playback_resume(struct MPContext *mpctx, const char *file);
527
char *mp_get_playback_resume_dir(struct MPContext *mpctx);
528
void mp_write_watch_later_conf(struct MPContext *mpctx);
529
void mp_delete_watch_later_conf(struct MPContext *mpctx, const char *file);
530
struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx,
531
                                                struct playlist *playlist);
532
533
// loadfile.c
534
void mp_abort_playback_async(struct MPContext *mpctx);
535
void mp_abort_add(struct MPContext *mpctx, struct mp_abort_entry *abort);
536
void mp_abort_remove(struct MPContext *mpctx, struct mp_abort_entry *abort);
537
void mp_abort_recheck_locked(struct MPContext *mpctx,
538
                             struct mp_abort_entry *abort);
539
void mp_abort_trigger_locked(struct MPContext *mpctx,
540
                             struct mp_abort_entry *abort);
541
int mp_add_external_file(struct MPContext *mpctx, char *filename,
542
                         enum stream_type filter, struct mp_cancel *cancel,
543
                         enum track_flags flags);
544
void mark_track_selection(struct MPContext *mpctx, int order,
545
                          enum stream_type type, int value);
546
12.1k
#define FLAG_MARK_SELECTION 1
547
void mp_switch_track(struct MPContext *mpctx, enum stream_type type,
548
                     struct track *track, int flags);
549
void mp_switch_track_n(struct MPContext *mpctx, int order,
550
                       enum stream_type type, struct track *track, int flags);
551
void mp_deselect_track(struct MPContext *mpctx, struct track *track);
552
struct track *mp_track_by_tid(struct MPContext *mpctx, enum stream_type type,
553
                              int tid);
554
void add_demuxer_tracks(struct MPContext *mpctx, struct demuxer *demuxer);
555
bool mp_remove_track(struct MPContext *mpctx, struct track *track);
556
struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction,
557
                                    bool force, bool update_loop);
558
void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e);
559
void mp_play_files(struct MPContext *mpctx);
560
void update_demuxer_properties(struct MPContext *mpctx);
561
bool track_is_visible(struct MPContext *mpctx, struct track *track);
562
void print_track_list(struct MPContext *mpctx, const char *msg);
563
void reselect_demux_stream(struct MPContext *mpctx, struct track *track,
564
                           bool refresh_only);
565
void prepare_playlist(struct MPContext *mpctx, struct playlist *pl, bool overwrite_current);
566
void autoload_external_files(struct MPContext *mpctx, struct mp_cancel *cancel);
567
struct track *select_default_track(struct MPContext *mpctx, int order,
568
                                   enum stream_type type);
569
void prefetch_next(struct MPContext *mpctx);
570
void update_lavfi_complex(struct MPContext *mpctx);
571
572
// main.c
573
int mp_initialize(struct MPContext *mpctx, char **argv);
574
struct MPContext *mp_create(void);
575
void mp_destroy(struct MPContext *mpctx);
576
void mp_print_version(struct mp_log *log, int always);
577
void mp_update_logging(struct MPContext *mpctx, bool preinit);
578
void issue_refresh_seek(struct MPContext *mpctx, enum seek_precision min_prec);
579
580
// misc.c
581
double rel_time_to_abs(struct MPContext *mpctx, struct m_rel_time t);
582
double get_play_end_pts(struct MPContext *mpctx);
583
double get_play_start_pts(struct MPContext *mpctx);
584
bool get_ab_loop_times(struct MPContext *mpctx, double t[2]);
585
void merge_playlist_files(struct playlist *pl);
586
void update_content_type(struct MPContext *mpctx, struct track *track);
587
void update_vo_playback_state(struct MPContext *mpctx);
588
void update_window_title(struct MPContext *mpctx, bool force);
589
void error_on_track(struct MPContext *mpctx, struct track *track);
590
int stream_dump(struct MPContext *mpctx, const char *source_filename);
591
double get_track_seek_offset(struct MPContext *mpctx, struct track *track);
592
char *mp_format_track_metadata(void *ctx, struct track *t, bool add_lang);
593
const char *mp_find_non_filename_media_title(MPContext *mpctx);
594
595
// osd.c
596
void set_osd_bar(struct MPContext *mpctx, int type,
597
                 double min, double max, double neutral, double val);
598
bool set_osd_msg(struct MPContext *mpctx, int level, int time,
599
                 const char* fmt, ...) MP_PRINTF_ATTRIBUTE(4,5);
600
void set_osd_function(struct MPContext *mpctx, int osd_function);
601
void term_osd_clear_subs(struct MPContext *mpctx);
602
void term_osd_set_subs(struct MPContext *mpctx, const char *text, int order);
603
void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size);
604
void set_osd_bar_chapters(struct MPContext *mpctx, int type);
605
606
// playloop.c
607
void mp_wait_events(struct MPContext *mpctx);
608
void mp_set_timeout(struct MPContext *mpctx, double sleeptime);
609
void mp_wakeup_core(struct MPContext *mpctx);
610
void mp_wakeup_core_cb(void *ctx);
611
void mp_core_lock(struct MPContext *mpctx);
612
void mp_core_unlock(struct MPContext *mpctx);
613
void handle_option_callbacks(struct MPContext *mpctx);
614
double get_relative_time(struct MPContext *mpctx);
615
void reset_playback_state(struct MPContext *mpctx);
616
void set_pause_state(struct MPContext *mpctx, bool user_pause);
617
void update_internal_pause_state(struct MPContext *mpctx);
618
void update_core_idle_state(struct MPContext *mpctx);
619
void add_step_frame(struct MPContext *mpctx, int dir, bool use_seek);
620
void step_frame_mute(struct MPContext *mpctx, bool mute);
621
void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
622
                enum seek_precision exact, int flags);
623
double get_time_length(struct MPContext *mpctx);
624
double get_start_time(struct MPContext *mpctx, int dir);
625
double get_current_time(struct MPContext *mpctx);
626
double get_playback_time(struct MPContext *mpctx);
627
double get_current_pos_ratio(struct MPContext *mpctx, bool use_range);
628
int get_current_chapter(struct MPContext *mpctx);
629
char *chapter_display_name(struct MPContext *mpctx, int chapter);
630
char *chapter_name(struct MPContext *mpctx, int chapter);
631
double chapter_start_time(struct MPContext *mpctx, int chapter);
632
int get_chapter_count(struct MPContext *mpctx);
633
int get_cache_buffering_percentage(struct MPContext *mpctx);
634
void execute_queued_seek(struct MPContext *mpctx);
635
void run_playloop(struct MPContext *mpctx);
636
void mp_idle(struct MPContext *mpctx);
637
void idle_loop(struct MPContext *mpctx);
638
int handle_force_window(struct MPContext *mpctx, bool force);
639
void seek_to_last_frame(struct MPContext *mpctx);
640
void update_screensaver_state(struct MPContext *mpctx);
641
void update_ab_loop_clip(struct MPContext *mpctx);
642
bool get_internal_paused(struct MPContext *mpctx);
643
644
// scripting.c
645
struct mp_script_args {
646
    const struct mp_scripting *backend;
647
    struct MPContext *mpctx;
648
    struct mp_log *log;
649
    struct mpv_handle *client;
650
    const char *filename;
651
    const char *path;
652
};
653
struct mp_scripting {
654
    const char *name;       // e.g. "lua script"
655
    const char *file_ext;   // e.g. "lua"
656
    bool no_thread;         // don't run load() on dedicated thread
657
    int (*load)(struct mp_script_args *args);
658
};
659
bool mp_load_scripts(struct MPContext *mpctx);
660
void mp_load_builtin_scripts(struct MPContext *mpctx);
661
int64_t mp_load_user_script(struct MPContext *mpctx, const char *fname);
662
663
// sub.c
664
void redraw_subs(struct MPContext *mpctx);
665
void reset_subtitle_state(struct MPContext *mpctx);
666
void reinit_sub(struct MPContext *mpctx, struct track *track);
667
void reinit_sub_all(struct MPContext *mpctx);
668
void uninit_sub(struct MPContext *mpctx, struct track *track);
669
void uninit_sub_all(struct MPContext *mpctx);
670
void update_osd_msg(struct MPContext *mpctx);
671
bool update_subtitles(struct MPContext *mpctx, double video_pts);
672
673
// video.c
674
void reset_video_state(struct MPContext *mpctx);
675
int init_video_decoder(struct MPContext *mpctx, struct track *track);
676
void reinit_video_chain(struct MPContext *mpctx);
677
void reinit_video_chain_src(struct MPContext *mpctx, struct track *track);
678
int reinit_video_filters(struct MPContext *mpctx);
679
void write_video(struct MPContext *mpctx);
680
void mp_force_video_refresh(struct MPContext *mpctx);
681
void uninit_video_out(struct MPContext *mpctx);
682
void uninit_video_chain(struct MPContext *mpctx);
683
double calc_average_frame_duration(struct MPContext *mpctx);
684
685
#endif /* MPLAYER_MP_CORE_H */