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

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

Issue 2269903002: Add FlexFEC header formatters. (pt. 5) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@header_reader_writer-pt4-generalize_header_formatting
Patch Set: Review response 5. Created 4 years, 3 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 size_t UlpfecHeaderWriter::MinPacketMaskSize(const uint8_t* packet_mask, 92 size_t UlpfecHeaderWriter::MinPacketMaskSize(const uint8_t* packet_mask,
93 size_t packet_mask_size) const { 93 size_t packet_mask_size) const {
94 return packet_mask_size; 94 return packet_mask_size;
95 } 95 }
96 96
97 size_t UlpfecHeaderWriter::FecHeaderSize(size_t packet_mask_size) const { 97 size_t UlpfecHeaderWriter::FecHeaderSize(size_t packet_mask_size) const {
98 return UlpfecHeaderSize(packet_mask_size); 98 return UlpfecHeaderSize(packet_mask_size);
99 } 99 }
100 100
101 void UlpfecHeaderWriter::FinalizeFecHeader( 101 void UlpfecHeaderWriter::FinalizeFecHeader(
102 uint32_t media_ssrc,
danilchap 2016/09/21 11:17:56 there is construct uint32_t /* media_ssrc */ to st
brandtr 2016/09/21 11:43:28 Done.
102 uint16_t seq_num_base, 103 uint16_t seq_num_base,
103 const uint8_t* packet_mask, 104 const uint8_t* packet_mask,
104 size_t packet_mask_size, 105 size_t packet_mask_size,
105 ForwardErrorCorrection::Packet* fec_packet) const { 106 ForwardErrorCorrection::Packet* fec_packet) const {
106 // Set E bit to zero. 107 // Set E bit to zero.
107 fec_packet->data[0] &= 0x7f; 108 fec_packet->data[0] &= 0x7f;
108 // Set L bit based on packet mask size. (Note that the packet mask 109 // Set L bit based on packet mask size. (Note that the packet mask
109 // can only take on two discrete values.) 110 // can only take on two discrete values.)
110 bool l_bit = (packet_mask_size == kUlpfecPacketMaskSizeLBitSet); 111 bool l_bit = (packet_mask_size == kUlpfecPacketMaskSizeLBitSet);
111 if (l_bit) { 112 if (l_bit) {
112 fec_packet->data[0] |= 0x40; // Set the L bit. 113 fec_packet->data[0] |= 0x40; // Set the L bit.
113 } else { 114 } else {
114 RTC_DCHECK_EQ(packet_mask_size, kUlpfecPacketMaskSizeLBitClear); 115 RTC_DCHECK_EQ(packet_mask_size, kUlpfecPacketMaskSizeLBitClear);
115 fec_packet->data[0] &= 0xbf; // Clear the L bit. 116 fec_packet->data[0] &= 0xbf; // Clear the L bit.
116 } 117 }
117 // Copy length recovery field from temporary location. 118 // Copy length recovery field from temporary location.
118 memcpy(&fec_packet->data[8], &fec_packet->data[2], 2); 119 memcpy(&fec_packet->data[8], &fec_packet->data[2], 2);
119 // Write sequence number base. 120 // Write sequence number base.
120 ByteWriter<uint16_t>::WriteBigEndian(&fec_packet->data[2], seq_num_base); 121 ByteWriter<uint16_t>::WriteBigEndian(&fec_packet->data[2], seq_num_base);
121 // Protection length is set to entire packet. (This is not 122 // Protection length is set to entire packet. (This is not
122 // required in general.) 123 // required in general.)
123 const size_t fec_header_size = FecHeaderSize(packet_mask_size); 124 const size_t fec_header_size = FecHeaderSize(packet_mask_size);
124 ByteWriter<uint16_t>::WriteBigEndian(&fec_packet->data[10], 125 ByteWriter<uint16_t>::WriteBigEndian(&fec_packet->data[10],
125 fec_packet->length - fec_header_size); 126 fec_packet->length - fec_header_size);
126 // Copy the packet mask. 127 // Copy the packet mask.
127 memcpy(&fec_packet->data[12], packet_mask, packet_mask_size); 128 memcpy(&fec_packet->data[12], packet_mask, packet_mask_size);
128 } 129 }
129 130
130 } // namespace webrtc 131 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698