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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h

Issue 2997803002: Reduce locking when collecting receive statistics. (Closed)
Patch Set: Undo RtcpReportBlocks() optimization Created 3 years, 4 months 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 | « no previous file | webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc » ('j') | 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_ 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_ 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_
13 13
14 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" 14 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
15 15
16 #include <algorithm> 16 #include <algorithm>
17 #include <map> 17 #include <map>
18 #include <vector> 18 #include <vector>
19 19
20 #include "webrtc/rtc_base/criticalsection.h" 20 #include "webrtc/rtc_base/criticalsection.h"
21 #include "webrtc/rtc_base/rate_statistics.h" 21 #include "webrtc/rtc_base/rate_statistics.h"
22 #include "webrtc/system_wrappers/include/ntp_time.h" 22 #include "webrtc/system_wrappers/include/ntp_time.h"
23 23
24 namespace webrtc { 24 namespace webrtc {
25 25
26 class StreamStatisticianImpl : public StreamStatistician { 26 class StreamStatisticianImpl : public StreamStatistician {
27 public: 27 public:
28 StreamStatisticianImpl(Clock* clock, 28 StreamStatisticianImpl(uint32_t ssrc,
29 Clock* clock,
29 RtcpStatisticsCallback* rtcp_callback, 30 RtcpStatisticsCallback* rtcp_callback,
30 StreamDataCountersCallback* rtp_callback); 31 StreamDataCountersCallback* rtp_callback);
31 virtual ~StreamStatisticianImpl() {} 32 virtual ~StreamStatisticianImpl() {}
32 33
33 bool GetStatistics(RtcpStatistics* statistics, bool reset) override; 34 bool GetStatistics(RtcpStatistics* statistics, bool reset) override;
34 void GetDataCounters(size_t* bytes_received, 35 void GetDataCounters(size_t* bytes_received,
35 uint32_t* packets_received) const override; 36 uint32_t* packets_received) const override;
36 void GetReceiveStreamDataCounters( 37 void GetReceiveStreamDataCounters(
37 StreamDataCounters* data_counters) const override; 38 StreamDataCounters* data_counters) const override;
38 uint32_t BitrateReceived() const override; 39 uint32_t BitrateReceived() const override;
39 bool IsRetransmitOfOldPacket(const RTPHeader& header, 40 bool IsRetransmitOfOldPacket(const RTPHeader& header,
40 int64_t min_rtt) const override; 41 int64_t min_rtt) const override;
41 bool IsPacketInOrder(uint16_t sequence_number) const override; 42 bool IsPacketInOrder(uint16_t sequence_number) const override;
42 43
43 void IncomingPacket(const RTPHeader& rtp_header, 44 void IncomingPacket(const RTPHeader& rtp_header,
44 size_t packet_length, 45 size_t packet_length,
45 bool retransmitted); 46 bool retransmitted);
46 void FecPacketReceived(const RTPHeader& header, size_t packet_length); 47 void FecPacketReceived(const RTPHeader& header, size_t packet_length);
47 void SetMaxReorderingThreshold(int max_reordering_threshold); 48 void SetMaxReorderingThreshold(int max_reordering_threshold);
48 virtual void LastReceiveTimeNtp(uint32_t* secs, uint32_t* frac) const; 49 virtual void LastReceiveTimeNtp(uint32_t* secs, uint32_t* frac) const;
49 50
50 private: 51 private:
51 bool InOrderPacketInternal(uint16_t sequence_number) const; 52 bool InOrderPacketInternal(uint16_t sequence_number) const;
52 RtcpStatistics CalculateRtcpStatistics(); 53 RtcpStatistics CalculateRtcpStatistics()
54 EXCLUSIVE_LOCKS_REQUIRED(stream_lock_);
53 void UpdateJitter(const RTPHeader& header, NtpTime receive_time); 55 void UpdateJitter(const RTPHeader& header, NtpTime receive_time);
54 void UpdateCounters(const RTPHeader& rtp_header, 56 StreamDataCounters UpdateCounters(const RTPHeader& rtp_header,
55 size_t packet_length, 57 size_t packet_length,
56 bool retransmitted); 58 bool retransmitted);
57 void NotifyRtpCallback() LOCKS_EXCLUDED(stream_lock_); 59 void NotifyRtpCallback(const StreamDataCounters&)
58 void NotifyRtcpCallback() LOCKS_EXCLUDED(stream_lock_); 60 LOCKS_EXCLUDED(stream_lock_);
61 void NotifyRtcpCallback(const RtcpStatistics&) LOCKS_EXCLUDED(stream_lock_);
sprang_webrtc 2017/08/14 09:43:06 Nit: These don't seem to be very useful anymore, c
danilchap 2017/08/14 10:45:32 Checked documentation for LOCKS_EXCLUDED - it does
sprang_webrtc 2017/08/14 11:25:38 Ah, shoot. Just assumed there was.
59 62
63 const uint32_t ssrc_;
60 Clock* const clock_; 64 Clock* const clock_;
61 rtc::CriticalSection stream_lock_; 65 rtc::CriticalSection stream_lock_;
62 RateStatistics incoming_bitrate_; 66 RateStatistics incoming_bitrate_;
63 uint32_t ssrc_;
64 int max_reordering_threshold_; // In number of packets or sequence numbers. 67 int max_reordering_threshold_; // In number of packets or sequence numbers.
65 68
66 // Stats on received RTP packets. 69 // Stats on received RTP packets.
67 uint32_t jitter_q4_; 70 uint32_t jitter_q4_;
68 uint32_t cumulative_loss_; 71 uint32_t cumulative_loss_;
69 uint32_t jitter_q4_transmission_time_offset_; 72 uint32_t jitter_q4_transmission_time_offset_;
70 73
71 int64_t last_receive_time_ms_; 74 int64_t last_receive_time_ms_;
72 NtpTime last_receive_time_ntp_; 75 NtpTime last_receive_time_ntp_;
73 uint32_t last_received_timestamp_; 76 uint32_t last_received_timestamp_;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 131
129 Clock* const clock_; 132 Clock* const clock_;
130 rtc::CriticalSection receive_statistics_lock_; 133 rtc::CriticalSection receive_statistics_lock_;
131 StatisticianImplMap statisticians_; 134 StatisticianImplMap statisticians_;
132 135
133 RtcpStatisticsCallback* rtcp_stats_callback_; 136 RtcpStatisticsCallback* rtcp_stats_callback_;
134 StreamDataCountersCallback* rtp_stats_callback_; 137 StreamDataCountersCallback* rtp_stats_callback_;
135 }; 138 };
136 } // namespace webrtc 139 } // namespace webrtc
137 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_ 140 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698