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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 25 matching lines...) Expand all
36 // The Feedback Control Information (FCI) for the Full Intra Request 36 // The Feedback Control Information (FCI) for the Full Intra Request
37 // consists of one or more FCI entries. 37 // consists of one or more FCI entries.
38 // FCI: 38 // FCI:
39 // 0 1 2 3 39 // 0 1 2 3
40 // 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 40 // 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
41 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 // | SSRC | 42 // | SSRC |
43 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 // | Seq nr. | Reserved = 0 | 44 // | Seq nr. | Reserved = 0 |
45 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46
47 Fir::Fir() = default;
48
49 Fir::~Fir() = default;
50
46 bool Fir::Parse(const CommonHeader& packet) { 51 bool Fir::Parse(const CommonHeader& packet) {
47 RTC_DCHECK_EQ(packet.type(), kPacketType); 52 RTC_DCHECK_EQ(packet.type(), kPacketType);
48 RTC_DCHECK_EQ(packet.fmt(), kFeedbackMessageType); 53 RTC_DCHECK_EQ(packet.fmt(), kFeedbackMessageType);
49 54
50 // The FCI field MUST contain one or more FIR entries. 55 // The FCI field MUST contain one or more FIR entries.
51 if (packet.payload_size_bytes() < kCommonFeedbackLength + kFciLength) { 56 if (packet.payload_size_bytes() < kCommonFeedbackLength + kFciLength) {
52 LOG(LS_WARNING) << "Packet is too small to be a valid FIR packet."; 57 LOG(LS_WARNING) << "Packet is too small to be a valid FIR packet.";
53 return false; 58 return false;
54 } 59 }
55 60
56 if ((packet.payload_size_bytes() - kCommonFeedbackLength) % kFciLength != 0) { 61 if ((packet.payload_size_bytes() - kCommonFeedbackLength) % kFciLength != 0) {
57 LOG(LS_WARNING) << "Invalid size for a valid FIR packet."; 62 LOG(LS_WARNING) << "Invalid size for a valid FIR packet.";
58 return false; 63 return false;
59 } 64 }
60 65
61 ParseCommonFeedback(packet.payload()); 66 ParseCommonFeedback(packet.payload());
62 67
63 size_t number_of_fci_items = 68 size_t number_of_fci_items =
64 (packet.payload_size_bytes() - kCommonFeedbackLength) / kFciLength; 69 (packet.payload_size_bytes() - kCommonFeedbackLength) / kFciLength;
65 const uint8_t* next_fci = packet.payload() + kCommonFeedbackLength; 70 const uint8_t* next_fci = packet.payload() + kCommonFeedbackLength;
66 items_.resize(number_of_fci_items); 71 items_.resize(number_of_fci_items);
67 for (Request& request : items_) { 72 for (Request& request : items_) {
68 request.ssrc = ByteReader<uint32_t>::ReadBigEndian(next_fci); 73 request.ssrc = ByteReader<uint32_t>::ReadBigEndian(next_fci);
69 request.seq_nr = ByteReader<uint8_t>::ReadBigEndian(next_fci + 4); 74 request.seq_nr = ByteReader<uint8_t>::ReadBigEndian(next_fci + 4);
70 next_fci += kFciLength; 75 next_fci += kFciLength;
71 } 76 }
72 return true; 77 return true;
73 } 78 }
74 79
80 size_t Fir::BlockLength() const {
81 return kHeaderLength + kCommonFeedbackLength + kFciLength * items_.size();
82 }
83
75 bool Fir::Create(uint8_t* packet, 84 bool Fir::Create(uint8_t* packet,
76 size_t* index, 85 size_t* index,
77 size_t max_length, 86 size_t max_length,
78 RtcpPacket::PacketReadyCallback* callback) const { 87 RtcpPacket::PacketReadyCallback* callback) const {
79 RTC_DCHECK(!items_.empty()); 88 RTC_DCHECK(!items_.empty());
80 while (*index + BlockLength() > max_length) { 89 while (*index + BlockLength() > max_length) {
81 if (!OnBufferFull(packet, index, callback)) 90 if (!OnBufferFull(packet, index, callback))
82 return false; 91 return false;
83 } 92 }
84 size_t index_end = *index + BlockLength(); 93 size_t index_end = *index + BlockLength();
85 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, 94 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet,
86 index); 95 index);
87 RTC_DCHECK_EQ(Psfb::media_ssrc(), 0); 96 RTC_DCHECK_EQ(Psfb::media_ssrc(), 0);
88 CreateCommonFeedback(packet + *index); 97 CreateCommonFeedback(packet + *index);
89 *index += kCommonFeedbackLength; 98 *index += kCommonFeedbackLength;
90 99
91 constexpr uint32_t kReserved = 0; 100 constexpr uint32_t kReserved = 0;
92 for (const Request& request : items_) { 101 for (const Request& request : items_) {
93 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, request.ssrc); 102 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, request.ssrc);
94 ByteWriter<uint8_t>::WriteBigEndian(packet + *index + 4, request.seq_nr); 103 ByteWriter<uint8_t>::WriteBigEndian(packet + *index + 4, request.seq_nr);
95 ByteWriter<uint32_t, 3>::WriteBigEndian(packet + *index + 5, kReserved); 104 ByteWriter<uint32_t, 3>::WriteBigEndian(packet + *index + 5, kReserved);
96 *index += kFciLength; 105 *index += kFciLength;
97 } 106 }
98 RTC_CHECK_EQ(*index, index_end); 107 RTC_CHECK_EQ(*index, index_end);
99 return true; 108 return true;
100 } 109 }
101 } // namespace rtcp 110 } // namespace rtcp
102 } // namespace webrtc 111 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698