OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 * | 9 * |
10 */ | 10 */ |
11 | 11 |
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_ | 12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_ |
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_ | 13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_ |
14 | 14 |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/base/basictypes.h" | 17 #include "webrtc/base/basictypes.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 namespace rtcp { | 20 namespace rtcp { |
| 21 struct ReceiveTimeInfo { |
| 22 // RFC 3611 4.5 |
| 23 ReceiveTimeInfo() : ssrc(0), last_rr(0), delay_since_last_rr(0) {} |
| 24 ReceiveTimeInfo(uint32_t ssrc, uint32_t last_rr, uint32_t delay) |
| 25 : ssrc(ssrc), last_rr(last_rr), delay_since_last_rr(delay) {} |
| 26 uint32_t ssrc; |
| 27 uint32_t last_rr; |
| 28 uint32_t delay_since_last_rr; |
| 29 }; |
21 | 30 |
22 // DLRR Report Block: Delay since the Last Receiver Report (RFC 3611). | 31 // DLRR Report Block: Delay since the Last Receiver Report (RFC 3611). |
23 class Dlrr { | 32 class Dlrr { |
24 public: | 33 public: |
25 struct SubBlock { | |
26 // RFC 3611 4.5 | |
27 uint32_t ssrc; | |
28 uint32_t last_rr; | |
29 uint32_t delay_since_last_rr; | |
30 }; | |
31 | |
32 static const uint8_t kBlockType = 5; | 34 static const uint8_t kBlockType = 5; |
33 static const size_t kMaxNumberOfDlrrItems = 100; | 35 static const size_t kMaxNumberOfDlrrItems = 100; |
34 | 36 |
35 Dlrr() {} | 37 Dlrr() {} |
36 Dlrr(const Dlrr& other) = default; | 38 Dlrr(const Dlrr& other) = default; |
37 ~Dlrr() {} | 39 ~Dlrr() {} |
38 | 40 |
39 Dlrr& operator=(const Dlrr& other) = default; | 41 Dlrr& operator=(const Dlrr& other) = default; |
40 | 42 |
41 // Second parameter is value read from block header, | 43 // Second parameter is value read from block header, |
42 // i.e. size of block in 32bits excluding block header itself. | 44 // i.e. size of block in 32bits excluding block header itself. |
43 bool Parse(const uint8_t* buffer, uint16_t block_length_32bits); | 45 bool Parse(const uint8_t* buffer, uint16_t block_length_32bits); |
44 | 46 |
45 size_t BlockLength() const; | 47 size_t BlockLength() const; |
46 // Fills buffer with the Dlrr. | 48 // Fills buffer with the Dlrr. |
47 // Consumes BlockLength() bytes. | 49 // Consumes BlockLength() bytes. |
48 void Create(uint8_t* buffer) const; | 50 void Create(uint8_t* buffer) const; |
49 | 51 |
50 // Max 100 DLRR Items can be added per DLRR report block. | 52 // Max 100 DLRR Items can be added per DLRR report block. |
| 53 bool WithDlrrItem(const ReceiveTimeInfo& time_info); |
51 bool WithDlrrItem(uint32_t ssrc, uint32_t last_rr, uint32_t delay_last_rr); | 54 bool WithDlrrItem(uint32_t ssrc, uint32_t last_rr, uint32_t delay_last_rr); |
52 | 55 |
53 const std::vector<SubBlock>& sub_blocks() const { return sub_blocks_; } | 56 const std::vector<ReceiveTimeInfo>& sub_blocks() const { return sub_blocks_; } |
54 | 57 |
55 private: | 58 private: |
56 static const size_t kBlockHeaderLength = 4; | 59 static const size_t kBlockHeaderLength = 4; |
57 static const size_t kSubBlockLength = 12; | 60 static const size_t kSubBlockLength = 12; |
58 | 61 |
59 std::vector<SubBlock> sub_blocks_; | 62 std::vector<ReceiveTimeInfo> sub_blocks_; |
60 }; | 63 }; |
61 } // namespace rtcp | 64 } // namespace rtcp |
62 } // namespace webrtc | 65 } // namespace webrtc |
63 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_ | 66 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_ |
OLD | NEW |