Files
OBS-WebKitGTK/src/protocol.h
2026-07-20 10:23:57 +05:00

75 lines
1.6 KiB
C

#pragma once
#include <stddef.h>
#include <stdint.h>
#define OWB_CONFIG_MAGIC 0x4f574243u /* OWBC */
#define OWB_COMMAND_MAGIC 0x4f574245u /* OWBE */
#define OWB_PROTOCOL_VERSION 3u
#define OWB_MAX_STRING (16u * 1024u * 1024u)
#define OWB_SHARED_MAGIC 0x4f574246u /* OWBF */
#define OWB_SHARED_FRAME_FD 198
#define OWB_SHARED_FRAME_SLOTS 2u
struct owb_config_header {
uint32_t magic;
uint32_t version;
uint32_t width;
uint32_t height;
uint32_t fps;
uint32_t zoom_percent;
uint32_t transparent;
uint32_t hardware_acceleration;
uint32_t url_length;
uint32_t css_length;
};
struct owb_shared_frames {
uint32_t magic;
uint32_t version;
uint32_t width;
uint32_t height;
uint32_t stride;
uint32_t slot_count;
uint64_t sequence[OWB_SHARED_FRAME_SLOTS];
uint8_t pixels[1];
};
static inline size_t owb_frame_size(uint32_t width, uint32_t height)
{
return (size_t)width * (size_t)height * 4u;
}
static inline size_t owb_shared_size(uint32_t width, uint32_t height)
{
return offsetof(struct owb_shared_frames, pixels) +
owb_frame_size(width, height) * OWB_SHARED_FRAME_SLOTS;
}
static inline uint8_t *owb_shared_slot(struct owb_shared_frames *shared, uint32_t slot)
{
return shared->pixels + owb_frame_size(shared->width, shared->height) * slot;
}
enum owb_command_type {
OWB_MOUSE_MOVE = 1,
OWB_MOUSE_CLICK = 2,
OWB_MOUSE_WHEEL = 3,
OWB_FOCUS = 4,
OWB_KEY = 5,
OWB_RELOAD = 6,
};
/* Fixed-size control messages keep the renderer's nonblocking parser simple. */
struct owb_command {
uint32_t magic;
uint32_t type;
int32_t x;
int32_t y;
int32_t value1;
int32_t value2;
uint32_t modifiers;
uint32_t text_length;
char text[64];
};