2013-08-15 23:38:54 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_
|
|
|
|
|
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_
|
|
|
|
|
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h"
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/bitrate.h"
|
|
|
|
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
|
|
|
|
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class CriticalSectionWrapper;
|
|
|
|
|
|
2013-08-21 20:58:21 +00:00
|
|
|
class StreamStatisticianImpl : public StreamStatistician {
|
2013-08-15 23:38:54 +00:00
|
|
|
public:
|
2013-08-21 20:58:21 +00:00
|
|
|
explicit StreamStatisticianImpl(Clock* clock);
|
|
|
|
|
|
|
|
|
|
virtual ~StreamStatisticianImpl() {}
|
2013-08-21 16:22:21 +00:00
|
|
|
|
2013-08-21 20:58:21 +00:00
|
|
|
virtual bool GetStatistics(Statistics* statistics, bool reset) OVERRIDE;
|
|
|
|
|
virtual void GetDataCounters(uint32_t* bytes_received,
|
|
|
|
|
uint32_t* packets_received) const OVERRIDE;
|
|
|
|
|
virtual uint32_t BitrateReceived() const OVERRIDE;
|
|
|
|
|
virtual void ResetStatistics() OVERRIDE;
|
|
|
|
|
|
|
|
|
|
void IncomingPacket(const RTPHeader& rtp_header, size_t bytes,
|
|
|
|
|
bool retransmitted, bool in_order);
|
|
|
|
|
void ProcessBitrate();
|
|
|
|
|
virtual void LastReceiveTimeNtp(uint32_t* secs, uint32_t* frac) const;
|
2013-08-15 23:38:54 +00:00
|
|
|
|
|
|
|
|
private:
|
2013-08-21 19:44:13 +00:00
|
|
|
Clock* clock_;
|
2013-08-21 20:58:21 +00:00
|
|
|
scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
2013-08-15 23:38:54 +00:00
|
|
|
Bitrate incoming_bitrate_;
|
|
|
|
|
uint32_t ssrc_;
|
2013-08-21 20:58:21 +00:00
|
|
|
|
2013-08-15 23:38:54 +00:00
|
|
|
// Stats on received RTP packets.
|
|
|
|
|
uint32_t jitter_q4_;
|
|
|
|
|
uint32_t jitter_max_q4_;
|
|
|
|
|
uint32_t cumulative_loss_;
|
|
|
|
|
uint32_t jitter_q4_transmission_time_offset_;
|
|
|
|
|
|
2013-08-21 20:58:21 +00:00
|
|
|
uint32_t last_receive_time_secs_;
|
|
|
|
|
uint32_t last_receive_time_frac_;
|
2013-08-15 23:38:54 +00:00
|
|
|
uint32_t last_received_timestamp_;
|
|
|
|
|
int32_t last_received_transmission_time_offset_;
|
|
|
|
|
uint16_t received_seq_first_;
|
|
|
|
|
uint16_t received_seq_max_;
|
|
|
|
|
uint16_t received_seq_wraps_;
|
2013-08-21 20:58:21 +00:00
|
|
|
bool first_packet_;
|
2013-08-15 23:38:54 +00:00
|
|
|
|
|
|
|
|
// Current counter values.
|
|
|
|
|
uint16_t received_packet_overhead_;
|
|
|
|
|
uint32_t received_byte_count_;
|
|
|
|
|
uint32_t received_retransmitted_packets_;
|
|
|
|
|
uint32_t received_inorder_packet_count_;
|
|
|
|
|
|
|
|
|
|
// 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_;
|
2013-08-21 20:58:21 +00:00
|
|
|
Statistics last_reported_statistics_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ReceiveStatisticsImpl : public ReceiveStatistics {
|
|
|
|
|
public:
|
|
|
|
|
explicit ReceiveStatisticsImpl(Clock* clock);
|
|
|
|
|
|
|
|
|
|
~ReceiveStatisticsImpl();
|
|
|
|
|
|
|
|
|
|
// Implement ReceiveStatistics.
|
|
|
|
|
virtual void IncomingPacket(const RTPHeader& header, size_t bytes,
|
|
|
|
|
bool old_packet, bool in_order) OVERRIDE;
|
|
|
|
|
virtual StatisticianMap GetActiveStatisticians() const OVERRIDE;
|
|
|
|
|
virtual StreamStatistician* GetStatistician(uint32_t ssrc) const OVERRIDE;
|
|
|
|
|
|
|
|
|
|
// Implement Module.
|
|
|
|
|
virtual int32_t Process() OVERRIDE;
|
|
|
|
|
virtual int32_t TimeUntilNextProcess() OVERRIDE;
|
|
|
|
|
|
|
|
|
|
void ChangeSsrc(uint32_t from_ssrc, uint32_t to_ssrc);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
typedef std::map<uint32_t, StreamStatisticianImpl*> StatisticianImplMap;
|
|
|
|
|
|
|
|
|
|
Clock* clock_;
|
|
|
|
|
scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
|
|
|
|
int64_t last_rate_update_ms_;
|
|
|
|
|
StatisticianImplMap statisticians_;
|
2013-08-15 23:38:54 +00:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RECEIVE_STATISTICS_IMPL_H_
|