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 15 matching lines...) Expand all Loading... |
26 #include "webrtc/p2p/base/port.h" | 26 #include "webrtc/p2p/base/port.h" |
27 | 27 |
28 namespace webrtc { | 28 namespace webrtc { |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) { | 32 std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) { |
33 return "RTCCertificate_" + fingerprint; | 33 return "RTCCertificate_" + fingerprint; |
34 } | 34 } |
35 | 35 |
| 36 std::string RTCCodecStatsIDFromDirectionMediaAndPayload( |
| 37 bool inbound, bool audio, uint32_t payload_type) { |
| 38 // TODO(hbos): When we are able to handle multiple m= lines of the same media |
| 39 // type (and multiple BaseChannels for the same type is possible?) this needs |
| 40 // to be updated to differentiate the transport being used, and stats need to |
| 41 // be collected for all of them. crbug.com/659117 |
| 42 if (inbound) { |
| 43 return audio ? "RTCCodec_InboundAudio_" + rtc::ToString<>(payload_type) |
| 44 : "RTCCodec_InboundVideo_" + rtc::ToString<>(payload_type); |
| 45 } |
| 46 return audio ? "RTCCodec_OutboundAudio_" + rtc::ToString<>(payload_type) |
| 47 : "RTCCodec_OutboundVideo_" + rtc::ToString<>(payload_type); |
| 48 } |
| 49 |
36 std::string RTCIceCandidatePairStatsIDFromConnectionInfo( | 50 std::string RTCIceCandidatePairStatsIDFromConnectionInfo( |
37 const cricket::ConnectionInfo& info) { | 51 const cricket::ConnectionInfo& info) { |
38 return "RTCIceCandidatePair_" + info.local_candidate.id() + "_" + | 52 return "RTCIceCandidatePair_" + info.local_candidate.id() + "_" + |
39 info.remote_candidate.id(); | 53 info.remote_candidate.id(); |
40 } | 54 } |
41 | 55 |
42 std::string RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( | 56 std::string RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( |
43 const MediaStreamTrackInterface& track) { | 57 const MediaStreamTrackInterface& track) { |
44 return "RTCMediaStreamTrack_" + track.id(); | 58 return "RTCMediaStreamTrack_" + track.id(); |
45 } | 59 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 case DataChannelInterface::kClosing: | 107 case DataChannelInterface::kClosing: |
94 return RTCDataChannelState::kClosing; | 108 return RTCDataChannelState::kClosing; |
95 case DataChannelInterface::kClosed: | 109 case DataChannelInterface::kClosed: |
96 return RTCDataChannelState::kClosed; | 110 return RTCDataChannelState::kClosed; |
97 default: | 111 default: |
98 RTC_NOTREACHED(); | 112 RTC_NOTREACHED(); |
99 return nullptr; | 113 return nullptr; |
100 } | 114 } |
101 } | 115 } |
102 | 116 |
| 117 std::unique_ptr<RTCCodecStats> CodecStatsFromRtpCodecParameters( |
| 118 uint64_t timestamp_us, bool inbound, bool audio, |
| 119 const RtpCodecParameters& codec_params) { |
| 120 RTC_DCHECK_GE(codec_params.payload_type, 0); |
| 121 RTC_DCHECK_LE(codec_params.payload_type, 127); |
| 122 uint32_t payload_type = static_cast<uint32_t>(codec_params.payload_type); |
| 123 std::unique_ptr<RTCCodecStats> codec_stats(new RTCCodecStats( |
| 124 RTCCodecStatsIDFromDirectionMediaAndPayload(inbound, audio, payload_type), |
| 125 timestamp_us)); |
| 126 codec_stats->payload_type = payload_type; |
| 127 codec_stats->codec = (audio ? "audio/" : "video/") + codec_params.mime_type; |
| 128 codec_stats->clock_rate = static_cast<uint32_t>(codec_params.clock_rate); |
| 129 return codec_stats; |
| 130 } |
| 131 |
103 void SetMediaStreamTrackStatsFromMediaStreamTrackInterface( | 132 void SetMediaStreamTrackStatsFromMediaStreamTrackInterface( |
104 const MediaStreamTrackInterface& track, | 133 const MediaStreamTrackInterface& track, |
105 RTCMediaStreamTrackStats* track_stats) { | 134 RTCMediaStreamTrackStats* track_stats) { |
106 track_stats->track_identifier = track.id(); | 135 track_stats->track_identifier = track.id(); |
107 track_stats->ended = (track.state() == MediaStreamTrackInterface::kEnded); | 136 track_stats->ended = (track.state() == MediaStreamTrackInterface::kEnded); |
108 } | 137 } |
109 | 138 |
110 // Provides the media independent counters (both audio and video). | 139 // Provides the media independent counters (both audio and video). |
111 void SetInboundRTPStreamStatsFromMediaReceiverInfo( | 140 void SetInboundRTPStreamStatsFromMediaReceiverInfo( |
112 const cricket::MediaReceiverInfo& media_receiver_info, | 141 const cricket::MediaReceiverInfo& media_receiver_info, |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 424 |
396 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( | 425 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( |
397 int64_t timestamp_us) { | 426 int64_t timestamp_us) { |
398 RTC_DCHECK(signaling_thread_->IsCurrent()); | 427 RTC_DCHECK(signaling_thread_->IsCurrent()); |
399 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 428 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
400 timestamp_us); | 429 timestamp_us); |
401 | 430 |
402 SessionStats session_stats; | 431 SessionStats session_stats; |
403 if (pc_->session()->GetTransportStats(&session_stats)) { | 432 if (pc_->session()->GetTransportStats(&session_stats)) { |
404 std::map<std::string, CertificateStatsPair> transport_cert_stats = | 433 std::map<std::string, CertificateStatsPair> transport_cert_stats = |
405 PrepareTransportCertificateStats_s(session_stats); | 434 PrepareTransportCertificateStats(session_stats); |
| 435 MediaInfo media_info = PrepareMediaInfo(session_stats); |
406 | 436 |
407 ProduceCertificateStats_s( | 437 ProduceCertificateStats_s( |
408 timestamp_us, transport_cert_stats, report.get()); | 438 timestamp_us, transport_cert_stats, report.get()); |
| 439 ProduceCodecStats_s( |
| 440 timestamp_us, media_info, report.get()); |
409 ProduceIceCandidateAndPairStats_s( | 441 ProduceIceCandidateAndPairStats_s( |
410 timestamp_us, session_stats, report.get()); | 442 timestamp_us, session_stats, report.get()); |
411 ProduceRTPStreamStats_s( | 443 ProduceRTPStreamStats_s( |
412 timestamp_us, session_stats, report.get()); | 444 timestamp_us, session_stats, media_info, report.get()); |
413 ProduceTransportStats_s( | 445 ProduceTransportStats_s( |
414 timestamp_us, session_stats, transport_cert_stats, report.get()); | 446 timestamp_us, session_stats, transport_cert_stats, report.get()); |
415 } | 447 } |
416 ProduceDataChannelStats_s(timestamp_us, report.get()); | 448 ProduceDataChannelStats_s(timestamp_us, report.get()); |
417 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); | 449 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); |
418 ProducePeerConnectionStats_s(timestamp_us, report.get()); | 450 ProducePeerConnectionStats_s(timestamp_us, report.get()); |
419 | 451 |
420 AddPartialResults(report); | 452 AddPartialResults(report); |
421 } | 453 } |
422 | 454 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 ProduceCertificateStatsFromSSLCertificateStats( | 536 ProduceCertificateStatsFromSSLCertificateStats( |
505 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); | 537 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); |
506 } | 538 } |
507 if (transport_cert_stats_pair.second.remote) { | 539 if (transport_cert_stats_pair.second.remote) { |
508 ProduceCertificateStatsFromSSLCertificateStats( | 540 ProduceCertificateStatsFromSSLCertificateStats( |
509 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); | 541 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); |
510 } | 542 } |
511 } | 543 } |
512 } | 544 } |
513 | 545 |
| 546 void RTCStatsCollector::ProduceCodecStats_s( |
| 547 int64_t timestamp_us, const MediaInfo& media_info, |
| 548 RTCStatsReport* report) const { |
| 549 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 550 // Audio |
| 551 if (media_info.voice) { |
| 552 // Inbound |
| 553 for (const auto& pair : media_info.voice->receive_codecs) { |
| 554 report->AddStats(CodecStatsFromRtpCodecParameters( |
| 555 timestamp_us, true, true, pair.second)); |
| 556 } |
| 557 // Outbound |
| 558 for (const auto& pair : media_info.voice->send_codecs) { |
| 559 report->AddStats(CodecStatsFromRtpCodecParameters( |
| 560 timestamp_us, false, true, pair.second)); |
| 561 } |
| 562 } |
| 563 // Video |
| 564 if (media_info.video) { |
| 565 // Inbound |
| 566 for (const auto& pair : media_info.video->receive_codecs) { |
| 567 report->AddStats(CodecStatsFromRtpCodecParameters( |
| 568 timestamp_us, true, false, pair.second)); |
| 569 } |
| 570 // Outbound |
| 571 for (const auto& pair : media_info.video->send_codecs) { |
| 572 report->AddStats(CodecStatsFromRtpCodecParameters( |
| 573 timestamp_us, false, false, pair.second)); |
| 574 } |
| 575 } |
| 576 } |
| 577 |
514 void RTCStatsCollector::ProduceDataChannelStats_s( | 578 void RTCStatsCollector::ProduceDataChannelStats_s( |
515 int64_t timestamp_us, RTCStatsReport* report) const { | 579 int64_t timestamp_us, RTCStatsReport* report) const { |
516 RTC_DCHECK(signaling_thread_->IsCurrent()); | 580 RTC_DCHECK(signaling_thread_->IsCurrent()); |
517 for (const rtc::scoped_refptr<DataChannel>& data_channel : | 581 for (const rtc::scoped_refptr<DataChannel>& data_channel : |
518 pc_->sctp_data_channels()) { | 582 pc_->sctp_data_channels()) { |
519 std::unique_ptr<RTCDataChannelStats> data_channel_stats( | 583 std::unique_ptr<RTCDataChannelStats> data_channel_stats( |
520 new RTCDataChannelStats( | 584 new RTCDataChannelStats( |
521 "RTCDataChannel_" + rtc::ToString<>(data_channel->id()), | 585 "RTCDataChannel_" + rtc::ToString<>(data_channel->id()), |
522 timestamp_us)); | 586 timestamp_us)); |
523 data_channel_stats->label = data_channel->label(); | 587 data_channel_stats->label = data_channel->label(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 RTC_DCHECK(signaling_thread_->IsCurrent()); | 659 RTC_DCHECK(signaling_thread_->IsCurrent()); |
596 std::unique_ptr<RTCPeerConnectionStats> stats( | 660 std::unique_ptr<RTCPeerConnectionStats> stats( |
597 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); | 661 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); |
598 stats->data_channels_opened = internal_record_.data_channels_opened; | 662 stats->data_channels_opened = internal_record_.data_channels_opened; |
599 stats->data_channels_closed = internal_record_.data_channels_closed; | 663 stats->data_channels_closed = internal_record_.data_channels_closed; |
600 report->AddStats(std::move(stats)); | 664 report->AddStats(std::move(stats)); |
601 } | 665 } |
602 | 666 |
603 void RTCStatsCollector::ProduceRTPStreamStats_s( | 667 void RTCStatsCollector::ProduceRTPStreamStats_s( |
604 int64_t timestamp_us, const SessionStats& session_stats, | 668 int64_t timestamp_us, const SessionStats& session_stats, |
605 RTCStatsReport* report) const { | 669 const MediaInfo& media_info, RTCStatsReport* report) const { |
606 RTC_DCHECK(signaling_thread_->IsCurrent()); | 670 RTC_DCHECK(signaling_thread_->IsCurrent()); |
607 | 671 |
608 // Audio | 672 // Audio |
609 if (pc_->session()->voice_channel()) { | 673 if (media_info.voice) { |
610 cricket::VoiceMediaInfo voice_media_info; | 674 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
611 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { | 675 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); |
612 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 676 RTC_DCHECK(!transport_id.empty()); |
613 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); | 677 // Inbound |
614 RTC_DCHECK(!transport_id.empty()); | 678 for (const cricket::VoiceReceiverInfo& voice_receiver_info : |
615 // Inbound | 679 media_info.voice->receivers) { |
616 for (const cricket::VoiceReceiverInfo& voice_receiver_info : | 680 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
617 voice_media_info.receivers) { | 681 // is fixed. |
618 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 682 if (voice_receiver_info.ssrc() == 0) |
619 // is fixed. | 683 continue; |
620 if (voice_receiver_info.ssrc() == 0) | 684 std::unique_ptr<RTCInboundRTPStreamStats> inbound_audio( |
621 continue; | 685 new RTCInboundRTPStreamStats( |
622 std::unique_ptr<RTCInboundRTPStreamStats> inbound_audio( | 686 RTCInboundRTPStreamStatsIDFromSSRC( |
623 new RTCInboundRTPStreamStats( | 687 true, voice_receiver_info.ssrc()), |
624 RTCInboundRTPStreamStatsIDFromSSRC( | 688 timestamp_us)); |
625 true, voice_receiver_info.ssrc()), | 689 SetInboundRTPStreamStatsFromVoiceReceiverInfo( |
626 timestamp_us)); | 690 voice_receiver_info, inbound_audio.get()); |
627 SetInboundRTPStreamStatsFromVoiceReceiverInfo( | 691 inbound_audio->transport_id = transport_id; |
628 voice_receiver_info, inbound_audio.get()); | 692 if (voice_receiver_info.codec_payload_type) { |
629 inbound_audio->transport_id = transport_id; | 693 inbound_audio->codec_id = |
630 report->AddStats(std::move(inbound_audio)); | 694 RTCCodecStatsIDFromDirectionMediaAndPayload( |
| 695 true, true, *voice_receiver_info.codec_payload_type); |
631 } | 696 } |
632 // Outbound | 697 report->AddStats(std::move(inbound_audio)); |
633 for (const cricket::VoiceSenderInfo& voice_sender_info : | 698 } |
634 voice_media_info.senders) { | 699 // Outbound |
635 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 700 for (const cricket::VoiceSenderInfo& voice_sender_info : |
636 // is fixed. | 701 media_info.voice->senders) { |
637 if (voice_sender_info.ssrc() == 0) | 702 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
638 continue; | 703 // is fixed. |
639 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_audio( | 704 if (voice_sender_info.ssrc() == 0) |
640 new RTCOutboundRTPStreamStats( | 705 continue; |
641 RTCOutboundRTPStreamStatsIDFromSSRC( | 706 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_audio( |
642 true, voice_sender_info.ssrc()), | 707 new RTCOutboundRTPStreamStats( |
643 timestamp_us)); | 708 RTCOutboundRTPStreamStatsIDFromSSRC( |
644 SetOutboundRTPStreamStatsFromVoiceSenderInfo( | 709 true, voice_sender_info.ssrc()), |
645 voice_sender_info, outbound_audio.get()); | 710 timestamp_us)); |
646 outbound_audio->transport_id = transport_id; | 711 SetOutboundRTPStreamStatsFromVoiceSenderInfo( |
647 report->AddStats(std::move(outbound_audio)); | 712 voice_sender_info, outbound_audio.get()); |
| 713 outbound_audio->transport_id = transport_id; |
| 714 if (voice_sender_info.codec_payload_type) { |
| 715 outbound_audio->codec_id = |
| 716 RTCCodecStatsIDFromDirectionMediaAndPayload( |
| 717 false, true, *voice_sender_info.codec_payload_type); |
648 } | 718 } |
| 719 report->AddStats(std::move(outbound_audio)); |
649 } | 720 } |
650 } | 721 } |
651 // Video | 722 // Video |
652 if (pc_->session()->video_channel()) { | 723 if (media_info.video) { |
653 cricket::VideoMediaInfo video_media_info; | 724 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
654 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { | 725 session_stats.proxy_to_transport, *pc_->session()->video_channel()); |
655 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 726 RTC_DCHECK(!transport_id.empty()); |
656 session_stats.proxy_to_transport, *pc_->session()->video_channel()); | 727 // Inbound |
657 RTC_DCHECK(!transport_id.empty()); | 728 for (const cricket::VideoReceiverInfo& video_receiver_info : |
658 // Inbound | 729 media_info.video->receivers) { |
659 for (const cricket::VideoReceiverInfo& video_receiver_info : | 730 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
660 video_media_info.receivers) { | 731 // is fixed. |
661 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 732 if (video_receiver_info.ssrc() == 0) |
662 // is fixed. | 733 continue; |
663 if (video_receiver_info.ssrc() == 0) | 734 std::unique_ptr<RTCInboundRTPStreamStats> inbound_video( |
664 continue; | 735 new RTCInboundRTPStreamStats( |
665 std::unique_ptr<RTCInboundRTPStreamStats> inbound_video( | 736 RTCInboundRTPStreamStatsIDFromSSRC( |
666 new RTCInboundRTPStreamStats( | 737 false, video_receiver_info.ssrc()), |
667 RTCInboundRTPStreamStatsIDFromSSRC( | 738 timestamp_us)); |
668 false, video_receiver_info.ssrc()), | 739 SetInboundRTPStreamStatsFromVideoReceiverInfo( |
669 timestamp_us)); | 740 video_receiver_info, inbound_video.get()); |
670 SetInboundRTPStreamStatsFromVideoReceiverInfo( | 741 inbound_video->transport_id = transport_id; |
671 video_receiver_info, inbound_video.get()); | 742 if (video_receiver_info.codec_payload_type) { |
672 inbound_video->transport_id = transport_id; | 743 inbound_video->codec_id = |
673 report->AddStats(std::move(inbound_video)); | 744 RTCCodecStatsIDFromDirectionMediaAndPayload( |
| 745 true, false, *video_receiver_info.codec_payload_type); |
674 } | 746 } |
675 // Outbound | 747 report->AddStats(std::move(inbound_video)); |
676 for (const cricket::VideoSenderInfo& video_sender_info : | 748 } |
677 video_media_info.senders) { | 749 // Outbound |
678 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 750 for (const cricket::VideoSenderInfo& video_sender_info : |
679 // is fixed. | 751 media_info.video->senders) { |
680 if (video_sender_info.ssrc() == 0) | 752 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
681 continue; | 753 // is fixed. |
682 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_video( | 754 if (video_sender_info.ssrc() == 0) |
683 new RTCOutboundRTPStreamStats( | 755 continue; |
684 RTCOutboundRTPStreamStatsIDFromSSRC( | 756 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_video( |
685 false, video_sender_info.ssrc()), | 757 new RTCOutboundRTPStreamStats( |
686 timestamp_us)); | 758 RTCOutboundRTPStreamStatsIDFromSSRC( |
687 SetOutboundRTPStreamStatsFromVideoSenderInfo( | 759 false, video_sender_info.ssrc()), |
688 video_sender_info, outbound_video.get()); | 760 timestamp_us)); |
689 outbound_video->transport_id = transport_id; | 761 SetOutboundRTPStreamStatsFromVideoSenderInfo( |
690 report->AddStats(std::move(outbound_video)); | 762 video_sender_info, outbound_video.get()); |
| 763 outbound_video->transport_id = transport_id; |
| 764 if (video_sender_info.codec_payload_type) { |
| 765 outbound_video->codec_id = |
| 766 RTCCodecStatsIDFromDirectionMediaAndPayload( |
| 767 false, false, *video_sender_info.codec_payload_type); |
691 } | 768 } |
| 769 report->AddStats(std::move(outbound_video)); |
692 } | 770 } |
693 } | 771 } |
694 } | 772 } |
695 | 773 |
696 void RTCStatsCollector::ProduceTransportStats_s( | 774 void RTCStatsCollector::ProduceTransportStats_s( |
697 int64_t timestamp_us, const SessionStats& session_stats, | 775 int64_t timestamp_us, const SessionStats& session_stats, |
698 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, | 776 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, |
699 RTCStatsReport* report) const { | 777 RTCStatsReport* report) const { |
700 RTC_DCHECK(signaling_thread_->IsCurrent()); | 778 RTC_DCHECK(signaling_thread_->IsCurrent()); |
701 for (const auto& transport : session_stats.transport_stats) { | 779 for (const auto& transport : session_stats.transport_stats) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 if (!local_certificate_id.empty()) | 831 if (!local_certificate_id.empty()) |
754 transport_stats->local_certificate_id = local_certificate_id; | 832 transport_stats->local_certificate_id = local_certificate_id; |
755 if (!remote_certificate_id.empty()) | 833 if (!remote_certificate_id.empty()) |
756 transport_stats->remote_certificate_id = remote_certificate_id; | 834 transport_stats->remote_certificate_id = remote_certificate_id; |
757 report->AddStats(std::move(transport_stats)); | 835 report->AddStats(std::move(transport_stats)); |
758 } | 836 } |
759 } | 837 } |
760 } | 838 } |
761 | 839 |
762 std::map<std::string, RTCStatsCollector::CertificateStatsPair> | 840 std::map<std::string, RTCStatsCollector::CertificateStatsPair> |
763 RTCStatsCollector::PrepareTransportCertificateStats_s( | 841 RTCStatsCollector::PrepareTransportCertificateStats( |
764 const SessionStats& session_stats) const { | 842 const SessionStats& session_stats) const { |
765 RTC_DCHECK(signaling_thread_->IsCurrent()); | 843 RTC_DCHECK(signaling_thread_->IsCurrent()); |
766 std::map<std::string, CertificateStatsPair> transport_cert_stats; | 844 std::map<std::string, CertificateStatsPair> transport_cert_stats; |
767 for (const auto& transport_stats : session_stats.transport_stats) { | 845 for (const auto& transport_stats : session_stats.transport_stats) { |
768 CertificateStatsPair certificate_stats_pair; | 846 CertificateStatsPair certificate_stats_pair; |
769 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; | 847 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; |
770 if (pc_->session()->GetLocalCertificate( | 848 if (pc_->session()->GetLocalCertificate( |
771 transport_stats.second.transport_name, &local_certificate)) { | 849 transport_stats.second.transport_name, &local_certificate)) { |
772 certificate_stats_pair.local = | 850 certificate_stats_pair.local = |
773 local_certificate->ssl_certificate().GetStats(); | 851 local_certificate->ssl_certificate().GetStats(); |
774 } | 852 } |
775 std::unique_ptr<rtc::SSLCertificate> remote_certificate = | 853 std::unique_ptr<rtc::SSLCertificate> remote_certificate = |
776 pc_->session()->GetRemoteSSLCertificate( | 854 pc_->session()->GetRemoteSSLCertificate( |
777 transport_stats.second.transport_name); | 855 transport_stats.second.transport_name); |
778 if (remote_certificate) { | 856 if (remote_certificate) { |
779 certificate_stats_pair.remote = remote_certificate->GetStats(); | 857 certificate_stats_pair.remote = remote_certificate->GetStats(); |
780 } | 858 } |
781 transport_cert_stats.insert( | 859 transport_cert_stats.insert( |
782 std::make_pair(transport_stats.second.transport_name, | 860 std::make_pair(transport_stats.second.transport_name, |
783 std::move(certificate_stats_pair))); | 861 std::move(certificate_stats_pair))); |
784 } | 862 } |
785 return transport_cert_stats; | 863 return transport_cert_stats; |
786 } | 864 } |
787 | 865 |
| 866 RTCStatsCollector::MediaInfo RTCStatsCollector::PrepareMediaInfo( |
| 867 const SessionStats& session_stats) const { |
| 868 MediaInfo media_info; |
| 869 if (pc_->session()->voice_channel()) { |
| 870 cricket::VoiceMediaInfo voice_media_info; |
| 871 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { |
| 872 media_info.voice = rtc::Optional<cricket::VoiceMediaInfo>( |
| 873 std::move(voice_media_info)); |
| 874 } |
| 875 } |
| 876 if (pc_->session()->video_channel()) { |
| 877 cricket::VideoMediaInfo video_media_info; |
| 878 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { |
| 879 media_info.video = rtc::Optional<cricket::VideoMediaInfo>( |
| 880 std::move(video_media_info)); |
| 881 } |
| 882 } |
| 883 return media_info; |
| 884 } |
| 885 |
788 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { | 886 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { |
789 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); | 887 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); |
790 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); | 888 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); |
791 } | 889 } |
792 | 890 |
793 void RTCStatsCollector::OnDataChannelOpened(DataChannel* channel) { | 891 void RTCStatsCollector::OnDataChannelOpened(DataChannel* channel) { |
794 RTC_DCHECK(signaling_thread_->IsCurrent()); | 892 RTC_DCHECK(signaling_thread_->IsCurrent()); |
795 bool result = internal_record_.opened_data_channels.insert( | 893 bool result = internal_record_.opened_data_channels.insert( |
796 reinterpret_cast<uintptr_t>(channel)).second; | 894 reinterpret_cast<uintptr_t>(channel)).second; |
797 ++internal_record_.data_channels_opened; | 895 ++internal_record_.data_channels_opened; |
(...skipping 15 matching lines...) Expand all Loading... |
813 const std::string& type) { | 911 const std::string& type) { |
814 return CandidateTypeToRTCIceCandidateType(type); | 912 return CandidateTypeToRTCIceCandidateType(type); |
815 } | 913 } |
816 | 914 |
817 const char* DataStateToRTCDataChannelStateForTesting( | 915 const char* DataStateToRTCDataChannelStateForTesting( |
818 DataChannelInterface::DataState state) { | 916 DataChannelInterface::DataState state) { |
819 return DataStateToRTCDataChannelState(state); | 917 return DataStateToRTCDataChannelState(state); |
820 } | 918 } |
821 | 919 |
822 } // namespace webrtc | 920 } // namespace webrtc |
OLD | NEW |