| 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 #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_); | |
| 58 void NotifyRtcpCallback() LOCKS_EXCLUDED(stream_lock_); | |
| 59 | 59 |
| 60 const uint32_t ssrc_; |
| 60 Clock* const clock_; | 61 Clock* const clock_; |
| 61 rtc::CriticalSection stream_lock_; | 62 rtc::CriticalSection stream_lock_; |
| 62 RateStatistics incoming_bitrate_; | 63 RateStatistics incoming_bitrate_; |
| 63 uint32_t ssrc_; | |
| 64 int max_reordering_threshold_; // In number of packets or sequence numbers. | 64 int max_reordering_threshold_; // In number of packets or sequence numbers. |
| 65 | 65 |
| 66 // Stats on received RTP packets. | 66 // Stats on received RTP packets. |
| 67 uint32_t jitter_q4_; | 67 uint32_t jitter_q4_; |
| 68 uint32_t cumulative_loss_; | 68 uint32_t cumulative_loss_; |
| 69 uint32_t jitter_q4_transmission_time_offset_; | 69 uint32_t jitter_q4_transmission_time_offset_; |
| 70 | 70 |
| 71 int64_t last_receive_time_ms_; | 71 int64_t last_receive_time_ms_; |
| 72 NtpTime last_receive_time_ntp_; | 72 NtpTime last_receive_time_ntp_; |
| 73 uint32_t last_received_timestamp_; | 73 uint32_t last_received_timestamp_; |
| 74 int32_t last_received_transmission_time_offset_; | 74 int32_t last_received_transmission_time_offset_; |
| 75 uint16_t received_seq_first_; | 75 uint16_t received_seq_first_; |
| 76 uint16_t received_seq_max_; | 76 uint16_t received_seq_max_; |
| 77 uint16_t received_seq_wraps_; | 77 uint16_t received_seq_wraps_; |
| 78 | 78 |
| 79 // Current counter values. | 79 // Current counter values. |
| 80 size_t received_packet_overhead_; | 80 size_t received_packet_overhead_; |
| 81 StreamDataCounters receive_counters_; | 81 StreamDataCounters receive_counters_; |
| 82 | 82 |
| 83 // Counter values when we sent the last report. | 83 // Counter values when we sent the last report. |
| 84 uint32_t last_report_inorder_packets_; | 84 uint32_t last_report_inorder_packets_; |
| 85 uint32_t last_report_old_packets_; | 85 uint32_t last_report_old_packets_; |
| 86 uint16_t last_report_seq_max_; | 86 uint16_t last_report_seq_max_; |
| 87 RtcpStatistics last_reported_statistics_; | 87 RtcpStatistics last_reported_statistics_; |
| 88 | 88 |
| 89 // stream_lock_ shouldn't be held when calling callbacks. |
| 89 RtcpStatisticsCallback* const rtcp_callback_; | 90 RtcpStatisticsCallback* const rtcp_callback_; |
| 90 StreamDataCountersCallback* const rtp_callback_; | 91 StreamDataCountersCallback* const rtp_callback_; |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 class ReceiveStatisticsImpl : public ReceiveStatistics, | 94 class ReceiveStatisticsImpl : public ReceiveStatistics, |
| 94 public RtcpStatisticsCallback, | 95 public RtcpStatisticsCallback, |
| 95 public StreamDataCountersCallback { | 96 public StreamDataCountersCallback { |
| 96 public: | 97 public: |
| 97 explicit ReceiveStatisticsImpl(Clock* clock); | 98 explicit ReceiveStatisticsImpl(Clock* clock); |
| 98 | 99 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 128 | 129 |
| 129 Clock* const clock_; | 130 Clock* const clock_; |
| 130 rtc::CriticalSection receive_statistics_lock_; | 131 rtc::CriticalSection receive_statistics_lock_; |
| 131 StatisticianImplMap statisticians_; | 132 StatisticianImplMap statisticians_; |
| 132 | 133 |
| 133 RtcpStatisticsCallback* rtcp_stats_callback_; | 134 RtcpStatisticsCallback* rtcp_stats_callback_; |
| 134 StreamDataCountersCallback* rtp_stats_callback_; | 135 StreamDataCountersCallback* rtp_stats_callback_; |
| 135 }; | 136 }; |
| 136 } // namespace webrtc | 137 } // namespace webrtc |
| 137 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_ | 138 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_ |
| OLD | NEW |