Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h

Issue 1670973002: [rtp_rtcp] rtcp::Tmmbn cleaned and got Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase & spelling Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698