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

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 block.Create(buffer + *pos);
162 AssignUWord32(buffer, pos, (*it).SSRC); 162 *pos += ReportBlock::kLength;
163 AssignUWord8(buffer, pos, (*it).FractionLost);
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 } 163 }
170 } 164 }
171 165
172 // Transmission Time Offsets in RTP Streams (RFC 5450). 166 // Transmission Time Offsets in RTP Streams (RFC 5450).
173 // 167 //
174 // 0 1 2 3 168 // 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 169 // 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 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 170 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
177 // hdr |V=2|P| RC | PT=IJ=195 | length | 171 // hdr |V=2|P| RC | PT=IJ=195 | length |
178 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 172 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 CreateSenderReport(sr_, packet, index); 768 CreateSenderReport(sr_, packet, index);
775 CreateReportBlocks(report_blocks_, packet, index); 769 CreateReportBlocks(report_blocks_, packet, index);
776 return true; 770 return true;
777 } 771 }
778 772
779 bool SenderReport::WithReportBlock(const ReportBlock& block) { 773 bool SenderReport::WithReportBlock(const ReportBlock& block) {
780 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { 774 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) {
781 LOG(LS_WARNING) << "Max report blocks reached."; 775 LOG(LS_WARNING) << "Max report blocks reached.";
782 return false; 776 return false;
783 } 777 }
784 report_blocks_.push_back(block.report_block_); 778 report_blocks_.push_back(block);
785 sr_.NumberOfReportBlocks = report_blocks_.size(); 779 sr_.NumberOfReportBlocks = report_blocks_.size();
786 return true; 780 return true;
787 } 781 }
788 782
789 bool ReceiverReport::Create(uint8_t* packet, 783 bool ReceiverReport::Create(uint8_t* packet,
790 size_t* index, 784 size_t* index,
791 size_t max_length, 785 size_t max_length,
792 RtcpPacket::PacketReadyCallback* callback) const { 786 RtcpPacket::PacketReadyCallback* callback) const {
793 while (*index + BlockLength() > max_length) { 787 while (*index + BlockLength() > max_length) {
794 if (!OnBufferFull(packet, index, callback)) 788 if (!OnBufferFull(packet, index, callback))
795 return false; 789 return false;
796 } 790 }
797 CreateHeader(rr_.NumberOfReportBlocks, PT_RR, HeaderLength(), packet, index); 791 CreateHeader(rr_.NumberOfReportBlocks, PT_RR, HeaderLength(), packet, index);
798 CreateReceiverReport(rr_, packet, index); 792 CreateReceiverReport(rr_, packet, index);
799 CreateReportBlocks(report_blocks_, packet, index); 793 CreateReportBlocks(report_blocks_, packet, index);
800 return true; 794 return true;
801 } 795 }
802 796
803 bool ReceiverReport::WithReportBlock(const ReportBlock& block) { 797 bool ReceiverReport::WithReportBlock(const ReportBlock& block) {
804 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { 798 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) {
805 LOG(LS_WARNING) << "Max report blocks reached."; 799 LOG(LS_WARNING) << "Max report blocks reached.";
806 return false; 800 return false;
807 } 801 }
808 report_blocks_.push_back(block.report_block_); 802 report_blocks_.push_back(block);
809 rr_.NumberOfReportBlocks = report_blocks_.size(); 803 rr_.NumberOfReportBlocks = report_blocks_.size();
810 return true; 804 return true;
811 } 805 }
812 806
813 bool Ij::Create(uint8_t* packet, 807 bool Ij::Create(uint8_t* packet,
814 size_t* index, 808 size_t* index,
815 size_t max_length, 809 size_t max_length,
816 RtcpPacket::PacketReadyCallback* callback) const { 810 RtcpPacket::PacketReadyCallback* callback) const {
817 while (*index + BlockLength() > max_length) { 811 while (*index + BlockLength() > max_length) {
818 if (!OnBufferFull(packet, index, callback)) 812 if (!OnBufferFull(packet, index, callback))
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 return length_; 1214 return length_;
1221 } 1215 }
1222 1216
1223 void RawPacket::SetLength(size_t length) { 1217 void RawPacket::SetLength(size_t length) {
1224 assert(length <= buffer_length_); 1218 assert(length <= buffer_length_);
1225 length_ = length; 1219 length_ = length;
1226 } 1220 }
1227 1221
1228 } // namespace rtcp 1222 } // namespace rtcp
1229 } // namespace webrtc 1223 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/report_block.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698