Remove |running_| state from NackModule to avoid running a tight loop.
Also reducing locking in NackModule (and by extension RtpStreamReceiver) BUG=webrtc:7246 Review-Url: https://codereview.webrtc.org/2720603002 Cr-Commit-Position: refs/heads/master@{#16856}
This commit is contained in:
@ -46,7 +46,6 @@ NackModule::NackModule(Clock* clock,
|
||||
nack_sender_(nack_sender),
|
||||
keyframe_request_sender_(keyframe_request_sender),
|
||||
reordering_histogram_(kNumReorderingBuckets, kMaxReorderedPackets),
|
||||
running_(true),
|
||||
initialized_(false),
|
||||
rtt_ms_(kDefaultRttMs),
|
||||
newest_seq_num_(0),
|
||||
@ -58,8 +57,6 @@ NackModule::NackModule(Clock* clock,
|
||||
|
||||
int NackModule::OnReceivedPacket(const VCMPacket& packet) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (!running_)
|
||||
return -1;
|
||||
uint16_t seq_num = packet.seqNum;
|
||||
// TODO(philipel): When the packet includes information whether it is
|
||||
// retransmitted or not, use that value instead. For
|
||||
@ -132,21 +129,22 @@ void NackModule::Clear() {
|
||||
keyframe_list_.clear();
|
||||
}
|
||||
|
||||
void NackModule::Stop() {
|
||||
rtc::CritScope lock(&crit_);
|
||||
running_ = false;
|
||||
}
|
||||
|
||||
int64_t NackModule::TimeUntilNextProcess() {
|
||||
rtc::CritScope lock(&crit_);
|
||||
return std::max<int64_t>(next_process_time_ms_ - clock_->TimeInMilliseconds(),
|
||||
0);
|
||||
}
|
||||
|
||||
void NackModule::Process() {
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (!running_)
|
||||
return;
|
||||
if (nack_sender_) {
|
||||
std::vector<uint16_t> nack_batch;
|
||||
{
|
||||
rtc::CritScope lock(&crit_);
|
||||
nack_batch = GetNackBatch(kTimeOnly);
|
||||
}
|
||||
|
||||
if (!nack_batch.empty())
|
||||
nack_sender_->SendNack(nack_batch);
|
||||
}
|
||||
|
||||
// Update the next_process_time_ms_ in intervals to achieve
|
||||
// the targeted frequency over time. Also add multiple intervals
|
||||
@ -160,10 +158,6 @@ void NackModule::Process() {
|
||||
(now_ms - next_process_time_ms_) /
|
||||
kProcessIntervalMs * kProcessIntervalMs;
|
||||
}
|
||||
|
||||
std::vector<uint16_t> nack_batch = GetNackBatch(kTimeOnly);
|
||||
if (!nack_batch.empty() && nack_sender_ != nullptr)
|
||||
nack_sender_->SendNack(nack_batch);
|
||||
}
|
||||
|
||||
bool NackModule::RemovePacketsUntilKeyFrame() {
|
||||
|
||||
@ -36,7 +36,6 @@ class NackModule : public Module {
|
||||
void ClearUpTo(uint16_t seq_num);
|
||||
void UpdateRtt(int64_t rtt_ms);
|
||||
void Clear();
|
||||
void Stop();
|
||||
|
||||
// Module implementation
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
@ -82,16 +81,20 @@ class NackModule : public Module {
|
||||
NackSender* const nack_sender_;
|
||||
KeyFrameRequestSender* const keyframe_request_sender_;
|
||||
|
||||
// TODO(philipel): Some of the variables below are consistently used on a
|
||||
// known thread (e.g. see |initialized_|). Those probably do not need
|
||||
// synchronized access.
|
||||
std::map<uint16_t, NackInfo, DescendingSeqNumComp<uint16_t>> nack_list_
|
||||
GUARDED_BY(crit_);
|
||||
std::set<uint16_t, DescendingSeqNumComp<uint16_t>> keyframe_list_
|
||||
GUARDED_BY(crit_);
|
||||
video_coding::Histogram reordering_histogram_ GUARDED_BY(crit_);
|
||||
bool running_ GUARDED_BY(crit_);
|
||||
bool initialized_ GUARDED_BY(crit_);
|
||||
int64_t rtt_ms_ GUARDED_BY(crit_);
|
||||
uint16_t newest_seq_num_ GUARDED_BY(crit_);
|
||||
int64_t next_process_time_ms_ GUARDED_BY(crit_);
|
||||
|
||||
// Only touched on the process thread.
|
||||
int64_t next_process_time_ms_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user