-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbytestream.h
More file actions
71 lines (56 loc) · 1.69 KB
/
bytestream.h
File metadata and controls
71 lines (56 loc) · 1.69 KB
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
// bytestream.h
//
// Purpose: Utilities for creating bytestream-able data
// Author: Luke van der Hoeven
// Date: 7/5/12
// Protocol definition
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include "tpl.h"
#define SC_TimeBase 1000.0
#define STOP 0x01
#define START 0x02
#define MOUSE 0x03
#define VIDEO 0x04
#define NO_DATA 0xFF
typedef uint32_t sc_time;
static char TPL_STRUCTURE[] = "S(vu)B";
typedef struct {
uint16_t x, y;
} sc_mouse_coords;
typedef struct {
uint16_t x;
uint16_t y;
uint16_t width;
uint16_t height;
} sc_frame_rect;
typedef struct {
uint16_t type;
sc_time timestamp;
} sc_bytestream_header;
typedef struct {
uint8_t *framePtr;
int size;
} sc_frame;
typedef struct {
sc_bytestream_header header;
tpl_bin body;
} sc_bytestream_packet;
sc_bytestream_packet sc_bytestream_put_start(int fd);
sc_bytestream_packet sc_bytestream_put_stop(int fd);
sc_bytestream_packet sc_bytestream_put_mouse_data(int fd, sc_mouse_coords coords);
sc_bytestream_packet sc_bytestream_put_frame(int fd, sc_frame frame, sc_time timestamp);
sc_mouse_coords sc_bytestream_get_mouse_data(int fd);
sc_frame sc_bytestream_get_frame(int fd);
sc_bytestream_packet sc_bytestream_get_event(int fd);
sc_bytestream_header sc_bytestream_get_event_header(int fd);
sc_bytestream_header create_header(uint8_t type);
sc_bytestream_header create_header_with_time(uint8_t type, sc_time timestamp);
void serialize_packet(int fd, sc_bytestream_packet packet);
sc_bytestream_packet deserialize_packet(int fd);
sc_frame parse_frame(sc_bytestream_packet packet);
sc_mouse_coords parse_mouse_coords(sc_bytestream_packet packet);