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

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

Issue 1420283022: rtcp::ReportBlock refactored to contain parsing (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 147 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
148 // | extended highest sequence number received | 148 // | extended highest sequence number received |
149 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 149 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
150 // | interarrival jitter | 150 // | interarrival jitter |
151 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 151 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 // | last SR (LSR) | 152 // | last SR (LSR) |
153 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 153 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
154 // | delay since last SR (DLSR) | 154 // | delay since last SR (DLSR) |
155 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ 155 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
156 156
157 void CreateReportBlocks(const std::vector<RTCPPacketReportBlockItem>& blocks, 157 void CreateReportBlocks(const std::vector<ReportBlock>& blocks,
158 uint8_t* buffer, 158 uint8_t* buffer,
159 size_t* pos) { 159 size_t* pos) {
160 for (std::vector<RTCPPacketReportBlockItem>::const_iterator 160 for (const ReportBlock& block : blocks) {
161 it = blocks.begin(); it != blocks.end(); ++it) { 161 size_t bytes_consumed = block.Create(buffer + *pos);
162 AssignUWord32(buffer, pos, (*it).SSRC); 162 RTC_CHECK_GT(bytes_consumed, 0u);
åsapersson 2015/11/12 14:26:24 Maybe move check to when setting the field cum los
danilchap 2015/11/12 15:30:45 Moved check for CumulativeLost to ReportBlock::Wit
163 AssignUWord8(buffer, pos, (*it).FractionLost); 163 *pos += bytes_consumed;
164 AssignUWord24(buffer, pos, (*it).CumulativeNumOfPacketsLost);
165 AssignUWord32(buffer, pos, (*it).ExtendedHighestSequenceNumber);
166 AssignUWord32(buffer, pos, (*it).Jitter);
167 AssignUWord32(buffer, pos, (*it).LastSR);
168 AssignUWord32(buffer, pos, (*it).DelayLastSR);
169 } 164 }
170 } 165 }
171 166
172 // Transmission Time Offsets in RTP Streams (RFC 5450). 167 // Transmission Time Offsets in RTP Streams (RFC 5450).
173 // 168 //
174 // 0 1 2 3 169 // 0 1 2 3
175 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 170 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
176 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 171 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
177 // hdr |V=2|P| RC | PT=IJ=195 | length | 172 // hdr |V=2|P| RC | PT=IJ=195 | length |
178 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 173 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 CreateSenderReport(sr_, packet, index); 769 CreateSenderReport(sr_, packet, index);
775 CreateReportBlocks(report_blocks_, packet, index); 770 CreateReportBlocks(report_blocks_, packet, index);
776 return true; 771 return true;
777 } 772 }
778 773
779 bool SenderReport::WithReportBlock(const ReportBlock& block) { 774 bool SenderReport::WithReportBlock(const ReportBlock& block) {
780 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { 775 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) {
781 LOG(LS_WARNING) << "Max report blocks reached."; 776 LOG(LS_WARNING) << "Max report blocks reached.";
782 return false; 777 return false;
783 } 778 }
784 report_blocks_.push_back(block.report_block_); 779 report_blocks_.push_back(block);
785 sr_.NumberOfReportBlocks = report_blocks_.size(); 780 sr_.NumberOfReportBlocks = report_blocks_.size();
786 return true; 781 return true;
787 } 782 }
788 783
789 bool ReceiverReport::Create(uint8_t* packet, 784 bool ReceiverReport::Create(uint8_t* packet,
790 size_t* index, 785 size_t* index,
791 size_t max_length, 786 size_t max_length,
792 RtcpPacket::PacketReadyCallback* callback) const { 787 RtcpPacket::PacketReadyCallback* callback) const {
793 while (*index + BlockLength() > max_length) { 788 while (*index + BlockLength() > max_length) {
794 if (!OnBufferFull(packet, index, callback)) 789 if (!OnBufferFull(packet, index, callback))
795 return false; 790 return false;
796 } 791 }
797 CreateHeader(rr_.NumberOfReportBlocks, PT_RR, HeaderLength(), packet, index); 792 CreateHeader(rr_.NumberOfReportBlocks, PT_RR, HeaderLength(), packet, index);
798 CreateReceiverReport(rr_, packet, index); 793 CreateReceiverReport(rr_, packet, index);
799 CreateReportBlocks(report_blocks_, packet, index); 794 CreateReportBlocks(report_blocks_, packet, index);
800 return true; 795 return true;
801 } 796 }
802 797
803 bool ReceiverReport::WithReportBlock(const ReportBlock& block) { 798 bool ReceiverReport::WithReportBlock(const ReportBlock& block) {
804 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { 799 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) {
805 LOG(LS_WARNING) << "Max report blocks reached."; 800 LOG(LS_WARNING) << "Max report blocks reached.";
806 return false; 801 return false;
807 } 802 }
808 report_blocks_.push_back(block.report_block_); 803 report_blocks_.push_back(block);
809 rr_.NumberOfReportBlocks = report_blocks_.size(); 804 rr_.NumberOfReportBlocks = report_blocks_.size();
810 return true; 805 return true;
811 } 806 }
812 807
813 bool Ij::Create(uint8_t* packet, 808 bool Ij::Create(uint8_t* packet,
814 size_t* index, 809 size_t* index,
815 size_t max_length, 810 size_t max_length,
816 RtcpPacket::PacketReadyCallback* callback) const { 811 RtcpPacket::PacketReadyCallback* callback) const {
817 while (*index + BlockLength() > max_length) { 812 while (*index + BlockLength() > max_length) {
818 if (!OnBufferFull(packet, index, callback)) 813 if (!OnBufferFull(packet, index, callback))
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 return length_; 1215 return length_;
1221 } 1216 }
1222 1217
1223 void RawPacket::SetLength(size_t length) { 1218 void RawPacket::SetLength(size_t length) {
1224 assert(length <= buffer_length_); 1219 assert(length <= buffer_length_);
1225 length_ = length; 1220 length_ = length;
1226 } 1221 }
1227 1222
1228 } // namespace rtcp 1223 } // namespace rtcp
1229 } // namespace webrtc 1224 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698