2014-01-07 09:54:34 +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_SEND_STATISTICS_PROXY_H_
|
|
|
|
|
#define WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2015-05-01 13:00:41 +02:00
|
|
|
#include "webrtc/base/criticalsection.h"
|
2015-03-18 09:51:05 +00:00
|
|
|
#include "webrtc/base/ratetracker.h"
|
2015-02-26 14:34:55 +00:00
|
|
|
#include "webrtc/base/scoped_ptr.h"
|
2014-09-24 06:05:00 +00:00
|
|
|
#include "webrtc/base/thread_annotations.h"
|
2014-01-07 09:54:34 +00:00
|
|
|
#include "webrtc/common_types.h"
|
2014-12-01 15:23:21 +00:00
|
|
|
#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
|
2015-02-26 13:15:22 +00:00
|
|
|
#include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
|
2014-12-01 15:23:21 +00:00
|
|
|
#include "webrtc/system_wrappers/interface/clock.h"
|
2015-05-12 16:51:11 +02:00
|
|
|
#include "webrtc/video_engine/overuse_frame_detector.h"
|
|
|
|
|
#include "webrtc/video_engine/vie_encoder.h"
|
2014-01-07 09:54:34 +00:00
|
|
|
#include "webrtc/video_send_stream.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-02-26 12:19:31 +00:00
|
|
|
class SendStatisticsProxy : public CpuOveruseMetricsObserver,
|
|
|
|
|
public RtcpStatisticsCallback,
|
2015-02-19 12:47:00 +00:00
|
|
|
public RtcpPacketTypeCounterObserver,
|
2014-01-07 09:54:34 +00:00
|
|
|
public StreamDataCountersCallback,
|
|
|
|
|
public BitrateStatisticsObserver,
|
|
|
|
|
public FrameCountObserver,
|
|
|
|
|
public ViEEncoderObserver,
|
2015-02-26 13:15:22 +00:00
|
|
|
public VideoEncoderRateObserver,
|
2014-07-11 13:44:02 +00:00
|
|
|
public SendSideDelayObserver {
|
2014-01-07 09:54:34 +00:00
|
|
|
public:
|
2014-12-01 15:23:21 +00:00
|
|
|
static const int kStatsTimeoutMs;
|
|
|
|
|
|
|
|
|
|
SendStatisticsProxy(Clock* clock, const VideoSendStream::Config& config);
|
2014-01-07 09:54:34 +00:00
|
|
|
virtual ~SendStatisticsProxy();
|
|
|
|
|
|
2014-12-01 15:23:21 +00:00
|
|
|
VideoSendStream::Stats GetStats();
|
|
|
|
|
|
|
|
|
|
virtual void OnSendEncodedImage(const EncodedImage& encoded_image,
|
|
|
|
|
const RTPVideoHeader* rtp_video_header);
|
2015-03-18 09:51:05 +00:00
|
|
|
// Used to update incoming frame rate.
|
|
|
|
|
void OnIncomingFrame();
|
2014-01-07 09:54:34 +00:00
|
|
|
|
2015-02-26 13:15:22 +00:00
|
|
|
// From VideoEncoderRateObserver.
|
|
|
|
|
void OnSetRates(uint32_t bitrate_bps, int framerate) override;
|
|
|
|
|
|
2014-01-07 09:54:34 +00:00
|
|
|
protected:
|
2015-02-26 12:19:31 +00:00
|
|
|
// From CpuOveruseMetricsObserver.
|
2015-03-04 12:58:35 +00:00
|
|
|
void CpuOveruseMetricsUpdated(const CpuOveruseMetrics& metrics) override;
|
2014-01-07 09:54:34 +00:00
|
|
|
// From RtcpStatisticsCallback.
|
2015-03-04 12:58:35 +00:00
|
|
|
void StatisticsUpdated(const RtcpStatistics& statistics,
|
|
|
|
|
uint32_t ssrc) override;
|
|
|
|
|
void CNameChanged(const char* cname, uint32_t ssrc) override;
|
2015-02-19 12:47:00 +00:00
|
|
|
// From 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-01-07 09:54:34 +00:00
|
|
|
// From StreamDataCountersCallback.
|
2015-03-04 12:58:35 +00:00
|
|
|
void DataCountersUpdated(const StreamDataCounters& counters,
|
|
|
|
|
uint32_t ssrc) override;
|
2014-01-07 09:54:34 +00:00
|
|
|
|
|
|
|
|
// From BitrateStatisticsObserver.
|
2015-03-04 12:58:35 +00:00
|
|
|
void Notify(const BitrateStatistics& total_stats,
|
|
|
|
|
const BitrateStatistics& retransmit_stats,
|
|
|
|
|
uint32_t ssrc) override;
|
2014-01-07 09:54:34 +00:00
|
|
|
|
|
|
|
|
// From FrameCountObserver.
|
2015-03-04 12:58:35 +00:00
|
|
|
void FrameCountUpdated(const FrameCounts& frame_counts,
|
|
|
|
|
uint32_t ssrc) override;
|
2014-01-07 09:54:34 +00:00
|
|
|
|
|
|
|
|
// From ViEEncoderObserver.
|
2015-03-04 12:58:35 +00:00
|
|
|
void OutgoingRate(const int video_channel,
|
|
|
|
|
const unsigned int framerate,
|
|
|
|
|
const unsigned int bitrate) override;
|
2014-01-07 09:54:34 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void SuspendChange(int video_channel, bool is_suspended) override;
|
2014-01-07 09:54:34 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void SendSideDelayUpdated(int avg_delay_ms,
|
|
|
|
|
int max_delay_ms,
|
|
|
|
|
uint32_t ssrc) override;
|
2014-07-11 13:44:02 +00:00
|
|
|
|
2014-01-07 09:54:34 +00:00
|
|
|
private:
|
2014-12-01 15:23:21 +00:00
|
|
|
struct StatsUpdateTimes {
|
|
|
|
|
StatsUpdateTimes() : resolution_update_ms(0) {}
|
|
|
|
|
int64_t resolution_update_ms;
|
|
|
|
|
};
|
|
|
|
|
void PurgeOldStats() EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
2015-02-25 10:42:16 +00:00
|
|
|
VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc)
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
2014-01-07 09:54:34 +00:00
|
|
|
|
2014-12-01 15:23:21 +00:00
|
|
|
Clock* const clock_;
|
2014-01-07 09:54:34 +00:00
|
|
|
const VideoSendStream::Config config_;
|
2015-05-01 13:00:41 +02:00
|
|
|
mutable rtc::CriticalSection crit_;
|
2014-04-28 13:00:21 +00:00
|
|
|
VideoSendStream::Stats stats_ GUARDED_BY(crit_);
|
2015-03-18 09:51:05 +00:00
|
|
|
rtc::RateTracker input_frame_rate_tracker_ GUARDED_BY(crit_);
|
2014-12-01 15:23:21 +00:00
|
|
|
std::map<uint32_t, StatsUpdateTimes> update_times_ GUARDED_BY(crit_);
|
2014-01-07 09:54:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
#endif // WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_
|