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

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

Issue 2495253002: Update header formatterts to FlexFEC draft 03. (Closed)
Patch Set: Created 4 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) 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 FlexfecHeaderReader::~FlexfecHeaderReader() = default; 78 FlexfecHeaderReader::~FlexfecHeaderReader() = default;
79 79
80 // TODO(brandtr): Update this function when we support flexible masks, 80 // TODO(brandtr): Update this function when we support flexible masks,
81 // retransmissions, and/or several protected SSRCs. 81 // retransmissions, and/or several protected SSRCs.
82 bool FlexfecHeaderReader::ReadFecHeader( 82 bool FlexfecHeaderReader::ReadFecHeader(
83 ForwardErrorCorrection::ReceivedFecPacket* fec_packet) const { 83 ForwardErrorCorrection::ReceivedFecPacket* fec_packet) const {
84 if (fec_packet->pkt->length <= kBaseHeaderSize + kStreamSpecificHeaderSize) { 84 if (fec_packet->pkt->length <= kBaseHeaderSize + kStreamSpecificHeaderSize) {
85 LOG(LS_WARNING) << "Discarding truncated FlexFEC packet."; 85 LOG(LS_WARNING) << "Discarding truncated FlexFEC packet.";
86 return false; 86 return false;
87 } 87 }
88 bool f_bit = (fec_packet->pkt->data[0] & 0x80) != 0; 88 bool r_bit = (fec_packet->pkt->data[0] & 0x80) != 0;
89 if (r_bit) {
90 LOG(LS_INFO) << "FlexFEC packet with retransmission bit set. We do not yet "
91 "support this, thus discarding the packet.";
92 return false;
93 }
94 bool f_bit = (fec_packet->pkt->data[0] & 0x40) != 0;
89 if (f_bit) { 95 if (f_bit) {
90 LOG(LS_INFO) << "FlexFEC packet with inflexible generator matrix. We do " 96 LOG(LS_INFO) << "FlexFEC packet with inflexible generator matrix. We do "
91 "not yet support this, thus discarding packet."; 97 "not yet support this, thus discarding packet.";
92 return false; 98 return false;
93 } 99 }
94 bool r_bit = (fec_packet->pkt->data[0] & 0x40) != 0;
95 if (r_bit) {
96 LOG(LS_INFO) << "FlexFEC packet with retransmission bit set. We do not yet "
97 "support this, thus discarding the packet.";
98 return false;
99 }
100 uint8_t ssrc_count = 100 uint8_t ssrc_count =
101 ByteReader<uint8_t>::ReadBigEndian(&fec_packet->pkt->data[8]); 101 ByteReader<uint8_t>::ReadBigEndian(&fec_packet->pkt->data[8]);
102 if (ssrc_count != 1) { 102 if (ssrc_count != 1) {
103 LOG(LS_INFO) << "FlexFEC packet protecting multiple media SSRCs. We do not " 103 LOG(LS_INFO) << "FlexFEC packet protecting multiple media SSRCs. We do not "
104 "yet support this, thus discarding packet."; 104 "yet support this, thus discarding packet.";
105 return false; 105 return false;
106 } 106 }
107 uint32_t protected_ssrc = 107 uint32_t protected_ssrc =
108 ByteReader<uint32_t>::ReadBigEndian(&fec_packet->pkt->data[12]); 108 ByteReader<uint32_t>::ReadBigEndian(&fec_packet->pkt->data[12]);
109 uint16_t seq_num_base = 109 uint16_t seq_num_base =
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // writing in space that is intended for the header. 240 // writing in space that is intended for the header.
241 // 241 //
242 // TODO(brandtr): Update this function when we support offset-based masks, 242 // TODO(brandtr): Update this function when we support offset-based masks,
243 // retransmissions, and protecting multiple SSRCs. 243 // retransmissions, and protecting multiple SSRCs.
244 void FlexfecHeaderWriter::FinalizeFecHeader( 244 void FlexfecHeaderWriter::FinalizeFecHeader(
245 uint32_t media_ssrc, 245 uint32_t media_ssrc,
246 uint16_t seq_num_base, 246 uint16_t seq_num_base,
247 const uint8_t* packet_mask, 247 const uint8_t* packet_mask,
248 size_t packet_mask_size, 248 size_t packet_mask_size,
249 ForwardErrorCorrection::Packet* fec_packet) const { 249 ForwardErrorCorrection::Packet* fec_packet) const {
250 fec_packet->data[0] &= 0x7f; // Clear F bit. 250 fec_packet->data[0] &= 0x7f; // Clear R bit.
251 fec_packet->data[0] &= 0xbf; // Clear R bit. 251 fec_packet->data[0] &= 0xbf; // Clear F bit.
252 ByteWriter<uint8_t>::WriteBigEndian(&fec_packet->data[8], kSsrcCount); 252 ByteWriter<uint8_t>::WriteBigEndian(&fec_packet->data[8], kSsrcCount);
253 ByteWriter<uint32_t, 3>::WriteBigEndian(&fec_packet->data[9], kReservedBits); 253 ByteWriter<uint32_t, 3>::WriteBigEndian(&fec_packet->data[9], kReservedBits);
254 ByteWriter<uint32_t>::WriteBigEndian(&fec_packet->data[12], media_ssrc); 254 ByteWriter<uint32_t>::WriteBigEndian(&fec_packet->data[12], media_ssrc);
255 ByteWriter<uint16_t>::WriteBigEndian(&fec_packet->data[16], seq_num_base); 255 ByteWriter<uint16_t>::WriteBigEndian(&fec_packet->data[16], seq_num_base);
256 // Adapt ULPFEC packet mask to FlexFEC header. 256 // Adapt ULPFEC packet mask to FlexFEC header.
257 // 257 //
258 // We treat the mask parts as unsigned integers with host order endianness 258 // We treat the mask parts as unsigned integers with host order endianness
259 // in order to simplify the bit shifting between bytes. 259 // in order to simplify the bit shifting between bytes.
260 uint8_t* const written_packet_mask = fec_packet->data + kPacketMaskOffset; 260 uint8_t* const written_packet_mask = fec_packet->data + kPacketMaskOffset;
261 if (packet_mask_size == kUlpfecPacketMaskSizeLBitSet) { 261 if (packet_mask_size == kUlpfecPacketMaskSizeLBitSet) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 written_packet_mask[2] |= 0x80; // Set K-bit 1. 302 written_packet_mask[2] |= 0x80; // Set K-bit 1.
303 written_packet_mask[2] |= 0x40; // Set bit 15. 303 written_packet_mask[2] |= 0x40; // Set bit 15.
304 } 304 }
305 } else { 305 } else {
306 RTC_NOTREACHED() << "Incorrect packet mask size: " << packet_mask_size 306 RTC_NOTREACHED() << "Incorrect packet mask size: " << packet_mask_size
307 << "."; 307 << ".";
308 } 308 }
309 } 309 }
310 310
311 } // namespace webrtc 311 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698