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