5 * Definitions for the Metacube2 protocol, used to communicate with Cubemap.
7 * Note: This file is meant to compile as both C and C++, for easier inclusion
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
18 * Metadata packets; should not be counted as data, but rather
19 * parsed (or ignored if you don't understand them).
21 * Metadata packets start with a uint64_t (network byte order)
22 * that describe the type; the rest is defined by the type.
24 #define METACUBE_FLAGS_METADATA 0x4
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. */
35 uint16_t metacube2_compute_crc(const struct metacube2_block_header *hdr);
38 * Set by the encoder, and can be measured for latency purposes (e.g., if the
39 * network can't keep up, the latency will tend to increase.
41 #define METACUBE_METADATA_TYPE_ENCODER_TIMESTAMP 0x1
43 struct metacube2_timestamp_packet {
44 uint64_t type; /* METACUBE_METADATA_TYPE_ENCODER_TIMESTAMP, in network byte order. */
47 * Time since the UTC epoch. Basically a struct timespec.
48 * Both are in network byte order.
55 * Sent before a block to mark its presentation timestamp (ie., counts
56 * only for the next Metacube block). Used so that the reflector can know
57 * the length (in seconds) of fragments.
59 #define METACUBE_METADATA_TYPE_NEXT_BLOCK_PTS 0x2
61 struct metacube2_pts_packet {
62 uint64_t type; /* METACUBE_METADATA_TYPE_NEXT_BLOCK_PTS, in network byte order. */
64 /* The timestamp of the first packet in the next block, in network byte order. */
67 /* Timebase "pts" is expressed in, as a fraction. Network byte order. */
68 uint64_t timebase_num, timebase_den;
71 #endif /* !defined(_METACUBE_H) */