sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_ |
| 12 | #define WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_ |
| 13 | |
| 14 | #include <string> |
| 15 | |
pbos@webrtc.org | 38344ed | 2014-09-24 06:05:00 +0000 | [diff] [blame] | 16 | #include "webrtc/base/thread_annotations.h" |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 17 | #include "webrtc/common_types.h" |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 18 | #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" |
| 19 | #include "webrtc/system_wrappers/interface/clock.h" |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 20 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 21 | #include "webrtc/video_engine/include/vie_capture.h" |
| 22 | #include "webrtc/video_engine/include/vie_codec.h" |
| 23 | #include "webrtc/video_send_stream.h" |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 24 | |
| 25 | namespace webrtc { |
| 26 | |
| 27 | class CriticalSectionWrapper; |
| 28 | |
| 29 | class SendStatisticsProxy : public RtcpStatisticsCallback, |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 30 | public RtcpPacketTypeCounterObserver, |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 31 | public StreamDataCountersCallback, |
| 32 | public BitrateStatisticsObserver, |
| 33 | public FrameCountObserver, |
| 34 | public ViEEncoderObserver, |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 35 | public ViECaptureObserver, |
| 36 | public SendSideDelayObserver { |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 37 | public: |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 38 | static const int kStatsTimeoutMs; |
| 39 | |
| 40 | SendStatisticsProxy(Clock* clock, const VideoSendStream::Config& config); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 41 | virtual ~SendStatisticsProxy(); |
| 42 | |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 43 | VideoSendStream::Stats GetStats(); |
| 44 | |
| 45 | virtual void OnSendEncodedImage(const EncodedImage& encoded_image, |
| 46 | const RTPVideoHeader* rtp_video_header); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 47 | |
| 48 | protected: |
| 49 | // From RtcpStatisticsCallback. |
| 50 | virtual void StatisticsUpdated(const RtcpStatistics& statistics, |
| 51 | uint32_t ssrc) OVERRIDE; |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 52 | virtual void CNameChanged(const char *cname, uint32_t ssrc) OVERRIDE; |
pbos@webrtc.org | 1d0fa5d | 2015-02-19 12:47:00 +0000 | [diff] [blame] | 53 | // From RtcpPacketTypeCounterObserver |
| 54 | virtual void RtcpPacketTypesCounterUpdated( |
| 55 | uint32_t ssrc, |
| 56 | const RtcpPacketTypeCounter& packet_counter) OVERRIDE; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 57 | // From StreamDataCountersCallback. |
| 58 | virtual void DataCountersUpdated(const StreamDataCounters& counters, |
| 59 | uint32_t ssrc) OVERRIDE; |
| 60 | |
| 61 | // From BitrateStatisticsObserver. |
stefan@webrtc.org | 0bae1fa | 2014-11-05 14:05:29 +0000 | [diff] [blame] | 62 | virtual void Notify(const BitrateStatistics& total_stats, |
| 63 | const BitrateStatistics& retransmit_stats, |
| 64 | uint32_t ssrc) OVERRIDE; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 65 | |
| 66 | // From FrameCountObserver. |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 67 | virtual void FrameCountUpdated(const FrameCounts& frame_counts, |
| 68 | uint32_t ssrc) OVERRIDE; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 69 | |
| 70 | // From ViEEncoderObserver. |
| 71 | virtual void OutgoingRate(const int video_channel, |
| 72 | const unsigned int framerate, |
| 73 | const unsigned int bitrate) OVERRIDE; |
| 74 | |
henrik.lundin@webrtc.org | b10363f | 2014-03-13 13:31:21 +0000 | [diff] [blame] | 75 | virtual void SuspendChange(int video_channel, bool is_suspended) OVERRIDE; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 76 | |
| 77 | // From ViECaptureObserver. |
| 78 | virtual void BrightnessAlarm(const int capture_id, |
| 79 | const Brightness brightness) OVERRIDE {} |
| 80 | |
| 81 | virtual void CapturedFrameRate(const int capture_id, |
| 82 | const unsigned char frame_rate) OVERRIDE; |
| 83 | |
| 84 | virtual void NoPictureAlarm(const int capture_id, |
| 85 | const CaptureAlarm alarm) OVERRIDE {} |
| 86 | |
stefan@webrtc.org | 168f23f | 2014-07-11 13:44:02 +0000 | [diff] [blame] | 87 | virtual void SendSideDelayUpdated(int avg_delay_ms, |
| 88 | int max_delay_ms, |
| 89 | uint32_t ssrc) OVERRIDE; |
| 90 | |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 91 | private: |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 92 | struct StatsUpdateTimes { |
| 93 | StatsUpdateTimes() : resolution_update_ms(0) {} |
| 94 | int64_t resolution_update_ms; |
| 95 | }; |
| 96 | void PurgeOldStats() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
pbos@webrtc.org | 09c77b9 | 2015-02-25 10:42:16 +0000 | [diff] [blame^] | 97 | VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc) |
| 98 | EXCLUSIVE_LOCKS_REQUIRED(crit_); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 99 | |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 100 | Clock* const clock_; |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 101 | const VideoSendStream::Config config_; |
pbos@webrtc.org | de1429e | 2014-04-28 13:00:21 +0000 | [diff] [blame] | 102 | scoped_ptr<CriticalSectionWrapper> crit_; |
| 103 | VideoSendStream::Stats stats_ GUARDED_BY(crit_); |
pbos@webrtc.org | 273a414 | 2014-12-01 15:23:21 +0000 | [diff] [blame] | 104 | std::map<uint32_t, StatsUpdateTimes> update_times_ GUARDED_BY(crit_); |
sprang@webrtc.org | ccd4284 | 2014-01-07 09:54:34 +0000 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | } // namespace webrtc |
| 108 | #endif // WEBRTC_VIDEO_SEND_STATISTICS_PROXY_H_ |