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 | 11 |
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_ | 12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBR_H_ |
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_ | 13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBR_H_ |
14 | 14 |
15 #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 // Temporary Maximum Media Stream Bit Rate Request (TMMBR) (RFC 5104). |
23 // Temporary Maximum Media Stream Bit Rate Notification (TMMBN) (RFC 5104). | 22 class Tmmbr : public RtcpPacket { |
24 class Tmmbn : public RtcpPacket { | |
25 public: | 23 public: |
26 Tmmbn() : RtcpPacket() { | 24 Tmmbr() : RtcpPacket() { |
27 memset(&tmmbn_, 0, sizeof(tmmbn_)); | 25 memset(&tmmbr_, 0, sizeof(tmmbr_)); |
| 26 memset(&tmmbr_item_, 0, sizeof(tmmbr_item_)); |
28 } | 27 } |
29 | 28 |
30 virtual ~Tmmbn() {} | 29 virtual ~Tmmbr() {} |
31 | 30 |
32 void From(uint32_t ssrc) { | 31 void From(uint32_t ssrc) { |
33 tmmbn_.SenderSSRC = ssrc; | 32 tmmbr_.SenderSSRC = ssrc; |
34 } | 33 } |
35 // Max 50 TMMBR can be added per TMMBN. | 34 void To(uint32_t ssrc) { |
36 bool WithTmmbr(uint32_t ssrc, uint32_t bitrate_kbps, uint16_t overhead); | 35 tmmbr_item_.SSRC = ssrc; |
| 36 } |
| 37 void WithBitrateKbps(uint32_t bitrate_kbps) { |
| 38 tmmbr_item_.MaxTotalMediaBitRate = bitrate_kbps; |
| 39 } |
| 40 void WithOverhead(uint16_t overhead) { |
| 41 assert(overhead <= 0x1ff); |
| 42 tmmbr_item_.MeasuredOverhead = overhead; |
| 43 } |
37 | 44 |
38 protected: | 45 protected: |
39 bool Create(uint8_t* packet, | 46 bool Create(uint8_t* packet, |
40 size_t* index, | 47 size_t* index, |
41 size_t max_length, | 48 size_t max_length, |
42 RtcpPacket::PacketReadyCallback* callback) const override; | 49 RtcpPacket::PacketReadyCallback* callback) const override; |
43 | 50 |
44 private: | 51 private: |
45 static const int kMaxNumberOfTmmbrs = 50; | |
46 | |
47 size_t BlockLength() const { | 52 size_t BlockLength() const { |
48 const size_t kFciLen = 8; | 53 const size_t kFciLen = 8; |
49 return kCommonFbFmtLength + kFciLen * tmmbn_items_.size(); | 54 return kCommonFbFmtLength + kFciLen; |
50 } | 55 } |
51 | 56 |
52 RTCPUtility::RTCPPacketRTPFBTMMBN tmmbn_; | 57 RTCPUtility::RTCPPacketRTPFBTMMBR tmmbr_; |
53 std::vector<RTCPUtility::RTCPPacketRTPFBTMMBRItem> tmmbn_items_; | 58 RTCPUtility::RTCPPacketRTPFBTMMBRItem tmmbr_item_; |
54 | 59 |
55 RTC_DISALLOW_COPY_AND_ASSIGN(Tmmbn); | 60 RTC_DISALLOW_COPY_AND_ASSIGN(Tmmbr); |
56 }; | 61 }; |
57 | |
58 } // namespace rtcp | 62 } // namespace rtcp |
59 } // namespace webrtc | 63 } // namespace webrtc |
60 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBN_H_ | 64 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_TMMBR_H_ |
OLD | NEW |