2014-02-07 12:06:29 +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_VIDEO_RECEIVE_STATISTICS_PROXY_H_
|
|
|
|
|
#define WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_
|
|
|
|
|
|
2016-02-24 01:35:40 -08:00
|
|
|
#include <map>
|
2014-02-07 12:06:29 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
2015-05-01 13:00:41 +02:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2016-02-23 22:49:42 -08:00
|
|
|
#include "webrtc/base/rate_statistics.h"
|
2015-07-22 06:52:00 -07:00
|
|
|
#include "webrtc/base/ratetracker.h"
|
2014-09-24 06:05:00 +00:00
|
|
|
#include "webrtc/base/thread_annotations.h"
|
2014-02-07 12:06:29 +00:00
|
|
|
#include "webrtc/common_types.h"
|
2016-04-18 21:12:48 -07:00
|
|
|
#include "webrtc/common_video/include/frame_callback.h"
|
2015-11-18 22:00:21 +01:00
|
|
|
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
|
2015-12-09 12:13:30 +01:00
|
|
|
#include "webrtc/video/report_block_stats.h"
|
2016-11-02 07:14:03 -07:00
|
|
|
#include "webrtc/video/stats_counter.h"
|
2016-05-03 21:22:04 -07:00
|
|
|
#include "webrtc/video/video_stream_decoder.h"
|
2014-02-07 12:06:29 +00:00
|
|
|
#include "webrtc/video_receive_stream.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class Clock;
|
|
|
|
|
class ViECodec;
|
|
|
|
|
class ViEDecoderObserver;
|
2015-10-20 23:55:26 -07:00
|
|
|
struct CodecSpecificInfo;
|
2014-02-07 12:06:29 +00:00
|
|
|
|
2015-08-28 07:35:32 -07:00
|
|
|
class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback,
|
2014-02-07 12:06:29 +00:00
|
|
|
public RtcpStatisticsCallback,
|
2015-02-19 12:47:00 +00:00
|
|
|
public RtcpPacketTypeCounterObserver,
|
2014-12-19 15:45:03 +00:00
|
|
|
public StreamDataCountersCallback {
|
2014-02-07 12:06:29 +00:00
|
|
|
public:
|
2016-06-10 17:58:01 +02:00
|
|
|
ReceiveStatisticsProxy(const VideoReceiveStream::Config* config,
|
2016-02-24 01:35:40 -08:00
|
|
|
Clock* clock);
|
2014-02-07 12:06:29 +00:00
|
|
|
virtual ~ReceiveStatisticsProxy();
|
|
|
|
|
|
|
|
|
|
VideoReceiveStream::Stats GetStats() const;
|
|
|
|
|
|
|
|
|
|
void OnDecodedFrame();
|
2016-11-02 07:14:03 -07:00
|
|
|
void OnSyncOffsetUpdated(int64_t sync_offset_ms, double estimated_freq_khz);
|
2016-09-23 02:09:46 -07:00
|
|
|
void OnRenderedFrame(const VideoFrame& frame);
|
2015-08-28 07:35:32 -07:00
|
|
|
void OnIncomingPayloadType(int payload_type);
|
2015-12-18 16:01:11 +01:00
|
|
|
void OnDecoderImplementationName(const char* implementation_name);
|
2015-08-28 07:35:32 -07:00
|
|
|
void OnIncomingRate(unsigned int framerate, unsigned int bitrate_bps);
|
|
|
|
|
void OnDecoderTiming(int decode_ms,
|
|
|
|
|
int max_decode_ms,
|
|
|
|
|
int current_delay_ms,
|
|
|
|
|
int target_delay_ms,
|
|
|
|
|
int jitter_buffer_ms,
|
|
|
|
|
int min_playout_delay_ms,
|
2015-10-06 04:08:15 -07:00
|
|
|
int render_delay_ms,
|
|
|
|
|
int64_t rtt_ms);
|
2014-02-07 12:06:29 +00:00
|
|
|
|
2015-10-20 23:55:26 -07:00
|
|
|
void OnPreDecode(const EncodedImage& encoded_image,
|
|
|
|
|
const CodecSpecificInfo* codec_specific_info);
|
|
|
|
|
|
2015-07-22 06:52:00 -07:00
|
|
|
// Overrides VCMReceiveStatisticsCallback.
|
2015-03-04 12:58:35 +00:00
|
|
|
void OnReceiveRatesUpdated(uint32_t bitRate, uint32_t frameRate) override;
|
|
|
|
|
void OnFrameCountsUpdated(const FrameCounts& frame_counts) override;
|
|
|
|
|
void OnDiscardedPacketsUpdated(int discarded_packets) override;
|
2014-12-19 15:45:03 +00:00
|
|
|
|
2014-12-18 13:50:16 +00:00
|
|
|
// Overrides RtcpStatisticsCallback.
|
2015-03-04 12:58:35 +00:00
|
|
|
void StatisticsUpdated(const webrtc::RtcpStatistics& statistics,
|
|
|
|
|
uint32_t ssrc) override;
|
|
|
|
|
void CNameChanged(const char* cname, uint32_t ssrc) override;
|
2014-02-07 12:06:29 +00:00
|
|
|
|
2015-07-22 06:52:00 -07:00
|
|
|
// Overrides RtcpPacketTypeCounterObserver.
|
2015-03-04 12:58:35 +00:00
|
|
|
void RtcpPacketTypesCounterUpdated(
|
2015-02-19 12:47:00 +00:00
|
|
|
uint32_t ssrc,
|
2015-03-04 12:58:35 +00:00
|
|
|
const RtcpPacketTypeCounter& packet_counter) override;
|
2014-02-07 12:06:29 +00:00
|
|
|
// Overrides StreamDataCountersCallback.
|
2015-03-04 12:58:35 +00:00
|
|
|
void DataCountersUpdated(const webrtc::StreamDataCounters& counters,
|
|
|
|
|
uint32_t ssrc) override;
|
2014-02-07 12:06:29 +00:00
|
|
|
|
2014-12-18 13:50:16 +00:00
|
|
|
private:
|
2015-07-22 06:52:00 -07:00
|
|
|
struct SampleCounter {
|
|
|
|
|
SampleCounter() : sum(0), num_samples(0) {}
|
|
|
|
|
void Add(int sample);
|
|
|
|
|
int Avg(int min_required_samples) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int sum;
|
|
|
|
|
int num_samples;
|
|
|
|
|
};
|
2015-10-20 23:55:26 -07:00
|
|
|
struct QpCounters {
|
|
|
|
|
SampleCounter vp8;
|
|
|
|
|
};
|
2015-07-22 06:52:00 -07:00
|
|
|
|
|
|
|
|
void UpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
|
|
|
|
|
2014-04-28 13:00:21 +00:00
|
|
|
Clock* const clock_;
|
2016-06-10 17:58:01 +02:00
|
|
|
// Ownership of this object lies with the owner of the ReceiveStatisticsProxy
|
|
|
|
|
// instance. Lifetime is guaranteed to outlive |this|.
|
|
|
|
|
// TODO(tommi): In practice the config_ reference is only used for accessing
|
2016-10-04 23:28:39 -07:00
|
|
|
// config_.rtp.ulpfec.ulpfec_payload_type. Instead of holding a pointer back,
|
2016-06-10 17:58:01 +02:00
|
|
|
// we could just store the value of ulpfec_payload_type and change the
|
|
|
|
|
// ReceiveStatisticsProxy() ctor to accept a const& of Config (since we'll
|
|
|
|
|
// then no longer store a pointer to the object).
|
|
|
|
|
const VideoReceiveStream::Config& config_;
|
2016-07-27 00:39:09 -07:00
|
|
|
const int64_t start_ms_;
|
2014-04-28 13:00:21 +00:00
|
|
|
|
2016-01-25 03:52:44 -08:00
|
|
|
rtc::CriticalSection crit_;
|
2014-04-28 13:00:21 +00:00
|
|
|
VideoReceiveStream::Stats stats_ GUARDED_BY(crit_);
|
|
|
|
|
RateStatistics decode_fps_estimator_ GUARDED_BY(crit_);
|
|
|
|
|
RateStatistics renders_fps_estimator_ GUARDED_BY(crit_);
|
2015-09-14 10:38:08 -07:00
|
|
|
rtc::RateTracker render_fps_tracker_ GUARDED_BY(crit_);
|
2015-10-08 00:41:59 -07:00
|
|
|
rtc::RateTracker render_pixel_tracker_ GUARDED_BY(crit_);
|
2015-07-22 06:52:00 -07:00
|
|
|
SampleCounter render_width_counter_ GUARDED_BY(crit_);
|
|
|
|
|
SampleCounter render_height_counter_ GUARDED_BY(crit_);
|
2016-03-15 01:00:47 -07:00
|
|
|
SampleCounter sync_offset_counter_ GUARDED_BY(crit_);
|
2015-07-24 00:20:58 -07:00
|
|
|
SampleCounter decode_time_counter_ GUARDED_BY(crit_);
|
2016-04-27 23:42:35 -07:00
|
|
|
SampleCounter jitter_buffer_delay_counter_ GUARDED_BY(crit_);
|
|
|
|
|
SampleCounter target_delay_counter_ GUARDED_BY(crit_);
|
|
|
|
|
SampleCounter current_delay_counter_ GUARDED_BY(crit_);
|
2015-10-06 04:08:15 -07:00
|
|
|
SampleCounter delay_counter_ GUARDED_BY(crit_);
|
2016-09-23 02:09:46 -07:00
|
|
|
SampleCounter e2e_delay_counter_ GUARDED_BY(crit_);
|
2016-11-02 07:14:03 -07:00
|
|
|
MaxCounter freq_offset_counter_ GUARDED_BY(crit_);
|
2015-04-27 10:09:49 +02:00
|
|
|
ReportBlockStats report_block_stats_ GUARDED_BY(crit_);
|
2015-10-20 23:55:26 -07:00
|
|
|
QpCounters qp_counters_; // Only accessed on the decoding thread.
|
2016-02-24 01:35:40 -08:00
|
|
|
std::map<uint32_t, StreamDataCounters> rtx_stats_ GUARDED_BY(crit_);
|
2014-02-07 12:06:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
#endif // WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_
|