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