2020-07-12 11:17:03 +00:00
|
|
|
/*
|
2022-04-09 22:54:57 +00:00
|
|
|
* Copyright (c) 2020 - 2022 Andri Yngvason
|
2020-07-12 11:17:03 +00:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
|
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
|
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2020-07-11 17:54:35 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-07-06 21:16:58 +00:00
|
|
|
#include "rfbclient.h"
|
2022-07-06 21:09:02 +00:00
|
|
|
|
2020-07-11 17:54:35 +00:00
|
|
|
#include <stdbool.h>
|
2020-12-06 19:52:02 +00:00
|
|
|
#include <unistd.h>
|
2020-07-11 17:54:35 +00:00
|
|
|
#include <pixman.h>
|
|
|
|
#include <wayland-client.h>
|
|
|
|
|
2022-04-09 22:54:57 +00:00
|
|
|
#define VNC_CLIENT_MAX_AV_FRAMES 64
|
|
|
|
|
|
|
|
struct open_h264;
|
|
|
|
struct AVFrame;
|
|
|
|
|
|
|
|
struct vnc_av_frame {
|
|
|
|
struct AVFrame* frame;
|
|
|
|
int x, y, width, height;
|
|
|
|
};
|
|
|
|
|
2020-07-11 17:54:35 +00:00
|
|
|
struct vnc_client {
|
|
|
|
rfbClient* client;
|
|
|
|
|
2022-04-09 22:54:57 +00:00
|
|
|
struct open_h264* open_h264;
|
|
|
|
bool current_rect_is_av_frame;
|
|
|
|
struct vnc_av_frame* av_frames[VNC_CLIENT_MAX_AV_FRAMES];
|
|
|
|
int n_av_frames;
|
2022-04-14 18:41:34 +00:00
|
|
|
uint64_t pts;
|
2022-04-09 22:54:57 +00:00
|
|
|
|
2020-07-11 17:54:35 +00:00
|
|
|
int (*alloc_fb)(struct vnc_client*);
|
|
|
|
void (*update_fb)(struct vnc_client*);
|
2020-12-06 19:52:02 +00:00
|
|
|
void (*cut_text)(struct vnc_client*, const char*, size_t);
|
2023-04-09 10:06:13 +00:00
|
|
|
void (*ntp_event)(struct vnc_client*, uint32_t t0, uint32_t t1,
|
|
|
|
uint32_t t2, uint32_t t3);
|
2020-07-11 17:54:35 +00:00
|
|
|
|
|
|
|
void* userdata;
|
|
|
|
struct pixman_region16 damage;
|
2022-06-05 12:42:50 +00:00
|
|
|
|
|
|
|
bool handler_lock;
|
2022-07-03 10:46:29 +00:00
|
|
|
bool is_updating;
|
2020-07-11 17:54:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct vnc_client* vnc_client_create(void);
|
|
|
|
void vnc_client_destroy(struct vnc_client* self);
|
|
|
|
|
|
|
|
int vnc_client_connect(struct vnc_client* self, const char* address, int port);
|
2022-06-05 12:42:50 +00:00
|
|
|
int vnc_client_init(struct vnc_client* self);
|
2020-07-11 17:54:35 +00:00
|
|
|
|
2022-04-03 19:00:14 +00:00
|
|
|
int vnc_client_set_pixel_format(struct vnc_client* self, uint32_t format);
|
2020-07-11 17:54:35 +00:00
|
|
|
|
|
|
|
int vnc_client_get_fd(const struct vnc_client* self);
|
|
|
|
int vnc_client_get_width(const struct vnc_client* self);
|
|
|
|
int vnc_client_get_height(const struct vnc_client* self);
|
|
|
|
int vnc_client_get_stride(const struct vnc_client* self);
|
|
|
|
void* vnc_client_get_fb(const struct vnc_client* self);
|
|
|
|
void vnc_client_set_fb(struct vnc_client* self, void* fb);
|
|
|
|
const char* vnc_client_get_desktop_name(const struct vnc_client* self);
|
|
|
|
int vnc_client_process(struct vnc_client* self);
|
|
|
|
void vnc_client_send_pointer_event(struct vnc_client* self, int x, int y,
|
|
|
|
uint32_t button_mask);
|
|
|
|
void vnc_client_send_keyboard_event(struct vnc_client* self, uint32_t symbol,
|
2020-11-30 21:59:55 +00:00
|
|
|
uint32_t code, bool is_pressed);
|
2020-07-11 22:24:11 +00:00
|
|
|
void vnc_client_set_encodings(struct vnc_client* self, const char* encodings);
|
|
|
|
void vnc_client_set_quality_level(struct vnc_client* self, int value);
|
|
|
|
void vnc_client_set_compression_level(struct vnc_client* self, int value);
|
2020-12-06 19:52:02 +00:00
|
|
|
void vnc_client_send_cut_text(struct vnc_client* self, const char* text,
|
|
|
|
size_t len);
|
2022-07-03 10:47:27 +00:00
|
|
|
void vnc_client_clear_av_frames(struct vnc_client* self);
|
2023-04-09 10:06:13 +00:00
|
|
|
void vnc_client_send_ntp_event(struct vnc_client* self, uint32_t t0,
|
|
|
|
uint32_t t1, uint32_t t2, uint32_t t3);
|