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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace webrtc { | 30 namespace webrtc { |
31 | 31 |
32 class Clock; | 32 class Clock; |
33 class ViECodec; | 33 class ViECodec; |
34 class ViEDecoderObserver; | 34 class ViEDecoderObserver; |
35 struct CodecSpecificInfo; | 35 struct CodecSpecificInfo; |
36 | 36 |
37 class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback, | 37 class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback, |
38 public RtcpStatisticsCallback, | 38 public RtcpStatisticsCallback, |
39 public RtcpPacketTypeCounterObserver, | 39 public RtcpPacketTypeCounterObserver, |
40 public StreamDataCountersCallback { | 40 public StreamDataCountersCallback, |
| 41 public CallStatsObserver { |
41 public: | 42 public: |
42 ReceiveStatisticsProxy(const VideoReceiveStream::Config* config, | 43 ReceiveStatisticsProxy(const VideoReceiveStream::Config* config, |
43 Clock* clock); | 44 Clock* clock); |
44 virtual ~ReceiveStatisticsProxy(); | 45 virtual ~ReceiveStatisticsProxy(); |
45 | 46 |
46 VideoReceiveStream::Stats GetStats() const; | 47 VideoReceiveStream::Stats GetStats() const; |
47 | 48 |
48 void OnDecodedFrame(); | 49 void OnDecodedFrame(); |
49 void OnSyncOffsetUpdated(int64_t sync_offset_ms, double estimated_freq_khz); | 50 void OnSyncOffsetUpdated(int64_t sync_offset_ms, double estimated_freq_khz); |
50 void OnRenderedFrame(const VideoFrame& frame); | 51 void OnRenderedFrame(const VideoFrame& frame); |
51 void OnIncomingPayloadType(int payload_type); | 52 void OnIncomingPayloadType(int payload_type); |
52 void OnDecoderImplementationName(const char* implementation_name); | 53 void OnDecoderImplementationName(const char* implementation_name); |
53 void OnIncomingRate(unsigned int framerate, unsigned int bitrate_bps); | 54 void OnIncomingRate(unsigned int framerate, unsigned int bitrate_bps); |
54 void OnDecoderTiming(int decode_ms, | |
55 int max_decode_ms, | |
56 int current_delay_ms, | |
57 int target_delay_ms, | |
58 int jitter_buffer_ms, | |
59 int min_playout_delay_ms, | |
60 int render_delay_ms, | |
61 int64_t rtt_ms); | |
62 | 55 |
63 void OnPreDecode(const EncodedImage& encoded_image, | 56 void OnPreDecode(const EncodedImage& encoded_image, |
64 const CodecSpecificInfo* codec_specific_info); | 57 const CodecSpecificInfo* codec_specific_info); |
65 | 58 |
66 // Overrides VCMReceiveStatisticsCallback. | 59 // Overrides VCMReceiveStatisticsCallback. |
67 void OnReceiveRatesUpdated(uint32_t bitRate, uint32_t frameRate) override; | 60 void OnReceiveRatesUpdated(uint32_t bitRate, uint32_t frameRate) override; |
68 void OnFrameCountsUpdated(const FrameCounts& frame_counts) override; | 61 void OnFrameCountsUpdated(const FrameCounts& frame_counts) override; |
69 void OnDiscardedPacketsUpdated(int discarded_packets) override; | 62 void OnDiscardedPacketsUpdated(int discarded_packets) override; |
| 63 void OnCompleteFrame(bool is_keyframe, size_t size_bytes) override; |
| 64 void OnFrameBufferTimingsUpdated(int decode_ms, |
| 65 int max_decode_ms, |
| 66 int current_delay_ms, |
| 67 int target_delay_ms, |
| 68 int jitter_buffer_ms, |
| 69 int min_playout_delay_ms, |
| 70 int render_delay_ms) override; |
70 | 71 |
71 // Overrides RtcpStatisticsCallback. | 72 // Overrides RtcpStatisticsCallback. |
72 void StatisticsUpdated(const webrtc::RtcpStatistics& statistics, | 73 void StatisticsUpdated(const webrtc::RtcpStatistics& statistics, |
73 uint32_t ssrc) override; | 74 uint32_t ssrc) override; |
74 void CNameChanged(const char* cname, uint32_t ssrc) override; | 75 void CNameChanged(const char* cname, uint32_t ssrc) override; |
75 | 76 |
76 // Overrides RtcpPacketTypeCounterObserver. | 77 // Overrides RtcpPacketTypeCounterObserver. |
77 void RtcpPacketTypesCounterUpdated( | 78 void RtcpPacketTypesCounterUpdated( |
78 uint32_t ssrc, | 79 uint32_t ssrc, |
79 const RtcpPacketTypeCounter& packet_counter) override; | 80 const RtcpPacketTypeCounter& packet_counter) override; |
80 // Overrides StreamDataCountersCallback. | 81 // Overrides StreamDataCountersCallback. |
81 void DataCountersUpdated(const webrtc::StreamDataCounters& counters, | 82 void DataCountersUpdated(const webrtc::StreamDataCounters& counters, |
82 uint32_t ssrc) override; | 83 uint32_t ssrc) override; |
83 | 84 |
| 85 // Implements CallStatsObserver. |
| 86 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 87 |
84 private: | 88 private: |
85 struct SampleCounter { | 89 struct SampleCounter { |
86 SampleCounter() : sum(0), num_samples(0) {} | 90 SampleCounter() : sum(0), num_samples(0) {} |
87 void Add(int sample); | 91 void Add(int sample); |
88 int Avg(int64_t min_required_samples) const; | 92 int Avg(int64_t min_required_samples) const; |
89 void Reset(); | 93 void Reset(); |
90 | 94 |
91 private: | 95 private: |
92 int64_t sum; | 96 int64_t sum; |
93 int64_t num_samples; | 97 int64_t num_samples; |
94 }; | 98 }; |
95 struct QpCounters { | 99 struct QpCounters { |
96 SampleCounter vp8; | 100 SampleCounter vp8; |
97 }; | 101 }; |
98 | 102 |
99 void UpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 103 void UpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
100 | 104 |
101 void QualitySample() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 105 void QualitySample() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
102 | 106 |
| 107 // Removes info about old frames and then updates the framerate/bitrate. |
| 108 void UpdateFrameAndBitrate(int64_t now_ms) const |
| 109 EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 110 |
103 Clock* const clock_; | 111 Clock* const clock_; |
104 // Ownership of this object lies with the owner of the ReceiveStatisticsProxy | 112 // Ownership of this object lies with the owner of the ReceiveStatisticsProxy |
105 // instance. Lifetime is guaranteed to outlive |this|. | 113 // instance. Lifetime is guaranteed to outlive |this|. |
106 // TODO(tommi): In practice the config_ reference is only used for accessing | 114 // TODO(tommi): In practice the config_ reference is only used for accessing |
107 // config_.rtp.ulpfec.ulpfec_payload_type. Instead of holding a pointer back, | 115 // config_.rtp.ulpfec.ulpfec_payload_type. Instead of holding a pointer back, |
108 // we could just store the value of ulpfec_payload_type and change the | 116 // we could just store the value of ulpfec_payload_type and change the |
109 // ReceiveStatisticsProxy() ctor to accept a const& of Config (since we'll | 117 // ReceiveStatisticsProxy() ctor to accept a const& of Config (since we'll |
110 // then no longer store a pointer to the object). | 118 // then no longer store a pointer to the object). |
111 const VideoReceiveStream::Config& config_; | 119 const VideoReceiveStream::Config& config_; |
112 const int64_t start_ms_; | 120 const int64_t start_ms_; |
113 | 121 |
114 rtc::CriticalSection crit_; | 122 rtc::CriticalSection crit_; |
115 int64_t last_sample_time_ GUARDED_BY(crit_); | 123 int64_t last_sample_time_ GUARDED_BY(crit_); |
116 QualityThreshold fps_threshold_ GUARDED_BY(crit_); | 124 QualityThreshold fps_threshold_ GUARDED_BY(crit_); |
117 QualityThreshold qp_threshold_ GUARDED_BY(crit_); | 125 QualityThreshold qp_threshold_ GUARDED_BY(crit_); |
118 QualityThreshold variance_threshold_ GUARDED_BY(crit_); | 126 QualityThreshold variance_threshold_ GUARDED_BY(crit_); |
119 SampleCounter qp_sample_ GUARDED_BY(crit_); | 127 SampleCounter qp_sample_ GUARDED_BY(crit_); |
120 int num_bad_states_ GUARDED_BY(crit_); | 128 int num_bad_states_ GUARDED_BY(crit_); |
121 int num_certain_states_ GUARDED_BY(crit_); | 129 int num_certain_states_ GUARDED_BY(crit_); |
122 VideoReceiveStream::Stats stats_ GUARDED_BY(crit_); | 130 mutable VideoReceiveStream::Stats stats_ GUARDED_BY(crit_); |
123 RateStatistics decode_fps_estimator_ GUARDED_BY(crit_); | 131 RateStatistics decode_fps_estimator_ GUARDED_BY(crit_); |
124 RateStatistics renders_fps_estimator_ GUARDED_BY(crit_); | 132 RateStatistics renders_fps_estimator_ GUARDED_BY(crit_); |
125 rtc::RateTracker render_fps_tracker_ GUARDED_BY(crit_); | 133 rtc::RateTracker render_fps_tracker_ GUARDED_BY(crit_); |
126 rtc::RateTracker render_pixel_tracker_ GUARDED_BY(crit_); | 134 rtc::RateTracker render_pixel_tracker_ GUARDED_BY(crit_); |
127 SampleCounter render_width_counter_ GUARDED_BY(crit_); | 135 SampleCounter render_width_counter_ GUARDED_BY(crit_); |
128 SampleCounter render_height_counter_ GUARDED_BY(crit_); | 136 SampleCounter render_height_counter_ GUARDED_BY(crit_); |
129 SampleCounter sync_offset_counter_ GUARDED_BY(crit_); | 137 SampleCounter sync_offset_counter_ GUARDED_BY(crit_); |
130 SampleCounter decode_time_counter_ GUARDED_BY(crit_); | 138 SampleCounter decode_time_counter_ GUARDED_BY(crit_); |
131 SampleCounter jitter_buffer_delay_counter_ GUARDED_BY(crit_); | 139 SampleCounter jitter_buffer_delay_counter_ GUARDED_BY(crit_); |
132 SampleCounter target_delay_counter_ GUARDED_BY(crit_); | 140 SampleCounter target_delay_counter_ GUARDED_BY(crit_); |
133 SampleCounter current_delay_counter_ GUARDED_BY(crit_); | 141 SampleCounter current_delay_counter_ GUARDED_BY(crit_); |
134 SampleCounter delay_counter_ GUARDED_BY(crit_); | 142 SampleCounter delay_counter_ GUARDED_BY(crit_); |
135 SampleCounter e2e_delay_counter_ GUARDED_BY(crit_); | 143 SampleCounter e2e_delay_counter_ GUARDED_BY(crit_); |
136 MaxCounter freq_offset_counter_ GUARDED_BY(crit_); | 144 MaxCounter freq_offset_counter_ GUARDED_BY(crit_); |
137 int64_t first_report_block_time_ms_ GUARDED_BY(crit_); | 145 int64_t first_report_block_time_ms_ GUARDED_BY(crit_); |
138 ReportBlockStats report_block_stats_ GUARDED_BY(crit_); | 146 ReportBlockStats report_block_stats_ GUARDED_BY(crit_); |
139 QpCounters qp_counters_; // Only accessed on the decoding thread. | 147 QpCounters qp_counters_; // Only accessed on the decoding thread. |
140 std::map<uint32_t, StreamDataCounters> rtx_stats_ GUARDED_BY(crit_); | 148 std::map<uint32_t, StreamDataCounters> rtx_stats_ GUARDED_BY(crit_); |
| 149 int64_t avg_rtt_ms_ GUARDED_BY(crit_); |
| 150 mutable std::map<int64_t, size_t> frame_window_ GUARDED_BY(&crit_); |
| 151 mutable size_t frame_window_accumulated_bytes_ GUARDED_BY(&crit_); |
141 }; | 152 }; |
142 | 153 |
143 } // namespace webrtc | 154 } // namespace webrtc |
144 #endif // WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ | 155 #endif // WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_ |
OLD | NEW |