Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 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 RTCCodecStatsIDFromDirectionTypeAndPayload( | |
|
Taylor Brandstetter
2016/11/17 22:01:51
nit: I think you meant "DirectionAndPayloadType"?
hta-webrtc
2016/11/23 07:37:35
It's from "Direction, Type and Payload", so I gues
hbos
2016/11/23 09:40:59
Hm, I replaced "Type" with "Media" as in media typ
| |
| 37 bool inbound, bool audio, uint32_t payload_type) { | |
| 38 if (inbound) { | |
| 39 return audio ? "RTCCodec_InboundAudio_" + rtc::ToString<>(payload_type) | |
|
Taylor Brandstetter
2016/11/17 22:01:51
This is close, but what's really needed is somethi
hbos
2016/11/18 09:08:13
Hmm. I do pc_->session()->voice_channel()->GetStat
Taylor Brandstetter
2016/11/18 19:34:15
No, you're right. This is what I was talking about
hta-webrtc
2016/11/23 07:37:35
Add a TODO to update this when we handle multiple
hbos
2016/11/23 09:40:59
Done.
| |
| 40 : "RTCCodec_InboundVideo_" + rtc::ToString<>(payload_type); | |
| 41 } | |
| 42 return audio ? "RTCCodec_OutboundAudio_" + rtc::ToString<>(payload_type) | |
| 43 : "RTCCodec_OutboundVideo_" + rtc::ToString<>(payload_type); | |
| 44 } | |
| 45 | |
| 36 std::string RTCIceCandidatePairStatsIDFromConnectionInfo( | 46 std::string RTCIceCandidatePairStatsIDFromConnectionInfo( |
| 37 const cricket::ConnectionInfo& info) { | 47 const cricket::ConnectionInfo& info) { |
| 38 return "RTCIceCandidatePair_" + info.local_candidate.id() + "_" + | 48 return "RTCIceCandidatePair_" + info.local_candidate.id() + "_" + |
| 39 info.remote_candidate.id(); | 49 info.remote_candidate.id(); |
| 40 } | 50 } |
| 41 | 51 |
| 42 std::string RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( | 52 std::string RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( |
| 43 const MediaStreamTrackInterface& track) { | 53 const MediaStreamTrackInterface& track) { |
| 44 return "RTCMediaStreamTrack_" + track.id(); | 54 return "RTCMediaStreamTrack_" + track.id(); |
| 45 } | 55 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 case DataChannelInterface::kClosing: | 103 case DataChannelInterface::kClosing: |
| 94 return RTCDataChannelState::kClosing; | 104 return RTCDataChannelState::kClosing; |
| 95 case DataChannelInterface::kClosed: | 105 case DataChannelInterface::kClosed: |
| 96 return RTCDataChannelState::kClosed; | 106 return RTCDataChannelState::kClosed; |
| 97 default: | 107 default: |
| 98 RTC_NOTREACHED(); | 108 RTC_NOTREACHED(); |
| 99 return nullptr; | 109 return nullptr; |
| 100 } | 110 } |
| 101 } | 111 } |
| 102 | 112 |
| 113 std::unique_ptr<RTCCodecStats> CodecStatsFromRtpCodecParameters( | |
| 114 uint64_t timestamp_us, bool inbound, bool audio, | |
| 115 const RtpCodecParameters& codec_params) { | |
| 116 RTC_DCHECK_GE(codec_params.payload_type, 0); | |
| 117 RTC_DCHECK_LE(codec_params.payload_type, 127); | |
| 118 uint32_t payload_type = static_cast<uint32_t>(codec_params.payload_type); | |
| 119 std::unique_ptr<RTCCodecStats> codec_stats(new RTCCodecStats( | |
| 120 RTCCodecStatsIDFromDirectionTypeAndPayload(inbound, audio, payload_type), | |
| 121 timestamp_us)); | |
| 122 codec_stats->payload_type = payload_type; | |
| 123 codec_stats->codec = (audio ? "audio/" : "video/") + codec_params.mime_type; | |
| 124 codec_stats->clock_rate = static_cast<uint32_t>(codec_params.clock_rate); | |
| 125 return codec_stats; | |
| 126 } | |
| 127 | |
| 103 void SetMediaStreamTrackStatsFromMediaStreamTrackInterface( | 128 void SetMediaStreamTrackStatsFromMediaStreamTrackInterface( |
| 104 const MediaStreamTrackInterface& track, | 129 const MediaStreamTrackInterface& track, |
| 105 RTCMediaStreamTrackStats* track_stats) { | 130 RTCMediaStreamTrackStats* track_stats) { |
| 106 track_stats->track_identifier = track.id(); | 131 track_stats->track_identifier = track.id(); |
| 107 track_stats->ended = (track.state() == MediaStreamTrackInterface::kEnded); | 132 track_stats->ended = (track.state() == MediaStreamTrackInterface::kEnded); |
| 108 } | 133 } |
| 109 | 134 |
| 110 void SetInboundRTPStreamStatsFromMediaReceiverInfo( | 135 void SetInboundRTPStreamStatsFromMediaReceiverInfo( |
| 111 const cricket::MediaReceiverInfo& media_receiver_info, | 136 const cricket::MediaReceiverInfo& media_receiver_info, |
| 112 RTCInboundRTPStreamStats* inbound_stats) { | 137 RTCInboundRTPStreamStats* inbound_stats) { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 | 410 |
| 386 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( | 411 void RTCStatsCollector::ProducePartialResultsOnSignalingThread( |
| 387 int64_t timestamp_us) { | 412 int64_t timestamp_us) { |
| 388 RTC_DCHECK(signaling_thread_->IsCurrent()); | 413 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 389 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 414 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
| 390 timestamp_us); | 415 timestamp_us); |
| 391 | 416 |
| 392 SessionStats session_stats; | 417 SessionStats session_stats; |
| 393 if (pc_->session()->GetTransportStats(&session_stats)) { | 418 if (pc_->session()->GetTransportStats(&session_stats)) { |
| 394 std::map<std::string, CertificateStatsPair> transport_cert_stats = | 419 std::map<std::string, CertificateStatsPair> transport_cert_stats = |
| 395 PrepareTransportCertificateStats_s(session_stats); | 420 PrepareTransportCertificateStats(session_stats); |
| 421 MediaInfo media_info = PrepareMediaInfo(session_stats); | |
| 396 | 422 |
| 397 ProduceCertificateStats_s( | 423 ProduceCertificateStats_s( |
| 398 timestamp_us, transport_cert_stats, report.get()); | 424 timestamp_us, transport_cert_stats, report.get()); |
| 425 ProduceCodecStats_s( | |
| 426 timestamp_us, media_info, report.get()); | |
| 399 ProduceIceCandidateAndPairStats_s( | 427 ProduceIceCandidateAndPairStats_s( |
| 400 timestamp_us, session_stats, report.get()); | 428 timestamp_us, session_stats, report.get()); |
| 401 ProduceRTPStreamStats_s( | 429 ProduceRTPStreamStats_s( |
| 402 timestamp_us, session_stats, report.get()); | 430 timestamp_us, session_stats, media_info, report.get()); |
| 403 ProduceTransportStats_s( | 431 ProduceTransportStats_s( |
| 404 timestamp_us, session_stats, transport_cert_stats, report.get()); | 432 timestamp_us, session_stats, transport_cert_stats, report.get()); |
| 405 } | 433 } |
| 406 ProduceDataChannelStats_s(timestamp_us, report.get()); | 434 ProduceDataChannelStats_s(timestamp_us, report.get()); |
| 407 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); | 435 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); |
| 408 ProducePeerConnectionStats_s(timestamp_us, report.get()); | 436 ProducePeerConnectionStats_s(timestamp_us, report.get()); |
| 409 | 437 |
| 410 AddPartialResults(report); | 438 AddPartialResults(report); |
| 411 } | 439 } |
| 412 | 440 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 ProduceCertificateStatsFromSSLCertificateStats( | 522 ProduceCertificateStatsFromSSLCertificateStats( |
| 495 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); | 523 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); |
| 496 } | 524 } |
| 497 if (transport_cert_stats_pair.second.remote) { | 525 if (transport_cert_stats_pair.second.remote) { |
| 498 ProduceCertificateStatsFromSSLCertificateStats( | 526 ProduceCertificateStatsFromSSLCertificateStats( |
| 499 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); | 527 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); |
| 500 } | 528 } |
| 501 } | 529 } |
| 502 } | 530 } |
| 503 | 531 |
| 532 void RTCStatsCollector::ProduceCodecStats_s( | |
| 533 int64_t timestamp_us, const MediaInfo& media_info, | |
| 534 RTCStatsReport* report) const { | |
| 535 RTC_DCHECK(signaling_thread_->IsCurrent()); | |
| 536 // Audio | |
| 537 if (media_info.voice) { | |
| 538 // Inbound | |
| 539 for (const auto& pair : media_info.voice->receive_codecs) { | |
| 540 report->AddStats(CodecStatsFromRtpCodecParameters( | |
| 541 timestamp_us, true, true, pair.second)); | |
| 542 } | |
| 543 // Outbound | |
| 544 for (const auto& pair : media_info.voice->send_codecs) { | |
| 545 report->AddStats(CodecStatsFromRtpCodecParameters( | |
| 546 timestamp_us, false, true, pair.second)); | |
| 547 } | |
| 548 } | |
| 549 // Video | |
| 550 if (media_info.video) { | |
| 551 // Inbound | |
| 552 for (const auto& pair : media_info.video->receive_codecs) { | |
| 553 report->AddStats(CodecStatsFromRtpCodecParameters( | |
| 554 timestamp_us, true, false, pair.second)); | |
| 555 } | |
| 556 // Outbound | |
| 557 for (const auto& pair : media_info.video->send_codecs) { | |
| 558 report->AddStats(CodecStatsFromRtpCodecParameters( | |
| 559 timestamp_us, false, false, pair.second)); | |
| 560 } | |
| 561 } | |
| 562 } | |
| 563 | |
| 504 void RTCStatsCollector::ProduceDataChannelStats_s( | 564 void RTCStatsCollector::ProduceDataChannelStats_s( |
| 505 int64_t timestamp_us, RTCStatsReport* report) const { | 565 int64_t timestamp_us, RTCStatsReport* report) const { |
| 506 RTC_DCHECK(signaling_thread_->IsCurrent()); | 566 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 507 for (const rtc::scoped_refptr<DataChannel>& data_channel : | 567 for (const rtc::scoped_refptr<DataChannel>& data_channel : |
| 508 pc_->sctp_data_channels()) { | 568 pc_->sctp_data_channels()) { |
| 509 std::unique_ptr<RTCDataChannelStats> data_channel_stats( | 569 std::unique_ptr<RTCDataChannelStats> data_channel_stats( |
| 510 new RTCDataChannelStats( | 570 new RTCDataChannelStats( |
| 511 "RTCDataChannel_" + rtc::ToString<>(data_channel->id()), | 571 "RTCDataChannel_" + rtc::ToString<>(data_channel->id()), |
| 512 timestamp_us)); | 572 timestamp_us)); |
| 513 data_channel_stats->label = data_channel->label(); | 573 data_channel_stats->label = data_channel->label(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 RTC_DCHECK(signaling_thread_->IsCurrent()); | 645 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 586 std::unique_ptr<RTCPeerConnectionStats> stats( | 646 std::unique_ptr<RTCPeerConnectionStats> stats( |
| 587 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); | 647 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); |
| 588 stats->data_channels_opened = internal_record_.data_channels_opened; | 648 stats->data_channels_opened = internal_record_.data_channels_opened; |
| 589 stats->data_channels_closed = internal_record_.data_channels_closed; | 649 stats->data_channels_closed = internal_record_.data_channels_closed; |
| 590 report->AddStats(std::move(stats)); | 650 report->AddStats(std::move(stats)); |
| 591 } | 651 } |
| 592 | 652 |
| 593 void RTCStatsCollector::ProduceRTPStreamStats_s( | 653 void RTCStatsCollector::ProduceRTPStreamStats_s( |
| 594 int64_t timestamp_us, const SessionStats& session_stats, | 654 int64_t timestamp_us, const SessionStats& session_stats, |
| 595 RTCStatsReport* report) const { | 655 const MediaInfo& media_info, RTCStatsReport* report) const { |
| 596 RTC_DCHECK(signaling_thread_->IsCurrent()); | 656 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 597 | 657 |
| 598 // Audio | 658 // Audio |
| 599 if (pc_->session()->voice_channel()) { | 659 if (media_info.voice) { |
| 600 cricket::VoiceMediaInfo voice_media_info; | 660 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
| 601 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { | 661 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); |
| 602 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 662 RTC_DCHECK(!transport_id.empty()); |
| 603 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); | 663 // Inbound |
| 604 RTC_DCHECK(!transport_id.empty()); | 664 for (const cricket::VoiceReceiverInfo& voice_receiver_info : |
| 605 // Inbound | 665 media_info.voice->receivers) { |
| 606 for (const cricket::VoiceReceiverInfo& voice_receiver_info : | 666 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
| 607 voice_media_info.receivers) { | 667 // is fixed. |
| 608 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 668 if (voice_receiver_info.ssrc() == 0) |
| 609 // is fixed. | 669 continue; |
| 610 if (voice_receiver_info.ssrc() == 0) | 670 std::unique_ptr<RTCInboundRTPStreamStats> inbound_audio( |
| 611 continue; | 671 new RTCInboundRTPStreamStats( |
| 612 std::unique_ptr<RTCInboundRTPStreamStats> inbound_audio( | 672 RTCInboundRTPStreamStatsIDFromSSRC( |
| 613 new RTCInboundRTPStreamStats( | 673 true, voice_receiver_info.ssrc()), |
| 614 RTCInboundRTPStreamStatsIDFromSSRC( | 674 timestamp_us)); |
| 615 true, voice_receiver_info.ssrc()), | 675 SetInboundRTPStreamStatsFromVoiceReceiverInfo( |
| 616 timestamp_us)); | 676 voice_receiver_info, inbound_audio.get()); |
| 617 SetInboundRTPStreamStatsFromVoiceReceiverInfo( | 677 inbound_audio->transport_id = transport_id; |
| 618 voice_receiver_info, inbound_audio.get()); | 678 if (voice_receiver_info.codec_payload_type) { |
| 619 inbound_audio->transport_id = transport_id; | 679 inbound_audio->codec_id = |
| 620 report->AddStats(std::move(inbound_audio)); | 680 RTCCodecStatsIDFromDirectionTypeAndPayload( |
| 681 true, true, *voice_receiver_info.codec_payload_type); | |
| 621 } | 682 } |
| 622 // Outbound | 683 report->AddStats(std::move(inbound_audio)); |
| 623 for (const cricket::VoiceSenderInfo& voice_sender_info : | 684 } |
| 624 voice_media_info.senders) { | 685 // Outbound |
| 625 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 686 for (const cricket::VoiceSenderInfo& voice_sender_info : |
| 626 // is fixed. | 687 media_info.voice->senders) { |
| 627 if (voice_sender_info.ssrc() == 0) | 688 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
| 628 continue; | 689 // is fixed. |
| 629 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_audio( | 690 if (voice_sender_info.ssrc() == 0) |
| 630 new RTCOutboundRTPStreamStats( | 691 continue; |
| 631 RTCOutboundRTPStreamStatsIDFromSSRC( | 692 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_audio( |
| 632 true, voice_sender_info.ssrc()), | 693 new RTCOutboundRTPStreamStats( |
| 633 timestamp_us)); | 694 RTCOutboundRTPStreamStatsIDFromSSRC( |
| 634 SetOutboundRTPStreamStatsFromVoiceSenderInfo( | 695 true, voice_sender_info.ssrc()), |
| 635 voice_sender_info, outbound_audio.get()); | 696 timestamp_us)); |
| 636 outbound_audio->transport_id = transport_id; | 697 SetOutboundRTPStreamStatsFromVoiceSenderInfo( |
| 637 report->AddStats(std::move(outbound_audio)); | 698 voice_sender_info, outbound_audio.get()); |
| 699 outbound_audio->transport_id = transport_id; | |
| 700 if (voice_sender_info.codec_payload_type) { | |
| 701 outbound_audio->codec_id = | |
| 702 RTCCodecStatsIDFromDirectionTypeAndPayload( | |
| 703 false, true, *voice_sender_info.codec_payload_type); | |
| 638 } | 704 } |
| 705 report->AddStats(std::move(outbound_audio)); | |
| 639 } | 706 } |
| 640 } | 707 } |
| 641 // Video | 708 // Video |
| 642 if (pc_->session()->video_channel()) { | 709 if (media_info.video) { |
| 643 cricket::VideoMediaInfo video_media_info; | 710 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
| 644 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { | 711 session_stats.proxy_to_transport, *pc_->session()->video_channel()); |
| 645 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 712 RTC_DCHECK(!transport_id.empty()); |
| 646 session_stats.proxy_to_transport, *pc_->session()->video_channel()); | 713 // Inbound |
| 647 RTC_DCHECK(!transport_id.empty()); | 714 for (const cricket::VideoReceiverInfo& video_receiver_info : |
| 648 // Inbound | 715 media_info.video->receivers) { |
| 649 for (const cricket::VideoReceiverInfo& video_receiver_info : | 716 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
| 650 video_media_info.receivers) { | 717 // is fixed. |
| 651 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 718 if (video_receiver_info.ssrc() == 0) |
| 652 // is fixed. | 719 continue; |
| 653 if (video_receiver_info.ssrc() == 0) | 720 std::unique_ptr<RTCInboundRTPStreamStats> inbound_video( |
| 654 continue; | 721 new RTCInboundRTPStreamStats( |
| 655 std::unique_ptr<RTCInboundRTPStreamStats> inbound_video( | 722 RTCInboundRTPStreamStatsIDFromSSRC( |
| 656 new RTCInboundRTPStreamStats( | 723 false, video_receiver_info.ssrc()), |
| 657 RTCInboundRTPStreamStatsIDFromSSRC( | 724 timestamp_us)); |
| 658 false, video_receiver_info.ssrc()), | 725 SetInboundRTPStreamStatsFromVideoReceiverInfo( |
| 659 timestamp_us)); | 726 video_receiver_info, inbound_video.get()); |
| 660 SetInboundRTPStreamStatsFromVideoReceiverInfo( | 727 inbound_video->transport_id = transport_id; |
| 661 video_receiver_info, inbound_video.get()); | 728 if (video_receiver_info.codec_payload_type) { |
| 662 inbound_video->transport_id = transport_id; | 729 inbound_video->codec_id = |
| 663 report->AddStats(std::move(inbound_video)); | 730 RTCCodecStatsIDFromDirectionTypeAndPayload( |
| 731 true, false, *video_receiver_info.codec_payload_type); | |
|
hta-webrtc
2016/11/23 07:37:35
nit: this shows that the arguments to the call bec
hbos
2016/11/23 09:40:59
No enum is readily available, keeping as-is.
| |
| 664 } | 732 } |
| 665 // Outbound | 733 report->AddStats(std::move(inbound_video)); |
| 666 for (const cricket::VideoSenderInfo& video_sender_info : | 734 } |
| 667 video_media_info.senders) { | 735 // Outbound |
| 668 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 736 for (const cricket::VideoSenderInfo& video_sender_info : |
| 669 // is fixed. | 737 media_info.video->senders) { |
| 670 if (video_sender_info.ssrc() == 0) | 738 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
| 671 continue; | 739 // is fixed. |
| 672 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_video( | 740 if (video_sender_info.ssrc() == 0) |
| 673 new RTCOutboundRTPStreamStats( | 741 continue; |
| 674 RTCOutboundRTPStreamStatsIDFromSSRC( | 742 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_video( |
| 675 false, video_sender_info.ssrc()), | 743 new RTCOutboundRTPStreamStats( |
| 676 timestamp_us)); | 744 RTCOutboundRTPStreamStatsIDFromSSRC( |
| 677 SetOutboundRTPStreamStatsFromVideoSenderInfo( | 745 false, video_sender_info.ssrc()), |
| 678 video_sender_info, outbound_video.get()); | 746 timestamp_us)); |
| 679 outbound_video->transport_id = transport_id; | 747 SetOutboundRTPStreamStatsFromVideoSenderInfo( |
| 680 report->AddStats(std::move(outbound_video)); | 748 video_sender_info, outbound_video.get()); |
| 749 outbound_video->transport_id = transport_id; | |
| 750 if (video_sender_info.codec_payload_type) { | |
| 751 outbound_video->codec_id = | |
| 752 RTCCodecStatsIDFromDirectionTypeAndPayload( | |
| 753 false, false, *video_sender_info.codec_payload_type); | |
| 681 } | 754 } |
| 755 report->AddStats(std::move(outbound_video)); | |
| 682 } | 756 } |
| 683 } | 757 } |
| 684 } | 758 } |
| 685 | 759 |
| 686 void RTCStatsCollector::ProduceTransportStats_s( | 760 void RTCStatsCollector::ProduceTransportStats_s( |
| 687 int64_t timestamp_us, const SessionStats& session_stats, | 761 int64_t timestamp_us, const SessionStats& session_stats, |
| 688 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, | 762 const std::map<std::string, CertificateStatsPair>& transport_cert_stats, |
| 689 RTCStatsReport* report) const { | 763 RTCStatsReport* report) const { |
| 690 RTC_DCHECK(signaling_thread_->IsCurrent()); | 764 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 691 for (const auto& transport : session_stats.transport_stats) { | 765 for (const auto& transport : session_stats.transport_stats) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 if (!local_certificate_id.empty()) | 817 if (!local_certificate_id.empty()) |
| 744 transport_stats->local_certificate_id = local_certificate_id; | 818 transport_stats->local_certificate_id = local_certificate_id; |
| 745 if (!remote_certificate_id.empty()) | 819 if (!remote_certificate_id.empty()) |
| 746 transport_stats->remote_certificate_id = remote_certificate_id; | 820 transport_stats->remote_certificate_id = remote_certificate_id; |
| 747 report->AddStats(std::move(transport_stats)); | 821 report->AddStats(std::move(transport_stats)); |
| 748 } | 822 } |
| 749 } | 823 } |
| 750 } | 824 } |
| 751 | 825 |
| 752 std::map<std::string, RTCStatsCollector::CertificateStatsPair> | 826 std::map<std::string, RTCStatsCollector::CertificateStatsPair> |
| 753 RTCStatsCollector::PrepareTransportCertificateStats_s( | 827 RTCStatsCollector::PrepareTransportCertificateStats( |
| 754 const SessionStats& session_stats) const { | 828 const SessionStats& session_stats) const { |
| 755 RTC_DCHECK(signaling_thread_->IsCurrent()); | 829 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 756 std::map<std::string, CertificateStatsPair> transport_cert_stats; | 830 std::map<std::string, CertificateStatsPair> transport_cert_stats; |
| 757 for (const auto& transport_stats : session_stats.transport_stats) { | 831 for (const auto& transport_stats : session_stats.transport_stats) { |
| 758 CertificateStatsPair certificate_stats_pair; | 832 CertificateStatsPair certificate_stats_pair; |
| 759 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; | 833 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate; |
| 760 if (pc_->session()->GetLocalCertificate( | 834 if (pc_->session()->GetLocalCertificate( |
| 761 transport_stats.second.transport_name, &local_certificate)) { | 835 transport_stats.second.transport_name, &local_certificate)) { |
| 762 certificate_stats_pair.local = | 836 certificate_stats_pair.local = |
| 763 local_certificate->ssl_certificate().GetStats(); | 837 local_certificate->ssl_certificate().GetStats(); |
| 764 } | 838 } |
| 765 std::unique_ptr<rtc::SSLCertificate> remote_certificate = | 839 std::unique_ptr<rtc::SSLCertificate> remote_certificate = |
| 766 pc_->session()->GetRemoteSSLCertificate( | 840 pc_->session()->GetRemoteSSLCertificate( |
| 767 transport_stats.second.transport_name); | 841 transport_stats.second.transport_name); |
| 768 if (remote_certificate) { | 842 if (remote_certificate) { |
| 769 certificate_stats_pair.remote = remote_certificate->GetStats(); | 843 certificate_stats_pair.remote = remote_certificate->GetStats(); |
| 770 } | 844 } |
| 771 transport_cert_stats.insert( | 845 transport_cert_stats.insert( |
| 772 std::make_pair(transport_stats.second.transport_name, | 846 std::make_pair(transport_stats.second.transport_name, |
| 773 std::move(certificate_stats_pair))); | 847 std::move(certificate_stats_pair))); |
| 774 } | 848 } |
| 775 return transport_cert_stats; | 849 return transport_cert_stats; |
| 776 } | 850 } |
| 777 | 851 |
| 852 RTCStatsCollector::MediaInfo RTCStatsCollector::PrepareMediaInfo( | |
| 853 const SessionStats& session_stats) const { | |
| 854 MediaInfo media_info; | |
| 855 if (pc_->session()->voice_channel()) { | |
| 856 cricket::VoiceMediaInfo voice_media_info; | |
| 857 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { | |
| 858 media_info.voice = rtc::Optional<cricket::VoiceMediaInfo>( | |
| 859 std::move(voice_media_info)); | |
| 860 } | |
| 861 } | |
| 862 if (pc_->session()->video_channel()) { | |
| 863 cricket::VideoMediaInfo video_media_info; | |
| 864 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { | |
| 865 media_info.video = rtc::Optional<cricket::VideoMediaInfo>( | |
| 866 std::move(video_media_info)); | |
| 867 } | |
| 868 } | |
| 869 return media_info; | |
| 870 } | |
| 871 | |
| 778 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { | 872 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { |
| 779 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); | 873 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); |
| 780 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); | 874 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); |
| 781 } | 875 } |
| 782 | 876 |
| 783 void RTCStatsCollector::OnDataChannelOpened(DataChannel* channel) { | 877 void RTCStatsCollector::OnDataChannelOpened(DataChannel* channel) { |
| 784 RTC_DCHECK(signaling_thread_->IsCurrent()); | 878 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 785 bool result = internal_record_.opened_data_channels.insert( | 879 bool result = internal_record_.opened_data_channels.insert( |
| 786 reinterpret_cast<uintptr_t>(channel)).second; | 880 reinterpret_cast<uintptr_t>(channel)).second; |
| 787 ++internal_record_.data_channels_opened; | 881 ++internal_record_.data_channels_opened; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 803 const std::string& type) { | 897 const std::string& type) { |
| 804 return CandidateTypeToRTCIceCandidateType(type); | 898 return CandidateTypeToRTCIceCandidateType(type); |
| 805 } | 899 } |
| 806 | 900 |
| 807 const char* DataStateToRTCDataChannelStateForTesting( | 901 const char* DataStateToRTCDataChannelStateForTesting( |
| 808 DataChannelInterface::DataState state) { | 902 DataChannelInterface::DataState state) { |
| 809 return DataStateToRTCDataChannelState(state); | 903 return DataStateToRTCDataChannelState(state); |
| 810 } | 904 } |
| 811 | 905 |
| 812 } // namespace webrtc | 906 } // namespace webrtc |
| OLD | NEW |