OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 callbacks_) { | 173 callbacks_) { |
174 callback->OnStatsDelivered(cached_report_); | 174 callback->OnStatsDelivered(cached_report_); |
175 } | 175 } |
176 callbacks_.clear(); | 176 callbacks_.clear(); |
177 } | 177 } |
178 | 178 |
179 void RTCStatsCollector::ProduceCertificateStats_s( | 179 void RTCStatsCollector::ProduceCertificateStats_s( |
180 int64_t timestamp_us, const SessionStats& session_stats, | 180 int64_t timestamp_us, const SessionStats& session_stats, |
181 RTCStatsReport* report) const { | 181 RTCStatsReport* report) const { |
182 RTC_DCHECK(signaling_thread_->IsCurrent()); | 182 RTC_DCHECK(signaling_thread_->IsCurrent()); |
183 for (const auto& transport : session_stats.transport_stats) { | 183 for (const auto& transport_stats : session_stats.transport_stats) { |
184 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; | 184 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; |
185 if (pc_->session()->GetLocalCertificate( | 185 if (pc_->session()->GetLocalCertificate( |
186 transport.second.transport_name, &local_certificate)) { | 186 transport_stats.second.transport_name, &local_certificate)) { |
187 ProduceCertificateStatsFromSSLCertificateAndChain_s( | 187 ProduceCertificateStatsFromSSLCertificateAndChain_s( |
188 timestamp_us, local_certificate->ssl_certificate(), report); | 188 timestamp_us, local_certificate->ssl_certificate(), report); |
189 } | 189 } |
190 std::unique_ptr<rtc::SSLCertificate> remote_certificate = | 190 std::unique_ptr<rtc::SSLCertificate> remote_certificate = |
191 pc_->session()->GetRemoteSSLCertificate( | 191 pc_->session()->GetRemoteSSLCertificate( |
192 transport.second.transport_name); | 192 transport_stats.second.transport_name); |
193 if (remote_certificate) { | 193 if (remote_certificate) { |
194 ProduceCertificateStatsFromSSLCertificateAndChain_s( | 194 ProduceCertificateStatsFromSSLCertificateAndChain_s( |
195 timestamp_us, *remote_certificate.get(), report); | 195 timestamp_us, *remote_certificate.get(), report); |
196 } | 196 } |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 void RTCStatsCollector::ProduceCertificateStatsFromSSLCertificateAndChain_s( | 200 void RTCStatsCollector::ProduceCertificateStatsFromSSLCertificateAndChain_s( |
201 int64_t timestamp_us, const rtc::SSLCertificate& certificate, | 201 int64_t timestamp_us, const rtc::SSLCertificate& certificate, |
202 RTCStatsReport* report) const { | 202 RTCStatsReport* report) const { |
(...skipping 12 matching lines...) Expand all Loading... |
215 prev_stats->issuer_certificate_id = stats->id(); | 215 prev_stats->issuer_certificate_id = stats->id(); |
216 report->AddStats(std::unique_ptr<RTCCertificateStats>(stats)); | 216 report->AddStats(std::unique_ptr<RTCCertificateStats>(stats)); |
217 prev_stats = stats; | 217 prev_stats = stats; |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 void RTCStatsCollector::ProduceIceCandidateAndPairStats_s( | 221 void RTCStatsCollector::ProduceIceCandidateAndPairStats_s( |
222 int64_t timestamp_us, const SessionStats& session_stats, | 222 int64_t timestamp_us, const SessionStats& session_stats, |
223 RTCStatsReport* report) const { | 223 RTCStatsReport* report) const { |
224 RTC_DCHECK(signaling_thread_->IsCurrent()); | 224 RTC_DCHECK(signaling_thread_->IsCurrent()); |
225 for (const auto& transport : session_stats.transport_stats) { | 225 for (const auto& transport_stats : session_stats.transport_stats) { |
226 for (const auto& channel : transport.second.channel_stats) { | 226 for (const auto& channel_stats : transport_stats.second.channel_stats) { |
227 for (const cricket::ConnectionInfo& info : channel.connection_infos) { | 227 for (const cricket::ConnectionInfo& info : |
228 // TODO(hbos): Produce |RTCIceCandidatePairStats| referencing the | 228 channel_stats.connection_infos) { |
229 // resulting |RTCIceCandidateStats| pair. crbug.com/633550 | 229 const std::string& id = "RTCIceCandidatePair_" + |
| 230 info.local_candidate.id() + "_" + info.remote_candidate.id(); |
| 231 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( |
| 232 new RTCIceCandidatePairStats(id, timestamp_us)); |
| 233 |
| 234 // TODO(hbos): Set all of the |RTCIceCandidatePairStats|'s members, |
| 235 // crbug.com/633550. |
| 236 |
| 237 // TODO(hbos): Set candidate_pair_stats->transport_id. Should be ID to |
| 238 // RTCTransportStats which does not exist yet: crbug.com/653873. |
| 239 |
230 // TODO(hbos): There could be other candidates that are not paired with | 240 // TODO(hbos): There could be other candidates that are not paired with |
231 // anything. We don't have a complete list. Local candidates come from | 241 // anything. We don't have a complete list. Local candidates come from |
232 // Port objects, and prflx candidates (both local and remote) are only | 242 // Port objects, and prflx candidates (both local and remote) are only |
233 // stored in candidate pairs. crbug.com/632723 | 243 // stored in candidate pairs. crbug.com/632723 |
234 ProduceIceCandidateStats_s( | 244 candidate_pair_stats->local_candidate_id = ProduceIceCandidateStats_s( |
235 timestamp_us, info.local_candidate, true, report); | 245 timestamp_us, info.local_candidate, true, report); |
236 ProduceIceCandidateStats_s( | 246 candidate_pair_stats->remote_candidate_id = ProduceIceCandidateStats_s( |
237 timestamp_us, info.remote_candidate, false, report); | 247 timestamp_us, info.remote_candidate, false, report); |
| 248 |
| 249 // TODO(hbos): Set candidate_pair_stats->state. |
| 250 // TODO(hbos): Set candidate_pair_stats->priority. |
| 251 // TODO(hbos): Set candidate_pair_stats->nominated. |
| 252 // TODO(hbos): This writable is different than the spec. It goes to |
| 253 // false after a certain amount of time without a response passes. |
| 254 // crbug.com/633550 |
| 255 candidate_pair_stats->writable = info.writable; |
| 256 // TODO(hbos): Set candidate_pair_stats->readable. |
| 257 candidate_pair_stats->bytes_sent = |
| 258 static_cast<uint64_t>(info.sent_total_bytes); |
| 259 candidate_pair_stats->bytes_received = |
| 260 static_cast<uint64_t>(info.recv_total_bytes); |
| 261 // TODO(hbos): Set candidate_pair_stats->total_rtt. |
| 262 // TODO(hbos): The |info.rtt| measurement is smoothed. It shouldn't be |
| 263 // smoothed according to the spec. crbug.com/633550. See |
| 264 // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-curr
entrtt |
| 265 candidate_pair_stats->current_rtt = |
| 266 static_cast<double>(info.rtt) / 1000.0; |
| 267 // TODO(hbos): Set candidate_pair_stats->available_outgoing_bitrate. |
| 268 // TODO(hbos): Set candidate_pair_stats->available_incoming_bitrate. |
| 269 // TODO(hbos): Set candidate_pair_stats->requests_received. |
| 270 candidate_pair_stats->requests_sent = |
| 271 static_cast<uint64_t>(info.sent_ping_requests_total); |
| 272 candidate_pair_stats->responses_received = |
| 273 static_cast<uint64_t>(info.recv_ping_responses); |
| 274 candidate_pair_stats->responses_sent = |
| 275 static_cast<uint64_t>(info.sent_ping_responses); |
| 276 // TODO(hbos): Set candidate_pair_stats->retransmissions_received. |
| 277 // TODO(hbos): Set candidate_pair_stats->retransmissions_sent. |
| 278 // TODO(hbos): Set candidate_pair_stats->consent_requests_received. |
| 279 // TODO(hbos): Set candidate_pair_stats->consent_requests_sent. |
| 280 // TODO(hbos): Set candidate_pair_stats->consent_responses_received. |
| 281 // TODO(hbos): Set candidate_pair_stats->consent_responses_sent. |
| 282 |
| 283 report->AddStats(std::move(candidate_pair_stats)); |
238 } | 284 } |
239 } | 285 } |
240 } | 286 } |
241 } | 287 } |
242 | 288 |
243 const std::string& RTCStatsCollector::ProduceIceCandidateStats_s( | 289 const std::string& RTCStatsCollector::ProduceIceCandidateStats_s( |
244 int64_t timestamp_us, const cricket::Candidate& candidate, bool is_local, | 290 int64_t timestamp_us, const cricket::Candidate& candidate, bool is_local, |
245 RTCStatsReport* report) const { | 291 RTCStatsReport* report) const { |
246 RTC_DCHECK(signaling_thread_->IsCurrent()); | 292 RTC_DCHECK(signaling_thread_->IsCurrent()); |
247 const std::string& id = "RTCIceCandidate_" + candidate.id(); | 293 const std::string& id = "RTCIceCandidate_" + candidate.id(); |
248 const RTCStats* stats = report->Get(id); | 294 const RTCStats* stats = report->Get(id); |
249 if (!stats) { | 295 if (!stats) { |
250 std::unique_ptr<RTCIceCandidateStats> candidate_stats; | 296 std::unique_ptr<RTCIceCandidateStats> candidate_stats; |
251 if (is_local) { | 297 if (is_local) |
252 candidate_stats.reset( | 298 candidate_stats.reset(new RTCLocalIceCandidateStats(id, timestamp_us)); |
253 new RTCLocalIceCandidateStats(id, timestamp_us)); | 299 else |
254 } else { | 300 candidate_stats.reset(new RTCRemoteIceCandidateStats(id, timestamp_us)); |
255 candidate_stats.reset( | |
256 new RTCRemoteIceCandidateStats(id, timestamp_us)); | |
257 } | |
258 candidate_stats->ip = candidate.address().ipaddr().ToString(); | 301 candidate_stats->ip = candidate.address().ipaddr().ToString(); |
259 candidate_stats->port = static_cast<int32_t>(candidate.address().port()); | 302 candidate_stats->port = static_cast<int32_t>(candidate.address().port()); |
260 candidate_stats->protocol = candidate.protocol(); | 303 candidate_stats->protocol = candidate.protocol(); |
261 candidate_stats->candidate_type = CandidateTypeToRTCIceCandidateType( | 304 candidate_stats->candidate_type = CandidateTypeToRTCIceCandidateType( |
262 candidate.type()); | 305 candidate.type()); |
263 candidate_stats->priority = static_cast<int32_t>(candidate.priority()); | 306 candidate_stats->priority = static_cast<int32_t>(candidate.priority()); |
264 // TODO(hbos): Define candidate_stats->url. crbug.com/632723 | 307 // TODO(hbos): Define candidate_stats->url. crbug.com/632723 |
265 | 308 |
266 stats = candidate_stats.get(); | 309 stats = candidate_stats.get(); |
267 report->AddStats(std::move(candidate_stats)); | 310 report->AddStats(std::move(candidate_stats)); |
(...skipping 20 matching lines...) Expand all Loading... |
288 // constant. | 331 // constant. |
289 std::unique_ptr<RTCPeerConnectionStats> stats( | 332 std::unique_ptr<RTCPeerConnectionStats> stats( |
290 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); | 333 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); |
291 stats->data_channels_opened = data_channels_opened; | 334 stats->data_channels_opened = data_channels_opened; |
292 stats->data_channels_closed = static_cast<uint32_t>(data_channels.size()) - | 335 stats->data_channels_closed = static_cast<uint32_t>(data_channels.size()) - |
293 data_channels_opened; | 336 data_channels_opened; |
294 report->AddStats(std::move(stats)); | 337 report->AddStats(std::move(stats)); |
295 } | 338 } |
296 | 339 |
297 } // namespace webrtc | 340 } // namespace webrtc |
OLD | NEW |