danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | * |
| 10 | */ |
| 11 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 12 | #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_ |
| 13 | #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_ |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 14 | |
Niels Möller | 65ec0fc | 2018-05-21 11:46:20 +0200 | [diff] [blame] | 15 | #include <stddef.h> |
| 16 | #include <stdint.h> |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 17 | |
Niels Möller | 65ec0fc | 2018-05-21 11:46:20 +0200 | [diff] [blame] | 18 | #include <vector> |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | namespace rtcp { |
Danil Chapovalov | d0c7bba | 2016-01-26 14:12:46 +0100 | [diff] [blame] | 22 | struct ReceiveTimeInfo { |
| 23 | // RFC 3611 4.5 |
| 24 | ReceiveTimeInfo() : ssrc(0), last_rr(0), delay_since_last_rr(0) {} |
| 25 | ReceiveTimeInfo(uint32_t ssrc, uint32_t last_rr, uint32_t delay) |
| 26 | : ssrc(ssrc), last_rr(last_rr), delay_since_last_rr(delay) {} |
| 27 | uint32_t ssrc; |
| 28 | uint32_t last_rr; |
| 29 | uint32_t delay_since_last_rr; |
| 30 | }; |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 31 | |
| 32 | // DLRR Report Block: Delay since the Last Receiver Report (RFC 3611). |
| 33 | class Dlrr { |
| 34 | public: |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 35 | static const uint8_t kBlockType = 5; |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 36 | |
eladalon | 8fa21c4 | 2017-06-16 07:07:47 -0700 | [diff] [blame] | 37 | Dlrr(); |
| 38 | Dlrr(const Dlrr& other); |
| 39 | ~Dlrr(); |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 40 | |
| 41 | Dlrr& operator=(const Dlrr& other) = default; |
| 42 | |
danilchap | 80ac24d | 2016-10-31 08:40:47 -0700 | [diff] [blame] | 43 | // Dlrr without items treated same as no dlrr block. |
| 44 | explicit operator bool() const { return !sub_blocks_.empty(); } |
| 45 | |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 46 | // Second parameter is value read from block header, |
| 47 | // i.e. size of block in 32bits excluding block header itself. |
| 48 | bool Parse(const uint8_t* buffer, uint16_t block_length_32bits); |
| 49 | |
| 50 | size_t BlockLength() const; |
| 51 | // Fills buffer with the Dlrr. |
| 52 | // Consumes BlockLength() bytes. |
| 53 | void Create(uint8_t* buffer) const; |
| 54 | |
danilchap | 80ac24d | 2016-10-31 08:40:47 -0700 | [diff] [blame] | 55 | void ClearItems() { sub_blocks_.clear(); } |
| 56 | void AddDlrrItem(const ReceiveTimeInfo& time_info) { |
| 57 | sub_blocks_.push_back(time_info); |
| 58 | } |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 59 | |
Danil Chapovalov | d0c7bba | 2016-01-26 14:12:46 +0100 | [diff] [blame] | 60 | const std::vector<ReceiveTimeInfo>& sub_blocks() const { return sub_blocks_; } |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 61 | |
| 62 | private: |
| 63 | static const size_t kBlockHeaderLength = 4; |
| 64 | static const size_t kSubBlockLength = 12; |
| 65 | |
Danil Chapovalov | d0c7bba | 2016-01-26 14:12:46 +0100 | [diff] [blame] | 66 | std::vector<ReceiveTimeInfo> sub_blocks_; |
danilchap | 54999d4 | 2015-12-16 01:56:20 -0800 | [diff] [blame] | 67 | }; |
| 68 | } // namespace rtcp |
| 69 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 70 | #endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_ |