]> git.sesse.net Git - cubemap/blob - metacube2.h
Fix a problem where streams with paths exactly 7 characters long get broken buffering...
[cubemap] / metacube2.h
1 #ifndef _METACUBE2_H
2 #define _METACUBE2_H
3
4 /*
5  * Definitions for the Metacube2 protocol, used to communicate with Cubemap.
6  *
7  * Note: This file is meant to compile as both C and C++, for easier inclusion
8  * in other projects.
9  */
10
11 #include <stdint.h>
12
13 #define METACUBE2_SYNC "cube!map"  /* 8 bytes long. */
14 #define METACUBE_FLAGS_HEADER 0x1
15 #define METACUBE_FLAGS_NOT_SUITABLE_FOR_STREAM_START 0x2
16
17 /*
18  * Metadata packets; should not be counted as data, but rather
19  * parsed (or ignored if you don't understand them).
20  *
21  * Metadata packets start with a uint64_t (network byte order)
22  * that describe the type; the rest is defined by the type.
23  */
24 #define METACUBE_FLAGS_METADATA 0x4
25
26 struct metacube2_block_header {
27         char sync[8];    /* METACUBE2_SYNC */
28         uint32_t size;   /* Network byte order. Does not include header. */
29         uint16_t flags;  /* Network byte order. METACUBE_FLAGS_*. */
30         uint16_t csum;   /* Network byte order. CRC16 of size and flags.
31                             If METACUBE_FLAGS_METADATA is set, inverted
32                             so that older clients will ignore it as broken. */
33 };
34
35 uint16_t metacube2_compute_crc(const struct metacube2_block_header *hdr);
36
37 /*
38  * The only currently defined metadata type. Set by the encoder,
39  * and can be measured for latency purposes (e.g., if the network
40  * can't keep up, the latency will tend to increase.
41  */
42 #define METACUBE_METADATA_TYPE_ENCODER_TIMESTAMP 0x1
43
44 struct metacube2_timestamp_packet {
45         uint64_t type;  /* METACUBE_METADATA_TYPE_ENCODER_TIMESTAMP, in network byte order. */
46
47         /*
48          * Time since the UTC epoch. Basically a struct timespec.
49          * Both are in network byte order.
50          */
51         uint64_t tv_sec;
52         uint64_t tv_nsec;
53 };
54
55 #endif  /* !defined(_METACUBE_H) */