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

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

Issue 1581983003: [rtp_rtcp] rtcp::Fir moved into own file (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 12 matching lines...) Expand all
23 using webrtc::RTCPUtility::PT_APP; 23 using webrtc::RTCPUtility::PT_APP;
24 using webrtc::RTCPUtility::PT_IJ; 24 using webrtc::RTCPUtility::PT_IJ;
25 using webrtc::RTCPUtility::PT_PSFB; 25 using webrtc::RTCPUtility::PT_PSFB;
26 using webrtc::RTCPUtility::PT_RTPFB; 26 using webrtc::RTCPUtility::PT_RTPFB;
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;
34 using webrtc::RTCPUtility::RTCPPacketPSFBFIRItem;
35 using webrtc::RTCPUtility::RTCPPacketPSFBREMBItem; 33 using webrtc::RTCPUtility::RTCPPacketPSFBREMBItem;
36 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI; 34 using webrtc::RTCPUtility::RTCPPacketPSFBRPSI;
37 using webrtc::RTCPUtility::RTCPPacketReportBlockItem; 35 using webrtc::RTCPUtility::RTCPPacketReportBlockItem;
38 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK; 36 using webrtc::RTCPUtility::RTCPPacketRTPFBNACK;
39 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem; 37 using webrtc::RTCPUtility::RTCPPacketRTPFBNACKItem;
40 using webrtc::RTCPUtility::RTCPPacketSR; 38 using webrtc::RTCPUtility::RTCPPacketSR;
41 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem; 39 using webrtc::RTCPUtility::RTCPPacketXRDLRRReportBlockItem;
42 using webrtc::RTCPUtility::RTCPPacketXR; 40 using webrtc::RTCPUtility::RTCPPacketXR;
43 41
44 namespace webrtc { 42 namespace webrtc {
45 namespace rtcp { 43 namespace rtcp {
46 namespace { 44 namespace {
47 // Unused SSRC of media source, set to 0. 45 // Unused SSRC of media source, set to 0.
48 const uint32_t kUnusedMediaSourceSsrc0 = 0; 46 const uint32_t kUnusedMediaSourceSsrc0 = 0;
49 47
50 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) { 48 void AssignUWord8(uint8_t* buffer, size_t* offset, uint8_t value) {
51 buffer[(*offset)++] = value; 49 buffer[(*offset)++] = value;
52 } 50 }
53 void AssignUWord16(uint8_t* buffer, size_t* offset, uint16_t value) { 51 void AssignUWord16(uint8_t* buffer, size_t* offset, uint16_t value) {
54 ByteWriter<uint16_t>::WriteBigEndian(buffer + *offset, value); 52 ByteWriter<uint16_t>::WriteBigEndian(buffer + *offset, value);
55 *offset += 2; 53 *offset += 2;
56 } 54 }
57 void AssignUWord24(uint8_t* buffer, size_t* offset, uint32_t value) {
58 ByteWriter<uint32_t, 3>::WriteBigEndian(buffer + *offset, value);
59 *offset += 3;
60 }
61 void AssignUWord32(uint8_t* buffer, size_t* offset, uint32_t value) { 55 void AssignUWord32(uint8_t* buffer, size_t* offset, uint32_t value) {
62 ByteWriter<uint32_t>::WriteBigEndian(buffer + *offset, value); 56 ByteWriter<uint32_t>::WriteBigEndian(buffer + *offset, value);
63 *offset += 4; 57 *offset += 4;
64 } 58 }
65 59
66 void ComputeMantissaAnd6bitBase2Exponent(uint32_t input_base10, 60 void ComputeMantissaAnd6bitBase2Exponent(uint32_t input_base10,
67 uint8_t bits_mantissa, 61 uint8_t bits_mantissa,
68 uint32_t* mantissa, 62 uint32_t* mantissa,
69 uint8_t* exp) { 63 uint8_t* exp) {
70 // input_base10 = mantissa * 2^exp 64 // input_base10 = mantissa * 2^exp
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 AssignUWord32(buffer, pos, rpsi.SenderSSRC); 194 AssignUWord32(buffer, pos, rpsi.SenderSSRC);
201 AssignUWord32(buffer, pos, rpsi.MediaSSRC); 195 AssignUWord32(buffer, pos, rpsi.MediaSSRC);
202 AssignUWord8(buffer, pos, padding_bytes * 8); 196 AssignUWord8(buffer, pos, padding_bytes * 8);
203 AssignUWord8(buffer, pos, rpsi.PayloadType); 197 AssignUWord8(buffer, pos, rpsi.PayloadType);
204 memcpy(buffer + *pos, rpsi.NativeBitString, rpsi.NumberOfValidBits / 8); 198 memcpy(buffer + *pos, rpsi.NativeBitString, rpsi.NumberOfValidBits / 8);
205 *pos += rpsi.NumberOfValidBits / 8; 199 *pos += rpsi.NumberOfValidBits / 8;
206 memset(buffer + *pos, 0, padding_bytes); 200 memset(buffer + *pos, 0, padding_bytes);
207 *pos += padding_bytes; 201 *pos += padding_bytes;
208 } 202 }
209 203
210 // Full intra request (FIR) (RFC 5104).
211 //
212 // FCI:
213 //
214 // 0 1 2 3
215 // 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
216 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
217 // | SSRC |
218 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
219 // | Seq nr. | Reserved |
220 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
221
222 void CreateFir(const RTCPPacketPSFBFIR& fir,
223 const RTCPPacketPSFBFIRItem& fir_item,
224 uint8_t* buffer,
225 size_t* pos) {
226 AssignUWord32(buffer, pos, fir.SenderSSRC);
227 AssignUWord32(buffer, pos, kUnusedMediaSourceSsrc0);
228 AssignUWord32(buffer, pos, fir_item.SSRC);
229 AssignUWord8(buffer, pos, fir_item.CommandSequenceNumber);
230 AssignUWord24(buffer, pos, 0);
231 }
232
233 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb). 204 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb).
234 // 205 //
235 // 0 1 2 3 206 // 0 1 2 3
236 // 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 207 // 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
237 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 208 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
238 // |V=2|P| FMT=15 | PT=206 | length | 209 // |V=2|P| FMT=15 | PT=206 | length |
239 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 210 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
240 // | SSRC of packet sender | 211 // | SSRC of packet sender |
241 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 212 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
242 // | SSRC of media source | 213 // | SSRC of media source |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 rpsi_.NativeBitString[pos++] = static_cast<uint8_t>(picture_id & 0x7f); 463 rpsi_.NativeBitString[pos++] = static_cast<uint8_t>(picture_id & 0x7f);
493 rpsi_.NumberOfValidBits = pos * 8; 464 rpsi_.NumberOfValidBits = pos * 8;
494 465
495 // Calculate padding bytes (to reach next 32-bit boundary, 1, 2 or 3 bytes). 466 // Calculate padding bytes (to reach next 32-bit boundary, 1, 2 or 3 bytes).
496 padding_bytes_ = 4 - ((2 + required_bytes) % 4); 467 padding_bytes_ = 4 - ((2 + required_bytes) % 4);
497 if (padding_bytes_ == 4) { 468 if (padding_bytes_ == 4) {
498 padding_bytes_ = 0; 469 padding_bytes_ = 0;
499 } 470 }
500 } 471 }
501 472
502 bool Fir::Create(uint8_t* packet,
503 size_t* index,
504 size_t max_length,
505 RtcpPacket::PacketReadyCallback* callback) const {
506 while (*index + BlockLength() > max_length) {
507 if (!OnBufferFull(packet, index, callback))
508 return false;
509 }
510 const uint8_t kFmt = 4;
511 CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index);
512 CreateFir(fir_, fir_item_, packet, index);
513 return true;
514 }
515
516 bool Remb::Create(uint8_t* packet, 473 bool Remb::Create(uint8_t* packet,
517 size_t* index, 474 size_t* index,
518 size_t max_length, 475 size_t max_length,
519 RtcpPacket::PacketReadyCallback* callback) const { 476 RtcpPacket::PacketReadyCallback* callback) const {
520 while (*index + BlockLength() > max_length) { 477 while (*index + BlockLength() > max_length) {
521 if (!OnBufferFull(packet, index, callback)) 478 if (!OnBufferFull(packet, index, callback))
522 return false; 479 return false;
523 } 480 }
524 const uint8_t kFmt = 15; 481 const uint8_t kFmt = 15;
525 CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index); 482 CreateHeader(kFmt, PT_PSFB, HeaderLength(), packet, index);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 return length_; 582 return length_;
626 } 583 }
627 584
628 void RawPacket::SetLength(size_t length) { 585 void RawPacket::SetLength(size_t length) {
629 assert(length <= buffer_length_); 586 assert(length <= buffer_length_);
630 length_ = length; 587 length_ = length;
631 } 588 }
632 589
633 } // namespace rtcp 590 } // namespace rtcp
634 } // namespace webrtc 591 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698