OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_ |
13 | 13 |
14 #include <vector> | 14 #include <vector> |
| 15 |
15 #include "webrtc/base/basictypes.h" | 16 #include "webrtc/base/basictypes.h" |
16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" |
17 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 namespace rtcp { | 21 namespace rtcp { |
21 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb). | 22 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb). |
22 class Remb : public RtcpPacket { | 23 class Remb : public Psfb { |
23 public: | 24 public: |
24 Remb() : RtcpPacket() { | 25 static const uint8_t kFeedbackMessageType = 15; |
25 memset(&remb_, 0, sizeof(remb_)); | |
26 memset(&remb_item_, 0, sizeof(remb_item_)); | |
27 } | |
28 | 26 |
29 virtual ~Remb() {} | 27 Remb() : bitrate_bps_(0) {} |
| 28 ~Remb() override {} |
30 | 29 |
31 void From(uint32_t ssrc) { | 30 // Parse assumes header is already parsed and validated. |
32 remb_.SenderSSRC = ssrc; | 31 bool Parse(const RTCPUtility::RtcpCommonHeader& header, |
33 } | 32 const uint8_t* payload); // Size of the payload is in the header. |
34 void AppliesTo(uint32_t ssrc); | |
35 | 33 |
36 void WithBitrateBps(uint32_t bitrate_bps) { | 34 bool AppliesTo(uint32_t ssrc); |
37 remb_item_.BitRate = bitrate_bps; | 35 bool AppliesToMany(const std::vector<uint32_t>& ssrcs); |
38 } | 36 void WithBitrateBps(uint32_t bitrate_bps) { bitrate_bps_ = bitrate_bps; } |
| 37 |
| 38 uint32_t bitrate_bps() const { return bitrate_bps_; } |
| 39 const std::vector<uint32_t>& ssrcs() const { return ssrcs_; } |
39 | 40 |
40 protected: | 41 protected: |
41 bool Create(uint8_t* packet, | 42 bool Create(uint8_t* packet, |
42 size_t* index, | 43 size_t* index, |
43 size_t max_length, | 44 size_t max_length, |
44 RtcpPacket::PacketReadyCallback* callback) const override; | 45 RtcpPacket::PacketReadyCallback* callback) const override; |
45 | 46 |
46 private: | 47 size_t BlockLength() const override { |
47 static const int kMaxNumberOfSsrcs = 0xff; | 48 return kHeaderLength + kCommonFeedbackLength + (2 + ssrcs_.size()) * 4; |
48 | |
49 size_t BlockLength() const { | |
50 return (remb_item_.NumberOfSSRCs + 5) * 4; | |
51 } | 49 } |
52 | 50 |
53 RTCPUtility::RTCPPacketPSFBAPP remb_; | 51 private: |
54 RTCPUtility::RTCPPacketPSFBREMBItem remb_item_; | 52 static const size_t kMaxNumberOfSsrcs = 0xff; |
| 53 static const uint32_t kUniqueIdentifier = 0x52454D42; // 'R' 'E' 'M' 'B'. |
| 54 |
| 55 // Media ssrc is unused, shadow base class setter and getter. |
| 56 void To(uint32_t); |
| 57 uint32_t media_ssrc() const; |
| 58 |
| 59 uint32_t bitrate_bps_; |
| 60 std::vector<uint32_t> ssrcs_; |
55 | 61 |
56 RTC_DISALLOW_COPY_AND_ASSIGN(Remb); | 62 RTC_DISALLOW_COPY_AND_ASSIGN(Remb); |
57 }; | 63 }; |
58 } // namespace rtcp | 64 } // namespace rtcp |
59 } // namespace webrtc | 65 } // namespace webrtc |
60 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_ | 66 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_REMB_H_ |
OLD | NEW |