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