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 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 | |
| 264 candidate_pair_stats->current_rtt = | |
| 265 static_cast<double>(info.rtt) / 1000.0; | |
| 266 // TODO(hbos): Set candidate_pair_stats->available_outgoing_bitrate. | |
| 267 // TODO(hbos): Set candidate_pair_stats->available_incoming_bitrate. | |
| 268 candidate_pair_stats->requests_received = | |
| 269 static_cast<uint64_t>(info.recv_ping_responses); | |
|
Taylor Brandstetter
2016/10/11 17:26:50
"requests received" = "responses received"?
hbos
2016/10/11 18:26:45
Oops, brainfart. Done.
| |
| 270 // TODO(hbos): Set candidate_pair_stats->requests_sent. | |
| 271 // TODO(hbos): Set candidate_pair_stats->responses_received. | |
| 272 // TODO(hbos): Set candidate_pair_stats->responses_sent. | |
| 273 // TODO(hbos): Set candidate_pair_stats->retransmissions_received. | |
| 274 // TODO(hbos): Set candidate_pair_stats->retransmissions_sent. | |
| 275 // TODO(hbos): Set candidate_pair_stats->consent_requests_received. | |
| 276 // TODO(hbos): Set candidate_pair_stats->consent_requests_sent. | |
| 277 // TODO(hbos): Set candidate_pair_stats->consent_responses_received. | |
| 278 // TODO(hbos): Set candidate_pair_stats->consent_responses_sent. | |
| 279 | |
| 280 report->AddStats(std::move(candidate_pair_stats)); | |
| 238 } | 281 } |
| 239 } | 282 } |
| 240 } | 283 } |
| 241 } | 284 } |
| 242 | 285 |
| 243 const std::string& RTCStatsCollector::ProduceIceCandidateStats_s( | 286 const std::string& RTCStatsCollector::ProduceIceCandidateStats_s( |
| 244 int64_t timestamp_us, const cricket::Candidate& candidate, bool is_local, | 287 int64_t timestamp_us, const cricket::Candidate& candidate, bool is_local, |
| 245 RTCStatsReport* report) const { | 288 RTCStatsReport* report) const { |
| 246 RTC_DCHECK(signaling_thread_->IsCurrent()); | 289 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 247 const std::string& id = "RTCIceCandidate_" + candidate.id(); | 290 const std::string& id = "RTCIceCandidate_" + candidate.id(); |
| 248 const RTCStats* stats = report->Get(id); | 291 const RTCStats* stats = report->Get(id); |
| 249 if (!stats) { | 292 if (!stats) { |
| 250 std::unique_ptr<RTCIceCandidateStats> candidate_stats; | 293 std::unique_ptr<RTCIceCandidateStats> candidate_stats; |
| 251 if (is_local) { | 294 if (is_local) |
| 252 candidate_stats.reset( | 295 candidate_stats.reset(new RTCLocalIceCandidateStats(id, timestamp_us)); |
| 253 new RTCLocalIceCandidateStats(id, timestamp_us)); | 296 else |
| 254 } else { | 297 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(); | 298 candidate_stats->ip = candidate.address().ipaddr().ToString(); |
| 259 candidate_stats->port = static_cast<int32_t>(candidate.address().port()); | 299 candidate_stats->port = static_cast<int32_t>(candidate.address().port()); |
| 260 candidate_stats->protocol = candidate.protocol(); | 300 candidate_stats->protocol = candidate.protocol(); |
| 261 candidate_stats->candidate_type = CandidateTypeToRTCIceCandidateType( | 301 candidate_stats->candidate_type = CandidateTypeToRTCIceCandidateType( |
| 262 candidate.type()); | 302 candidate.type()); |
| 263 candidate_stats->priority = static_cast<int32_t>(candidate.priority()); | 303 candidate_stats->priority = static_cast<int32_t>(candidate.priority()); |
| 264 // TODO(hbos): Define candidate_stats->url. crbug.com/632723 | 304 // TODO(hbos): Define candidate_stats->url. crbug.com/632723 |
| 265 | 305 |
| 266 stats = candidate_stats.get(); | 306 stats = candidate_stats.get(); |
| 267 report->AddStats(std::move(candidate_stats)); | 307 report->AddStats(std::move(candidate_stats)); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 288 // constant. | 328 // constant. |
| 289 std::unique_ptr<RTCPeerConnectionStats> stats( | 329 std::unique_ptr<RTCPeerConnectionStats> stats( |
| 290 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); | 330 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); |
| 291 stats->data_channels_opened = data_channels_opened; | 331 stats->data_channels_opened = data_channels_opened; |
| 292 stats->data_channels_closed = static_cast<uint32_t>(data_channels.size()) - | 332 stats->data_channels_closed = static_cast<uint32_t>(data_channels.size()) - |
| 293 data_channels_opened; | 333 data_channels_opened; |
| 294 report->AddStats(std::move(stats)); | 334 report->AddStats(std::move(stats)); |
| 295 } | 335 } |
| 296 | 336 |
| 297 } // namespace webrtc | 337 } // namespace webrtc |
| OLD | NEW |