| 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 RTC_DCHECK(signaling_thread_->IsCurrent()); | 284 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 285 for (const auto& transport_stats : session_stats.transport_stats) { | 285 for (const auto& transport_stats : session_stats.transport_stats) { |
| 286 for (const auto& channel_stats : transport_stats.second.channel_stats) { | 286 for (const auto& channel_stats : transport_stats.second.channel_stats) { |
| 287 for (const cricket::ConnectionInfo& info : | 287 for (const cricket::ConnectionInfo& info : |
| 288 channel_stats.connection_infos) { | 288 channel_stats.connection_infos) { |
| 289 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( | 289 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( |
| 290 new RTCIceCandidatePairStats( | 290 new RTCIceCandidatePairStats( |
| 291 RTCIceCandidatePairStatsIDFromConnectionInfo(info), | 291 RTCIceCandidatePairStatsIDFromConnectionInfo(info), |
| 292 timestamp_us)); | 292 timestamp_us)); |
| 293 | 293 |
| 294 // TODO(hbos): Set all of the |RTCIceCandidatePairStats|'s members, | |
| 295 // crbug.com/633550. | |
| 296 | |
| 297 // TODO(hbos): Set candidate_pair_stats->transport_id. Should be ID to | |
| 298 // RTCTransportStats which does not exist yet: crbug.com/653873. | |
| 299 | |
| 300 // TODO(hbos): There could be other candidates that are not paired with | 294 // TODO(hbos): There could be other candidates that are not paired with |
| 301 // anything. We don't have a complete list. Local candidates come from | 295 // anything. We don't have a complete list. Local candidates come from |
| 302 // Port objects, and prflx candidates (both local and remote) are only | 296 // Port objects, and prflx candidates (both local and remote) are only |
| 303 // stored in candidate pairs. crbug.com/632723 | 297 // stored in candidate pairs. crbug.com/632723 |
| 304 candidate_pair_stats->local_candidate_id = ProduceIceCandidateStats_s( | 298 candidate_pair_stats->local_candidate_id = ProduceIceCandidateStats_s( |
| 305 timestamp_us, info.local_candidate, true, report); | 299 timestamp_us, info.local_candidate, true, report); |
| 306 candidate_pair_stats->remote_candidate_id = ProduceIceCandidateStats_s( | 300 candidate_pair_stats->remote_candidate_id = ProduceIceCandidateStats_s( |
| 307 timestamp_us, info.remote_candidate, false, report); | 301 timestamp_us, info.remote_candidate, false, report); |
| 308 | 302 |
| 309 // TODO(hbos): Set candidate_pair_stats->state. | |
| 310 // TODO(hbos): Set candidate_pair_stats->priority. | |
| 311 // TODO(hbos): Set candidate_pair_stats->nominated. | |
| 312 // TODO(hbos): This writable is different than the spec. It goes to | 303 // TODO(hbos): This writable is different than the spec. It goes to |
| 313 // false after a certain amount of time without a response passes. | 304 // false after a certain amount of time without a response passes. |
| 314 // crbug.com/633550 | 305 // crbug.com/633550 |
| 315 candidate_pair_stats->writable = info.writable; | 306 candidate_pair_stats->writable = info.writable; |
| 316 // TODO(hbos): Set candidate_pair_stats->readable. | |
| 317 candidate_pair_stats->bytes_sent = | 307 candidate_pair_stats->bytes_sent = |
| 318 static_cast<uint64_t>(info.sent_total_bytes); | 308 static_cast<uint64_t>(info.sent_total_bytes); |
| 319 candidate_pair_stats->bytes_received = | 309 candidate_pair_stats->bytes_received = |
| 320 static_cast<uint64_t>(info.recv_total_bytes); | 310 static_cast<uint64_t>(info.recv_total_bytes); |
| 321 // TODO(hbos): Set candidate_pair_stats->total_rtt. | |
| 322 // TODO(hbos): The |info.rtt| measurement is smoothed. It shouldn't be | 311 // TODO(hbos): The |info.rtt| measurement is smoothed. It shouldn't be |
| 323 // smoothed according to the spec. crbug.com/633550. See | 312 // smoothed according to the spec. crbug.com/633550. See |
| 324 // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-curr
entrtt | 313 // https://w3c.github.io/webrtc-stats/#dom-rtcicecandidatepairstats-curr
entrtt |
| 325 candidate_pair_stats->current_rtt = | 314 candidate_pair_stats->current_rtt = |
| 326 static_cast<double>(info.rtt) / 1000.0; | 315 static_cast<double>(info.rtt) / 1000.0; |
| 327 // TODO(hbos): Set candidate_pair_stats->available_outgoing_bitrate. | |
| 328 // TODO(hbos): Set candidate_pair_stats->available_incoming_bitrate. | |
| 329 // TODO(hbos): Set candidate_pair_stats->requests_received. | |
| 330 candidate_pair_stats->requests_sent = | 316 candidate_pair_stats->requests_sent = |
| 331 static_cast<uint64_t>(info.sent_ping_requests_total); | 317 static_cast<uint64_t>(info.sent_ping_requests_total); |
| 332 candidate_pair_stats->responses_received = | 318 candidate_pair_stats->responses_received = |
| 333 static_cast<uint64_t>(info.recv_ping_responses); | 319 static_cast<uint64_t>(info.recv_ping_responses); |
| 334 candidate_pair_stats->responses_sent = | 320 candidate_pair_stats->responses_sent = |
| 335 static_cast<uint64_t>(info.sent_ping_responses); | 321 static_cast<uint64_t>(info.sent_ping_responses); |
| 336 // TODO(hbos): Set candidate_pair_stats->retransmissions_received. | |
| 337 // TODO(hbos): Set candidate_pair_stats->retransmissions_sent. | |
| 338 // TODO(hbos): Set candidate_pair_stats->consent_requests_received. | |
| 339 // TODO(hbos): Set candidate_pair_stats->consent_requests_sent. | |
| 340 // TODO(hbos): Set candidate_pair_stats->consent_responses_received. | |
| 341 // TODO(hbos): Set candidate_pair_stats->consent_responses_sent. | |
| 342 | 322 |
| 343 report->AddStats(std::move(candidate_pair_stats)); | 323 report->AddStats(std::move(candidate_pair_stats)); |
| 344 } | 324 } |
| 345 } | 325 } |
| 346 } | 326 } |
| 347 } | 327 } |
| 348 | 328 |
| 349 const std::string& RTCStatsCollector::ProduceIceCandidateStats_s( | 329 const std::string& RTCStatsCollector::ProduceIceCandidateStats_s( |
| 350 int64_t timestamp_us, const cricket::Candidate& candidate, bool is_local, | 330 int64_t timestamp_us, const cricket::Candidate& candidate, bool is_local, |
| 351 RTCStatsReport* report) const { | 331 RTCStatsReport* report) const { |
| 352 RTC_DCHECK(signaling_thread_->IsCurrent()); | 332 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 353 const std::string& id = "RTCIceCandidate_" + candidate.id(); | 333 const std::string& id = "RTCIceCandidate_" + candidate.id(); |
| 354 const RTCStats* stats = report->Get(id); | 334 const RTCStats* stats = report->Get(id); |
| 355 if (!stats) { | 335 if (!stats) { |
| 356 std::unique_ptr<RTCIceCandidateStats> candidate_stats; | 336 std::unique_ptr<RTCIceCandidateStats> candidate_stats; |
| 357 if (is_local) | 337 if (is_local) |
| 358 candidate_stats.reset(new RTCLocalIceCandidateStats(id, timestamp_us)); | 338 candidate_stats.reset(new RTCLocalIceCandidateStats(id, timestamp_us)); |
| 359 else | 339 else |
| 360 candidate_stats.reset(new RTCRemoteIceCandidateStats(id, timestamp_us)); | 340 candidate_stats.reset(new RTCRemoteIceCandidateStats(id, timestamp_us)); |
| 361 candidate_stats->ip = candidate.address().ipaddr().ToString(); | 341 candidate_stats->ip = candidate.address().ipaddr().ToString(); |
| 362 candidate_stats->port = static_cast<int32_t>(candidate.address().port()); | 342 candidate_stats->port = static_cast<int32_t>(candidate.address().port()); |
| 363 candidate_stats->protocol = candidate.protocol(); | 343 candidate_stats->protocol = candidate.protocol(); |
| 364 candidate_stats->candidate_type = CandidateTypeToRTCIceCandidateType( | 344 candidate_stats->candidate_type = CandidateTypeToRTCIceCandidateType( |
| 365 candidate.type()); | 345 candidate.type()); |
| 366 candidate_stats->priority = static_cast<int32_t>(candidate.priority()); | 346 candidate_stats->priority = static_cast<int32_t>(candidate.priority()); |
| 367 // TODO(hbos): Define candidate_stats->url. crbug.com/632723 | |
| 368 | 347 |
| 369 stats = candidate_stats.get(); | 348 stats = candidate_stats.get(); |
| 370 report->AddStats(std::move(candidate_stats)); | 349 report->AddStats(std::move(candidate_stats)); |
| 371 } | 350 } |
| 372 RTC_DCHECK_EQ(stats->type(), is_local ? RTCLocalIceCandidateStats::kType | 351 RTC_DCHECK_EQ(stats->type(), is_local ? RTCLocalIceCandidateStats::kType |
| 373 : RTCRemoteIceCandidateStats::kType); | 352 : RTCRemoteIceCandidateStats::kType); |
| 374 return stats->id(); | 353 return stats->id(); |
| 375 } | 354 } |
| 376 | 355 |
| 377 void RTCStatsCollector::ProducePeerConnectionStats_s( | 356 void RTCStatsCollector::ProducePeerConnectionStats_s( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 const std::string& type) { | 472 const std::string& type) { |
| 494 return CandidateTypeToRTCIceCandidateType(type); | 473 return CandidateTypeToRTCIceCandidateType(type); |
| 495 } | 474 } |
| 496 | 475 |
| 497 const char* DataStateToRTCDataChannelStateForTesting( | 476 const char* DataStateToRTCDataChannelStateForTesting( |
| 498 DataChannelInterface::DataState state) { | 477 DataChannelInterface::DataState state) { |
| 499 return DataStateToRTCDataChannelState(state); | 478 return DataStateToRTCDataChannelState(state); |
| 500 } | 479 } |
| 501 | 480 |
| 502 } // namespace webrtc | 481 } // namespace webrtc |
| OLD | NEW |