OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 StatsReport* report = AddTrackReport(reports, track_id); | 81 StatsReport* report = AddTrackReport(reports, track_id); |
82 RTC_DCHECK(report != nullptr); | 82 RTC_DCHECK(report != nullptr); |
83 track_ids[track_id] = report; | 83 track_ids[track_id] = report; |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 void ExtractCommonSendProperties(const cricket::MediaSenderInfo& info, | 87 void ExtractCommonSendProperties(const cricket::MediaSenderInfo& info, |
88 StatsReport* report) { | 88 StatsReport* report) { |
89 report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name); | 89 report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name); |
90 report->AddInt64(StatsReport::kStatsValueNameBytesSent, info.bytes_sent); | 90 report->AddInt64(StatsReport::kStatsValueNameBytesSent, info.bytes_sent); |
91 report->AddInt64(StatsReport::kStatsValueNameRtt, info.rtt_ms); | 91 if (info.rtt_ms >= 0) { |
| 92 report->AddInt64(StatsReport::kStatsValueNameRtt, info.rtt_ms); |
| 93 } |
92 } | 94 } |
93 | 95 |
94 void ExtractCommonReceiveProperties(const cricket::MediaReceiverInfo& info, | 96 void ExtractCommonReceiveProperties(const cricket::MediaReceiverInfo& info, |
95 StatsReport* report) { | 97 StatsReport* report) { |
96 report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name); | 98 report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name); |
97 } | 99 } |
98 | 100 |
99 void SetAudioProcessingStats(StatsReport* report, | 101 void SetAudioProcessingStats(StatsReport* report, |
100 bool typing_noise_detected, | 102 bool typing_noise_detected, |
101 int echo_return_loss, | 103 int echo_return_loss, |
102 int echo_return_loss_enhancement, | 104 int echo_return_loss_enhancement, |
103 int echo_delay_median_ms, | 105 int echo_delay_median_ms, |
104 float aec_quality_min, | 106 float aec_quality_min, |
105 int echo_delay_std_ms) { | 107 int echo_delay_std_ms) { |
106 report->AddBoolean(StatsReport::kStatsValueNameTypingNoiseState, | 108 report->AddBoolean(StatsReport::kStatsValueNameTypingNoiseState, |
107 typing_noise_detected); | 109 typing_noise_detected); |
108 report->AddFloat(StatsReport::kStatsValueNameEchoCancellationQualityMin, | 110 if (aec_quality_min >= 0.0f) { |
109 aec_quality_min); | 111 report->AddFloat(StatsReport::kStatsValueNameEchoCancellationQualityMin, |
| 112 aec_quality_min); |
| 113 } |
110 const IntForAdd ints[] = { | 114 const IntForAdd ints[] = { |
111 { StatsReport::kStatsValueNameEchoReturnLoss, echo_return_loss }, | |
112 { StatsReport::kStatsValueNameEchoReturnLossEnhancement, | |
113 echo_return_loss_enhancement }, | |
114 { StatsReport::kStatsValueNameEchoDelayMedian, echo_delay_median_ms }, | 115 { StatsReport::kStatsValueNameEchoDelayMedian, echo_delay_median_ms }, |
115 { StatsReport::kStatsValueNameEchoDelayStdDev, echo_delay_std_ms }, | 116 { StatsReport::kStatsValueNameEchoDelayStdDev, echo_delay_std_ms }, |
116 }; | 117 }; |
117 for (const auto& i : ints) | 118 for (const auto& i : ints) { |
118 report->AddInt(i.name, i.value); | 119 if (i.value >= 0) { |
| 120 report->AddInt(i.name, i.value); |
| 121 } |
| 122 } |
| 123 // These can take on valid negative values. |
| 124 report->AddInt(StatsReport::kStatsValueNameEchoReturnLoss, echo_return_loss); |
| 125 report->AddInt(StatsReport::kStatsValueNameEchoReturnLossEnhancement, |
| 126 echo_return_loss_enhancement); |
119 } | 127 } |
120 | 128 |
121 void ExtractStats(const cricket::VoiceReceiverInfo& info, StatsReport* report) { | 129 void ExtractStats(const cricket::VoiceReceiverInfo& info, StatsReport* report) { |
122 ExtractCommonReceiveProperties(info, report); | 130 ExtractCommonReceiveProperties(info, report); |
123 const FloatForAdd floats[] = { | 131 const FloatForAdd floats[] = { |
124 { StatsReport::kStatsValueNameExpandRate, info.expand_rate }, | 132 { StatsReport::kStatsValueNameExpandRate, info.expand_rate }, |
125 { StatsReport::kStatsValueNameSecondaryDecodedRate, | 133 { StatsReport::kStatsValueNameSecondaryDecodedRate, |
126 info.secondary_decoded_rate }, | 134 info.secondary_decoded_rate }, |
127 { StatsReport::kStatsValueNameSpeechExpandRate, info.speech_expand_rate }, | 135 { StatsReport::kStatsValueNameSpeechExpandRate, info.speech_expand_rate }, |
128 { StatsReport::kStatsValueNameAccelerateRate, info.accelerate_rate }, | 136 { StatsReport::kStatsValueNameAccelerateRate, info.accelerate_rate }, |
129 { StatsReport::kStatsValueNamePreemptiveExpandRate, | 137 { StatsReport::kStatsValueNamePreemptiveExpandRate, |
130 info.preemptive_expand_rate }, | 138 info.preemptive_expand_rate }, |
131 }; | 139 }; |
132 | 140 |
133 const IntForAdd ints[] = { | 141 const IntForAdd ints[] = { |
134 { StatsReport::kStatsValueNameAudioOutputLevel, info.audio_level }, | |
135 { StatsReport::kStatsValueNameCurrentDelayMs, info.delay_estimate_ms }, | 142 { StatsReport::kStatsValueNameCurrentDelayMs, info.delay_estimate_ms }, |
136 { StatsReport::kStatsValueNameDecodingCNG, info.decoding_cng }, | 143 { StatsReport::kStatsValueNameDecodingCNG, info.decoding_cng }, |
137 { StatsReport::kStatsValueNameDecodingCTN, info.decoding_calls_to_neteq }, | 144 { StatsReport::kStatsValueNameDecodingCTN, info.decoding_calls_to_neteq }, |
138 { StatsReport::kStatsValueNameDecodingCTSG, | 145 { StatsReport::kStatsValueNameDecodingCTSG, |
139 info.decoding_calls_to_silence_generator }, | 146 info.decoding_calls_to_silence_generator }, |
140 { StatsReport::kStatsValueNameDecodingNormal, info.decoding_normal }, | 147 { StatsReport::kStatsValueNameDecodingNormal, info.decoding_normal }, |
141 { StatsReport::kStatsValueNameDecodingPLC, info.decoding_plc }, | 148 { StatsReport::kStatsValueNameDecodingPLC, info.decoding_plc }, |
142 { StatsReport::kStatsValueNameDecodingPLCCNG, info.decoding_plc_cng }, | 149 { StatsReport::kStatsValueNameDecodingPLCCNG, info.decoding_plc_cng }, |
143 { StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms }, | 150 { StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms }, |
144 { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms }, | 151 { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms }, |
145 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, | 152 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, |
146 { StatsReport::kStatsValueNamePacketsReceived, info.packets_rcvd }, | 153 { StatsReport::kStatsValueNamePacketsReceived, info.packets_rcvd }, |
147 { StatsReport::kStatsValueNamePreferredJitterBufferMs, | 154 { StatsReport::kStatsValueNamePreferredJitterBufferMs, |
148 info.jitter_buffer_preferred_ms }, | 155 info.jitter_buffer_preferred_ms }, |
149 }; | 156 }; |
150 | 157 |
151 for (const auto& f : floats) | 158 for (const auto& f : floats) |
152 report->AddFloat(f.name, f.value); | 159 report->AddFloat(f.name, f.value); |
153 | 160 |
154 for (const auto& i : ints) | 161 for (const auto& i : ints) |
155 report->AddInt(i.name, i.value); | 162 report->AddInt(i.name, i.value); |
| 163 if (info.audio_level >= 0) { |
| 164 report->AddInt(StatsReport::kStatsValueNameAudioOutputLevel, |
| 165 info.audio_level); |
| 166 } |
156 | 167 |
157 report->AddInt64(StatsReport::kStatsValueNameBytesReceived, | 168 report->AddInt64(StatsReport::kStatsValueNameBytesReceived, |
158 info.bytes_rcvd); | 169 info.bytes_rcvd); |
159 report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs, | 170 if (info.capture_start_ntp_time_ms >= 0) { |
160 info.capture_start_ntp_time_ms); | 171 report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs, |
| 172 info.capture_start_ntp_time_ms); |
| 173 } |
161 report->AddString(StatsReport::kStatsValueNameMediaType, "audio"); | 174 report->AddString(StatsReport::kStatsValueNameMediaType, "audio"); |
162 } | 175 } |
163 | 176 |
164 void ExtractStats(const cricket::VoiceSenderInfo& info, StatsReport* report) { | 177 void ExtractStats(const cricket::VoiceSenderInfo& info, StatsReport* report) { |
165 ExtractCommonSendProperties(info, report); | 178 ExtractCommonSendProperties(info, report); |
166 | 179 |
167 SetAudioProcessingStats( | 180 SetAudioProcessingStats( |
168 report, info.typing_noise_detected, info.echo_return_loss, | 181 report, info.typing_noise_detected, info.echo_return_loss, |
169 info.echo_return_loss_enhancement, info.echo_delay_median_ms, | 182 info.echo_return_loss_enhancement, info.echo_delay_median_ms, |
170 info.aec_quality_min, info.echo_delay_std_ms); | 183 info.aec_quality_min, info.echo_delay_std_ms); |
171 | 184 |
172 RTC_DCHECK_GE(info.audio_level, 0); | 185 RTC_DCHECK_GE(info.audio_level, 0); |
173 const IntForAdd ints[] = { | 186 const IntForAdd ints[] = { |
174 { StatsReport::kStatsValueNameAudioInputLevel, info.audio_level}, | 187 { StatsReport::kStatsValueNameAudioInputLevel, info.audio_level}, |
175 { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms }, | 188 { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms }, |
176 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, | 189 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, |
177 { StatsReport::kStatsValueNamePacketsSent, info.packets_sent }, | 190 { StatsReport::kStatsValueNamePacketsSent, info.packets_sent }, |
178 }; | 191 }; |
179 | 192 |
180 for (const auto& i : ints) | 193 for (const auto& i : ints) { |
181 report->AddInt(i.name, i.value); | 194 if (i.value >= 0) { |
| 195 report->AddInt(i.name, i.value); |
| 196 } |
| 197 } |
182 report->AddString(StatsReport::kStatsValueNameMediaType, "audio"); | 198 report->AddString(StatsReport::kStatsValueNameMediaType, "audio"); |
183 } | 199 } |
184 | 200 |
185 void ExtractStats(const cricket::VideoReceiverInfo& info, StatsReport* report) { | 201 void ExtractStats(const cricket::VideoReceiverInfo& info, StatsReport* report) { |
186 ExtractCommonReceiveProperties(info, report); | 202 ExtractCommonReceiveProperties(info, report); |
187 report->AddString(StatsReport::kStatsValueNameCodecImplementationName, | 203 report->AddString(StatsReport::kStatsValueNameCodecImplementationName, |
188 info.decoder_implementation_name); | 204 info.decoder_implementation_name); |
189 report->AddInt64(StatsReport::kStatsValueNameBytesReceived, | 205 report->AddInt64(StatsReport::kStatsValueNameBytesReceived, |
190 info.bytes_rcvd); | 206 info.bytes_rcvd); |
191 report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs, | 207 if (info.capture_start_ntp_time_ms >= 0) { |
192 info.capture_start_ntp_time_ms); | 208 report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs, |
| 209 info.capture_start_ntp_time_ms); |
| 210 } |
193 const IntForAdd ints[] = { | 211 const IntForAdd ints[] = { |
194 { StatsReport::kStatsValueNameCurrentDelayMs, info.current_delay_ms }, | 212 { StatsReport::kStatsValueNameCurrentDelayMs, info.current_delay_ms }, |
195 { StatsReport::kStatsValueNameDecodeMs, info.decode_ms }, | 213 { StatsReport::kStatsValueNameDecodeMs, info.decode_ms }, |
196 { StatsReport::kStatsValueNameFirsSent, info.firs_sent }, | 214 { StatsReport::kStatsValueNameFirsSent, info.firs_sent }, |
197 { StatsReport::kStatsValueNameFrameHeightReceived, info.frame_height }, | 215 { StatsReport::kStatsValueNameFrameHeightReceived, info.frame_height }, |
198 { StatsReport::kStatsValueNameFrameRateDecoded, info.framerate_decoded }, | 216 { StatsReport::kStatsValueNameFrameRateDecoded, info.framerate_decoded }, |
199 { StatsReport::kStatsValueNameFrameRateOutput, info.framerate_output }, | 217 { StatsReport::kStatsValueNameFrameRateOutput, info.framerate_output }, |
200 { StatsReport::kStatsValueNameFrameRateReceived, info.framerate_rcvd }, | 218 { StatsReport::kStatsValueNameFrameRateReceived, info.framerate_rcvd }, |
201 { StatsReport::kStatsValueNameFrameWidthReceived, info.frame_width }, | 219 { StatsReport::kStatsValueNameFrameWidthReceived, info.frame_width }, |
202 { StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms }, | 220 { StatsReport::kStatsValueNameJitterBufferMs, info.jitter_buffer_ms }, |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); | 881 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
864 | 882 |
865 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; | 883 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
866 | 884 |
867 for (const auto& dc : pc_->sctp_data_channels()) { | 885 for (const auto& dc : pc_->sctp_data_channels()) { |
868 StatsReport::Id id(StatsReport::NewTypedIntId( | 886 StatsReport::Id id(StatsReport::NewTypedIntId( |
869 StatsReport::kStatsReportTypeDataChannel, dc->id())); | 887 StatsReport::kStatsReportTypeDataChannel, dc->id())); |
870 StatsReport* report = reports_.ReplaceOrAddNew(id); | 888 StatsReport* report = reports_.ReplaceOrAddNew(id); |
871 report->set_timestamp(stats_gathering_started_); | 889 report->set_timestamp(stats_gathering_started_); |
872 report->AddString(StatsReport::kStatsValueNameLabel, dc->label()); | 890 report->AddString(StatsReport::kStatsValueNameLabel, dc->label()); |
873 report->AddInt(StatsReport::kStatsValueNameDataChannelId, dc->id()); | 891 // Filter out the initial id (-1). |
| 892 if (dc->id() >= 0) { |
| 893 report->AddInt(StatsReport::kStatsValueNameDataChannelId, dc->id()); |
| 894 } |
874 report->AddString(StatsReport::kStatsValueNameProtocol, dc->protocol()); | 895 report->AddString(StatsReport::kStatsValueNameProtocol, dc->protocol()); |
875 report->AddString(StatsReport::kStatsValueNameState, | 896 report->AddString(StatsReport::kStatsValueNameState, |
876 DataChannelInterface::DataStateString(dc->state())); | 897 DataChannelInterface::DataStateString(dc->state())); |
877 } | 898 } |
878 } | 899 } |
879 | 900 |
880 StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type, | 901 StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type, |
881 const std::string& id, | 902 const std::string& id, |
882 StatsReport::Direction direction) { | 903 StatsReport::Direction direction) { |
883 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); | 904 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 StatsReport* report = entry.second; | 993 StatsReport* report = entry.second; |
973 report->set_timestamp(stats_gathering_started_); | 994 report->set_timestamp(stats_gathering_started_); |
974 } | 995 } |
975 } | 996 } |
976 | 997 |
977 void StatsCollector::ClearUpdateStatsCacheForTest() { | 998 void StatsCollector::ClearUpdateStatsCacheForTest() { |
978 stats_gathering_started_ = 0; | 999 stats_gathering_started_ = 0; |
979 } | 1000 } |
980 | 1001 |
981 } // namespace webrtc | 1002 } // namespace webrtc |
OLD | NEW |