| 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_TMMBN_H_ |
| 13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_ |
| 14 | 13 |
| 15 #include <vector> | 14 #include <vector> |
| 15 |
| 16 #include "webrtc/base/basictypes.h" | 16 #include "webrtc/base/basictypes.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmb_item.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 namespace rtcp { | 22 namespace rtcp { |
| 23 // Temporary Maximum Media Stream Bit Rate Notification (TMMBN). |
| 24 // RFC 5104, Section 4.2.2. |
| 25 class Tmmbn : public Rtpfb { |
| 26 public: |
| 27 static const uint8_t kFeedbackMessageType = 4; |
| 22 | 28 |
| 23 // Temporary Maximum Media Stream Bit Rate Notification (TMMBN) (RFC 5104). | 29 Tmmbn() {} |
| 24 class Tmmbn : public RtcpPacket { | 30 ~Tmmbn() override {} |
| 25 public: | 31 |
| 26 Tmmbn() : RtcpPacket() { | 32 // Parse assumes header is already parsed and validated. |
| 27 memset(&tmmbn_, 0, sizeof(tmmbn_)); | 33 bool Parse(const RTCPUtility::RtcpCommonHeader& header, |
| 34 const uint8_t* payload); // Size of the payload is in the header. |
| 35 |
| 36 void WithTmmbr(uint32_t ssrc, uint32_t bitrate_kbps, uint16_t overhead) { |
| 37 WithTmmbr(TmmbItem(ssrc, bitrate_kbps * 1000, overhead)); |
| 28 } | 38 } |
| 39 void WithTmmbr(const TmmbItem& item); |
| 29 | 40 |
| 30 virtual ~Tmmbn() {} | 41 const std::vector<TmmbItem>& items() const { return items_; } |
| 31 | |
| 32 void From(uint32_t ssrc) { | |
| 33 tmmbn_.SenderSSRC = ssrc; | |
| 34 } | |
| 35 // Max 50 TMMBR can be added per TMMBN. | |
| 36 bool WithTmmbr(uint32_t ssrc, uint32_t bitrate_kbps, uint16_t overhead); | |
| 37 | 42 |
| 38 protected: | 43 protected: |
| 39 bool Create(uint8_t* packet, | 44 bool Create(uint8_t* packet, |
| 40 size_t* index, | 45 size_t* index, |
| 41 size_t max_length, | 46 size_t max_length, |
| 42 RtcpPacket::PacketReadyCallback* callback) const override; | 47 RtcpPacket::PacketReadyCallback* callback) const override; |
| 43 | 48 |
| 44 private: | 49 private: |
| 45 static const int kMaxNumberOfTmmbrs = 50; | 50 size_t BlockLength() const override { |
| 46 | 51 return kHeaderLength + kCommonFeedbackLength + |
| 47 size_t BlockLength() const { | 52 TmmbItem::kLength * items_.size(); |
| 48 const size_t kFciLen = 8; | |
| 49 return kCommonFbFmtLength + kFciLen * tmmbn_items_.size(); | |
| 50 } | 53 } |
| 51 | 54 |
| 52 RTCPUtility::RTCPPacketRTPFBTMMBN tmmbn_; | 55 // Media ssrc is unused, shadow base class setter and getter. |
| 53 std::vector<RTCPUtility::RTCPPacketRTPFBTMMBRItem> tmmbn_items_; | 56 void To(uint32_t ssrc); |
| 57 uint32_t media_ssrc() const; |
| 58 |
| 59 std::vector<TmmbItem> items_; |
| 54 | 60 |
| 55 RTC_DISALLOW_COPY_AND_ASSIGN(Tmmbn); | 61 RTC_DISALLOW_COPY_AND_ASSIGN(Tmmbn); |
| 56 }; | 62 }; |
| 57 | |
| 58 } // namespace rtcp | 63 } // namespace rtcp |
| 59 } // namespace webrtc | 64 } // namespace webrtc |
| 60 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_ | 65 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_ |
| OLD | NEW |