Chromium Code Reviews

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.cc

Issue 2937403002: Style fixes in rtcp_packet/ (Closed)
Patch Set: CR response Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 */ 9 */
10 10
(...skipping 20 matching lines...)
31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32 // 4 | Unused = 0 | 32 // 4 | Unused = 0 |
33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 // 8 | Unique identifier 'R' 'E' 'M' 'B' | 34 // 8 | Unique identifier 'R' 'E' 'M' 'B' |
35 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 // 12 | Num SSRC | BR Exp | BR Mantissa | 36 // 12 | Num SSRC | BR Exp | BR Mantissa |
37 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 // 16 | SSRC feedback | 38 // 16 | SSRC feedback |
39 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 // : ... : 40 // : ... :
41
42 Remb::Remb() : bitrate_bps_(0) {}
43
44 Remb::~Remb() = default;
45
41 bool Remb::Parse(const CommonHeader& packet) { 46 bool Remb::Parse(const CommonHeader& packet) {
42 RTC_DCHECK(packet.type() == kPacketType); 47 RTC_DCHECK(packet.type() == kPacketType);
43 RTC_DCHECK_EQ(packet.fmt(), kFeedbackMessageType); 48 RTC_DCHECK_EQ(packet.fmt(), kFeedbackMessageType);
44 49
45 if (packet.payload_size_bytes() < 16) { 50 if (packet.payload_size_bytes() < 16) {
46 LOG(LS_WARNING) << "Payload length " << packet.payload_size_bytes() 51 LOG(LS_WARNING) << "Payload length " << packet.payload_size_bytes()
47 << " is too small for Remb packet."; 52 << " is too small for Remb packet.";
48 return false; 53 return false;
49 } 54 }
50 const uint8_t* const payload = packet.payload(); 55 const uint8_t* const payload = packet.payload();
(...skipping 34 matching lines...)
85 90
86 bool Remb::SetSsrcs(std::vector<uint32_t> ssrcs) { 91 bool Remb::SetSsrcs(std::vector<uint32_t> ssrcs) {
87 if (ssrcs.size() > kMaxNumberOfSsrcs) { 92 if (ssrcs.size() > kMaxNumberOfSsrcs) {
88 LOG(LS_WARNING) << "Not enough space for all given SSRCs."; 93 LOG(LS_WARNING) << "Not enough space for all given SSRCs.";
89 return false; 94 return false;
90 } 95 }
91 ssrcs_ = std::move(ssrcs); 96 ssrcs_ = std::move(ssrcs);
92 return true; 97 return true;
93 } 98 }
94 99
100 size_t Remb::BlockLength() const {
101 return kHeaderLength + kCommonFeedbackLength + (2 + ssrcs_.size()) * 4;
102 }
103
95 bool Remb::Create(uint8_t* packet, 104 bool Remb::Create(uint8_t* packet,
96 size_t* index, 105 size_t* index,
97 size_t max_length, 106 size_t max_length,
98 RtcpPacket::PacketReadyCallback* callback) const { 107 RtcpPacket::PacketReadyCallback* callback) const {
99 while (*index + BlockLength() > max_length) { 108 while (*index + BlockLength() > max_length) {
100 if (!OnBufferFull(packet, index, callback)) 109 if (!OnBufferFull(packet, index, callback))
101 return false; 110 return false;
102 } 111 }
103 size_t index_end = *index + BlockLength(); 112 size_t index_end = *index + BlockLength();
104 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, 113 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet,
(...skipping 18 matching lines...)
123 132
124 for (uint32_t ssrc : ssrcs_) { 133 for (uint32_t ssrc : ssrcs_) {
125 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, ssrc); 134 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, ssrc);
126 *index += sizeof(uint32_t); 135 *index += sizeof(uint32_t);
127 } 136 }
128 RTC_DCHECK_EQ(index_end, *index); 137 RTC_DCHECK_EQ(index_end, *index);
129 return true; 138 return true;
130 } 139 }
131 } // namespace rtcp 140 } // namespace rtcp
132 } // namespace webrtc 141 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h » ('j') | no next file with comments »

Powered by Google App Engine