audrey/src/vapi/mpv.vapi

179 lines
4.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 ();
2024-10-25 22:00:20 +00:00
[CCode (cname = "mpv_handle", free_function = "mpv_terminate_destroy")]
2024-10-17 10:05:20 +00:00
[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 unowned WakeupCallback wakeup_callback {
2024-10-17 10:05:20 +00:00
[CCode (cname = "mpv_set_wakeup_callback")] set;
}
[CCode (cname = "mpv_set_property")]
2024-10-18 20:13:28 +00:00
private 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
2024-10-25 20:09:57 +00:00
[CCode (cname = "mpv_command_async")]
public Error command_async (uint64 reply_userdata, [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-25 22:00:20 +00:00
~Handle () {
GLib.debug ("destroying mpv handle");
}
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)
{
2024-10-18 20:13:28 +00:00
return (EventProperty?) data;
}
public unowned EventEndFile? parse_end_file ()
requires (event_id == EventId.END_FILE)
requires (error >= 0)
{
return (EventEndFile?) data;
2024-10-17 20:32:51 +00:00
}
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-20 11:17:40 +00:00
public bool parse_flag ()
requires (format == Format.FLAG)
{
return (* (int *) data) == 1;
}
2024-10-17 10:05:20 +00:00
}
2024-10-18 20:13:28 +00:00
[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,
}
2024-10-17 10:05:20 +00:00
}