blob: f0f23022f53233d6fd7523d3afb543af06ee2c29 [file] [log] [blame]
danilchap54999d42015-12-16 01:56:20 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020012#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_
13#define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_
danilchap54999d42015-12-16 01:56:20 -080014
15#include <vector>
16
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "rtc_base/basictypes.h"
danilchap54999d42015-12-16 01:56:20 -080018
19namespace webrtc {
20namespace rtcp {
Danil Chapovalovd0c7bba2016-01-26 14:12:46 +010021struct 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};
danilchap54999d42015-12-16 01:56:20 -080030
31// DLRR Report Block: Delay since the Last Receiver Report (RFC 3611).
32class Dlrr {
33 public:
danilchap54999d42015-12-16 01:56:20 -080034 static const uint8_t kBlockType = 5;
danilchap54999d42015-12-16 01:56:20 -080035
eladalon8fa21c42017-06-16 07:07:47 -070036 Dlrr();
37 Dlrr(const Dlrr& other);
38 ~Dlrr();
danilchap54999d42015-12-16 01:56:20 -080039
40 Dlrr& operator=(const Dlrr& other) = default;
41
danilchap80ac24d2016-10-31 08:40:47 -070042 // Dlrr without items treated same as no dlrr block.
43 explicit operator bool() const { return !sub_blocks_.empty(); }
44
danilchap54999d42015-12-16 01:56:20 -080045 // Second parameter is value read from block header,
46 // i.e. size of block in 32bits excluding block header itself.
47 bool Parse(const uint8_t* buffer, uint16_t block_length_32bits);
48
49 size_t BlockLength() const;
50 // Fills buffer with the Dlrr.
51 // Consumes BlockLength() bytes.
52 void Create(uint8_t* buffer) const;
53
danilchap80ac24d2016-10-31 08:40:47 -070054 void ClearItems() { sub_blocks_.clear(); }
55 void AddDlrrItem(const ReceiveTimeInfo& time_info) {
56 sub_blocks_.push_back(time_info);
57 }
danilchap54999d42015-12-16 01:56:20 -080058
Danil Chapovalovd0c7bba2016-01-26 14:12:46 +010059 const std::vector<ReceiveTimeInfo>& sub_blocks() const { return sub_blocks_; }
danilchap54999d42015-12-16 01:56:20 -080060
61 private:
62 static const size_t kBlockHeaderLength = 4;
63 static const size_t kSubBlockLength = 12;
64
Danil Chapovalovd0c7bba2016-01-26 14:12:46 +010065 std::vector<ReceiveTimeInfo> sub_blocks_;
danilchap54999d42015-12-16 01:56:20 -080066};
67} // namespace rtcp
68} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020069#endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_