aboutsummaryrefslogtreecommitdiffhomepage
path: root/artnet.h
blob: 0d61627eea1a03e26f57a8cb01cdd84b64d121f7 (plain)
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
#include <sys/socket.h>
#include "midimonster.h"

/*
 * TODO
 * 	bind per instance
 * 	destination per instance
 */

int init();
static int artnet_configure(char* option, char* value);
static int artnet_configure_instance(instance* instance, char* option, char* value);
static instance* artnet_instance();
static channel* artnet_channel(instance* instance, char* spec);
static int artnet_set(instance* inst, size_t num, channel** c, channel_value* v);
static int artnet_handle(size_t num, managed_fd* fds);
static int artnet_start();
static int artnet_shutdown();

#define ARTNET_PORT "6454"
#define ARTNET_VERSION 14
#define ARTNET_RECV_BUF 4096
#define ARTNET_KEEPALIVE_INTERVAL 15e5

typedef struct /*_artnet_universe_model*/ {
	uint8_t last_frame;
	uint8_t seq;
	uint8_t in[512];
	uint8_t out[512];
} artnet_universe;

typedef struct /*_artnet_instance_model*/ {
	uint8_t net;
	uint8_t uni;
	uint8_t mode;
	struct sockaddr_storage dest_addr;
	socklen_t dest_len;
	artnet_universe data;
} artnet_instance_data;

typedef union /*_artnet_instance_id*/ {
	struct {
		uint8_t net;
		uint8_t uni;
	} fields;
	uint64_t label;
} artnet_instance_id;

enum {
	output = 1,
	mark = 2
};

typedef struct /*_artnet_hdr*/ {
	uint8_t magic[8];
	uint16_t opcode;
	uint16_t version;
} artnet_hdr;

typedef struct /*_artnet_pkt*/ {
	uint8_t magic[8];
	uint16_t opcode;
	uint16_t version;
	uint8_t sequence;
	uint8_t port;
	uint8_t universe;
	uint8_t net;
	uint16_t length;
	uint8_t data[512];
} artnet_pkt;

enum artnet_pkt_opcode {
	OpDmx = 0x0050
};