blob: 232b25b096791afe0e406f12a0fb5f143855ff5d [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"
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010017
18namespace webrtc {
19namespace rtcp {
Danil Chapovalovd215ade2016-05-12 15:25:39 +020020class CommonHeader;
21
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010022// Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb).
danilchapd8dccd52016-01-20 12:08:51 -080023class Remb : public Psfb {
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010024 public:
danilchap822a16f2016-09-27 09:27:47 -070025 static constexpr size_t kMaxNumberOfSsrcs = 0xff;
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010026
eladalon8fa21c42017-06-16 07:07:47 -070027 Remb();
Mirko Bonadei55d5ef02018-09-03 09:47:38 +020028 Remb(const Remb&);
eladalon8fa21c42017-06-16 07:07:47 -070029 ~Remb() override;
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010030
danilchapd8dccd52016-01-20 12:08:51 -080031 // Parse assumes header is already parsed and validated.
Danil Chapovalovd215ade2016-05-12 15:25:39 +020032 bool Parse(const CommonHeader& packet);
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010033
danilchap822a16f2016-09-27 09:27:47 -070034 bool SetSsrcs(std::vector<uint32_t> ssrcs);
35 void SetBitrateBps(uint64_t bitrate_bps) { bitrate_bps_ = bitrate_bps; }
danilchapd8dccd52016-01-20 12:08:51 -080036
Danil Chapovalovd215ade2016-05-12 15:25:39 +020037 uint64_t bitrate_bps() const { return bitrate_bps_; }
danilchapd8dccd52016-01-20 12:08:51 -080038 const std::vector<uint32_t>& ssrcs() const { return ssrcs_; }
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010039
eladalon8fa21c42017-06-16 07:07:47 -070040 size_t BlockLength() const override;
41
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010042 bool Create(uint8_t* packet,
43 size_t* index,
44 size_t max_length,
Danil Chapovalov5c3cc412017-12-07 10:15:53 +010045 PacketReadyCallback callback) const override;
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010046
danilchapd8dccd52016-01-20 12:08:51 -080047 private:
Danil Chapovalovd215ade2016-05-12 15:25:39 +020048 static constexpr uint32_t kUniqueIdentifier = 0x52454D42; // 'R' 'E' 'M' 'B'.
danilchapd8dccd52016-01-20 12:08:51 -080049
50 // Media ssrc is unused, shadow base class setter and getter.
danilchap822a16f2016-09-27 09:27:47 -070051 void SetMediaSsrc(uint32_t);
danilchapd8dccd52016-01-20 12:08:51 -080052 uint32_t media_ssrc() const;
53
Danil Chapovalovd215ade2016-05-12 15:25:39 +020054 uint64_t bitrate_bps_;
danilchapd8dccd52016-01-20 12:08:51 -080055 std::vector<uint32_t> ssrcs_;
Danil Chapovalova5eba6c2016-01-15 12:40:15 +010056};
57} // namespace rtcp
58} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020059#endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_