File: metacube2.h

package info (click to toggle)
cubemap 1.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 428 kB
  • sloc: cpp: 4,431; sh: 114; perl: 102; makefile: 60
file content (55 lines) | stat: -rw-r--r-- 1,735 bytes parent folder | download | duplicates (2)
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
#ifndef _METACUBE2_H
#define _METACUBE2_H

/*
 * Definitions for the Metacube2 protocol, used to communicate with Cubemap.
 *
 * Note: This file is meant to compile as both C and C++, for easier inclusion
 * in other projects.
 */

#include <stdint.h>

#define METACUBE2_SYNC "cube!map"  /* 8 bytes long. */
#define METACUBE_FLAGS_HEADER 0x1
#define METACUBE_FLAGS_NOT_SUITABLE_FOR_STREAM_START 0x2

/*
 * Metadata packets; should not be counted as data, but rather
 * parsed (or ignored if you don't understand them).
 *
 * Metadata packets start with a uint64_t (network byte order)
 * that describe the type; the rest is defined by the type.
 */
#define METACUBE_FLAGS_METADATA 0x4

struct metacube2_block_header {
	char sync[8];    /* METACUBE2_SYNC */
	uint32_t size;   /* Network byte order. Does not include header. */
	uint16_t flags;  /* Network byte order. METACUBE_FLAGS_*. */
	uint16_t csum;   /* Network byte order. CRC16 of size and flags.
                            If METACUBE_FLAGS_METADATA is set, inverted
                            so that older clients will ignore it as broken. */
};

uint16_t metacube2_compute_crc(const struct metacube2_block_header *hdr);

/*
 * The only currently defined metadata type. Set by the encoder,
 * and can be measured for latency purposes (e.g., if the network
 * can't keep up, the latency will tend to increase.
 */
#define METACUBE_METADATA_TYPE_ENCODER_TIMESTAMP 0x1

struct metacube2_timestamp_packet {
	uint64_t type;  /* METACUBE_METADATA_TYPE_ENCODER_TIMESTAMP, in network byte order. */

	/*
	 * Time since the UTC epoch. Basically a struct timespec.
	 * Both are in network byte order.
	 */
	uint64_t tv_sec;
	uint64_t tv_nsec;
};

#endif  /* !defined(_METACUBE_H) */