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

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

Issue 2867713003: Remove hardcoded kValueSizeBytes values from variable-length header extensions. (Closed)
Patch Set: Patch 5 Created 3 years, 7 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return map; 57 return map;
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 FlexfecSender::FlexfecSender( 62 FlexfecSender::FlexfecSender(
63 int payload_type, 63 int payload_type,
64 uint32_t ssrc, 64 uint32_t ssrc,
65 uint32_t protected_media_ssrc, 65 uint32_t protected_media_ssrc,
66 const std::vector<RtpExtension>& rtp_header_extensions, 66 const std::vector<RtpExtension>& rtp_header_extensions,
67 rtc::ArrayView<const RtpExtensionSize> extension_sizes,
67 Clock* clock) 68 Clock* clock)
68 : clock_(clock), 69 : clock_(clock),
69 random_(clock_->TimeInMicroseconds()), 70 random_(clock_->TimeInMicroseconds()),
70 last_generated_packet_ms_(-1), 71 last_generated_packet_ms_(-1),
71 payload_type_(payload_type), 72 payload_type_(payload_type),
72 // Initialize the timestamp offset and RTP sequence numbers randomly. 73 // Initialize the timestamp offset and RTP sequence numbers randomly.
73 // (This is not intended to be cryptographically strong.) 74 // (This is not intended to be cryptographically strong.)
74 timestamp_offset_(random_.Rand<uint32_t>()), 75 timestamp_offset_(random_.Rand<uint32_t>()),
75 ssrc_(ssrc), 76 ssrc_(ssrc),
76 protected_media_ssrc_(protected_media_ssrc), 77 protected_media_ssrc_(protected_media_ssrc),
77 seq_num_(random_.Rand(1, kMaxInitRtpSeqNumber)), 78 seq_num_(random_.Rand(1, kMaxInitRtpSeqNumber)),
78 ulpfec_generator_(ForwardErrorCorrection::CreateFlexfec()), 79 ulpfec_generator_(ForwardErrorCorrection::CreateFlexfec()),
79 rtp_header_extension_map_(RegisterBweExtensions(rtp_header_extensions)) { 80 rtp_header_extension_map_(RegisterBweExtensions(rtp_header_extensions)),
81 header_extensions_size_(
82 rtp_header_extension_map_.GetTotalLengthInBytes(extension_sizes)) {
80 // This object should not have been instantiated if FlexFEC is disabled. 83 // This object should not have been instantiated if FlexFEC is disabled.
81 RTC_DCHECK_GE(payload_type, 0); 84 RTC_DCHECK_GE(payload_type, 0);
82 RTC_DCHECK_LE(payload_type, 127); 85 RTC_DCHECK_LE(payload_type, 127);
83 } 86 }
84 87
85 FlexfecSender::~FlexfecSender() = default; 88 FlexfecSender::~FlexfecSender() = default;
86 89
87 // We are reusing the implementation from UlpfecGenerator for SetFecParameters, 90 // We are reusing the implementation from UlpfecGenerator for SetFecParameters,
88 // AddRtpPacketAndGenerateFec, and FecAvailable. 91 // AddRtpPacketAndGenerateFec, and FecAvailable.
89 void FlexfecSender::SetFecParameters(const FecProtectionParams& params) { 92 void FlexfecSender::SetFecParameters(const FecProtectionParams& params) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 << " FlexFEC packets with payload type: " << payload_type_ 144 << " FlexFEC packets with payload type: " << payload_type_
142 << " and SSRC: " << ssrc_ << "."; 145 << " and SSRC: " << ssrc_ << ".";
143 last_generated_packet_ms_ = now_ms; 146 last_generated_packet_ms_ = now_ms;
144 } 147 }
145 148
146 return fec_packets_to_send; 149 return fec_packets_to_send;
147 } 150 }
148 151
149 // The overhead is BWE RTP header extensions and FlexFEC header. 152 // The overhead is BWE RTP header extensions and FlexFEC header.
150 size_t FlexfecSender::MaxPacketOverhead() const { 153 size_t FlexfecSender::MaxPacketOverhead() const {
151 return rtp_header_extension_map_.GetTotalLengthInBytes() + 154 return header_extensions_size_ + kFlexfecMaxHeaderSize;
152 kFlexfecMaxHeaderSize;
153 } 155 }
154 156
155 } // namespace webrtc 157 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698