1 /*
2  *  Copyright (c) 2016 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 #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMB_ITEM_H_
12 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMB_ITEM_H_
13 
14 #include <stddef.h>
15 #include <stdint.h>
16 
17 namespace webrtc {
18 namespace rtcp {
19 // RFC5104, Section 3.5.4
20 // Temporary Maximum Media Stream Bitrate Request/Notification.
21 // Used both by TMMBR and TMMBN rtcp packets.
22 class TmmbItem {
23  public:
24   static const size_t kLength = 8;
25 
TmmbItem()26   TmmbItem() : ssrc_(0), bitrate_bps_(0), packet_overhead_(0) {}
27   TmmbItem(uint32_t ssrc, uint64_t bitrate_bps, uint16_t overhead);
28 
29   bool Parse(const uint8_t* buffer);
30   void Create(uint8_t* buffer) const;
31 
set_ssrc(uint32_t ssrc)32   void set_ssrc(uint32_t ssrc) { ssrc_ = ssrc; }
set_bitrate_bps(uint64_t bitrate_bps)33   void set_bitrate_bps(uint64_t bitrate_bps) { bitrate_bps_ = bitrate_bps; }
34   void set_packet_overhead(uint16_t overhead);
35 
ssrc()36   uint32_t ssrc() const { return ssrc_; }
bitrate_bps()37   uint64_t bitrate_bps() const { return bitrate_bps_; }
packet_overhead()38   uint16_t packet_overhead() const { return packet_overhead_; }
39 
40  private:
41   // Media stream id.
42   uint32_t ssrc_;
43   // Maximum total media bit rate that the media receiver is
44   // currently prepared to accept for this media stream.
45   uint64_t bitrate_bps_;
46   // Per-packet overhead that the media receiver has observed
47   // for this media stream at its chosen reference protocol layer.
48   uint16_t packet_overhead_;
49 };
50 }  // namespace rtcp
51 }  // namespace webrtc
52 #endif  // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMB_ITEM_H_
53