Files
Velix-MPV-Core/include/mpv/harmony_playback.h
T

304 lines
11 KiB
C

/* Stable Harmony playback contract. This header intentionally does not
* expose libmpv, FFmpeg or render implementation types. */
#ifndef MPV_HARMONY_PLAYBACK_H_
#define MPV_HARMONY_PLAYBACK_H_
#include <stddef.h>
#include <stdint.h>
#ifndef MP_HARMONY_EXPORT
#ifdef _WIN32
#define MP_HARMONY_EXPORT __declspec(dllexport)
#elif defined(__GNUC__) || defined(__clang__)
#define MP_HARMONY_EXPORT __attribute__((visibility("default")))
#else
#define MP_HARMONY_EXPORT
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define MP_HARMONY_PLAYBACK_API_VERSION 1u
#define MP_HARMONY_TEXT 256
#define MP_HARMONY_URL 2048
#define MP_HARMONY_MAX_HEADERS 32
#define MP_HARMONY_MAX_SUBTITLES 32
#define MP_HARMONY_MAX_TRACKS 64
typedef struct mp_harmony_player mp_harmony_player;
typedef enum mp_harmony_state {
MP_HARMONY_IDLE = 0,
MP_HARMONY_OPENING,
MP_HARMONY_BUFFERING,
MP_HARMONY_READY,
MP_HARMONY_PLAYING,
MP_HARMONY_PAUSED,
MP_HARMONY_SEEKING,
MP_HARMONY_ENDED,
MP_HARMONY_STOPPED,
MP_HARMONY_ERROR,
MP_HARMONY_RELEASED,
} mp_harmony_state;
typedef enum mp_harmony_error_code {
MP_HARMONY_ERROR_NONE = 0,
MP_HARMONY_ERROR_NETWORK,
MP_HARMONY_ERROR_TLS,
MP_HARMONY_ERROR_HTTP,
MP_HARMONY_ERROR_DEMUX,
MP_HARMONY_ERROR_UNSUPPORTED_CONTAINER,
MP_HARMONY_ERROR_UNSUPPORTED_VIDEO_CODEC,
MP_HARMONY_ERROR_UNSUPPORTED_AUDIO_CODEC,
MP_HARMONY_ERROR_SUBTITLE,
MP_HARMONY_ERROR_DECODER,
MP_HARMONY_ERROR_AUDIO_OUTPUT,
MP_HARMONY_ERROR_VIDEO_OUTPUT,
MP_HARMONY_ERROR_SEEK,
MP_HARMONY_ERROR_FILE_NOT_FOUND,
MP_HARMONY_ERROR_PERMISSION,
MP_HARMONY_ERROR_UNKNOWN,
} mp_harmony_error_code;
typedef enum mp_harmony_seek_mode {
MP_HARMONY_SEEK_RELATIVE = 0,
MP_HARMONY_SEEK_ABSOLUTE,
MP_HARMONY_SEEK_PERCENT,
} mp_harmony_seek_mode;
typedef enum mp_harmony_track_type {
MP_HARMONY_TRACK_VIDEO = 0,
MP_HARMONY_TRACK_AUDIO,
MP_HARMONY_TRACK_SUBTITLE,
} mp_harmony_track_type;
typedef struct mp_harmony_http_header {
const char *name;
const char *value;
} mp_harmony_http_header;
typedef struct mp_harmony_subtitle_source {
const char *url;
const char *title;
const char *language;
const char *encoding;
int forced;
int select;
int is_default;
} mp_harmony_subtitle_source;
typedef struct mp_harmony_playback_request {
const char *url;
const char *title;
int64_t start_position_ms; /* < 0 means unset. */
const char *user_agent;
const char *referer;
const char *cookies;
const mp_harmony_http_header *http_headers;
size_t http_header_count;
const mp_harmony_subtitle_source *subtitle_files;
size_t subtitle_file_count;
const char *preferred_audio_language;
const char *preferred_subtitle_language;
int subtitle_enabled; /* < 0 means unset, 0 disables, 1 enables. */
int audio_track_id; /* < 0 means auto. */
int subtitle_track_id; /* < 0 means auto. */
double playback_speed; /* <= 0 means unset. */
double network_timeout; /* <= 0 means mpv default. */
const char *tls_ca_file; /* Optional PEM/CA bundle path for TLS verification. */
} mp_harmony_playback_request;
typedef struct mp_harmony_track {
int id;
mp_harmony_track_type type;
char title[MP_HARMONY_TEXT];
char language[MP_HARMONY_TEXT];
char codec[MP_HARMONY_TEXT];
int is_default;
int forced;
int selected;
int external;
} mp_harmony_track;
typedef struct mp_harmony_media_info {
char container[MP_HARMONY_TEXT];
char demuxer[MP_HARMONY_TEXT];
double duration;
char video_codec[MP_HARMONY_TEXT];
char audio_codec[MP_HARMONY_TEXT];
char pixel_format[MP_HARMONY_TEXT];
char color_primaries[MP_HARMONY_TEXT];
char color_transfer[MP_HARMONY_TEXT];
char color_space[MP_HARMONY_TEXT];
int width;
int height;
int bit_depth;
int audio_sample_rate;
int audio_channels;
char audio_channel_layout[MP_HARMONY_TEXT];
double fps;
int64_t bitrate;
int64_t video_bitrate;
int64_t audio_bitrate;
int track_count;
int subtitle_count;
/* Stable field names for bindings; width/height/color_space remain for ABI compatibility. */
int video_width;
int video_height;
char color_matrix[MP_HARMONY_TEXT];
} mp_harmony_media_info;
typedef struct mp_harmony_network_info {
char protocol[MP_HARMONY_TEXT];
char host[MP_HARMONY_TEXT];
char network_state[MP_HARMONY_TEXT];
int http_status;
int redirect_count;
int buffering;
double cache_duration;
int64_t cache_bytes;
char demuxer[MP_HARMONY_TEXT];
char container[MP_HARMONY_TEXT];
int64_t current_bitrate;
/* -1 unknown, 0 no observed 206 response, 1 observed byte-range support. */
int range_supported;
char seek_result[MP_HARMONY_TEXT];
} mp_harmony_network_info;
typedef struct mp_harmony_playback_metrics {
int64_t dropped_frames;
int64_t render_count;
int buffering;
double cache_duration;
int64_t cache_bytes;
int64_t current_bitrate;
int64_t buffering_enter_count;
int64_t buffering_exit_count;
int64_t buffering_total_ms;
int64_t buffering_max_single_ms;
int64_t network_wait_ms;
int64_t late_frames;
int64_t mistimed_frames;
int64_t decoder_frames;
} mp_harmony_playback_metrics;
typedef struct mp_harmony_playback_error {
mp_harmony_error_code code;
char raw_message[MP_HARMONY_TEXT];
} mp_harmony_playback_error;
/* Elapsed milliseconds from the current load request; -1 means unavailable. */
typedef struct mp_harmony_playback_timeline {
int64_t session_setup_ms;
int64_t mpv_create_ms;
int64_t mpv_initialize_ms;
int64_t load_command_ms;
int64_t start_file_ms;
int64_t network_open_begin_ms;
int64_t network_open_end_ms;
int64_t first_byte_ms;
int64_t demux_ready_ms;
int64_t file_loaded_ms;
int64_t video_decoder_ready_ms;
int64_t audio_decoder_ready_ms;
int64_t video_reconfig_ms;
int64_t audio_reconfig_ms;
int64_t render_context_ready_ms;
int64_t first_video_frame_available_ms;
int64_t first_render_begin_ms;
int64_t first_render_end_ms;
int64_t first_swap_ms;
int64_t startup_total_ms;
int64_t audio_renderer_start_ms;
int64_t first_audio_callback_ms;
int64_t playback_restart_ms;
int64_t seek_request_ms;
int64_t seek_command_ms;
int64_t seek_demux_ms;
int64_t seek_video_reconfig_ms;
int64_t seek_playback_restart_ms;
int64_t seek_first_frame_ms;
int64_t seek_first_swap_ms;
int64_t seek_command_latency_ms;
int64_t seek_recovery_ms;
int64_t seek_first_visible_frame_ms;
} mp_harmony_playback_timeline;
typedef struct mp_harmony_playback_snapshot {
uint64_t session_id;
mp_harmony_state state;
mp_harmony_error_code error_code;
char error_message[MP_HARMONY_TEXT];
double position;
double duration;
double fps;
int64_t dropped_frames;
int64_t first_frame_ms;
int64_t render_count;
int volume;
int muted;
double speed;
int64_t subtitle_delay_ms;
double subtitle_scale;
double subtitle_position;
int track_count;
mp_harmony_playback_error error;
mp_harmony_playback_metrics metrics;
mp_harmony_media_info media;
mp_harmony_network_info network;
mp_harmony_playback_timeline timeline;
} mp_harmony_playback_snapshot;
/* Stable model aliases for language bindings. */
typedef mp_harmony_playback_request PlaybackRequest;
typedef mp_harmony_playback_snapshot PlaybackState;
typedef mp_harmony_track Track;
typedef mp_harmony_media_info MediaInfo;
typedef mp_harmony_playback_metrics PlaybackMetrics;
typedef mp_harmony_playback_error PlaybackError;
MP_HARMONY_EXPORT mp_harmony_player *mp_harmony_playback_create(void);
MP_HARMONY_EXPORT int mp_harmony_playback_initialize(mp_harmony_player *player);
MP_HARMONY_EXPORT void mp_harmony_playback_destroy(mp_harmony_player *player);
MP_HARMONY_EXPORT int mp_harmony_playback_load(mp_harmony_player *player,
const mp_harmony_playback_request *request);
MP_HARMONY_EXPORT int mp_harmony_playback_play(mp_harmony_player *player);
MP_HARMONY_EXPORT int mp_harmony_playback_pause(mp_harmony_player *player);
MP_HARMONY_EXPORT int mp_harmony_playback_toggle_pause(mp_harmony_player *player);
MP_HARMONY_EXPORT int mp_harmony_playback_stop(mp_harmony_player *player);
MP_HARMONY_EXPORT int mp_harmony_playback_seek(mp_harmony_player *player, mp_harmony_seek_mode mode,
double value, int exact, int keyframe);
MP_HARMONY_EXPORT int mp_harmony_playback_set_speed(mp_harmony_player *player, double speed);
MP_HARMONY_EXPORT int mp_harmony_playback_set_volume(mp_harmony_player *player, double volume);
MP_HARMONY_EXPORT int mp_harmony_playback_set_mute(mp_harmony_player *player, int muted);
MP_HARMONY_EXPORT int mp_harmony_playback_set_audio_enabled(mp_harmony_player *player, int enabled);
MP_HARMONY_EXPORT int mp_harmony_playback_select_audio(mp_harmony_player *player, int track_id);
MP_HARMONY_EXPORT int mp_harmony_playback_select_subtitle(mp_harmony_player *player, int track_id);
MP_HARMONY_EXPORT int mp_harmony_playback_disable_subtitle(mp_harmony_player *player);
MP_HARMONY_EXPORT int mp_harmony_playback_add_subtitle(mp_harmony_player *player,
const mp_harmony_subtitle_source *source);
MP_HARMONY_EXPORT int mp_harmony_playback_remove_subtitle(mp_harmony_player *player, int track_id);
MP_HARMONY_EXPORT int mp_harmony_playback_set_subtitle_delay(mp_harmony_player *player, double seconds);
MP_HARMONY_EXPORT int mp_harmony_playback_set_subtitle_scale(mp_harmony_player *player, double scale);
MP_HARMONY_EXPORT int mp_harmony_playback_set_subtitle_position(mp_harmony_player *player, double position);
MP_HARMONY_EXPORT int mp_harmony_playback_set_ass_override(mp_harmony_player *player, const char *mode);
MP_HARMONY_EXPORT int mp_harmony_playback_get_tracks(mp_harmony_player *player,
mp_harmony_track *tracks, size_t capacity,
size_t *count);
MP_HARMONY_EXPORT int mp_harmony_playback_get_media_info(mp_harmony_player *player,
mp_harmony_media_info *info);
MP_HARMONY_EXPORT int mp_harmony_playback_get_network_info(mp_harmony_player *player,
mp_harmony_network_info *info);
MP_HARMONY_EXPORT int mp_harmony_playback_get_snapshot(mp_harmony_player *player,
mp_harmony_playback_snapshot *snapshot);
MP_HARMONY_EXPORT const char *mp_harmony_playback_state_name(mp_harmony_state state);
MP_HARMONY_EXPORT const char *mp_harmony_playback_error_name(mp_harmony_error_code error);
#ifdef __cplusplus
}
#endif
#endif