blob: b034a964fd02087b6e9b9f990900052fe9a66c47 [file] [log] [blame]
Danil Chapovalova5eba6c2016-01-15 12:40:15 +01001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_
12#define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010013
14#include <vector>
danilchapd8dccd52016-01-20 12:08:51 -080015
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/rtp_rtcp/source/rtcp_packet/psfb.h"
17#include "rtc_base/basictypes.h"
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010018
19namespace webrtc {
20namespace rtcp {
Danil Chapovalovd215ade2016-05-12 15:25:39 +020021class CommonHeader;
22
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010023// Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb).
danilchapd8dccd52016-01-20 12:08:51 -080024class Remb : public Psfb {
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010025 public:
Danil Chapovalovd215ade2016-05-12 15:25:39 +020026 static constexpr uint8_t kFeedbackMessageType = 15;
danilchap822a16f2016-09-27 09:27:47 -070027 static constexpr size_t kMaxNumberOfSsrcs = 0xff;
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010028
eladalon8fa21c42017-06-16 07:07:47 -070029 Remb();
30 ~Remb() override;
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010031
danilchapd8dccd52016-01-20 12:08:51 -080032 // Parse assumes header is already parsed and validated.
Danil Chapovalovd215ade2016-05-12 15:25:39 +020033 bool Parse(const CommonHeader& packet);
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010034
danilchap822a16f2016-09-27 09:27:47 -070035 bool SetSsrcs(std::vector<uint32_t> ssrcs);
36 void SetBitrateBps(uint64_t bitrate_bps) { bitrate_bps_ = bitrate_bps; }
danilchapd8dccd52016-01-20 12:08:51 -080037
Danil Chapovalovd215ade2016-05-12 15:25:39 +020038 uint64_t bitrate_bps() const { return bitrate_bps_; }
danilchapd8dccd52016-01-20 12:08:51 -080039 const std::vector<uint32_t>& ssrcs() const { return ssrcs_; }
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010040
eladalon8fa21c42017-06-16 07:07:47 -070041 size_t BlockLength() const override;
42
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010043 bool Create(uint8_t* packet,
44 size_t* index,
45 size_t max_length,
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010046 PacketReadyCallback callback) const override;
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010047
danilchapd8dccd52016-01-20 12:08:51 -080048 private:
Danil Chapovalovd215ade2016-05-12 15:25:39 +020049 static constexpr uint32_t kUniqueIdentifier = 0x52454D42; // 'R' 'E' 'M' 'B'.
danilchapd8dccd52016-01-20 12:08:51 -080050
51 // Media ssrc is unused, shadow base class setter and getter.
danilchap822a16f2016-09-27 09:27:47 -070052 void SetMediaSsrc(uint32_t);
danilchapd8dccd52016-01-20 12:08:51 -080053 uint32_t media_ssrc() const;
54
Danil Chapovalovd215ade2016-05-12 15:25:39 +020055 uint64_t bitrate_bps_;
danilchapd8dccd52016-01-20 12:08:51 -080056 std::vector<uint32_t> ssrcs_;
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010057};
58} // namespace rtcp
59} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020060#endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_