• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_
14 
15 #include <vector>
16 
17 #include "webrtc/base/basictypes.h"
18 
19 namespace webrtc {
20 namespace rtcp {
21 
22 // DLRR Report Block: Delay since the Last Receiver Report (RFC 3611).
23 class Dlrr {
24  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;
33   static const size_t kMaxNumberOfDlrrItems = 100;
34 
Dlrr()35   Dlrr() {}
36   Dlrr(const Dlrr& other) = default;
~Dlrr()37   ~Dlrr() {}
38 
39   Dlrr& operator=(const Dlrr& other) = default;
40 
41   // Second parameter is value read from block header,
42   // i.e. size of block in 32bits excluding block header itself.
43   bool Parse(const uint8_t* buffer, uint16_t block_length_32bits);
44 
45   size_t BlockLength() const;
46   // Fills buffer with the Dlrr.
47   // Consumes BlockLength() bytes.
48   void Create(uint8_t* buffer) const;
49 
50   // Max 100 DLRR Items can be added per DLRR report block.
51   bool WithDlrrItem(uint32_t ssrc, uint32_t last_rr, uint32_t delay_last_rr);
52 
sub_blocks()53   const std::vector<SubBlock>& sub_blocks() const { return sub_blocks_; }
54 
55  private:
56   static const size_t kBlockHeaderLength = 4;
57   static const size_t kSubBlockLength = 12;
58 
59   std::vector<SubBlock> sub_blocks_;
60 };
61 }  // namespace rtcp
62 }  // namespace webrtc
63 #endif  // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_DLRR_H_
64