blob: abb1323a332bf560b364fcea2acd4631895c3e4d (
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
* Copyright (c) 2021 Cisco and/or its affiliates.
*/
/* data packet
* +-----------------------------------------+
* | uint64_t: timestamp |
* | |
* +-----------------------------------------+
* | uint32_t: prod rate (bytes per sec) |
* +-----------------------------------------+
* | payload |
* | ... |
*/
/* nack packet
* +-----------------------------------------+
* | uint64_t: timestamp |
* | |
* +-----------------------------------------+
* | uint32_t: prod rate (bytes per sec) |
* +-----------------------------------------+
* | uint32_t: current seg in production |
* +-----------------------------------------+
*/
#pragma once
#include <arpa/inet.h>
namespace transport {
namespace protocol {
namespace rtc {
inline uint64_t _ntohll(const uint64_t *input) {
uint64_t return_val;
uint8_t *tmp = (uint8_t *)&return_val;
tmp[0] = *input >> 56;
tmp[1] = *input >> 48;
tmp[2] = *input >> 40;
tmp[3] = *input >> 32;
tmp[4] = *input >> 24;
tmp[5] = *input >> 16;
tmp[6] = *input >> 8;
tmp[7] = *input >> 0;
return return_val;
}
inline uint64_t _htonll(const uint64_t *input) { return (_ntohll(input)); }
const uint32_t DATA_HEADER_SIZE = 12; // bytes
// XXX: sizeof(data_packet_t) is 16
// beacuse of padding
const uint32_t NACK_HEADER_SIZE = 16;
struct data_packet_t {
uint64_t timestamp;
uint32_t prod_rate;
inline uint64_t getTimestamp() const { return _ntohll(×tamp); }
inline void setTimestamp(uint64_t time) { timestamp = _htonll(&time); }
inline uint32_t getProductionRate() const { return ntohl(prod_rate); }
inline void setProductionRate(uint32_t rate) { prod_rate = htonl(rate); }
};
struct nack_packet_t {
uint64_t timestamp;
uint32_t prod_rate;
uint32_t prod_seg;
inline uint64_t getTimestamp() const { return _ntohll(×tamp); }
inline void setTimestamp(uint64_t time) { timestamp = _htonll(&time); }
inline uint32_t getProductionRate() const { return ntohl(prod_rate); }
inline void setProductionRate(uint32_t rate) { prod_rate = htonl(rate); }
inline uint32_t getProductionSegement() const { return ntohl(prod_seg); }
inline void setProductionSegement(uint32_t seg) { prod_seg = htonl(seg); }
};
} // end namespace rtc
} // end namespace protocol
} // end namespace transport
|