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_REMB_H_
12 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_
13 
14 #include <vector>
15 
16 #include "modules/rtp_rtcp/source/rtcp_packet/psfb.h"
17 
18 namespace webrtc {
19 namespace rtcp {
20 class CommonHeader;
21 
22 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb).
23 class Remb : public Psfb {
24  public:
25   static constexpr size_t kMaxNumberOfSsrcs = 0xff;
26 
27   Remb();
28   Remb(const Remb&);
29   ~Remb() override;
30 
31   // Parse assumes header is already parsed and validated.
32   bool Parse(const CommonHeader& packet);
33 
34   bool SetSsrcs(std::vector<uint32_t> ssrcs);
SetBitrateBps(int64_t bitrate_bps)35   void SetBitrateBps(int64_t bitrate_bps) { bitrate_bps_ = bitrate_bps; }
36 
bitrate_bps()37   int64_t bitrate_bps() const { return bitrate_bps_; }
ssrcs()38   const std::vector<uint32_t>& ssrcs() const { return ssrcs_; }
39 
40   size_t BlockLength() const override;
41 
42   bool Create(uint8_t* packet,
43               size_t* index,
44               size_t max_length,
45               PacketReadyCallback callback) const override;
46 
47  private:
48   static constexpr uint32_t kUniqueIdentifier = 0x52454D42;  // 'R' 'E' 'M' 'B'.
49 
50   // Media ssrc is unused, shadow base class setter and getter.
51   void SetMediaSsrc(uint32_t);
52   uint32_t media_ssrc() const;
53 
54   int64_t bitrate_bps_;
55   std::vector<uint32_t> ssrcs_;
56 };
57 }  // namespace rtcp
58 }  // namespace webrtc
59 #endif  // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_
60