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

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

Issue 1551893002: [rtp_rtcp] rtcp::Sli packet moved into own file and got Parse function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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) 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 16 matching lines...) Expand all
27 using webrtc::RTCPUtility::PT_SDES; 27 using webrtc::RTCPUtility::PT_SDES;
28 using webrtc::RTCPUtility::PT_SR; 28 using webrtc::RTCPUtility::PT_SR;
29 using webrtc::RTCPUtility::PT_XR; 29 using webrtc::RTCPUtility::PT_XR;
30 30
31 using webrtc::RTCPUtility::RTCPPacketAPP; 31 using webrtc::RTCPUtility::RTCPPacketAPP;
32 using webrtc::RTCPUtility::RTCPPacketPSFBAPP; 32 using webrtc::RTCPUtility::RTCPPacketPSFBAPP;
33 using webrtc::RTCPUtility::RTCPPacketPSFBFIR; 33 using webrtc::RTCPUtility::RTCPPacketPSFBFIR;
34 using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem; 34 using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem;
35 using webrtc::RTCPUtility::RTCPPacketPSFBREMBItem; 35 using webrtc::RTCPUtility::RTCPPacketPSFBREMBItem;
36 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI; 36 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI;
37 using webrtc::RTCPUtility::RTCPPacketPSFBSLI;
38 using webrtc::RTCPUtility::RTCPPacketPSFBSLIItem;
39 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; 37 using webrtc::RTCPUtility::RTCPPacketReportBlockItem;
40 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; 38 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK;
41 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; 39 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem;
42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN; 40 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBN;
43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem; 41 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBNItem;
44 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR; 42 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBR;
45 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem; 43 using webrtc::RTCPUtility::RTCPPacketRTPFBTMMBRItem;
46 using webrtc::RTCPUtility::RTCPPacketSR; 44 using webrtc::RTCPUtility::RTCPPacketSR;
47 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; 45 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem;
48 using webrtc::RTCPUtility::RTCPPacketXR; 46 using webrtc::RTCPUtility::RTCPPacketXR;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 AssignUWord32(buffer, pos, (*it).ssrc); 176 AssignUWord32(buffer, pos, (*it).ssrc);
179 AssignUWord8(buffer, pos, kSdesItemType); 177 AssignUWord8(buffer, pos, kSdesItemType);
180 AssignUWord8(buffer, pos, (*it).name.length()); 178 AssignUWord8(buffer, pos, (*it).name.length());
181 memcpy(buffer + *pos, (*it).name.data(), (*it).name.length()); 179 memcpy(buffer + *pos, (*it).name.data(), (*it).name.length());
182 *pos += (*it).name.length(); 180 *pos += (*it).name.length();
183 memset(buffer + *pos, 0, (*it).null_octets); 181 memset(buffer + *pos, 0, (*it).null_octets);
184 *pos += (*it).null_octets; 182 *pos += (*it).null_octets;
185 } 183 }
186 } 184 }
187 185
188 // Slice loss indication (SLI) (RFC 4585).
189 //
190 // FCI:
191 //
192 // 0 1 2 3
193 // 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
194 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
195 // | First | Number | PictureID |
196 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
197
198 void CreateSli(const RTCPPacketPSFBSLI& sli,
199 const RTCPPacketPSFBSLIItem& sli_item,
200 uint8_t* buffer,
201 size_t* pos) {
202 AssignUWord32(buffer, pos, sli.SenderSSRC);
203 AssignUWord32(buffer, pos, sli.MediaSSRC);
204
205 AssignUWord8(buffer, pos, sli_item.FirstMB >> 5);
206 AssignUWord8(buffer, pos, (sli_item.FirstMB << 3) +
207 ((sli_item.NumberOfMB >> 10) & 0x07));
208 AssignUWord8(buffer, pos, sli_item.NumberOfMB >> 2);
209 AssignUWord8(buffer, pos, (sli_item.NumberOfMB << 6) + sli_item.PictureId);
210 }
211
212 // Reference picture selection indication (RPSI) (RFC 4585). 186 // Reference picture selection indication (RPSI) (RFC 4585).
213 // 187 //
214 // FCI: 188 // FCI:
215 // 189 //
216 // 0 1 2 3 190 // 0 1 2 3
217 // 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 191 // 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
218 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 192 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
219 // | PB |0| Payload Type| Native RPSI bit string | 193 // | PB |0| Payload Type| Native RPSI bit string |
220 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 194 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
221 // | defined per codec ... | Padding (0) | 195 // | defined per codec ... | Padding (0) |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 // Header (4 bytes). 525 // Header (4 bytes).
552 // Chunk: 526 // Chunk:
553 // SSRC/CSRC (4 bytes) | CNAME (1 byte) | length (1 byte) | name | padding. 527 // SSRC/CSRC (4 bytes) | CNAME (1 byte) | length (1 byte) | name | padding.
554 size_t length = kHeaderLength; 528 size_t length = kHeaderLength;
555 for (const Chunk& chunk : chunks_) 529 for (const Chunk& chunk : chunks_)
556 length += 6 + chunk.name.length() + chunk.null_octets; 530 length += 6 + chunk.name.length() + chunk.null_octets;
557 assert(length % 4 == 0); 531 assert(length % 4 == 0);
558 return length; 532 return length;
559 } 533 }
560 534
561 bool Sli::Create(uint8_t* packet,
562 size_t* index,
563 size_t max_length,
564 RtcpPacket::PacketReadyCallback* callback) const {
565 while (*index + BlockLength() > max_length) {
566 if (!OnBufferFull(packet, index, callback))
567 return false;
568 }
569 const uint8_t kFmt = 2;
570 CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index);
571 CreateSli(sli_, sli_item_, packet, index);
572 return true;
573 }
574
575 bool Rpsi::Create(uint8_t* packet, 535 bool Rpsi::Create(uint8_t* packet,
576 size_t* index, 536 size_t* index,
577 size_t max_length, 537 size_t max_length,
578 RtcpPacket::PacketReadyCallback* callback) const { 538 RtcpPacket::PacketReadyCallback* callback) const {
579 assert(rpsi_.NumberOfValidBits > 0); 539 assert(rpsi_.NumberOfValidBits > 0);
580 while (*index + BlockLength() > max_length) { 540 while (*index + BlockLength() > max_length) {
581 if (!OnBufferFull(packet, index, callback)) 541 if (!OnBufferFull(packet, index, callback))
582 return false; 542 return false;
583 } 543 }
584 const uint8_t kFmt = 3; 544 const uint8_t kFmt = 3;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 return length_; 742 return length_;
783 } 743 }
784 744
785 void RawPacket::SetLength(size_t length) { 745 void RawPacket::SetLength(size_t length) {
786 assert(length <= buffer_length_); 746 assert(length <= buffer_length_);
787 length_ = length; 747 length_ = length;
788 } 748 }
789 749
790 } // namespace rtcp 750 } // namespace rtcp
791 } // namespace webrtc 751 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698