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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.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. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 for (size_t index = 0; index < nack_items; ++index) { 68 for (size_t index = 0; index < nack_items; ++index) {
69 packed_[index].first_pid = ByteReader<uint16_t>::ReadBigEndian(next_nack); 69 packed_[index].first_pid = ByteReader<uint16_t>::ReadBigEndian(next_nack);
70 packed_[index].bitmask = ByteReader<uint16_t>::ReadBigEndian(next_nack + 2); 70 packed_[index].bitmask = ByteReader<uint16_t>::ReadBigEndian(next_nack + 2);
71 next_nack += kNackItemLength; 71 next_nack += kNackItemLength;
72 } 72 }
73 Unpack(); 73 Unpack();
74 74
75 return true; 75 return true;
76 } 76 }
77 77
78 size_t Nack::BlockLength() const {
79 return kHeaderLength + kCommonFeedbackLength +
80 packed_.size() * kNackItemLength;
81 }
82
78 bool Nack::Create(uint8_t* packet, 83 bool Nack::Create(uint8_t* packet,
79 size_t* index, 84 size_t* index,
80 size_t max_length, 85 size_t max_length,
81 RtcpPacket::PacketReadyCallback* callback) const { 86 RtcpPacket::PacketReadyCallback* callback) const {
82 RTC_DCHECK(!packed_.empty()); 87 RTC_DCHECK(!packed_.empty());
83 // If nack list can't fit in packet, try to fragment. 88 // If nack list can't fit in packet, try to fragment.
84 constexpr size_t kNackHeaderLength = kHeaderLength + kCommonFeedbackLength; 89 constexpr size_t kNackHeaderLength = kHeaderLength + kCommonFeedbackLength;
85 for (size_t nack_index = 0; nack_index < packed_.size();) { 90 for (size_t nack_index = 0; nack_index < packed_.size();) {
86 size_t bytes_left_in_buffer = max_length - *index; 91 size_t bytes_left_in_buffer = max_length - *index;
87 if (bytes_left_in_buffer < kNackHeaderLength + kNackItemLength) { 92 if (bytes_left_in_buffer < kNackHeaderLength + kNackItemLength) {
(...skipping 21 matching lines...) Expand all
109 ByteWriter<uint16_t>::WriteBigEndian(packet + *index + 0, item.first_pid); 114 ByteWriter<uint16_t>::WriteBigEndian(packet + *index + 0, item.first_pid);
110 ByteWriter<uint16_t>::WriteBigEndian(packet + *index + 2, item.bitmask); 115 ByteWriter<uint16_t>::WriteBigEndian(packet + *index + 2, item.bitmask);
111 *index += kNackItemLength; 116 *index += kNackItemLength;
112 } 117 }
113 RTC_DCHECK_LE(*index, max_length); 118 RTC_DCHECK_LE(*index, max_length);
114 } 119 }
115 120
116 return true; 121 return true;
117 } 122 }
118 123
119 size_t Nack::BlockLength() const {
120 return kHeaderLength + kCommonFeedbackLength +
121 packed_.size() * kNackItemLength;
122 }
123
124 void Nack::SetPacketIds(const uint16_t* nack_list, size_t length) { 124 void Nack::SetPacketIds(const uint16_t* nack_list, size_t length) {
125 RTC_DCHECK(nack_list); 125 RTC_DCHECK(nack_list);
126 RTC_DCHECK(packet_ids_.empty()); 126 RTC_DCHECK(packet_ids_.empty());
127 RTC_DCHECK(packed_.empty()); 127 RTC_DCHECK(packed_.empty());
128 packet_ids_.assign(nack_list, nack_list + length); 128 packet_ids_.assign(nack_list, nack_list + length);
129 Pack(); 129 Pack();
130 } 130 }
131 131
132 void Nack::Pack() { 132 void Nack::Pack() {
133 RTC_DCHECK(!packet_ids_.empty()); 133 RTC_DCHECK(!packet_ids_.empty());
(...skipping 26 matching lines...) Expand all
160 uint16_t pid = item.first_pid + 1; 160 uint16_t pid = item.first_pid + 1;
161 for (uint16_t bitmask = item.bitmask; bitmask != 0; bitmask >>= 1, ++pid) { 161 for (uint16_t bitmask = item.bitmask; bitmask != 0; bitmask >>= 1, ++pid) {
162 if (bitmask & 1) 162 if (bitmask & 1)
163 packet_ids_.push_back(pid); 163 packet_ids_.push_back(pid);
164 } 164 }
165 } 165 }
166 } 166 }
167 167
168 } // namespace rtcp 168 } // namespace rtcp
169 } // namespace webrtc 169 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698