-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathobs-vnc-source.h
130 lines (115 loc) · 2.53 KB
/
obs-vnc-source.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef OBS_VNC_SOURCE_H
#define OBS_VNC_SOURCE_H
#include <obs.h>
#include <util/threading.h>
#include <rfb/rfbconfig.h>
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(30, 0, 0)
#include <util/deque.h>
#else
#include <util/circlebuf.h>
#define deque_pop_front circlebuf_pop_front
#define deque_push_back circlebuf_push_back
#define deque_init circlebuf_init
#define deque_free circlebuf_free
#define deque circlebuf
#endif
enum vnc_encodings_e {
ve_tight = 1,
ve_zrle = 2,
ve_ultra = 4,
ve_hextile = 8,
ve_zlib = 16,
ve_corre = 32,
ve_rre = 64,
ve_raw = 128,
};
struct vncsrc_conig
{
char *host_name;
int host_port;
#ifdef LIBVNCSERVER_HAVE_SASL
char *user_name;
#endif // LIBVNCSERVER_HAVE_SASL
char *plain_passwd;
unsigned int rfb_timeout;
int bpp; // bits per pixel; 8, 16, [32] only.
int encodings;
int compress;
bool jpeg;
int quality;
int qosdscp;
enum connect_e {
connect_always = 0,
connect_at_shown = 1,
connect_at_active = 2,
connect_at_shown_disconnect_at_hidden = 1 + 4,
connect_at_active_disconnect_at_hidden = 2 + 4,
connect_at_active_disconnect_at_inactive = 2 + 8,
} connect_opt;
bool clear_at_disconnect;
int skip_update_l, skip_update_r, skip_update_t, skip_update_b;
};
struct vncsrc_interaction_event_s
{
enum type_e {
mouse_click,
mouse_click_up,
mouse_move,
mouse_leave,
mouse_wheel,
key_click,
key_click_up,
} type;
union {
// key
struct
{
uint32_t modifiers;
char text[8];
uint32_t native_vkey;
};
// mouse_click, mouse_wheel
struct
{
int32_t mouse_x, mouse_y;
int32_t button_type;
int x_delta;
int y_delta;
};
};
};
// for display_flags
#define VNCSRC_FLG_SHOWN 1
#define VNCSRC_FLG_ACTIVE 2
struct vnc_source
{
pthread_mutex_t config_mutex;
volatile struct vncsrc_conig config;
obs_source_t *source;
volatile bool need_reconnect;
volatile bool encoding_updated;
volatile bool dscp_updated;
volatile bool skip_updated;
volatile bool running;
volatile long display_flags;
struct obs_source_frame frame;
void *fb_vnc; // for 8-bit and 16-bit
pthread_mutex_t interact_mutex;
struct deque interacts;
// threads
pthread_t thread;
};
void vncsrc_thread_start(struct vnc_source *src);
void vncsrc_thread_stop(struct vnc_source *src);
void vncsrc_request_reconnect(struct vnc_source *src);
#define BFREE_IF_NONNULL(x) \
if (x) { \
bfree(x); \
(x) = NULL; \
}
static inline void vncsrc_config_destroy_member(volatile struct vncsrc_conig *c)
{
BFREE_IF_NONNULL(c->host_name);
BFREE_IF_NONNULL(c->plain_passwd);
}
#endif // OBS_VNC_SOURCE_H