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
12#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_
13#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_
14
15#include <vector>
16#include "webrtc/base/basictypes.h"
17#include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
18#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
19
20namespace webrtc {
21namespace rtcp {
22
23// Temporary Maximum Media Stream Bit Rate Notification (TMMBN) (RFC 5104).
24class Tmmbn : public RtcpPacket {
25 public:
26  Tmmbn() : RtcpPacket() {
27    memset(&tmmbn_, 0, sizeof(tmmbn_));
28  }
29
30  virtual ~Tmmbn() {}
31
32  void From(uint32_t ssrc) {
33    tmmbn_.SenderSSRC = ssrc;
34  }
35  // Max 50 TMMBR can be added per TMMBN.
36  bool WithTmmbr(uint32_t ssrc, uint32_t bitrate_kbps, uint16_t overhead);
37
38 protected:
39  bool Create(uint8_t* packet,
40              size_t* index,
41              size_t max_length,
42              RtcpPacket::PacketReadyCallback* callback) const override;
43
44 private:
45  static const int kMaxNumberOfTmmbrs = 50;
46
47  size_t BlockLength() const {
48    const size_t kFciLen = 8;
49    return kCommonFbFmtLength + kFciLen * tmmbn_items_.size();
50  }
51
52  RTCPUtility::RTCPPacketRTPFBTMMBN tmmbn_;
53  std::vector<RTCPUtility::RTCPPacketRTPFBTMMBRItem> tmmbn_items_;
54
55  RTC_DISALLOW_COPY_AND_ASSIGN(Tmmbn);
56};
57
58}  // namespace rtcp
59}  // namespace webrtc
60#endif  // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_
61