audrey/src/vapi/mpv.vapi

142 lines
3.8 KiB
Vala
Raw Normal View History

2024-10-17 10:05:20 +00:00
[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 ();
}
2024-10-17 10:05:20 +00:00
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 ();
2024-10-17 10:05:20 +00:00
[CCode (cname = "mpv_wait_event")]
2024-10-17 20:32:51 +00:00
public unowned Event? wait_event (double timeout);
2024-10-17 10:05:20 +00:00
public WakeupCallback wakeup_callback {
[CCode (cname = "mpv_set_wakeup_callback")] set;
}
[CCode (cname = "mpv_set_property")]
public Error set_property (string name, Format format, void *data);
2024-10-17 10:05:20 +00:00
[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);
}
2024-10-17 10:05:20 +00:00
public Error set_property_flag (string name, bool value) {
int flag = value ? 1 : 0;
2024-10-18 08:56:48 +00:00
return this.set_property (name, Format.FLAG, &flag);
}
2024-10-17 10:05:20 +00:00
[CCode (cname = "mpv_command")]
2024-10-17 20:32:51 +00:00
public Error command ([CCode (array_length = false)] string[] args);
2024-10-17 10:05:20 +00:00
[CCode (cname = "mpv_observe_property")]
public Error observe_property (uint64 reply_userdata, string name, Format format);
2024-10-17 10:05:20 +00:00
}
[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,
}
2024-10-17 20:32:51 +00:00
[CCode (cname = "mpv_event", destroy_function = "", has_type_id = false, has_copy_function = false)]
2024-10-17 10:05:20 +00:00
public struct Event {
EventId event_id;
Error error;
2024-10-17 10:05:20 +00:00
uint64 reply_userdata;
void *data;
2024-10-17 20:32:51 +00:00
public unowned EventProperty? parse_property ()
requires (event_id == EventId.PROPERTY_CHANGE)
requires (error >= 0)
{
return (Mpv.EventProperty?) data;
}
2024-10-17 10:05:20 +00:00
}
2024-10-17 20:32:51 +00:00
[CCode (cname = "mpv_event_property", destroy_function = "", has_type_id = false, has_copy_function = false)]
2024-10-17 10:05:20 +00:00
public struct EventProperty {
2024-10-17 20:45:50 +00:00
unowned string name;
2024-10-17 10:05:20 +00:00
Format format;
void *data;
2024-10-17 20:32:51 +00:00
public int64 parse_int64 ()
requires (format == Format.INT64)
{
return * (int64 *) data;
}
public double parse_double ()
requires (format == Format.DOUBLE)
{
return * (double *) data;
}
2024-10-17 10:05:20 +00:00
}
}