blob: fa807299b0b5b48ec4210b58fc0993e33ad1ffbf [file] [log] [blame]
Danil Chapovalova5eba6c2016-01-15 11:40:151/*
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 WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_
13
14#include <vector>
danilchapd8dccd52016-01-20 20:08:5115
Danil Chapovalova5eba6c2016-01-15 11:40:1516#include "webrtc/base/basictypes.h"
kwiberg4485ffb2016-04-26 15:14:3917#include "webrtc/base/constructormagic.h"
danilchapd8dccd52016-01-20 20:08:5118#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h"
Danil Chapovalova5eba6c2016-01-15 11:40:1519#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
20
21namespace webrtc {
22namespace rtcp {
23// Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb).
danilchapd8dccd52016-01-20 20:08:5124class Remb : public Psfb {
Danil Chapovalova5eba6c2016-01-15 11:40:1525 public:
danilchapd8dccd52016-01-20 20:08:5126 static const uint8_t kFeedbackMessageType = 15;
Danil Chapovalova5eba6c2016-01-15 11:40:1527
danilchapd8dccd52016-01-20 20:08:5128 Remb() : bitrate_bps_(0) {}
29 ~Remb() override {}
Danil Chapovalova5eba6c2016-01-15 11:40:1530
danilchapd8dccd52016-01-20 20:08:5131 // Parse assumes header is already parsed and validated.
32 bool Parse(const RTCPUtility::RtcpCommonHeader& header,
33 const uint8_t* payload); // Size of the payload is in the header.
Danil Chapovalova5eba6c2016-01-15 11:40:1534
danilchapd8dccd52016-01-20 20:08:5135 bool AppliesTo(uint32_t ssrc);
36 bool AppliesToMany(const std::vector<uint32_t>& ssrcs);
37 void WithBitrateBps(uint32_t bitrate_bps) { bitrate_bps_ = bitrate_bps; }
38
39 uint32_t bitrate_bps() const { return bitrate_bps_; }
40 const std::vector<uint32_t>& ssrcs() const { return ssrcs_; }
Danil Chapovalova5eba6c2016-01-15 11:40:1541
42 protected:
43 bool Create(uint8_t* packet,
44 size_t* index,
45 size_t max_length,
46 RtcpPacket::PacketReadyCallback* callback) const override;
47
danilchapd8dccd52016-01-20 20:08:5148 size_t BlockLength() const override {
49 return kHeaderLength + kCommonFeedbackLength + (2 + ssrcs_.size()) * 4;
Danil Chapovalova5eba6c2016-01-15 11:40:1550 }
51
danilchapd8dccd52016-01-20 20:08:5152 private:
53 static const size_t kMaxNumberOfSsrcs = 0xff;
54 static const uint32_t kUniqueIdentifier = 0x52454D42; // 'R' 'E' 'M' 'B'.
55
56 // Media ssrc is unused, shadow base class setter and getter.
57 void To(uint32_t);
58 uint32_t media_ssrc() const;
59
60 uint32_t bitrate_bps_;
61 std::vector<uint32_t> ssrcs_;
Danil Chapovalova5eba6c2016-01-15 11:40:1562
63 RTC_DISALLOW_COPY_AND_ASSIGN(Remb);
64};
65} // namespace rtcp
66} // namespace webrtc
67#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_