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