| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // "Now" using a system clock, relative to the UNIX epoch (Jan 1, 1970, | 409 // "Now" using a system clock, relative to the UNIX epoch (Jan 1, 1970, |
| 410 // UTC), in microseconds. The system clock could be modified and is not | 410 // UTC), in microseconds. The system clock could be modified and is not |
| 411 // necessarily monotonically increasing. | 411 // necessarily monotonically increasing. |
| 412 int64_t timestamp_us = rtc::TimeUTCMicros(); | 412 int64_t timestamp_us = rtc::TimeUTCMicros(); |
| 413 | 413 |
| 414 num_pending_partial_reports_ = 3; | 414 num_pending_partial_reports_ = 3; |
| 415 partial_report_timestamp_us_ = cache_now_us; | 415 partial_report_timestamp_us_ = cache_now_us; |
| 416 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, signaling_thread_, | 416 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, signaling_thread_, |
| 417 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnSignalingThread, | 417 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnSignalingThread, |
| 418 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); | 418 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); |
| 419 |
| 420 // TODO(hbos): No stats are gathered by |
| 421 // |ProducePartialResultsOnWorkerThread|, remove it. |
| 419 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, worker_thread_, | 422 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, worker_thread_, |
| 420 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnWorkerThread, | 423 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnWorkerThread, |
| 421 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); | 424 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); |
| 425 |
| 426 // Prepare |channel_names_| and |media_info_| for use in |
| 427 // |ProducePartialResultsOnNetworkThread|. |
| 428 channel_name_pairs_.reset(new ChannelNamePairs()); |
| 429 if (pc_->session()->voice_channel()) { |
| 430 channel_name_pairs_->voice = rtc::Optional<ChannelNamePair>( |
| 431 ChannelNamePair(pc_->session()->voice_channel()->content_name(), |
| 432 pc_->session()->voice_channel()->transport_name())); |
| 433 } |
| 434 if (pc_->session()->video_channel()) { |
| 435 channel_name_pairs_->video = rtc::Optional<ChannelNamePair>( |
| 436 ChannelNamePair(pc_->session()->video_channel()->content_name(), |
| 437 pc_->session()->video_channel()->transport_name())); |
| 438 } |
| 439 if (pc_->session()->data_channel()) { |
| 440 channel_name_pairs_->data = rtc::Optional<ChannelNamePair>( |
| 441 ChannelNamePair(pc_->session()->data_channel()->content_name(), |
| 442 pc_->session()->data_channel()->transport_name())); |
| 443 } |
| 444 media_info_.reset(PrepareMediaInfo_s().release()); |
| 422 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, network_thread_, | 445 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, network_thread_, |
| 423 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, | 446 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, |
| 424 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); | 447 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); |
| 425 } | 448 } |
| 426 } | 449 } |
| 427 | 450 |
| 428 void RTCStatsCollector::ClearCachedStatsReport() { | 451 void RTCStatsCollector::ClearCachedStatsReport() { |
| 429 RTC_DCHECK(signaling_thread_->IsCurrent()); | 452 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 430 cached_report_ = nullptr; | 453 cached_report_ = nullptr; |
| 431 } | 454 } |
| 432 | 455 |
| 433 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( | 456 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( |
| 434 int64_t timestamp_us) { | 457 int64_t timestamp_us) { |
| 435 RTC_DCHECK(signaling_thread_->IsCurrent()); | 458 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 436 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 459 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
| 437 timestamp_us); | 460 timestamp_us); |
| 438 | 461 |
| 439 SessionStats session_stats; | |
| 440 if (pc_->session()->GetTransportStats(&session_stats)) { | |
| 441 std::map<std::string, CertificateStatsPair> transport_cert_stats = | |
| 442 PrepareTransportCertificateStats(session_stats); | |
| 443 MediaInfo media_info = PrepareMediaInfo(session_stats); | |
| 444 | |
| 445 ProduceCertificateStats_s( | |
| 446 timestamp_us, transport_cert_stats, report.get()); | |
| 447 ProduceCodecStats_s( | |
| 448 timestamp_us, media_info, report.get()); | |
| 449 ProduceIceCandidateAndPairStats_s( | |
| 450 timestamp_us, session_stats, report.get()); | |
| 451 ProduceRTPStreamStats_s( | |
| 452 timestamp_us, session_stats, media_info, report.get()); | |
| 453 ProduceTransportStats_s( | |
| 454 timestamp_us, session_stats, transport_cert_stats, report.get()); | |
| 455 } | |
| 456 ProduceDataChannelStats_s(timestamp_us, report.get()); | 462 ProduceDataChannelStats_s(timestamp_us, report.get()); |
| 457 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); | 463 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); |
| 458 ProducePeerConnectionStats_s(timestamp_us, report.get()); | 464 ProducePeerConnectionStats_s(timestamp_us, report.get()); |
| 459 | 465 |
| 460 AddPartialResults(report); | 466 AddPartialResults(report); |
| 461 } | 467 } |
| 462 | 468 |
| 463 void RTCStatsCollector::ProducePartialResultsOnWorkerThread( | 469 void RTCStatsCollector::ProducePartialResultsOnWorkerThread( |
| 464 int64_t timestamp_us) { | 470 int64_t timestamp_us) { |
| 465 RTC_DCHECK(worker_thread_->IsCurrent()); | 471 RTC_DCHECK(worker_thread_->IsCurrent()); |
| 466 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 472 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
| 467 timestamp_us); | 473 timestamp_us); |
| 468 | 474 |
| 469 // TODO(hbos): Gather stats on worker thread. | 475 // TODO(hbos): There are no stats to be gathered on this thread, remove this |
| 470 // pc_->session()'s channels are owned by the signaling thread but there are | 476 // method. |
| 471 // some stats that are gathered on the worker thread. Instead of a synchronous | |
| 472 // invoke on "s->w" we could to the "w" work here asynchronously if it wasn't | |
| 473 // for the ownership issue. Synchronous invokes in other places makes it | |
| 474 // difficult to introduce locks without introducing deadlocks and the channels | |
| 475 // are not reference counted. | |
| 476 | 477 |
| 477 AddPartialResults(report); | 478 AddPartialResults(report); |
| 478 } | 479 } |
| 479 | 480 |
| 480 void RTCStatsCollector::ProducePartialResultsOnNetworkThread( | 481 void RTCStatsCollector::ProducePartialResultsOnNetworkThread( |
| 481 int64_t timestamp_us) { | 482 int64_t timestamp_us) { |
| 482 RTC_DCHECK(network_thread_->IsCurrent()); | 483 RTC_DCHECK(network_thread_->IsCurrent()); |
| 483 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 484 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
| 484 timestamp_us); | 485 timestamp_us); |
| 485 | 486 |
| 486 // TODO(hbos): Gather stats on network thread. | 487 std::unique_ptr<SessionStats> session_stats = |
| 487 // pc_->session()'s channels are owned by the signaling thread but there are | 488 pc_->session()->GetStats(*channel_name_pairs_); |
| 488 // some stats that are gathered on the network thread. Instead of a | 489 if (session_stats) { |
| 489 // synchronous invoke on "s->n" we could to the "n" work here asynchronously | 490 std::map<std::string, CertificateStatsPair> transport_cert_stats = |
| 490 // if it wasn't for the ownership issue. Synchronous invokes in other places | 491 PrepareTransportCertificateStats_n(*session_stats); |
| 491 // makes it difficult to introduce locks without introducing deadlocks and the | 492 |
| 492 // channels are not reference counted. | 493 ProduceCertificateStats_n( |
| 494 timestamp_us, transport_cert_stats, report.get()); |
| 495 ProduceCodecStats_n( |
| 496 timestamp_us, *media_info_, report.get()); |
| 497 ProduceIceCandidateAndPairStats_n( |
| 498 timestamp_us, *session_stats, report.get()); |
| 499 ProduceRTPStreamStats_n( |
| 500 timestamp_us, *session_stats, *media_info_, report.get()); |
| 501 ProduceTransportStats_n( |
| 502 timestamp_us, *session_stats, transport_cert_stats, report.get()); |
| 503 } |
| 493 | 504 |
| 494 AddPartialResults(report); | 505 AddPartialResults(report); |
| 495 } | 506 } |
| 496 | 507 |
| 497 void RTCStatsCollector::AddPartialResults( | 508 void RTCStatsCollector::AddPartialResults( |
| 498 const rtc::scoped_refptr<RTCStatsReport>& partial_report) { | 509 const rtc::scoped_refptr<RTCStatsReport>& partial_report) { |
| 499 if (!signaling_thread_->IsCurrent()) { | 510 if (!signaling_thread_->IsCurrent()) { |
| 500 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, signaling_thread_, | 511 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, signaling_thread_, |
| 501 rtc::Bind(&RTCStatsCollector::AddPartialResults_s, | 512 rtc::Bind(&RTCStatsCollector::AddPartialResults_s, |
| 502 rtc::scoped_refptr<RTCStatsCollector>(this), | 513 rtc::scoped_refptr<RTCStatsCollector>(this), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 527 RTC_DCHECK(signaling_thread_->IsCurrent()); | 538 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 528 RTC_DCHECK(!callbacks_.empty()); | 539 RTC_DCHECK(!callbacks_.empty()); |
| 529 RTC_DCHECK(cached_report_); | 540 RTC_DCHECK(cached_report_); |
| 530 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback : | 541 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback : |
| 531 callbacks_) { | 542 callbacks_) { |
| 532 callback->OnStatsDelivered(cached_report_); | 543 callback->OnStatsDelivered(cached_report_); |
| 533 } | 544 } |
| 534 callbacks_.clear(); | 545 callbacks_.clear(); |
| 535 } | 546 } |
| 536 | 547 |
| 537 void RTCStatsCollector::ProduceCertificateStats_s( | 548 void RTCStatsCollector::ProduceCertificateStats_n( |
| 538 int64_t timestamp_us, | 549 int64_t timestamp_us, |
| 539 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, | 550 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, |
| 540 RTCStatsReport* report) const { | 551 RTCStatsReport* report) const { |
| 541 RTC_DCHECK(signaling_thread_->IsCurrent()); | 552 RTC_DCHECK(network_thread_->IsCurrent()); |
| 542 for (const auto& transport_cert_stats_pair : transport_cert_stats) { | 553 for (const auto& transport_cert_stats_pair : transport_cert_stats) { |
| 543 if (transport_cert_stats_pair.second.local) { | 554 if (transport_cert_stats_pair.second.local) { |
| 544 ProduceCertificateStatsFromSSLCertificateStats( | 555 ProduceCertificateStatsFromSSLCertificateStats( |
| 545 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); | 556 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); |
| 546 } | 557 } |
| 547 if (transport_cert_stats_pair.second.remote) { | 558 if (transport_cert_stats_pair.second.remote) { |
| 548 ProduceCertificateStatsFromSSLCertificateStats( | 559 ProduceCertificateStatsFromSSLCertificateStats( |
| 549 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); | 560 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); |
| 550 } | 561 } |
| 551 } | 562 } |
| 552 } | 563 } |
| 553 | 564 |
| 554 void RTCStatsCollector::ProduceCodecStats_s( | 565 void RTCStatsCollector::ProduceCodecStats_n( |
| 555 int64_t timestamp_us, const MediaInfo& media_info, | 566 int64_t timestamp_us, const MediaInfo& media_info, |
| 556 RTCStatsReport* report) const { | 567 RTCStatsReport* report) const { |
| 557 RTC_DCHECK(signaling_thread_->IsCurrent()); | 568 RTC_DCHECK(network_thread_->IsCurrent()); |
| 558 // Audio | 569 // Audio |
| 559 if (media_info.voice) { | 570 if (media_info.voice) { |
| 560 // Inbound | 571 // Inbound |
| 561 for (const auto& pair : media_info.voice->receive_codecs) { | 572 for (const auto& pair : media_info.voice->receive_codecs) { |
| 562 report->AddStats(CodecStatsFromRtpCodecParameters( | 573 report->AddStats(CodecStatsFromRtpCodecParameters( |
| 563 timestamp_us, true, true, pair.second)); | 574 timestamp_us, true, true, pair.second)); |
| 564 } | 575 } |
| 565 // Outbound | 576 // Outbound |
| 566 for (const auto& pair : media_info.voice->send_codecs) { | 577 for (const auto& pair : media_info.voice->send_codecs) { |
| 567 report->AddStats(CodecStatsFromRtpCodecParameters( | 578 report->AddStats(CodecStatsFromRtpCodecParameters( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 598 data_channel_stats->state = | 609 data_channel_stats->state = |
| 599 DataStateToRTCDataChannelState(data_channel->state()); | 610 DataStateToRTCDataChannelState(data_channel->state()); |
| 600 data_channel_stats->messages_sent = data_channel->messages_sent(); | 611 data_channel_stats->messages_sent = data_channel->messages_sent(); |
| 601 data_channel_stats->bytes_sent = data_channel->bytes_sent(); | 612 data_channel_stats->bytes_sent = data_channel->bytes_sent(); |
| 602 data_channel_stats->messages_received = data_channel->messages_received(); | 613 data_channel_stats->messages_received = data_channel->messages_received(); |
| 603 data_channel_stats->bytes_received = data_channel->bytes_received(); | 614 data_channel_stats->bytes_received = data_channel->bytes_received(); |
| 604 report->AddStats(std::move(data_channel_stats)); | 615 report->AddStats(std::move(data_channel_stats)); |
| 605 } | 616 } |
| 606 } | 617 } |
| 607 | 618 |
| 608 void RTCStatsCollector::ProduceIceCandidateAndPairStats_s( | 619 void RTCStatsCollector::ProduceIceCandidateAndPairStats_n( |
| 609 int64_t timestamp_us, const SessionStats& session_stats, | 620 int64_t timestamp_us, const SessionStats& session_stats, |
| 610 RTCStatsReport* report) const { | 621 RTCStatsReport* report) const { |
| 611 RTC_DCHECK(signaling_thread_->IsCurrent()); | 622 RTC_DCHECK(network_thread_->IsCurrent()); |
| 612 for (const auto& transport_stats : session_stats.transport_stats) { | 623 for (const auto& transport_stats : session_stats.transport_stats) { |
| 613 for (const auto& channel_stats : transport_stats.second.channel_stats) { | 624 for (const auto& channel_stats : transport_stats.second.channel_stats) { |
| 614 std::string transport_id = RTCTransportStatsIDFromTransportChannel( | 625 std::string transport_id = RTCTransportStatsIDFromTransportChannel( |
| 615 transport_stats.second.transport_name, channel_stats.component); | 626 transport_stats.second.transport_name, channel_stats.component); |
| 616 for (const cricket::ConnectionInfo& info : | 627 for (const cricket::ConnectionInfo& info : |
| 617 channel_stats.connection_infos) { | 628 channel_stats.connection_infos) { |
| 618 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( | 629 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( |
| 619 new RTCIceCandidatePairStats( | 630 new RTCIceCandidatePairStats( |
| 620 RTCIceCandidatePairStatsIDFromConnectionInfo(info), | 631 RTCIceCandidatePairStatsIDFromConnectionInfo(info), |
| 621 timestamp_us)); | 632 timestamp_us)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 void RTCStatsCollector::ProducePeerConnectionStats_s( | 685 void RTCStatsCollector::ProducePeerConnectionStats_s( |
| 675 int64_t timestamp_us, RTCStatsReport* report) const { | 686 int64_t timestamp_us, RTCStatsReport* report) const { |
| 676 RTC_DCHECK(signaling_thread_->IsCurrent()); | 687 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 677 std::unique_ptr<RTCPeerConnectionStats> stats( | 688 std::unique_ptr<RTCPeerConnectionStats> stats( |
| 678 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); | 689 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); |
| 679 stats->data_channels_opened = internal_record_.data_channels_opened; | 690 stats->data_channels_opened = internal_record_.data_channels_opened; |
| 680 stats->data_channels_closed = internal_record_.data_channels_closed; | 691 stats->data_channels_closed = internal_record_.data_channels_closed; |
| 681 report->AddStats(std::move(stats)); | 692 report->AddStats(std::move(stats)); |
| 682 } | 693 } |
| 683 | 694 |
| 684 void RTCStatsCollector::ProduceRTPStreamStats_s( | 695 void RTCStatsCollector::ProduceRTPStreamStats_n( |
| 685 int64_t timestamp_us, const SessionStats& session_stats, | 696 int64_t timestamp_us, const SessionStats& session_stats, |
| 686 const MediaInfo& media_info, RTCStatsReport* report) const { | 697 const MediaInfo& media_info, RTCStatsReport* report) const { |
| 687 RTC_DCHECK(signaling_thread_->IsCurrent()); | 698 RTC_DCHECK(network_thread_->IsCurrent()); |
| 688 | 699 |
| 689 // Audio | 700 // Audio |
| 690 if (media_info.voice) { | 701 if (media_info.voice) { |
| 691 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 702 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
| 692 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); | 703 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); |
| 693 RTC_DCHECK(!transport_id.empty()); | 704 RTC_DCHECK(!transport_id.empty()); |
| 694 // Inbound | 705 // Inbound |
| 695 for (const cricket::VoiceReceiverInfo& voice_receiver_info : | 706 for (const cricket::VoiceReceiverInfo& voice_receiver_info : |
| 696 media_info.voice->receivers) { | 707 media_info.voice->receivers) { |
| 697 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 708 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 if (video_sender_info.codec_payload_type) { | 792 if (video_sender_info.codec_payload_type) { |
| 782 outbound_video->codec_id = | 793 outbound_video->codec_id = |
| 783 RTCCodecStatsIDFromDirectionMediaAndPayload( | 794 RTCCodecStatsIDFromDirectionMediaAndPayload( |
| 784 false, false, *video_sender_info.codec_payload_type); | 795 false, false, *video_sender_info.codec_payload_type); |
| 785 } | 796 } |
| 786 report->AddStats(std::move(outbound_video)); | 797 report->AddStats(std::move(outbound_video)); |
| 787 } | 798 } |
| 788 } | 799 } |
| 789 } | 800 } |
| 790 | 801 |
| 791 void RTCStatsCollector::ProduceTransportStats_s( | 802 void RTCStatsCollector::ProduceTransportStats_n( |
| 792 int64_t timestamp_us, const SessionStats& session_stats, | 803 int64_t timestamp_us, const SessionStats& session_stats, |
| 793 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, | 804 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, |
| 794 RTCStatsReport* report) const { | 805 RTCStatsReport* report) const { |
| 795 RTC_DCHECK(signaling_thread_->IsCurrent()); | 806 RTC_DCHECK(network_thread_->IsCurrent()); |
| 796 for (const auto& transport : session_stats.transport_stats) { | 807 for (const auto& transport : session_stats.transport_stats) { |
| 797 // Get reference to RTCP channel, if it exists. | 808 // Get reference to RTCP channel, if it exists. |
| 798 std::string rtcp_transport_stats_id; | 809 std::string rtcp_transport_stats_id; |
| 799 for (const auto& channel_stats : transport.second.channel_stats) { | 810 for (const auto& channel_stats : transport.second.channel_stats) { |
| 800 if (channel_stats.component == | 811 if (channel_stats.component == |
| 801 cricket::ICE_CANDIDATE_COMPONENT_RTCP) { | 812 cricket::ICE_CANDIDATE_COMPONENT_RTCP) { |
| 802 rtcp_transport_stats_id = RTCTransportStatsIDFromTransportChannel( | 813 rtcp_transport_stats_id = RTCTransportStatsIDFromTransportChannel( |
| 803 transport.second.transport_name, channel_stats.component); | 814 transport.second.transport_name, channel_stats.component); |
| 804 break; | 815 break; |
| 805 } | 816 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 if (!local_certificate_id.empty()) | 859 if (!local_certificate_id.empty()) |
| 849 transport_stats->local_certificate_id = local_certificate_id; | 860 transport_stats->local_certificate_id = local_certificate_id; |
| 850 if (!remote_certificate_id.empty()) | 861 if (!remote_certificate_id.empty()) |
| 851 transport_stats->remote_certificate_id = remote_certificate_id; | 862 transport_stats->remote_certificate_id = remote_certificate_id; |
| 852 report->AddStats(std::move(transport_stats)); | 863 report->AddStats(std::move(transport_stats)); |
| 853 } | 864 } |
| 854 } | 865 } |
| 855 } | 866 } |
| 856 | 867 |
| 857 std::map<std::string, RTCStatsCollector::CertificateStatsPair> | 868 std::map<std::string, RTCStatsCollector::CertificateStatsPair> |
| 858 RTCStatsCollector::PrepareTransportCertificateStats( | 869 RTCStatsCollector::PrepareTransportCertificateStats_n( |
| 859 const SessionStats& session_stats) const { | 870 const SessionStats& session_stats) const { |
| 860 RTC_DCHECK(signaling_thread_->IsCurrent()); | 871 RTC_DCHECK(network_thread_->IsCurrent()); |
| 861 std::map<std::string, CertificateStatsPair> transport_cert_stats; | 872 std::map<std::string, CertificateStatsPair> transport_cert_stats; |
| 862 for (const auto& transport_stats : session_stats.transport_stats) { | 873 for (const auto& transport_stats : session_stats.transport_stats) { |
| 863 CertificateStatsPair certificate_stats_pair; | 874 CertificateStatsPair certificate_stats_pair; |
| 864 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; | 875 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; |
| 865 if (pc_->session()->GetLocalCertificate( | 876 if (pc_->session()->GetLocalCertificate( |
| 866 transport_stats.second.transport_name, &local_certificate)) { | 877 transport_stats.second.transport_name, &local_certificate)) { |
| 867 certificate_stats_pair.local = | 878 certificate_stats_pair.local = |
| 868 local_certificate->ssl_certificate().GetStats(); | 879 local_certificate->ssl_certificate().GetStats(); |
| 869 } | 880 } |
| 870 std::unique_ptr<rtc::SSLCertificate> remote_certificate = | 881 std::unique_ptr<rtc::SSLCertificate> remote_certificate = |
| 871 pc_->session()->GetRemoteSSLCertificate( | 882 pc_->session()->GetRemoteSSLCertificate( |
| 872 transport_stats.second.transport_name); | 883 transport_stats.second.transport_name); |
| 873 if (remote_certificate) { | 884 if (remote_certificate) { |
| 874 certificate_stats_pair.remote = remote_certificate->GetStats(); | 885 certificate_stats_pair.remote = remote_certificate->GetStats(); |
| 875 } | 886 } |
| 876 transport_cert_stats.insert( | 887 transport_cert_stats.insert( |
| 877 std::make_pair(transport_stats.second.transport_name, | 888 std::make_pair(transport_stats.second.transport_name, |
| 878 std::move(certificate_stats_pair))); | 889 std::move(certificate_stats_pair))); |
| 879 } | 890 } |
| 880 return transport_cert_stats; | 891 return transport_cert_stats; |
| 881 } | 892 } |
| 882 | 893 |
| 883 RTCStatsCollector::MediaInfo RTCStatsCollector::PrepareMediaInfo( | 894 std::unique_ptr<RTCStatsCollector::MediaInfo> |
| 884 const SessionStats& session_stats) const { | 895 RTCStatsCollector::PrepareMediaInfo_s() const { |
| 885 MediaInfo media_info; | 896 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 897 std::unique_ptr<MediaInfo> media_info(new MediaInfo()); |
| 886 if (pc_->session()->voice_channel()) { | 898 if (pc_->session()->voice_channel()) { |
| 887 cricket::VoiceMediaInfo voice_media_info; | 899 cricket::VoiceMediaInfo voice_media_info; |
| 888 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { | 900 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { |
| 889 media_info.voice = rtc::Optional<cricket::VoiceMediaInfo>( | 901 media_info->voice = rtc::Optional<cricket::VoiceMediaInfo>( |
| 890 std::move(voice_media_info)); | 902 std::move(voice_media_info)); |
| 891 } | 903 } |
| 892 } | 904 } |
| 893 if (pc_->session()->video_channel()) { | 905 if (pc_->session()->video_channel()) { |
| 894 cricket::VideoMediaInfo video_media_info; | 906 cricket::VideoMediaInfo video_media_info; |
| 895 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { | 907 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { |
| 896 media_info.video = rtc::Optional<cricket::VideoMediaInfo>( | 908 media_info->video = rtc::Optional<cricket::VideoMediaInfo>( |
| 897 std::move(video_media_info)); | 909 std::move(video_media_info)); |
| 898 } | 910 } |
| 899 } | 911 } |
| 900 return media_info; | 912 return media_info; |
| 901 } | 913 } |
| 902 | 914 |
| 903 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { | 915 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { |
| 904 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); | 916 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); |
| 905 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); | 917 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); |
| 906 } | 918 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 928 const std::string& type) { | 940 const std::string& type) { |
| 929 return CandidateTypeToRTCIceCandidateType(type); | 941 return CandidateTypeToRTCIceCandidateType(type); |
| 930 } | 942 } |
| 931 | 943 |
| 932 const char* DataStateToRTCDataChannelStateForTesting( | 944 const char* DataStateToRTCDataChannelStateForTesting( |
| 933 DataChannelInterface::DataState state) { | 945 DataChannelInterface::DataState state) { |
| 934 return DataStateToRTCDataChannelState(state); | 946 return DataStateToRTCDataChannelState(state); |
| 935 } | 947 } |
| 936 | 948 |
| 937 } // namespace webrtc | 949 } // namespace webrtc |
| OLD | NEW |