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

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

Issue 2562983002: Remove sequenced task checker from FlexfecSender. (Closed)
Patch Set: Move test to https://codereview.webrtc.org/2573453002/ Created 4 years 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
« no previous file with comments | « webrtc/modules/rtp_rtcp/include/flexfec_sender.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // (This is not intended to be cryptographically strong.) 73 // (This is not intended to be cryptographically strong.)
74 timestamp_offset_(random_.Rand<uint32_t>()), 74 timestamp_offset_(random_.Rand<uint32_t>()),
75 ssrc_(ssrc), 75 ssrc_(ssrc),
76 protected_media_ssrc_(protected_media_ssrc), 76 protected_media_ssrc_(protected_media_ssrc),
77 seq_num_(random_.Rand(1, kMaxInitRtpSeqNumber)), 77 seq_num_(random_.Rand(1, kMaxInitRtpSeqNumber)),
78 ulpfec_generator_(ForwardErrorCorrection::CreateFlexfec()), 78 ulpfec_generator_(ForwardErrorCorrection::CreateFlexfec()),
79 rtp_header_extension_map_(RegisterBweExtensions(rtp_header_extensions)) { 79 rtp_header_extension_map_(RegisterBweExtensions(rtp_header_extensions)) {
80 // This object should not have been instantiated if FlexFEC is disabled. 80 // This object should not have been instantiated if FlexFEC is disabled.
81 RTC_DCHECK_GE(payload_type, 0); 81 RTC_DCHECK_GE(payload_type, 0);
82 RTC_DCHECK_LE(payload_type, 127); 82 RTC_DCHECK_LE(payload_type, 127);
83
84 // It's OK to create this object on a different thread/task queue than
85 // the one used during main operation.
86 sequence_checker_.Detach();
87 } 83 }
88 84
89 FlexfecSender::~FlexfecSender() = default; 85 FlexfecSender::~FlexfecSender() = default;
90 86
91 // We are reusing the implementation from UlpfecGenerator for SetFecParameters, 87 // We are reusing the implementation from UlpfecGenerator for SetFecParameters,
92 // AddRtpPacketAndGenerateFec, and FecAvailable. 88 // AddRtpPacketAndGenerateFec, and FecAvailable.
93 void FlexfecSender::SetFecParameters(const FecProtectionParams& params) { 89 void FlexfecSender::SetFecParameters(const FecProtectionParams& params) {
94 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
95 ulpfec_generator_.SetFecParameters(params); 90 ulpfec_generator_.SetFecParameters(params);
96 } 91 }
97 92
98 bool FlexfecSender::AddRtpPacketAndGenerateFec( 93 bool FlexfecSender::AddRtpPacketAndGenerateFec(const RtpPacketToSend& packet) {
99 const RtpPacketToSend& packet) {
100 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
101 // TODO(brandtr): Generalize this SSRC check when we support multistream 94 // TODO(brandtr): Generalize this SSRC check when we support multistream
102 // protection. 95 // protection.
103 RTC_DCHECK_EQ(packet.Ssrc(), protected_media_ssrc_); 96 RTC_DCHECK_EQ(packet.Ssrc(), protected_media_ssrc_);
104 return ulpfec_generator_.AddRtpPacketAndGenerateFec( 97 return ulpfec_generator_.AddRtpPacketAndGenerateFec(
105 packet.data(), packet.payload_size(), packet.headers_size()) == 0; 98 packet.data(), packet.payload_size(), packet.headers_size()) == 0;
106 } 99 }
107 100
108 bool FlexfecSender::FecAvailable() const { 101 bool FlexfecSender::FecAvailable() const {
109 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
110 return ulpfec_generator_.FecAvailable(); 102 return ulpfec_generator_.FecAvailable();
111 } 103 }
112 104
113 std::vector<std::unique_ptr<RtpPacketToSend>> 105 std::vector<std::unique_ptr<RtpPacketToSend>> FlexfecSender::GetFecPackets() {
114 FlexfecSender::GetFecPackets() {
115 RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
116
117 std::vector<std::unique_ptr<RtpPacketToSend>> fec_packets_to_send; 106 std::vector<std::unique_ptr<RtpPacketToSend>> fec_packets_to_send;
118 fec_packets_to_send.reserve(ulpfec_generator_.generated_fec_packets_.size()); 107 fec_packets_to_send.reserve(ulpfec_generator_.generated_fec_packets_.size());
119 for (const auto& fec_packet : ulpfec_generator_.generated_fec_packets_) { 108 for (const auto& fec_packet : ulpfec_generator_.generated_fec_packets_) {
120 std::unique_ptr<RtpPacketToSend> fec_packet_to_send( 109 std::unique_ptr<RtpPacketToSend> fec_packet_to_send(
121 new RtpPacketToSend(&rtp_header_extension_map_)); 110 new RtpPacketToSend(&rtp_header_extension_map_));
122 111
123 // RTP header. 112 // RTP header.
124 fec_packet_to_send->SetMarker(false); 113 fec_packet_to_send->SetMarker(false);
125 fec_packet_to_send->SetPayloadType(payload_type_); 114 fec_packet_to_send->SetPayloadType(payload_type_);
126 fec_packet_to_send->SetSequenceNumber(seq_num_++); 115 fec_packet_to_send->SetSequenceNumber(seq_num_++);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 return fec_packets_to_send; 148 return fec_packets_to_send;
160 } 149 }
161 150
162 // The overhead is BWE RTP header extensions and FlexFEC header. 151 // The overhead is BWE RTP header extensions and FlexFEC header.
163 size_t FlexfecSender::MaxPacketOverhead() const { 152 size_t FlexfecSender::MaxPacketOverhead() const {
164 return rtp_header_extension_map_.GetTotalLengthInBytes() + 153 return rtp_header_extension_map_.GetTotalLengthInBytes() +
165 kFlexfecMaxHeaderSize; 154 kFlexfecMaxHeaderSize;
166 } 155 }
167 156
168 } // namespace webrtc 157 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/include/flexfec_sender.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698