Add 1 sec timer to ModuleRtpRtcpImpl2 instead of frequent polling.

This reduces the number of times we grab a few locks down from
somewhere upwards of around a thousand time a second to a few times.

* Update the RTT value on the worker thread and fire callbacks.
* Trigger NotifyTmmbrUpdated() calls from the worker.
* Update the tests to use a GlobalSimulatedTimeController.

Change-Id: Ib81582494066b9460ae0aa84271f32311f30fbce
Bug: webrtc:11581
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177664
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31602}
This commit is contained in:
Tomas Gunnarsson
2020-07-01 08:53:21 +02:00
committed by Commit Bot
parent 20f45823e3
commit ba0ba71e93
8 changed files with 254 additions and 197 deletions

View File

@ -89,6 +89,11 @@ class RTCPReceiver final {
void SetRtcpXrRrtrStatus(bool enable);
bool GetAndResetXrRrRtt(int64_t* rtt_ms);
// Called once per second on the worker thread to do rtt calculations.
// Returns an optional rtt value if one is available.
absl::optional<TimeDelta> OnPeriodicRttUpdate(Timestamp newer_than,
bool sending);
// Get statistics.
int32_t StatisticsReceived(std::vector<RTCPReportBlock>* receiveBlocks) const;
// A snapshot of Report Blocks with additional data of interest to statistics.
@ -210,6 +215,12 @@ class RTCPReceiver final {
PacketInformation* packet_information)
RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
bool RtcpRrTimeoutLocked(Timestamp now)
RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
bool RtcpRrSequenceNumberTimeoutLocked(Timestamp now)
RTC_EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
Clock* const clock_;
const bool receiver_only_;
ModuleRtpRtcp* const rtp_rtcp_;
@ -222,7 +233,7 @@ class RTCPReceiver final {
NetworkStateEstimateObserver* const network_state_estimate_observer_;
TransportFeedbackObserver* const transport_feedback_observer_;
VideoBitrateAllocationObserver* const bitrate_allocation_observer_;
const int report_interval_ms_;
const TimeDelta report_interval_;
rtc::CriticalSection rtcp_receiver_lock_;
uint32_t remote_ssrc_ RTC_GUARDED_BY(rtcp_receiver_lock_);
@ -256,11 +267,12 @@ class RTCPReceiver final {
RTC_GUARDED_BY(rtcp_receiver_lock_);
// The last time we received an RTCP Report block for this module.
int64_t last_received_rb_ms_ RTC_GUARDED_BY(rtcp_receiver_lock_);
Timestamp last_received_rb_ RTC_GUARDED_BY(rtcp_receiver_lock_) =
Timestamp::PlusInfinity();
// The time we last received an RTCP RR telling we have successfully
// delivered RTP packet to the remote side.
int64_t last_increased_sequence_number_ms_;
Timestamp last_increased_sequence_number_ = Timestamp::PlusInfinity();
RtcpStatisticsCallback* const stats_callback_;
RtcpCnameCallback* const cname_callback_;