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 on the worker thread, remove this. | |
413 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, worker_thread_, | 415 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, worker_thread_, |
414 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnWorkerThread, | 416 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnWorkerThread, |
415 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); | 417 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); |
418 | |
419 // Prepare |channel_names_| and |media_info_| for use in | |
420 // |ProducePartialResultsOnNetworkThread|. | |
421 channel_name_pairs_.reset(pc_->session()->GetChannelNamePairs().release()); | |
Taylor Brandstetter
2016/12/13 19:47:07
I don't think a new method (GetChannelNamePairs) i
pthatcher1
2016/12/13 23:50:18
I was thinking the exact same thing.
hbos
2016/12/14 14:56:31
I replaced GetTransportStats with GetSessionStats
| |
422 media_info_.reset(PrepareMediaInfo_s().release()); | |
416 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, network_thread_, | 423 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, network_thread_, |
417 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, | 424 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, |
418 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); | 425 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); |
419 } | 426 } |
420 } | 427 } |
421 | 428 |
422 void RTCStatsCollector::ClearCachedStatsReport() { | 429 void RTCStatsCollector::ClearCachedStatsReport() { |
423 RTC_DCHECK(signaling_thread_->IsCurrent()); | 430 RTC_DCHECK(signaling_thread_->IsCurrent()); |
424 cached_report_ = nullptr; | 431 cached_report_ = nullptr; |
425 } | 432 } |
426 | 433 |
427 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( | 434 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( |
428 int64_t timestamp_us) { | 435 int64_t timestamp_us) { |
429 RTC_DCHECK(signaling_thread_->IsCurrent()); | 436 RTC_DCHECK(signaling_thread_->IsCurrent()); |
430 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 437 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
431 timestamp_us); | 438 timestamp_us); |
432 | 439 |
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()); | 440 ProduceDataChannelStats_s(timestamp_us, report.get()); |
451 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); | 441 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); |
452 ProducePeerConnectionStats_s(timestamp_us, report.get()); | 442 ProducePeerConnectionStats_s(timestamp_us, report.get()); |
453 | 443 |
454 AddPartialResults(report); | 444 AddPartialResults(report); |
455 } | 445 } |
456 | 446 |
457 void RTCStatsCollector::ProducePartialResultsOnWorkerThread( | 447 void RTCStatsCollector::ProducePartialResultsOnWorkerThread( |
458 int64_t timestamp_us) { | 448 int64_t timestamp_us) { |
459 RTC_DCHECK(worker_thread_->IsCurrent()); | 449 RTC_DCHECK(worker_thread_->IsCurrent()); |
460 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 450 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
461 timestamp_us); | 451 timestamp_us); |
462 | 452 |
463 // TODO(hbos): Gather stats on worker thread. | 453 // 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 | 454 // method. |
Taylor Brandstetter
2016/12/13 19:47:07
There are still stats that are ultimately gathered
hbos
2016/12/14 14:56:31
Acknowledge. Out of curiosity: this meaning (block
Taylor Brandstetter
2016/12/15 01:12:53
Yes. Here, to be specific: https://cs.chromium.org
hbos
2016/12/15 16:12:45
Oh, good to know, so we still do a network -> work
Taylor Brandstetter
2016/12/15 17:35:19
Yep, and it's actually two hops, one each for audi
hbos
2016/12/16 10:38:02
That should be reducible to 1 hop, but I don't thi
| |
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 | 455 |
471 AddPartialResults(report); | 456 AddPartialResults(report); |
472 } | 457 } |
473 | 458 |
474 void RTCStatsCollector::ProducePartialResultsOnNetworkThread( | 459 void RTCStatsCollector::ProducePartialResultsOnNetworkThread( |
475 int64_t timestamp_us) { | 460 int64_t timestamp_us) { |
476 RTC_DCHECK(network_thread_->IsCurrent()); | 461 RTC_DCHECK(network_thread_->IsCurrent()); |
477 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 462 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
478 timestamp_us); | 463 timestamp_us); |
479 | 464 |
480 // TODO(hbos): Gather stats on network thread. | 465 std::unique_ptr<SessionStats> session_stats = |
481 // pc_->session()'s channels are owned by the signaling thread but there are | 466 pc_->session()->GetSessionStats_n(*channel_name_pairs_); |
Taylor Brandstetter
2016/12/13 19:47:07
Instead of adding GetSessionStats_n, how about jus
pthatcher1
2016/12/13 23:50:19
I agree, but better yet, we could just expose the
Taylor Brandstetter
2016/12/14 00:10:25
Good point. But that may be introducing more inter
hbos
2016/12/14 14:56:31
With the latest changes there are no new functions
Taylor Brandstetter
2016/12/15 01:12:53
Makes sense; I didn't consider that.
| |
482 // some stats that are gathered on the network thread. Instead of a | 467 if (session_stats) { |
483 // synchronous invoke on "s->n" we could to the "n" work here asynchronously | 468 std::map<std::string, CertificateStatsPair> transport_cert_stats = |
484 // if it wasn't for the ownership issue. Synchronous invokes in other places | 469 PrepareTransportCertificateStats_n(*session_stats); |
485 // makes it difficult to introduce locks without introducing deadlocks and the | 470 |
486 // channels are not reference counted. | 471 ProduceCertificateStats_n( |
472 timestamp_us, transport_cert_stats, report.get()); | |
473 ProduceCodecStats_n( | |
474 timestamp_us, *media_info_, report.get()); | |
475 ProduceIceCandidateAndPairStats_n( | |
476 timestamp_us, *session_stats, report.get()); | |
477 ProduceRTPStreamStats_n( | |
478 timestamp_us, *session_stats, *media_info_, report.get()); | |
479 ProduceTransportStats_n( | |
480 timestamp_us, *session_stats, transport_cert_stats, report.get()); | |
481 } | |
487 | 482 |
488 AddPartialResults(report); | 483 AddPartialResults(report); |
489 } | 484 } |
490 | 485 |
491 void RTCStatsCollector::AddPartialResults( | 486 void RTCStatsCollector::AddPartialResults( |
492 const rtc::scoped_refptr<RTCStatsReport>& partial_report) { | 487 const rtc::scoped_refptr<RTCStatsReport>& partial_report) { |
493 if (!signaling_thread_->IsCurrent()) { | 488 if (!signaling_thread_->IsCurrent()) { |
494 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, signaling_thread_, | 489 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, signaling_thread_, |
495 rtc::Bind(&RTCStatsCollector::AddPartialResults_s, | 490 rtc::Bind(&RTCStatsCollector::AddPartialResults_s, |
496 rtc::scoped_refptr<RTCStatsCollector>(this), | 491 rtc::scoped_refptr<RTCStatsCollector>(this), |
(...skipping 24 matching lines...) Expand all Loading... | |
521 RTC_DCHECK(signaling_thread_->IsCurrent()); | 516 RTC_DCHECK(signaling_thread_->IsCurrent()); |
522 RTC_DCHECK(!callbacks_.empty()); | 517 RTC_DCHECK(!callbacks_.empty()); |
523 RTC_DCHECK(cached_report_); | 518 RTC_DCHECK(cached_report_); |
524 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback : | 519 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback : |
525 callbacks_) { | 520 callbacks_) { |
526 callback->OnStatsDelivered(cached_report_); | 521 callback->OnStatsDelivered(cached_report_); |
527 } | 522 } |
528 callbacks_.clear(); | 523 callbacks_.clear(); |
529 } | 524 } |
530 | 525 |
531 void RTCStatsCollector::ProduceCertificateStats_s( | 526 void RTCStatsCollector::ProduceCertificateStats_n( |
532 int64_t timestamp_us, | 527 int64_t timestamp_us, |
533 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, | 528 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, |
534 RTCStatsReport* report) const { | 529 RTCStatsReport* report) const { |
535 RTC_DCHECK(signaling_thread_->IsCurrent()); | 530 RTC_DCHECK(network_thread_->IsCurrent()); |
536 for (const auto& transport_cert_stats_pair : transport_cert_stats) { | 531 for (const auto& transport_cert_stats_pair : transport_cert_stats) { |
537 if (transport_cert_stats_pair.second.local) { | 532 if (transport_cert_stats_pair.second.local) { |
538 ProduceCertificateStatsFromSSLCertificateStats( | 533 ProduceCertificateStatsFromSSLCertificateStats( |
539 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); | 534 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); |
540 } | 535 } |
541 if (transport_cert_stats_pair.second.remote) { | 536 if (transport_cert_stats_pair.second.remote) { |
542 ProduceCertificateStatsFromSSLCertificateStats( | 537 ProduceCertificateStatsFromSSLCertificateStats( |
543 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); | 538 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); |
544 } | 539 } |
545 } | 540 } |
546 } | 541 } |
547 | 542 |
548 void RTCStatsCollector::ProduceCodecStats_s( | 543 void RTCStatsCollector::ProduceCodecStats_n( |
549 int64_t timestamp_us, const MediaInfo& media_info, | 544 int64_t timestamp_us, const MediaInfo& media_info, |
550 RTCStatsReport* report) const { | 545 RTCStatsReport* report) const { |
551 RTC_DCHECK(signaling_thread_->IsCurrent()); | 546 RTC_DCHECK(network_thread_->IsCurrent()); |
552 // Audio | 547 // Audio |
553 if (media_info.voice) { | 548 if (media_info.voice) { |
554 // Inbound | 549 // Inbound |
555 for (const auto& pair : media_info.voice->receive_codecs) { | 550 for (const auto& pair : media_info.voice->receive_codecs) { |
556 report->AddStats(CodecStatsFromRtpCodecParameters( | 551 report->AddStats(CodecStatsFromRtpCodecParameters( |
557 timestamp_us, true, true, pair.second)); | 552 timestamp_us, true, true, pair.second)); |
558 } | 553 } |
559 // Outbound | 554 // Outbound |
560 for (const auto& pair : media_info.voice->send_codecs) { | 555 for (const auto& pair : media_info.voice->send_codecs) { |
561 report->AddStats(CodecStatsFromRtpCodecParameters( | 556 report->AddStats(CodecStatsFromRtpCodecParameters( |
(...skipping 30 matching lines...) Expand all Loading... | |
592 data_channel_stats->state = | 587 data_channel_stats->state = |
593 DataStateToRTCDataChannelState(data_channel->state()); | 588 DataStateToRTCDataChannelState(data_channel->state()); |
594 data_channel_stats->messages_sent = data_channel->messages_sent(); | 589 data_channel_stats->messages_sent = data_channel->messages_sent(); |
595 data_channel_stats->bytes_sent = data_channel->bytes_sent(); | 590 data_channel_stats->bytes_sent = data_channel->bytes_sent(); |
596 data_channel_stats->messages_received = data_channel->messages_received(); | 591 data_channel_stats->messages_received = data_channel->messages_received(); |
597 data_channel_stats->bytes_received = data_channel->bytes_received(); | 592 data_channel_stats->bytes_received = data_channel->bytes_received(); |
598 report->AddStats(std::move(data_channel_stats)); | 593 report->AddStats(std::move(data_channel_stats)); |
599 } | 594 } |
600 } | 595 } |
601 | 596 |
602 void RTCStatsCollector::ProduceIceCandidateAndPairStats_s( | 597 void RTCStatsCollector::ProduceIceCandidateAndPairStats_n( |
603 int64_t timestamp_us, const SessionStats& session_stats, | 598 int64_t timestamp_us, const SessionStats& session_stats, |
604 RTCStatsReport* report) const { | 599 RTCStatsReport* report) const { |
605 RTC_DCHECK(signaling_thread_->IsCurrent()); | 600 RTC_DCHECK(network_thread_->IsCurrent()); |
606 for (const auto& transport_stats : session_stats.transport_stats) { | 601 for (const auto& transport_stats : session_stats.transport_stats) { |
607 for (const auto& channel_stats : transport_stats.second.channel_stats) { | 602 for (const auto& channel_stats : transport_stats.second.channel_stats) { |
608 std::string transport_id = RTCTransportStatsIDFromTransportChannel( | 603 std::string transport_id = RTCTransportStatsIDFromTransportChannel( |
609 transport_stats.second.transport_name, channel_stats.component); | 604 transport_stats.second.transport_name, channel_stats.component); |
610 for (const cricket::ConnectionInfo& info : | 605 for (const cricket::ConnectionInfo& info : |
611 channel_stats.connection_infos) { | 606 channel_stats.connection_infos) { |
612 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( | 607 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( |
613 new RTCIceCandidatePairStats( | 608 new RTCIceCandidatePairStats( |
614 RTCIceCandidatePairStatsIDFromConnectionInfo(info), | 609 RTCIceCandidatePairStatsIDFromConnectionInfo(info), |
615 timestamp_us)); | 610 timestamp_us)); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 void RTCStatsCollector::ProducePeerConnectionStats_s( | 663 void RTCStatsCollector::ProducePeerConnectionStats_s( |
669 int64_t timestamp_us, RTCStatsReport* report) const { | 664 int64_t timestamp_us, RTCStatsReport* report) const { |
670 RTC_DCHECK(signaling_thread_->IsCurrent()); | 665 RTC_DCHECK(signaling_thread_->IsCurrent()); |
671 std::unique_ptr<RTCPeerConnectionStats> stats( | 666 std::unique_ptr<RTCPeerConnectionStats> stats( |
672 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); | 667 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); |
673 stats->data_channels_opened = internal_record_.data_channels_opened; | 668 stats->data_channels_opened = internal_record_.data_channels_opened; |
674 stats->data_channels_closed = internal_record_.data_channels_closed; | 669 stats->data_channels_closed = internal_record_.data_channels_closed; |
675 report->AddStats(std::move(stats)); | 670 report->AddStats(std::move(stats)); |
676 } | 671 } |
677 | 672 |
678 void RTCStatsCollector::ProduceRTPStreamStats_s( | 673 void RTCStatsCollector::ProduceRTPStreamStats_n( |
679 int64_t timestamp_us, const SessionStats& session_stats, | 674 int64_t timestamp_us, const SessionStats& session_stats, |
680 const MediaInfo& media_info, RTCStatsReport* report) const { | 675 const MediaInfo& media_info, RTCStatsReport* report) const { |
681 RTC_DCHECK(signaling_thread_->IsCurrent()); | 676 RTC_DCHECK(network_thread_->IsCurrent()); |
682 | 677 |
683 // Audio | 678 // Audio |
684 if (media_info.voice) { | 679 if (media_info.voice) { |
685 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 680 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
686 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); | 681 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); |
687 RTC_DCHECK(!transport_id.empty()); | 682 RTC_DCHECK(!transport_id.empty()); |
688 // Inbound | 683 // Inbound |
689 for (const cricket::VoiceReceiverInfo& voice_receiver_info : | 684 for (const cricket::VoiceReceiverInfo& voice_receiver_info : |
690 media_info.voice->receivers) { | 685 media_info.voice->receivers) { |
691 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 686 // 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) { | 770 if (video_sender_info.codec_payload_type) { |
776 outbound_video->codec_id = | 771 outbound_video->codec_id = |
777 RTCCodecStatsIDFromDirectionMediaAndPayload( | 772 RTCCodecStatsIDFromDirectionMediaAndPayload( |
778 false, false, *video_sender_info.codec_payload_type); | 773 false, false, *video_sender_info.codec_payload_type); |
779 } | 774 } |
780 report->AddStats(std::move(outbound_video)); | 775 report->AddStats(std::move(outbound_video)); |
781 } | 776 } |
782 } | 777 } |
783 } | 778 } |
784 | 779 |
785 void RTCStatsCollector::ProduceTransportStats_s( | 780 void RTCStatsCollector::ProduceTransportStats_n( |
786 int64_t timestamp_us, const SessionStats& session_stats, | 781 int64_t timestamp_us, const SessionStats& session_stats, |
787 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, | 782 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, |
788 RTCStatsReport* report) const { | 783 RTCStatsReport* report) const { |
789 RTC_DCHECK(signaling_thread_->IsCurrent()); | 784 RTC_DCHECK(network_thread_->IsCurrent()); |
790 for (const auto& transport : session_stats.transport_stats) { | 785 for (const auto& transport : session_stats.transport_stats) { |
791 // Get reference to RTCP channel, if it exists. | 786 // Get reference to RTCP channel, if it exists. |
792 std::string rtcp_transport_stats_id; | 787 std::string rtcp_transport_stats_id; |
793 for (const auto& channel_stats : transport.second.channel_stats) { | 788 for (const auto& channel_stats : transport.second.channel_stats) { |
794 if (channel_stats.component == | 789 if (channel_stats.component == |
795 cricket::ICE_CANDIDATE_COMPONENT_RTCP) { | 790 cricket::ICE_CANDIDATE_COMPONENT_RTCP) { |
796 rtcp_transport_stats_id = RTCTransportStatsIDFromTransportChannel( | 791 rtcp_transport_stats_id = RTCTransportStatsIDFromTransportChannel( |
797 transport.second.transport_name, channel_stats.component); | 792 transport.second.transport_name, channel_stats.component); |
798 break; | 793 break; |
799 } | 794 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
842 if (!local_certificate_id.empty()) | 837 if (!local_certificate_id.empty()) |
843 transport_stats->local_certificate_id = local_certificate_id; | 838 transport_stats->local_certificate_id = local_certificate_id; |
844 if (!remote_certificate_id.empty()) | 839 if (!remote_certificate_id.empty()) |
845 transport_stats->remote_certificate_id = remote_certificate_id; | 840 transport_stats->remote_certificate_id = remote_certificate_id; |
846 report->AddStats(std::move(transport_stats)); | 841 report->AddStats(std::move(transport_stats)); |
847 } | 842 } |
848 } | 843 } |
849 } | 844 } |
850 | 845 |
851 std::map<std::string, RTCStatsCollector::CertificateStatsPair> | 846 std::map<std::string, RTCStatsCollector::CertificateStatsPair> |
852 RTCStatsCollector::PrepareTransportCertificateStats( | 847 RTCStatsCollector::PrepareTransportCertificateStats_n( |
853 const SessionStats& session_stats) const { | 848 const SessionStats& session_stats) const { |
854 RTC_DCHECK(signaling_thread_->IsCurrent()); | 849 RTC_DCHECK(network_thread_->IsCurrent()); |
855 std::map<std::string, CertificateStatsPair> transport_cert_stats; | 850 std::map<std::string, CertificateStatsPair> transport_cert_stats; |
856 for (const auto& transport_stats : session_stats.transport_stats) { | 851 for (const auto& transport_stats : session_stats.transport_stats) { |
857 CertificateStatsPair certificate_stats_pair; | 852 CertificateStatsPair certificate_stats_pair; |
858 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; | 853 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; |
859 if (pc_->session()->GetLocalCertificate( | 854 if (pc_->session()->GetLocalCertificate_n( |
860 transport_stats.second.transport_name, &local_certificate)) { | 855 transport_stats.second.transport_name, &local_certificate)) { |
861 certificate_stats_pair.local = | 856 certificate_stats_pair.local = |
862 local_certificate->ssl_certificate().GetStats(); | 857 local_certificate->ssl_certificate().GetStats(); |
863 } | 858 } |
864 std::unique_ptr<rtc::SSLCertificate> remote_certificate = | 859 std::unique_ptr<rtc::SSLCertificate> remote_certificate = |
865 pc_->session()->GetRemoteSSLCertificate( | 860 pc_->session()->GetRemoteSSLCertificate_n( |
866 transport_stats.second.transport_name); | 861 transport_stats.second.transport_name); |
867 if (remote_certificate) { | 862 if (remote_certificate) { |
868 certificate_stats_pair.remote = remote_certificate->GetStats(); | 863 certificate_stats_pair.remote = remote_certificate->GetStats(); |
869 } | 864 } |
870 transport_cert_stats.insert( | 865 transport_cert_stats.insert( |
871 std::make_pair(transport_stats.second.transport_name, | 866 std::make_pair(transport_stats.second.transport_name, |
872 std::move(certificate_stats_pair))); | 867 std::move(certificate_stats_pair))); |
873 } | 868 } |
874 return transport_cert_stats; | 869 return transport_cert_stats; |
875 } | 870 } |
876 | 871 |
877 RTCStatsCollector::MediaInfo RTCStatsCollector::PrepareMediaInfo( | 872 std::unique_ptr<RTCStatsCollector::MediaInfo> |
878 const SessionStats& session_stats) const { | 873 RTCStatsCollector::PrepareMediaInfo_s() const { |
879 MediaInfo media_info; | 874 RTC_DCHECK(signaling_thread_->IsCurrent()); |
875 std::unique_ptr<MediaInfo> media_info(new MediaInfo()); | |
880 if (pc_->session()->voice_channel()) { | 876 if (pc_->session()->voice_channel()) { |
881 cricket::VoiceMediaInfo voice_media_info; | 877 cricket::VoiceMediaInfo voice_media_info; |
882 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { | 878 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { |
883 media_info.voice = rtc::Optional<cricket::VoiceMediaInfo>( | 879 media_info->voice = rtc::Optional<cricket::VoiceMediaInfo>( |
884 std::move(voice_media_info)); | 880 std::move(voice_media_info)); |
885 } | 881 } |
886 } | 882 } |
887 if (pc_->session()->video_channel()) { | 883 if (pc_->session()->video_channel()) { |
888 cricket::VideoMediaInfo video_media_info; | 884 cricket::VideoMediaInfo video_media_info; |
889 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { | 885 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { |
890 media_info.video = rtc::Optional<cricket::VideoMediaInfo>( | 886 media_info->video = rtc::Optional<cricket::VideoMediaInfo>( |
891 std::move(video_media_info)); | 887 std::move(video_media_info)); |
892 } | 888 } |
893 } | 889 } |
894 return media_info; | 890 return media_info; |
895 } | 891 } |
896 | 892 |
897 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { | 893 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { |
898 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); | 894 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); |
899 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); | 895 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); |
900 } | 896 } |
(...skipping 21 matching lines...) Expand all Loading... | |
922 const std::string& type) { | 918 const std::string& type) { |
923 return CandidateTypeToRTCIceCandidateType(type); | 919 return CandidateTypeToRTCIceCandidateType(type); |
924 } | 920 } |
925 | 921 |
926 const char* DataStateToRTCDataChannelStateForTesting( | 922 const char* DataStateToRTCDataChannelStateForTesting( |
927 DataChannelInterface::DataState state) { | 923 DataChannelInterface::DataState state) { |
928 return DataStateToRTCDataChannelState(state); | 924 return DataStateToRTCDataChannelState(state); |
929 } | 925 } |
930 | 926 |
931 } // namespace webrtc | 927 } // namespace webrtc |
OLD | NEW |