Add lock annotations in StreamStatisticianImpl

Also consolidate lock operations to public methods only, moving one
CritScope out of UpdateCounters (private) up to IncomingPacket
(public).

Bug: webrtc:7135
Change-Id: I458857d3cfa49961fa34196ffe02cdefd83cec10
Reviewed-on: https://webrtc-review.googlesource.com/96122
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24443}
This commit is contained in:
Niels Möller
2018-08-27 12:32:21 +02:00
committed by Commit Bot
parent a1e4ae2371
commit b615d1af90
2 changed files with 29 additions and 21 deletions

View File

@ -48,40 +48,44 @@ class StreamStatisticianImpl : public StreamStatistician {
void SetMaxReorderingThreshold(int max_reordering_threshold);
private:
bool InOrderPacketInternal(uint16_t sequence_number) const;
bool InOrderPacketInternal(uint16_t sequence_number) const
RTC_EXCLUSIVE_LOCKS_REQUIRED(stream_lock_);
RtcpStatistics CalculateRtcpStatistics()
RTC_EXCLUSIVE_LOCKS_REQUIRED(stream_lock_);
void UpdateJitter(const RTPHeader& header, NtpTime receive_time);
void UpdateJitter(const RTPHeader& header, NtpTime receive_time)
RTC_EXCLUSIVE_LOCKS_REQUIRED(stream_lock_);
StreamDataCounters UpdateCounters(const RTPHeader& rtp_header,
size_t packet_length,
bool retransmitted);
bool retransmitted)
RTC_EXCLUSIVE_LOCKS_REQUIRED(stream_lock_);
const uint32_t ssrc_;
Clock* const clock_;
rtc::CriticalSection stream_lock_;
RateStatistics incoming_bitrate_;
int max_reordering_threshold_; // In number of packets or sequence numbers.
RateStatistics incoming_bitrate_ RTC_GUARDED_BY(&stream_lock_);
// In number of packets or sequence numbers.
int max_reordering_threshold_ RTC_GUARDED_BY(&stream_lock_);
// Stats on received RTP packets.
uint32_t jitter_q4_;
uint32_t cumulative_loss_;
uint32_t jitter_q4_ RTC_GUARDED_BY(&stream_lock_);
uint32_t cumulative_loss_ RTC_GUARDED_BY(&stream_lock_);
int64_t last_receive_time_ms_;
NtpTime last_receive_time_ntp_;
uint32_t last_received_timestamp_;
uint16_t received_seq_first_;
uint16_t received_seq_max_;
uint16_t received_seq_wraps_;
int64_t last_receive_time_ms_ RTC_GUARDED_BY(&stream_lock_);
NtpTime last_receive_time_ntp_ RTC_GUARDED_BY(&stream_lock_);
uint32_t last_received_timestamp_ RTC_GUARDED_BY(&stream_lock_);
uint16_t received_seq_first_ RTC_GUARDED_BY(&stream_lock_);
uint16_t received_seq_max_ RTC_GUARDED_BY(&stream_lock_);
uint16_t received_seq_wraps_ RTC_GUARDED_BY(&stream_lock_);
// Current counter values.
size_t received_packet_overhead_;
StreamDataCounters receive_counters_;
size_t received_packet_overhead_ RTC_GUARDED_BY(&stream_lock_);
StreamDataCounters receive_counters_ RTC_GUARDED_BY(&stream_lock_);
// Counter values when we sent the last report.
uint32_t last_report_inorder_packets_;
uint32_t last_report_old_packets_;
uint16_t last_report_seq_max_;
RtcpStatistics last_reported_statistics_;
uint32_t last_report_inorder_packets_ RTC_GUARDED_BY(&stream_lock_);
uint32_t last_report_old_packets_ RTC_GUARDED_BY(&stream_lock_);
uint16_t last_report_seq_max_ RTC_GUARDED_BY(&stream_lock_);
RtcpStatistics last_reported_statistics_ RTC_GUARDED_BY(&stream_lock_);
// stream_lock_ shouldn't be held when calling callbacks.
RtcpStatisticsCallback* const rtcp_callback_;