OLD | NEW |
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 | 18 |
19 #include "webrtc/base/criticalsection.h" | 19 #include "webrtc/base/criticalsection.h" |
20 #include "webrtc/modules/rtp_rtcp/source/bitrate.h" | 20 #include "webrtc/base/rate_statistics.h" |
21 #include "webrtc/system_wrappers/include/ntp_time.h" | 21 #include "webrtc/system_wrappers/include/ntp_time.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 class StreamStatisticianImpl : public StreamStatistician { | 25 class StreamStatisticianImpl : public StreamStatistician { |
26 public: | 26 public: |
27 StreamStatisticianImpl(Clock* clock, | 27 StreamStatisticianImpl(Clock* clock, |
28 RtcpStatisticsCallback* rtcp_callback, | 28 RtcpStatisticsCallback* rtcp_callback, |
29 StreamDataCountersCallback* rtp_callback); | 29 StreamDataCountersCallback* rtp_callback); |
30 virtual ~StreamStatisticianImpl() {} | 30 virtual ~StreamStatisticianImpl() {} |
31 | 31 |
32 bool GetStatistics(RtcpStatistics* statistics, bool reset) override; | 32 bool GetStatistics(RtcpStatistics* statistics, bool reset) override; |
33 void GetDataCounters(size_t* bytes_received, | 33 void GetDataCounters(size_t* bytes_received, |
34 uint32_t* packets_received) const override; | 34 uint32_t* packets_received) const override; |
35 void GetReceiveStreamDataCounters( | 35 void GetReceiveStreamDataCounters( |
36 StreamDataCounters* data_counters) const override; | 36 StreamDataCounters* data_counters) const override; |
37 uint32_t BitrateReceived() const override; | 37 uint32_t BitrateReceived() const override; |
38 bool IsRetransmitOfOldPacket(const RTPHeader& header, | 38 bool IsRetransmitOfOldPacket(const RTPHeader& header, |
39 int64_t min_rtt) const override; | 39 int64_t min_rtt) const override; |
40 bool IsPacketInOrder(uint16_t sequence_number) const override; | 40 bool IsPacketInOrder(uint16_t sequence_number) const override; |
41 | 41 |
42 void IncomingPacket(const RTPHeader& rtp_header, | 42 void IncomingPacket(const RTPHeader& rtp_header, |
43 size_t packet_length, | 43 size_t packet_length, |
44 bool retransmitted); | 44 bool retransmitted); |
45 void FecPacketReceived(const RTPHeader& header, size_t packet_length); | 45 void FecPacketReceived(const RTPHeader& header, size_t packet_length); |
46 void SetMaxReorderingThreshold(int max_reordering_threshold); | 46 void SetMaxReorderingThreshold(int max_reordering_threshold); |
47 void ProcessBitrate(); | |
48 virtual void LastReceiveTimeNtp(uint32_t* secs, uint32_t* frac) const; | 47 virtual void LastReceiveTimeNtp(uint32_t* secs, uint32_t* frac) const; |
49 | 48 |
50 private: | 49 private: |
51 bool InOrderPacketInternal(uint16_t sequence_number) const; | 50 bool InOrderPacketInternal(uint16_t sequence_number) const; |
52 RtcpStatistics CalculateRtcpStatistics(); | 51 RtcpStatistics CalculateRtcpStatistics(); |
53 void UpdateJitter(const RTPHeader& header, NtpTime receive_time); | 52 void UpdateJitter(const RTPHeader& header, NtpTime receive_time); |
54 void UpdateCounters(const RTPHeader& rtp_header, | 53 void UpdateCounters(const RTPHeader& rtp_header, |
55 size_t packet_length, | 54 size_t packet_length, |
56 bool retransmitted); | 55 bool retransmitted); |
57 void NotifyRtpCallback() LOCKS_EXCLUDED(stream_lock_); | 56 void NotifyRtpCallback() LOCKS_EXCLUDED(stream_lock_); |
58 void NotifyRtcpCallback() LOCKS_EXCLUDED(stream_lock_); | 57 void NotifyRtcpCallback() LOCKS_EXCLUDED(stream_lock_); |
59 | 58 |
60 Clock* clock_; | 59 Clock* const clock_; |
61 rtc::CriticalSection stream_lock_; | 60 rtc::CriticalSection stream_lock_; |
62 Bitrate incoming_bitrate_; | 61 RateStatistics incoming_bitrate_; |
63 uint32_t ssrc_; | 62 uint32_t ssrc_; |
64 int max_reordering_threshold_; // In number of packets or sequence numbers. | 63 int max_reordering_threshold_; // In number of packets or sequence numbers. |
65 | 64 |
66 // Stats on received RTP packets. | 65 // Stats on received RTP packets. |
67 uint32_t jitter_q4_; | 66 uint32_t jitter_q4_; |
68 uint32_t cumulative_loss_; | 67 uint32_t cumulative_loss_; |
69 uint32_t jitter_q4_transmission_time_offset_; | 68 uint32_t jitter_q4_transmission_time_offset_; |
70 | 69 |
71 int64_t last_receive_time_ms_; | 70 int64_t last_receive_time_ms_; |
72 NtpTime last_receive_time_ntp_; | 71 NtpTime last_receive_time_ntp_; |
(...skipping 28 matching lines...) Expand all Loading... |
101 // Implement ReceiveStatistics. | 100 // Implement ReceiveStatistics. |
102 void IncomingPacket(const RTPHeader& header, | 101 void IncomingPacket(const RTPHeader& header, |
103 size_t packet_length, | 102 size_t packet_length, |
104 bool retransmitted) override; | 103 bool retransmitted) override; |
105 void FecPacketReceived(const RTPHeader& header, | 104 void FecPacketReceived(const RTPHeader& header, |
106 size_t packet_length) override; | 105 size_t packet_length) override; |
107 StatisticianMap GetActiveStatisticians() const override; | 106 StatisticianMap GetActiveStatisticians() const override; |
108 StreamStatistician* GetStatistician(uint32_t ssrc) const override; | 107 StreamStatistician* GetStatistician(uint32_t ssrc) const override; |
109 void SetMaxReorderingThreshold(int max_reordering_threshold) override; | 108 void SetMaxReorderingThreshold(int max_reordering_threshold) override; |
110 | 109 |
111 // Implement Module. | |
112 void Process() override; | |
113 int64_t TimeUntilNextProcess() override; | |
114 | |
115 void RegisterRtcpStatisticsCallback( | 110 void RegisterRtcpStatisticsCallback( |
116 RtcpStatisticsCallback* callback) override; | 111 RtcpStatisticsCallback* callback) override; |
117 | 112 |
118 void RegisterRtpStatisticsCallback( | 113 void RegisterRtpStatisticsCallback( |
119 StreamDataCountersCallback* callback) override; | 114 StreamDataCountersCallback* callback) override; |
120 | 115 |
121 private: | 116 private: |
122 void StatisticsUpdated(const RtcpStatistics& statistics, | 117 void StatisticsUpdated(const RtcpStatistics& statistics, |
123 uint32_t ssrc) override; | 118 uint32_t ssrc) override; |
124 void CNameChanged(const char* cname, uint32_t ssrc) override; | 119 void CNameChanged(const char* cname, uint32_t ssrc) override; |
125 void DataCountersUpdated(const StreamDataCounters& counters, | 120 void DataCountersUpdated(const StreamDataCounters& counters, |
126 uint32_t ssrc) override; | 121 uint32_t ssrc) override; |
127 | 122 |
128 typedef std::map<uint32_t, StreamStatisticianImpl*> StatisticianImplMap; | 123 typedef std::map<uint32_t, StreamStatisticianImpl*> StatisticianImplMap; |
129 | 124 |
130 Clock* clock_; | 125 Clock* const clock_; |
131 rtc::CriticalSection receive_statistics_lock_; | 126 rtc::CriticalSection receive_statistics_lock_; |
132 int64_t last_rate_update_ms_; | |
133 StatisticianImplMap statisticians_; | 127 StatisticianImplMap statisticians_; |
134 | 128 |
135 RtcpStatisticsCallback* rtcp_stats_callback_; | 129 RtcpStatisticsCallback* rtcp_stats_callback_; |
136 StreamDataCountersCallback* rtp_stats_callback_; | 130 StreamDataCountersCallback* rtp_stats_callback_; |
137 }; | 131 }; |
138 } // namespace webrtc | 132 } // namespace webrtc |
139 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_ | 133 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_ |
OLD | NEW |