Chromium Code Reviews| 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 int connection_id = 0; |
| 228 // TODO(hbos): Produce |RTCIceCandidatePairStats| referencing the | 228 for (const cricket::ConnectionInfo& info : |
| 229 // resulting |RTCIceCandidateStats| pair. crbug.com/633550 | 229 channel_stats.connection_infos) { |
| 230 // TODO(hbos): The ID should be based on the object used to produce it. | |
| 231 // If another connection is removed, that should not affect this ID. As | |
| 232 // is, removing a connection info decrements the |connection_id| of all | |
| 233 // subsequent connections. crbug.com/633550 | |
|
Taylor Brandstetter
2016/10/10 21:45:37
A pair can be uniquely identified by the candidate
hbos
2016/10/10 22:39:56
Good thinkin'! Done.
| |
| 234 const std::string& id = "RTCTransportChannel_" + | |
| 235 transport_stats.second.transport_name + "_" + | |
| 236 rtc::ToString<>(channel_stats.component) + "_Connection_" + | |
| 237 rtc::ToString<>(connection_id); | |
| 238 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( | |
| 239 new RTCIceCandidatePairStats(id, timestamp_us)); | |
| 240 | |
| 241 // TODO(hbos): Set all of the |RTCIceCandidatePairStats|'s members, | |
| 242 // crbug.com/633550. | |
| 243 | |
| 244 // TODO(hbos): Set candidate_pair_stats->transport_id. Should be ID to | |
| 245 // RTCTransportStats which does not exist yet: crbug.com/653873. | |
| 246 | |
| 230 // TODO(hbos): There could be other candidates that are not paired with | 247 // 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 | 248 // anything. We don't have a complete list. Local candidates come from |
| 232 // Port objects, and prflx candidates (both local and remote) are only | 249 // Port objects, and prflx candidates (both local and remote) are only |
| 233 // stored in candidate pairs. crbug.com/632723 | 250 // stored in candidate pairs. crbug.com/632723 |
| 234 ProduceIceCandidateStats_s( | 251 candidate_pair_stats->local_candidate_id = ProduceIceCandidateStats_s( |
| 235 timestamp_us, info.local_candidate, true, report); | 252 timestamp_us, info.local_candidate, true, report); |
| 236 ProduceIceCandidateStats_s( | 253 candidate_pair_stats->remote_candidate_id = ProduceIceCandidateStats_s( |
| 237 timestamp_us, info.remote_candidate, false, report); | 254 timestamp_us, info.remote_candidate, false, report); |
| 255 | |
| 256 // TODO(hbos): Set candidate_pair_stats->state. | |
| 257 // TODO(hbos): Set candidate_pair_stats->priority. | |
| 258 // TODO(hbos): Set candidate_pair_stats->nominated. | |
| 259 candidate_pair_stats->writable = info.writable; | |
|
Taylor Brandstetter
2016/10/10 21:45:38
Our "writable" doesn't currently match the definit
hbos
2016/10/10 22:39:56
Acknowledged. Wrote a TODO comment.
| |
| 260 // TODO(hbos): Set candidate_pair_stats->readable. | |
| 261 candidate_pair_stats->bytes_sent = | |
| 262 static_cast<uint64_t>(info.sent_total_bytes); | |
| 263 candidate_pair_stats->bytes_received = | |
| 264 static_cast<uint64_t>(info.recv_total_bytes); | |
| 265 // TODO(hbos): Set candidate_pair_stats->total_rtt. | |
| 266 candidate_pair_stats->current_rtt = | |
| 267 static_cast<double>(info.rtt) / 1000.0; | |
|
Taylor Brandstetter
2016/10/10 21:45:37
I'm pretty sure "current_rtt" means the very last
hbos
2016/10/10 22:39:56
Ack. Wrote a comment.
| |
| 268 // TODO(hbos): Set candidate_pair_stats->available_outgoing_bitrate. | |
| 269 // TODO(hbos): Set candidate_pair_stats->available_incoming_bitrate. | |
| 270 // TODO(hbos): Set candidate_pair_stats->requests_received. | |
| 271 // TODO(hbos): Set candidate_pair_stats->requests_sent. | |
| 272 // TODO(hbos): Set candidate_pair_stats->responses_received. | |
| 273 // TODO(hbos): Set candidate_pair_stats->responses_sent. | |
| 274 // TODO(hbos): Set candidate_pair_stats->retransmissions_received. | |
| 275 // TODO(hbos): Set candidate_pair_stats->retransmissions_sent. | |
| 276 // TODO(hbos): Set candidate_pair_stats->consent_requests_received. | |
| 277 // TODO(hbos): Set candidate_pair_stats->consent_requests_sent. | |
| 278 // TODO(hbos): Set candidate_pair_stats->consent_responses_received. | |
| 279 // TODO(hbos): Set candidate_pair_stats->consent_responses_sent. | |
| 280 | |
| 281 report->AddStats(std::move(candidate_pair_stats)); | |
| 282 | |
| 283 ++connection_id; | |
| 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 |