• 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 MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REPORT_BLOCK_H_
13 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REPORT_BLOCK_H_
14 
15 #include <stddef.h>
16 #include <stdint.h>
17 
18 namespace webrtc {
19 namespace rtcp {
20 
21 // A ReportBlock represents the Sender Report packet from
22 // RFC 3550 section 6.4.1.
23 class ReportBlock {
24  public:
25   static const size_t kLength = 24;
26 
27   ReportBlock();
~ReportBlock()28   ~ReportBlock() {}
29 
30   bool Parse(const uint8_t* buffer, size_t length);
31 
32   // Fills buffer with the ReportBlock.
33   // Consumes ReportBlock::kLength bytes.
34   void Create(uint8_t* buffer) const;
35 
SetMediaSsrc(uint32_t ssrc)36   void SetMediaSsrc(uint32_t ssrc) { source_ssrc_ = ssrc; }
SetFractionLost(uint8_t fraction_lost)37   void SetFractionLost(uint8_t fraction_lost) {
38     fraction_lost_ = fraction_lost;
39   }
40   bool SetCumulativeLost(int32_t cumulative_lost);
SetExtHighestSeqNum(uint32_t ext_highest_seq_num)41   void SetExtHighestSeqNum(uint32_t ext_highest_seq_num) {
42     extended_high_seq_num_ = ext_highest_seq_num;
43   }
SetJitter(uint32_t jitter)44   void SetJitter(uint32_t jitter) { jitter_ = jitter; }
SetLastSr(uint32_t last_sr)45   void SetLastSr(uint32_t last_sr) { last_sr_ = last_sr; }
SetDelayLastSr(uint32_t delay_last_sr)46   void SetDelayLastSr(uint32_t delay_last_sr) {
47     delay_since_last_sr_ = delay_last_sr;
48   }
49 
source_ssrc()50   uint32_t source_ssrc() const { return source_ssrc_; }
fraction_lost()51   uint8_t fraction_lost() const { return fraction_lost_; }
cumulative_lost_signed()52   int32_t cumulative_lost_signed() const { return cumulative_lost_; }
53   // Deprecated - returns max(0, cumulative_lost_), not negative values.
54   uint32_t cumulative_lost() const;
extended_high_seq_num()55   uint32_t extended_high_seq_num() const { return extended_high_seq_num_; }
jitter()56   uint32_t jitter() const { return jitter_; }
last_sr()57   uint32_t last_sr() const { return last_sr_; }
delay_since_last_sr()58   uint32_t delay_since_last_sr() const { return delay_since_last_sr_; }
59 
60  private:
61   uint32_t source_ssrc_;     // 32 bits
62   uint8_t fraction_lost_;    // 8 bits representing a fixed point value 0..1
63   int32_t cumulative_lost_;  // Signed 24-bit value
64   uint32_t extended_high_seq_num_;  // 32 bits
65   uint32_t jitter_;                 // 32 bits
66   uint32_t last_sr_;                // 32 bits
67   uint32_t delay_since_last_sr_;    // 32 bits, units of 1/65536 seconds
68 };
69 
70 }  // namespace rtcp
71 }  // namespace webrtc
72 #endif  // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REPORT_BLOCK_H_
73