Remove sequenced task checker from FlexfecSender.
The packetization parts of this class are accessed from the
encoder thread, which might change under different occasions.
The use of a sequenced task checker here is thus incorrect, since
that requires the access to always be on the same thread, whenever
a task queue is not used.
The access to the instantiated object of this class, at least when
it comes to the RTP packetization parts, is however synchronized
using the lock in PayloadRouter::OnEncodedImage. We can therefore
safely remove the sequenced task checker.
BUG=webrtc:5654
Review-Url: https://codereview.webrtc.org/2562983002
Cr-Commit-Position: refs/heads/master@{#15549}
diff --git a/webrtc/modules/rtp_rtcp/include/flexfec_sender.h b/webrtc/modules/rtp_rtcp/include/flexfec_sender.h
index 48d3da0..fa4bd6e 100644
--- a/webrtc/modules/rtp_rtcp/include/flexfec_sender.h
+++ b/webrtc/modules/rtp_rtcp/include/flexfec_sender.h
@@ -29,6 +29,9 @@
class RtpPacketToSend;
+// Note that this class is not thread safe, and thus requires external
+// synchronization.
+
class FlexfecSender {
public:
FlexfecSender(int payload_type,
@@ -62,9 +65,8 @@
private:
// Utility.
Clock* const clock_;
- Random random_ GUARDED_BY(sequence_checker_);
- int64_t last_generated_packet_ms_ GUARDED_BY(sequence_checker_);
- rtc::SequencedTaskChecker sequence_checker_;
+ Random random_;
+ int64_t last_generated_packet_ms_;
// Config.
const int payload_type_;
@@ -72,10 +74,10 @@
const uint32_t ssrc_;
const uint32_t protected_media_ssrc_;
// Sequence number of next packet to generate.
- uint16_t seq_num_ GUARDED_BY(sequence_checker_);
+ uint16_t seq_num_;
// Implementation.
- UlpfecGenerator ulpfec_generator_ GUARDED_BY(sequence_checker_);
+ UlpfecGenerator ulpfec_generator_;
const RtpHeaderExtensionMap rtp_header_extension_map_;
};
diff --git a/webrtc/modules/rtp_rtcp/source/flexfec_sender.cc b/webrtc/modules/rtp_rtcp/source/flexfec_sender.cc
index ec8bbdc..5019456 100644
--- a/webrtc/modules/rtp_rtcp/source/flexfec_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/flexfec_sender.cc
@@ -80,10 +80,6 @@
// This object should not have been instantiated if FlexFEC is disabled.
RTC_DCHECK_GE(payload_type, 0);
RTC_DCHECK_LE(payload_type, 127);
-
- // It's OK to create this object on a different thread/task queue than
- // the one used during main operation.
- sequence_checker_.Detach();
}
FlexfecSender::~FlexfecSender() = default;
@@ -91,13 +87,10 @@
// We are reusing the implementation from UlpfecGenerator for SetFecParameters,
// AddRtpPacketAndGenerateFec, and FecAvailable.
void FlexfecSender::SetFecParameters(const FecProtectionParams& params) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
ulpfec_generator_.SetFecParameters(params);
}
-bool FlexfecSender::AddRtpPacketAndGenerateFec(
- const RtpPacketToSend& packet) {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
+bool FlexfecSender::AddRtpPacketAndGenerateFec(const RtpPacketToSend& packet) {
// TODO(brandtr): Generalize this SSRC check when we support multistream
// protection.
RTC_DCHECK_EQ(packet.Ssrc(), protected_media_ssrc_);
@@ -106,14 +99,10 @@
}
bool FlexfecSender::FecAvailable() const {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
return ulpfec_generator_.FecAvailable();
}
-std::vector<std::unique_ptr<RtpPacketToSend>>
-FlexfecSender::GetFecPackets() {
- RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_);
-
+std::vector<std::unique_ptr<RtpPacketToSend>> FlexfecSender::GetFecPackets() {
std::vector<std::unique_ptr<RtpPacketToSend>> fec_packets_to_send;
fec_packets_to_send.reserve(ulpfec_generator_.generated_fec_packets_.size());
for (const auto& fec_packet : ulpfec_generator_.generated_fec_packets_) {