summaryrefslogtreecommitdiffstats
path: root/player/core.h
diff options
context:
space:
mode:
Diffstat (limited to 'player/core.h')
-rw-r--r--player/core.h140
1 files changed, 65 insertions, 75 deletions
diff --git a/player/core.h b/player/core.h
index 70fc33448e..c44868cecd 100644
--- a/player/core.h
+++ b/player/core.h
@@ -18,19 +18,18 @@
#ifndef MPLAYER_MP_CORE_H
#define MPLAYER_MP_CORE_H
+#include <stdatomic.h>
#include <stdbool.h>
-#include <pthread.h>
-
-#include "osdep/atomic.h"
#include "libmpv/client.h"
+#include "audio/aframe.h"
#include "common/common.h"
-#include "filters/filter.h"
#include "filters/f_output_chain.h"
+#include "filters/filter.h"
#include "options/options.h"
+#include "osdep/threads.h"
#include "sub/osd.h"
-#include "audio/aframe.h"
#include "video/mp_image.h"
#include "video/out/vo.h"
@@ -43,7 +42,7 @@ enum stop_play_reason {
// also returned on unrecoverable playback errors
PT_NEXT_ENTRY, // prepare to play next entry in playlist
PT_CURRENT_ENTRY, // prepare to play mpctx->playlist->current
- PT_STOP, // stop playback, or transient state when going to next
+ PT_STOP, // stop playback / idle mode
PT_QUIT, // stop playback, quit player
PT_ERROR, // play next playlist entry (due to an error)
};
@@ -70,6 +69,7 @@ enum seek_type {
MPSEEK_ABSOLUTE,
MPSEEK_FACTOR,
MPSEEK_BACKSTEP,
+ MPSEEK_CHAPTER,
};
enum seek_precision {
@@ -92,24 +92,6 @@ struct seek_params {
unsigned flags; // MPSEEK_FLAG_*
};
-enum video_sync {
- VS_DEFAULT = 0,
- VS_DISP_RESAMPLE,
- VS_DISP_RESAMPLE_VDROP,
- VS_DISP_RESAMPLE_NONE,
- VS_DISP_ADROP,
- VS_DISP_VDROP,
- VS_DISP_NONE,
- VS_NONE,
-};
-
-#define VS_IS_DISP(x) ((x) == VS_DISP_RESAMPLE || \
- (x) == VS_DISP_RESAMPLE_VDROP || \
- (x) == VS_DISP_RESAMPLE_NONE || \
- (x) == VS_DISP_ADROP || \
- (x) == VS_DISP_VDROP || \
- (x) == VS_DISP_NONE)
-
// Information about past video frames that have been sent to the VO.
struct frame_info {
double pts;
@@ -132,10 +114,14 @@ struct track {
int demuxer_id; // same as stream->demuxer_id. -1 if not set.
int ff_index; // same as stream->ff_index, or 0.
+ int hls_bitrate; // same as stream->hls_bitrate. 0 if not set.
+ int program_id; // same as stream->program_id. -1 if not set.
char *title;
bool default_track, forced_track, dependent_track;
bool visual_impaired_track, hearing_impaired_track;
+ bool forced_select; // if the track was selected because it is forced
+ bool image;
bool attached_picture;
char *lang;
@@ -146,6 +132,8 @@ struct track {
char *external_filename;
bool auto_loaded;
+ bool demuxer_ready; // if more packets should be read (subtitles only)
+
struct demuxer *demuxer;
// Invariant: !stream || stream->demuxer == demuxer
struct sh_stream *stream;
@@ -160,9 +148,6 @@ struct track {
struct vo_chain *vo_c;
struct ao_chain *ao_c;
struct mp_pin *sink;
-
- // For stream recording (remuxing mode).
- struct mp_recorder_sink *remux_sink;
};
// Summarizes video filtering and output.
@@ -182,6 +167,7 @@ struct vo_chain {
bool is_coverart;
// - video consists of sparse still images
bool is_sparse;
+ bool sparse_eof_signalled;
bool underrun;
bool underrun_signaled;
@@ -190,28 +176,35 @@ struct vo_chain {
// Like vo_chain, for audio.
struct ao_chain {
struct mp_log *log;
+ struct MPContext *mpctx;
bool spdif_passthrough, spdif_failed;
struct mp_output_chain *filter;
struct ao *ao;
- struct mp_audio_buffer *ao_buffer;
+ struct mp_async_queue *ao_queue;
+ struct mp_filter *queue_filter;
+ struct mp_filter *ao_filter;
double ao_resume_time;
- // 1-element output frame queue.
- struct mp_aframe *output_frame;
bool out_eof;
-
double last_out_pts;
+ double start_pts;
+ bool start_pts_known;
+
+ bool audio_started;
+
struct track *track;
struct mp_pin *filter_src;
struct mp_pin *dec_src;
double delay;
+ bool untimed_throttle;
- bool underrun;
+ bool ao_underrun; // last known AO state
+ bool underrun; // for cache pause logic
};
/* Note that playback can be paused, stopped, etc. at any time. While paused,
@@ -223,14 +216,18 @@ struct ao_chain {
enum playback_status {
// code may compare status values numerically
STATUS_SYNCING, // seeking for a position to resume
- STATUS_FILLING, // decoding more data (so you start with full buffers)
STATUS_READY, // buffers full, playback can be started any time
STATUS_PLAYING, // normal playback
STATUS_DRAINING, // decoding has ended; still playing out queued buffers
STATUS_EOF, // playback has ended, or is disabled
};
-#define NUM_PTRACKS 2
+const char *mp_status_str(enum playback_status st);
+
+extern const int num_ptracks[STREAM_TYPE_COUNT];
+
+// Maximum of all num_ptracks[] values.
+#define MAX_PTRACKS 2
typedef struct MPContext {
bool initialized;
@@ -238,6 +235,7 @@ typedef struct MPContext {
struct mpv_global *global;
struct MPOpts *opts;
struct mp_log *log;
+ struct stats_ctx *stats;
struct m_config *mconfig;
struct input_ctx *input;
struct mp_client_api *clients;
@@ -258,6 +256,7 @@ typedef struct MPContext {
char *term_osd_status;
char *term_osd_subs;
char *term_osd_contents;
+ char *term_osd_title;
char *last_window_title;
struct voctrl_playback_state vo_playback_state;
@@ -277,6 +276,8 @@ typedef struct MPContext {
struct playlist_entry *playing; // currently playing file
char *filename; // immutable copy of playing->filename (or NULL)
char *stream_open_filename;
+ char **playlist_paths; // used strictly for playlist validation
+ int playlist_paths_len;
enum stop_play_reason stop_play;
bool playback_initialized; // playloop can be run/is running
int error_playing;
@@ -284,7 +285,6 @@ typedef struct MPContext {
// Return code to use with PT_QUIT
int quit_custom_rc;
bool has_quit_custom_rc;
- char **resume_defaults;
// Global file statistics
int files_played; // played without issues (even if stopped by user)
@@ -303,14 +303,12 @@ typedef struct MPContext {
struct track **tracks;
int num_tracks;
- int64_t death_hack; // don't fucking ask, just don't
-
char *track_layout_hash;
// Selected tracks. NULL if no track selected.
- // There can be NUM_PTRACKS of the same STREAM_TYPE selected at once.
+ // There can be num_ptracks[type] of the same STREAM_TYPE selected at once.
// Currently, this is used for the secondary subtitle track only.
- struct track *current_track[NUM_PTRACKS][STREAM_TYPE_COUNT];
+ struct track *current_track[MAX_PTRACKS][STREAM_TYPE_COUNT];
struct mp_filter *filter_root;
@@ -343,8 +341,6 @@ typedef struct MPContext {
int display_sync_drift_dir;
// Timing error (in seconds) due to rounding on vsync boundaries
double display_sync_error;
- double audio_drop_throttle;
- bool audio_drop_deprecated_msg;
// Number of mistimed frames.
int mistimed_frames_total;
bool hrseek_active; // skip all data until hrseek_pts
@@ -369,18 +365,15 @@ typedef struct MPContext {
/* timestamp of video frame currently visible on screen
* (or at least queued to be flipped by VO) */
double video_pts;
+ // Last seek target.
double last_seek_pts;
- // As video_pts, but is not reset when seeking away. (For the very short
- // period of time until a new frame is decoded and shown.)
- double last_vo_pts;
// Frame duration field from demuxer. Only used for duration of the last
// video frame.
double last_frame_duration;
// Video PTS, or audio PTS if video has ended.
double playback_pts;
- // audio stats only
- int64_t audio_stat_start;
- double written_audio;
+ // For logging only.
+ double logged_async_diff;
int last_chapter;
@@ -402,21 +395,20 @@ typedef struct MPContext {
double start_timestamp;
// Timestamp from the last time some timing functions read the
- // current time, in microseconds.
+ // current time, in nanoseconds.
// Used to turn a new time value to a delta from last time.
int64_t last_time;
struct seek_params seek;
- // Can be temporarily set to an external audio track after seeks. Then it
- // must be seeked to the video position once video is done seeking.
- struct track *seek_slave;
-
/* Heuristic for relative chapter seeks: keep track which chapter
* the user wanted to go to, even if we aren't exactly within the
* boundaries of that chapter due to an inaccurate seek. */
int last_chapter_seek;
- double last_chapter_pts;
+ bool last_chapter_flag;
+
+ /* Heuristic for potentially redrawing subs. */
+ bool redraw_subs;
bool paused; // internal pause state
bool playback_active; // not paused, restarting, loading, unloading
@@ -432,22 +424,21 @@ typedef struct MPContext {
bool demux_underrun;
double cache_stop_time;
int cache_buffer;
+ double cache_update_pts;
// Set after showing warning about decoding being too slow for realtime
// playback rate. Used to avoid showing it multiple times.
bool drop_message_shown;
- struct mp_recorder *recorder;
-
- char *cached_watch_later_configdir;
-
struct screenshot_ctx *screenshot_ctx;
struct command_ctx *command_ctx;
struct encode_lavc_context *encode_lavc_ctx;
struct mp_ipc_ctx *ipc_ctx;
- pthread_mutex_t abort_lock;
+ int64_t builtin_script_ids[5];
+
+ mp_mutex abort_lock;
// --- The following fields are protected by abort_lock
struct mp_abort_entry **abort_list;
@@ -455,7 +446,7 @@ typedef struct MPContext {
bool abort_all; // during final termination
// --- Owned by MPContext
- pthread_t open_thread;
+ mp_thread open_thread;
bool open_active; // open_thread is a valid thread handle, all setup
atomic_bool open_done;
// --- All fields below are immutable while open_active is true.
@@ -498,18 +489,17 @@ void clear_audio_output_buffers(struct MPContext *mpctx);
void update_playback_speed(struct MPContext *mpctx);
void uninit_audio_out(struct MPContext *mpctx);
void uninit_audio_chain(struct MPContext *mpctx);
-int init_audio_decoder(struct MPContext *mpctx, struct track *track);
void reinit_audio_chain_src(struct MPContext *mpctx, struct track *track);
void audio_update_volume(struct MPContext *mpctx);
-void audio_update_balance(struct MPContext *mpctx);
void reload_audio_output(struct MPContext *mpctx);
+void audio_start_ao(struct MPContext *mpctx);
// configfiles.c
void mp_parse_cfgfiles(struct MPContext *mpctx);
void mp_load_auto_profiles(struct MPContext *mpctx);
-void mp_get_resume_defaults(struct MPContext *mpctx);
-void mp_load_playback_resume(struct MPContext *mpctx, const char *file);
+bool mp_load_playback_resume(struct MPContext *mpctx, const char *file);
void mp_write_watch_later_conf(struct MPContext *mpctx);
+void mp_delete_watch_later_conf(struct MPContext *mpctx, const char *file);
struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx,
struct playlist *playlist);
@@ -521,9 +511,11 @@ void mp_abort_recheck_locked(struct MPContext *mpctx,
struct mp_abort_entry *abort);
void mp_abort_trigger_locked(struct MPContext *mpctx,
struct mp_abort_entry *abort);
-void uninit_player(struct MPContext *mpctx, unsigned int mask);
int mp_add_external_file(struct MPContext *mpctx, char *filename,
- enum stream_type filter, struct mp_cancel *cancel);
+ enum stream_type filter, struct mp_cancel *cancel,
+ bool cover_art);
+void mark_track_selection(struct MPContext *mpctx, int order,
+ enum stream_type type, int value);
#define FLAG_MARK_SELECTION 1
void mp_switch_track(struct MPContext *mpctx, enum stream_type type,
struct track *track, int flags);
@@ -535,20 +527,18 @@ struct track *mp_track_by_tid(struct MPContext *mpctx, enum stream_type type,
void add_demuxer_tracks(struct MPContext *mpctx, struct demuxer *demuxer);
bool mp_remove_track(struct MPContext *mpctx, struct track *track);
struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction,
- bool force, bool mutate);
+ bool force);
void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e);
void mp_play_files(struct MPContext *mpctx);
void update_demuxer_properties(struct MPContext *mpctx);
void print_track_list(struct MPContext *mpctx, const char *msg);
-void reselect_demux_stream(struct MPContext *mpctx, struct track *track);
+void reselect_demux_stream(struct MPContext *mpctx, struct track *track,
+ bool refresh_only);
void prepare_playlist(struct MPContext *mpctx, struct playlist *pl);
void autoload_external_files(struct MPContext *mpctx, struct mp_cancel *cancel);
struct track *select_default_track(struct MPContext *mpctx, int order,
enum stream_type type);
void prefetch_next(struct MPContext *mpctx);
-void close_recorder(struct MPContext *mpctx);
-void close_recorder_and_error(struct MPContext *mpctx);
-void open_recorder(struct MPContext *mpctx, bool on_init);
void update_lavfi_complex(struct MPContext *mpctx);
// main.c
@@ -565,6 +555,7 @@ double get_play_end_pts(struct MPContext *mpctx);
double get_play_start_pts(struct MPContext *mpctx);
bool get_ab_loop_times(struct MPContext *mpctx, double t[2]);
void merge_playlist_files(struct playlist *pl);
+void update_content_type(struct MPContext *mpctx, struct track *track);
void update_vo_playback_state(struct MPContext *mpctx);
void update_window_title(struct MPContext *mpctx, bool force);
void error_on_track(struct MPContext *mpctx, struct track *track);
@@ -588,7 +579,6 @@ void mp_wakeup_core(struct MPContext *mpctx);
void mp_wakeup_core_cb(void *ctx);
void mp_core_lock(struct MPContext *mpctx);
void mp_core_unlock(struct MPContext *mpctx);
-void mp_process_input(struct MPContext *mpctx);
double get_relative_time(struct MPContext *mpctx);
void reset_playback_state(struct MPContext *mpctx);
void set_pause_state(struct MPContext *mpctx, bool user_pause);
@@ -617,6 +607,7 @@ int handle_force_window(struct MPContext *mpctx, bool force);
void seek_to_last_frame(struct MPContext *mpctx);
void update_screensaver_state(struct MPContext *mpctx);
void update_ab_loop_clip(struct MPContext *mpctx);
+bool get_internal_paused(struct MPContext *mpctx);
// scripting.c
struct mp_script_args {
@@ -630,13 +621,15 @@ struct mp_script_args {
struct mp_scripting {
const char *name; // e.g. "lua script"
const char *file_ext; // e.g. "lua"
+ bool no_thread; // don't run load() on dedicated thread
int (*load)(struct mp_script_args *args);
};
bool mp_load_scripts(struct MPContext *mpctx);
void mp_load_builtin_scripts(struct MPContext *mpctx);
-int mp_load_user_script(struct MPContext *mpctx, const char *fname);
+int64_t mp_load_user_script(struct MPContext *mpctx, const char *fname);
// sub.c
+void redraw_subs(struct MPContext *mpctx);
void reset_subtitle_state(struct MPContext *mpctx);
void reinit_sub(struct MPContext *mpctx, struct track *track);
void reinit_sub_all(struct MPContext *mpctx);
@@ -646,8 +639,6 @@ void update_osd_msg(struct MPContext *mpctx);
bool update_subtitles(struct MPContext *mpctx, double video_pts);
// video.c
-int video_get_colors(struct vo_chain *vo_c, const char *item, int *value);
-int video_set_colors(struct vo_chain *vo_c, const char *item, int value);
void reset_video_state(struct MPContext *mpctx);
int init_video_decoder(struct MPContext *mpctx, struct track *track);
void reinit_video_chain(struct MPContext *mpctx);
@@ -658,6 +649,5 @@ void mp_force_video_refresh(struct MPContext *mpctx);
void uninit_video_out(struct MPContext *mpctx);
void uninit_video_chain(struct MPContext *mpctx);
double calc_average_frame_duration(struct MPContext *mpctx);
-int init_video_decoder(struct MPContext *mpctx, struct track *track);
#endif /* MPLAYER_MP_CORE_H */