[CCode (cheader_filename = "mpv/client.h")] namespace Mpv { [CCode (cname = "mpv_error", cprefix = "MPV_ERROR_", has_type_id = false)] public enum Error { SUCCESS, EVENT_QUEUE_FULL, NOMEM, UNINITIALIZED, INVALID_PARAMETER, OPTION_NOT_FOUND, OPTION_FORMAT, OPTION_ERROR, PROPERTY_NOT_FOUND, PROPERTY_FORMAT, PROPERTY_UNAVAILABLE, PROPERTY_ERROR, COMMAND, LOADING_FAILED, AO_INIT_FAILED, VO_INIT_FAILED, NOTHING_TO_PLAY, UNKNOWN_FORMAT, UNSUPPORTED, NOT_IMPLEMENTED, GENERIC; [CCode (cname = "mpv_error_string")] public unowned string to_string (); } public delegate void WakeupCallback (); [CCode (cname = "mpv_handle", free_function = "mpv_destroy")] [Compact] public class Handle { [CCode (cname = "mpv_create")] public Handle (); [CCode (cname = "mpv_initialize")] public Error initialize (); [CCode (cname = "mpv_wait_event")] public unowned Event? wait_event (double timeout); public WakeupCallback wakeup_callback { [CCode (cname = "mpv_set_wakeup_callback")] set; } [CCode (cname = "mpv_set_property")] private Error set_property (string name, Format format, void *data); [CCode (cname = "mpv_set_property_string")] public Error set_property_string (string name, string value); public Error set_property_int64 (string name, int64 value) { return this.set_property (name, Format.INT64, &value); } public Error set_property_flag (string name, bool value) { int flag = value ? 1 : 0; return this.set_property (name, Format.FLAG, &flag); } [CCode (cname = "mpv_command")] public Error command ([CCode (array_length = false)] string[] args); [CCode (cname = "mpv_observe_property")] public Error observe_property (uint64 reply_userdata, string name, Format format); } [CCode (cname = "mpv_format", cprefix = "MPV_FORMAT_", has_type_id = false)] public enum Format { NONE, STRING, OSD_STRING, FLAG, INT64, DOUBLE, NODE, NODE_ARRAY, NODE_MAP, BYTE_ARRAY, } [CCode (cname = "mpv_event_id", cprefix = "MPV_EVENT_", has_type_id = false)] public enum EventId { NONE, SHUTDOWN, LOG_MESSAGE, GET_PROPERTY_REPLY, SET_PROPERTY_REPLY, COMMAND_REPLY, START_FILE, END_FILE, FILE_LOADED, CLIENT_MESSAGE, VIDEO_RECONFIG, AUDIO_RECONFIG, SEEK, PLAYBACK_RESTART, PROPERTY_CHANGE, QUEUE_OVERFLOW, HOOK, } [CCode (cname = "mpv_event", destroy_function = "", has_type_id = false, has_copy_function = false)] public struct Event { EventId event_id; Error error; uint64 reply_userdata; void *data; public unowned EventProperty? parse_property () requires (event_id == EventId.PROPERTY_CHANGE) requires (error >= 0) { return (EventProperty?) data; } public unowned EventEndFile? parse_end_file () requires (event_id == EventId.END_FILE) requires (error >= 0) { return (EventEndFile?) data; } } [CCode (cname = "mpv_event_property", destroy_function = "", has_type_id = false, has_copy_function = false)] public struct EventProperty { unowned string name; Format format; void *data; public int64 parse_int64 () requires (format == Format.INT64) { return * (int64 *) data; } public double parse_double () requires (format == Format.DOUBLE) { return * (double *) data; } public bool parse_flag () requires (format == Format.FLAG) { return (* (int *) data) == 1; } } [CCode (cname = "mpv_event_end_file", destroy_function = "", has_type_id = false, has_copy_function = false)] public struct EventEndFile { EndFileReason reason; Error error; int64 playlist_entry_id; int playlist_insert_num_entries; } [CCode (cname = "mpv_end_file_reason", cprefix = "MPV_END_FILE_REASON_", has_type_id = false)] public enum EndFileReason { EOF, STOP, QUIT, ERROR, REDIRECT, } }