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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 : "RTCCodec_OutboundVideo_" + rtc::ToString<>(payload_type); | 47 : "RTCCodec_OutboundVideo_" + rtc::ToString<>(payload_type); |
48 } | 48 } |
49 | 49 |
50 std::string RTCIceCandidatePairStatsIDFromConnectionInfo( | 50 std::string RTCIceCandidatePairStatsIDFromConnectionInfo( |
51 const cricket::ConnectionInfo& info) { | 51 const cricket::ConnectionInfo& info) { |
52 return "RTCIceCandidatePair_" + info.local_candidate.id() + "_" + | 52 return "RTCIceCandidatePair_" + info.local_candidate.id() + "_" + |
53 info.remote_candidate.id(); | 53 info.remote_candidate.id(); |
54 } | 54 } |
55 | 55 |
56 std::string RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( | 56 std::string RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( |
57 const MediaStreamTrackInterface& track) { | 57 const MediaStreamTrackInterface& track, bool is_local) { |
58 return "RTCMediaStreamTrack_" + track.id(); | 58 return (is_local ? "RTCMediaStreamTrack_local_" + track.id() |
59 : "RTCMediaStreamTrack_remote_" + track.id()); | |
59 } | 60 } |
60 | 61 |
61 std::string RTCTransportStatsIDFromTransportChannel( | 62 std::string RTCTransportStatsIDFromTransportChannel( |
62 const std::string& transport_name, int channel_component) { | 63 const std::string& transport_name, int channel_component) { |
63 return "RTCTransport_" + transport_name + "_" + | 64 return "RTCTransport_" + transport_name + "_" + |
64 rtc::ToString<>(channel_component); | 65 rtc::ToString<>(channel_component); |
65 } | 66 } |
66 | 67 |
67 std::string RTCTransportStatsIDFromBaseChannel( | 68 std::string RTCTransportStatsIDFromBaseChannel( |
68 const ProxyTransportMap& proxy_to_transport, | 69 const ProxyTransportMap& proxy_to_transport, |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 std::unique_ptr<RTCMediaStreamStats> stream_stats( | 322 std::unique_ptr<RTCMediaStreamStats> stream_stats( |
322 new RTCMediaStreamStats( | 323 new RTCMediaStreamStats( |
323 (is_local ? "RTCMediaStream_local_" : "RTCMediaStream_remote_") + | 324 (is_local ? "RTCMediaStream_local_" : "RTCMediaStream_remote_") + |
324 stream->label(), timestamp_us)); | 325 stream->label(), timestamp_us)); |
325 stream_stats->stream_identifier = stream->label(); | 326 stream_stats->stream_identifier = stream->label(); |
326 stream_stats->track_ids = std::vector<std::string>(); | 327 stream_stats->track_ids = std::vector<std::string>(); |
327 // Audio Tracks | 328 // Audio Tracks |
328 for (const rtc::scoped_refptr<AudioTrackInterface>& audio_track : | 329 for (const rtc::scoped_refptr<AudioTrackInterface>& audio_track : |
329 stream->GetAudioTracks()) { | 330 stream->GetAudioTracks()) { |
330 std::string id = RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( | 331 std::string id = RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( |
331 *audio_track.get()); | 332 *audio_track.get(), is_local); |
332 if (report->Get(id)) { | 333 if (report->Get(id)) { |
333 // Skip track, stats already exist for it. | 334 // Skip track, stats already exist for it. |
334 continue; | 335 continue; |
335 } | 336 } |
336 std::unique_ptr<RTCMediaStreamTrackStats> audio_track_stats( | 337 std::unique_ptr<RTCMediaStreamTrackStats> audio_track_stats( |
337 new RTCMediaStreamTrackStats(id, timestamp_us)); | 338 new RTCMediaStreamTrackStats(id, timestamp_us)); |
338 stream_stats->track_ids->push_back(audio_track_stats->id()); | 339 stream_stats->track_ids->push_back(audio_track_stats->id()); |
339 SetMediaStreamTrackStatsFromMediaStreamTrackInterface( | 340 SetMediaStreamTrackStatsFromMediaStreamTrackInterface( |
340 *audio_track.get(), | 341 *audio_track.get(), |
341 audio_track_stats.get()); | 342 audio_track_stats.get()); |
(...skipping 17 matching lines...) Expand all Loading... | |
359 audio_track_stats->echo_return_loss_enhancement = static_cast<double>( | 360 audio_track_stats->echo_return_loss_enhancement = static_cast<double>( |
360 audio_processor_stats.echo_return_loss_enhancement); | 361 audio_processor_stats.echo_return_loss_enhancement); |
361 } | 362 } |
362 } | 363 } |
363 report->AddStats(std::move(audio_track_stats)); | 364 report->AddStats(std::move(audio_track_stats)); |
364 } | 365 } |
365 // Video Tracks | 366 // Video Tracks |
366 for (const rtc::scoped_refptr<VideoTrackInterface>& video_track : | 367 for (const rtc::scoped_refptr<VideoTrackInterface>& video_track : |
367 stream->GetVideoTracks()) { | 368 stream->GetVideoTracks()) { |
368 std::string id = RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( | 369 std::string id = RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( |
369 *video_track.get()); | 370 *video_track.get(), is_local); |
370 if (report->Get(id)) { | 371 if (report->Get(id)) { |
371 // Skip track, stats already exist for it. | 372 // Skip track, stats already exist for it. |
372 continue; | 373 continue; |
373 } | 374 } |
374 std::unique_ptr<RTCMediaStreamTrackStats> video_track_stats( | 375 std::unique_ptr<RTCMediaStreamTrackStats> video_track_stats( |
375 new RTCMediaStreamTrackStats(id, timestamp_us)); | 376 new RTCMediaStreamTrackStats(id, timestamp_us)); |
376 stream_stats->track_ids->push_back(video_track_stats->id()); | 377 stream_stats->track_ids->push_back(video_track_stats->id()); |
377 SetMediaStreamTrackStatsFromMediaStreamTrackInterface( | 378 SetMediaStreamTrackStatsFromMediaStreamTrackInterface( |
378 *video_track.get(), | 379 *video_track.get(), |
379 video_track_stats.get()); | 380 video_track_stats.get()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 // are no more pending partial reports. | 444 // are no more pending partial reports. |
444 | 445 |
445 // "Now" using a system clock, relative to the UNIX epoch (Jan 1, 1970, | 446 // "Now" using a system clock, relative to the UNIX epoch (Jan 1, 1970, |
446 // UTC), in microseconds. The system clock could be modified and is not | 447 // UTC), in microseconds. The system clock could be modified and is not |
447 // necessarily monotonically increasing. | 448 // necessarily monotonically increasing. |
448 int64_t timestamp_us = rtc::TimeUTCMicros(); | 449 int64_t timestamp_us = rtc::TimeUTCMicros(); |
449 | 450 |
450 num_pending_partial_reports_ = 2; | 451 num_pending_partial_reports_ = 2; |
451 partial_report_timestamp_us_ = cache_now_us; | 452 partial_report_timestamp_us_ = cache_now_us; |
452 | 453 |
453 // Prepare |channel_names_| and |media_info_| for use in | 454 // Prepare |channel_name_pairs_| for use in |
454 // |ProducePartialResultsOnNetworkThread|. | 455 // |ProducePartialResultsOnNetworkThread|. |
455 channel_name_pairs_.reset(new ChannelNamePairs()); | 456 channel_name_pairs_.reset(new ChannelNamePairs()); |
456 if (pc_->session()->voice_channel()) { | 457 if (pc_->session()->voice_channel()) { |
457 channel_name_pairs_->voice = rtc::Optional<ChannelNamePair>( | 458 channel_name_pairs_->voice = rtc::Optional<ChannelNamePair>( |
458 ChannelNamePair(pc_->session()->voice_channel()->content_name(), | 459 ChannelNamePair(pc_->session()->voice_channel()->content_name(), |
459 pc_->session()->voice_channel()->transport_name())); | 460 pc_->session()->voice_channel()->transport_name())); |
460 } | 461 } |
461 if (pc_->session()->video_channel()) { | 462 if (pc_->session()->video_channel()) { |
462 channel_name_pairs_->video = rtc::Optional<ChannelNamePair>( | 463 channel_name_pairs_->video = rtc::Optional<ChannelNamePair>( |
463 ChannelNamePair(pc_->session()->video_channel()->content_name(), | 464 ChannelNamePair(pc_->session()->video_channel()->content_name(), |
464 pc_->session()->video_channel()->transport_name())); | 465 pc_->session()->video_channel()->transport_name())); |
465 } | 466 } |
466 if (pc_->session()->data_channel()) { | 467 if (pc_->session()->data_channel()) { |
467 channel_name_pairs_->data = rtc::Optional<ChannelNamePair>( | 468 channel_name_pairs_->data = rtc::Optional<ChannelNamePair>( |
468 ChannelNamePair(pc_->session()->data_channel()->content_name(), | 469 ChannelNamePair(pc_->session()->data_channel()->content_name(), |
469 pc_->session()->data_channel()->transport_name())); | 470 pc_->session()->data_channel()->transport_name())); |
470 } | 471 } |
471 media_info_.reset(PrepareMediaInfo_s().release()); | 472 // Prepare |track_media_info_map_| for use in |
473 // |ProducePartialResultsOnNetworkThread| and | |
474 // |ProducePartialResultsOnSignalingThread|. | |
475 track_media_info_map_.reset(PrepareTrackMediaInfoMap_s().release()); | |
472 | 476 |
473 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, network_thread_, | 477 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, network_thread_, |
474 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, | 478 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, |
475 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); | 479 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); |
476 ProducePartialResultsOnSignalingThread(timestamp_us); | 480 ProducePartialResultsOnSignalingThread(timestamp_us); |
477 } | 481 } |
478 } | 482 } |
479 | 483 |
480 void RTCStatsCollector::ClearCachedStatsReport() { | 484 void RTCStatsCollector::ClearCachedStatsReport() { |
481 RTC_DCHECK(signaling_thread_->IsCurrent()); | 485 RTC_DCHECK(signaling_thread_->IsCurrent()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 | 518 |
515 std::unique_ptr<SessionStats> session_stats = | 519 std::unique_ptr<SessionStats> session_stats = |
516 pc_->session()->GetStats(*channel_name_pairs_); | 520 pc_->session()->GetStats(*channel_name_pairs_); |
517 if (session_stats) { | 521 if (session_stats) { |
518 std::map<std::string, CertificateStatsPair> transport_cert_stats = | 522 std::map<std::string, CertificateStatsPair> transport_cert_stats = |
519 PrepareTransportCertificateStats_n(*session_stats); | 523 PrepareTransportCertificateStats_n(*session_stats); |
520 | 524 |
521 ProduceCertificateStats_n( | 525 ProduceCertificateStats_n( |
522 timestamp_us, transport_cert_stats, report.get()); | 526 timestamp_us, transport_cert_stats, report.get()); |
523 ProduceCodecStats_n( | 527 ProduceCodecStats_n( |
524 timestamp_us, *media_info_, report.get()); | 528 timestamp_us, *track_media_info_map_, report.get()); |
525 ProduceIceCandidateAndPairStats_n( | 529 ProduceIceCandidateAndPairStats_n( |
526 timestamp_us, *session_stats, report.get()); | 530 timestamp_us, *session_stats, report.get()); |
527 ProduceRTPStreamStats_n( | 531 ProduceRTPStreamStats_n( |
528 timestamp_us, *session_stats, *media_info_, report.get()); | 532 timestamp_us, *session_stats, *track_media_info_map_, report.get()); |
529 ProduceTransportStats_n( | 533 ProduceTransportStats_n( |
530 timestamp_us, *session_stats, transport_cert_stats, report.get()); | 534 timestamp_us, *session_stats, transport_cert_stats, report.get()); |
531 } | 535 } |
532 | 536 |
533 AddPartialResults(report); | 537 AddPartialResults(report); |
534 } | 538 } |
535 | 539 |
536 void RTCStatsCollector::AddPartialResults( | 540 void RTCStatsCollector::AddPartialResults( |
537 const rtc::scoped_refptr<RTCStatsReport>& partial_report) { | 541 const rtc::scoped_refptr<RTCStatsReport>& partial_report) { |
538 if (!signaling_thread_->IsCurrent()) { | 542 if (!signaling_thread_->IsCurrent()) { |
(...skipping 12 matching lines...) Expand all Loading... | |
551 RTC_DCHECK_GT(num_pending_partial_reports_, 0); | 555 RTC_DCHECK_GT(num_pending_partial_reports_, 0); |
552 if (!partial_report_) | 556 if (!partial_report_) |
553 partial_report_ = partial_report; | 557 partial_report_ = partial_report; |
554 else | 558 else |
555 partial_report_->TakeMembersFrom(partial_report); | 559 partial_report_->TakeMembersFrom(partial_report); |
556 --num_pending_partial_reports_; | 560 --num_pending_partial_reports_; |
557 if (!num_pending_partial_reports_) { | 561 if (!num_pending_partial_reports_) { |
558 cache_timestamp_us_ = partial_report_timestamp_us_; | 562 cache_timestamp_us_ = partial_report_timestamp_us_; |
559 cached_report_ = partial_report_; | 563 cached_report_ = partial_report_; |
560 partial_report_ = nullptr; | 564 partial_report_ = nullptr; |
565 channel_name_pairs_.reset(); | |
566 track_media_info_map_.reset(); | |
561 DeliverCachedReport(); | 567 DeliverCachedReport(); |
562 } | 568 } |
563 } | 569 } |
564 | 570 |
565 void RTCStatsCollector::DeliverCachedReport() { | 571 void RTCStatsCollector::DeliverCachedReport() { |
566 RTC_DCHECK(signaling_thread_->IsCurrent()); | 572 RTC_DCHECK(signaling_thread_->IsCurrent()); |
567 RTC_DCHECK(!callbacks_.empty()); | 573 RTC_DCHECK(!callbacks_.empty()); |
568 RTC_DCHECK(cached_report_); | 574 RTC_DCHECK(cached_report_); |
569 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback : | 575 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback : |
570 callbacks_) { | 576 callbacks_) { |
(...skipping 13 matching lines...) Expand all Loading... | |
584 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); | 590 timestamp_us, *transport_cert_stats_pair.second.local.get(), report); |
585 } | 591 } |
586 if (transport_cert_stats_pair.second.remote) { | 592 if (transport_cert_stats_pair.second.remote) { |
587 ProduceCertificateStatsFromSSLCertificateStats( | 593 ProduceCertificateStatsFromSSLCertificateStats( |
588 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); | 594 timestamp_us, *transport_cert_stats_pair.second.remote.get(), report); |
589 } | 595 } |
590 } | 596 } |
591 } | 597 } |
592 | 598 |
593 void RTCStatsCollector::ProduceCodecStats_n( | 599 void RTCStatsCollector::ProduceCodecStats_n( |
594 int64_t timestamp_us, const MediaInfo& media_info, | 600 int64_t timestamp_us, const TrackMediaInfoMap& track_media_info_map, |
595 RTCStatsReport* report) const { | 601 RTCStatsReport* report) const { |
596 RTC_DCHECK(network_thread_->IsCurrent()); | 602 RTC_DCHECK(network_thread_->IsCurrent()); |
597 // Audio | 603 // Audio |
598 if (media_info.voice) { | 604 if (track_media_info_map.voice_media_info()) { |
599 // Inbound | 605 // Inbound |
600 for (const auto& pair : media_info.voice->receive_codecs) { | 606 for (const auto& pair : |
607 track_media_info_map.voice_media_info()->receive_codecs) { | |
601 report->AddStats(CodecStatsFromRtpCodecParameters( | 608 report->AddStats(CodecStatsFromRtpCodecParameters( |
602 timestamp_us, true, true, pair.second)); | 609 timestamp_us, true, true, pair.second)); |
603 } | 610 } |
604 // Outbound | 611 // Outbound |
605 for (const auto& pair : media_info.voice->send_codecs) { | 612 for (const auto& pair : |
613 track_media_info_map.voice_media_info()->send_codecs) { | |
606 report->AddStats(CodecStatsFromRtpCodecParameters( | 614 report->AddStats(CodecStatsFromRtpCodecParameters( |
607 timestamp_us, false, true, pair.second)); | 615 timestamp_us, false, true, pair.second)); |
608 } | 616 } |
609 } | 617 } |
610 // Video | 618 // Video |
611 if (media_info.video) { | 619 if (track_media_info_map.video_media_info()) { |
612 // Inbound | 620 // Inbound |
613 for (const auto& pair : media_info.video->receive_codecs) { | 621 for (const auto& pair : |
622 track_media_info_map.video_media_info()->receive_codecs) { | |
614 report->AddStats(CodecStatsFromRtpCodecParameters( | 623 report->AddStats(CodecStatsFromRtpCodecParameters( |
615 timestamp_us, true, false, pair.second)); | 624 timestamp_us, true, false, pair.second)); |
616 } | 625 } |
617 // Outbound | 626 // Outbound |
618 for (const auto& pair : media_info.video->send_codecs) { | 627 for (const auto& pair : |
628 track_media_info_map.video_media_info()->send_codecs) { | |
619 report->AddStats(CodecStatsFromRtpCodecParameters( | 629 report->AddStats(CodecStatsFromRtpCodecParameters( |
620 timestamp_us, false, false, pair.second)); | 630 timestamp_us, false, false, pair.second)); |
621 } | 631 } |
622 } | 632 } |
623 } | 633 } |
624 | 634 |
625 void RTCStatsCollector::ProduceDataChannelStats_s( | 635 void RTCStatsCollector::ProduceDataChannelStats_s( |
626 int64_t timestamp_us, RTCStatsReport* report) const { | 636 int64_t timestamp_us, RTCStatsReport* report) const { |
627 RTC_DCHECK(signaling_thread_->IsCurrent()); | 637 RTC_DCHECK(signaling_thread_->IsCurrent()); |
628 for (const rtc::scoped_refptr<DataChannel>& data_channel : | 638 for (const rtc::scoped_refptr<DataChannel>& data_channel : |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 RTC_DCHECK(signaling_thread_->IsCurrent()); | 728 RTC_DCHECK(signaling_thread_->IsCurrent()); |
719 std::unique_ptr<RTCPeerConnectionStats> stats( | 729 std::unique_ptr<RTCPeerConnectionStats> stats( |
720 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); | 730 new RTCPeerConnectionStats("RTCPeerConnection", timestamp_us)); |
721 stats->data_channels_opened = internal_record_.data_channels_opened; | 731 stats->data_channels_opened = internal_record_.data_channels_opened; |
722 stats->data_channels_closed = internal_record_.data_channels_closed; | 732 stats->data_channels_closed = internal_record_.data_channels_closed; |
723 report->AddStats(std::move(stats)); | 733 report->AddStats(std::move(stats)); |
724 } | 734 } |
725 | 735 |
726 void RTCStatsCollector::ProduceRTPStreamStats_n( | 736 void RTCStatsCollector::ProduceRTPStreamStats_n( |
727 int64_t timestamp_us, const SessionStats& session_stats, | 737 int64_t timestamp_us, const SessionStats& session_stats, |
728 const MediaInfo& media_info, RTCStatsReport* report) const { | 738 const TrackMediaInfoMap& track_media_info_map, |
739 RTCStatsReport* report) const { | |
729 RTC_DCHECK(network_thread_->IsCurrent()); | 740 RTC_DCHECK(network_thread_->IsCurrent()); |
730 | 741 |
731 // Audio | 742 // Audio |
732 if (media_info.voice) { | 743 if (track_media_info_map.voice_media_info()) { |
733 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 744 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
734 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); | 745 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); |
735 RTC_DCHECK(!transport_id.empty()); | 746 RTC_DCHECK(!transport_id.empty()); |
736 // Inbound | 747 // Inbound |
737 for (const cricket::VoiceReceiverInfo& voice_receiver_info : | 748 for (const cricket::VoiceReceiverInfo& voice_receiver_info : |
738 media_info.voice->receivers) { | 749 track_media_info_map.voice_media_info()->receivers) { |
739 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 750 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
740 // is fixed. | 751 // is fixed. |
741 if (voice_receiver_info.ssrc() == 0) | 752 if (voice_receiver_info.ssrc() == 0) |
742 continue; | 753 continue; |
743 std::unique_ptr<RTCInboundRTPStreamStats> inbound_audio( | 754 std::unique_ptr<RTCInboundRTPStreamStats> inbound_audio( |
744 new RTCInboundRTPStreamStats( | 755 new RTCInboundRTPStreamStats( |
745 RTCInboundRTPStreamStatsIDFromSSRC( | 756 RTCInboundRTPStreamStatsIDFromSSRC( |
746 true, voice_receiver_info.ssrc()), | 757 true, voice_receiver_info.ssrc()), |
747 timestamp_us)); | 758 timestamp_us)); |
748 SetInboundRTPStreamStatsFromVoiceReceiverInfo( | 759 SetInboundRTPStreamStatsFromVoiceReceiverInfo( |
749 voice_receiver_info, inbound_audio.get()); | 760 voice_receiver_info, inbound_audio.get()); |
761 rtc::scoped_refptr<AudioTrackInterface> audio_track = | |
762 track_media_info_map_->GetAudioTrack(voice_receiver_info); | |
763 RTC_DCHECK(audio_track); | |
764 inbound_audio->media_track_id = | |
765 RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( | |
766 *audio_track, false); | |
750 inbound_audio->transport_id = transport_id; | 767 inbound_audio->transport_id = transport_id; |
751 if (voice_receiver_info.codec_payload_type) { | 768 if (voice_receiver_info.codec_payload_type) { |
752 inbound_audio->codec_id = | 769 inbound_audio->codec_id = |
753 RTCCodecStatsIDFromDirectionMediaAndPayload( | 770 RTCCodecStatsIDFromDirectionMediaAndPayload( |
754 true, true, *voice_receiver_info.codec_payload_type); | 771 true, true, *voice_receiver_info.codec_payload_type); |
755 } | 772 } |
756 report->AddStats(std::move(inbound_audio)); | 773 report->AddStats(std::move(inbound_audio)); |
757 } | 774 } |
758 // Outbound | 775 // Outbound |
759 for (const cricket::VoiceSenderInfo& voice_sender_info : | 776 for (const cricket::VoiceSenderInfo& voice_sender_info : |
760 media_info.voice->senders) { | 777 track_media_info_map.voice_media_info()->senders) { |
761 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 778 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
762 // is fixed. | 779 // is fixed. |
763 if (voice_sender_info.ssrc() == 0) | 780 if (voice_sender_info.ssrc() == 0) |
764 continue; | 781 continue; |
765 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_audio( | 782 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_audio( |
766 new RTCOutboundRTPStreamStats( | 783 new RTCOutboundRTPStreamStats( |
767 RTCOutboundRTPStreamStatsIDFromSSRC( | 784 RTCOutboundRTPStreamStatsIDFromSSRC( |
768 true, voice_sender_info.ssrc()), | 785 true, voice_sender_info.ssrc()), |
769 timestamp_us)); | 786 timestamp_us)); |
770 SetOutboundRTPStreamStatsFromVoiceSenderInfo( | 787 SetOutboundRTPStreamStatsFromVoiceSenderInfo( |
771 voice_sender_info, outbound_audio.get()); | 788 voice_sender_info, outbound_audio.get()); |
789 rtc::scoped_refptr<AudioTrackInterface> audio_track = | |
790 track_media_info_map_->GetAudioTrack(voice_sender_info); | |
791 if (audio_track) { | |
792 outbound_audio->media_track_id = | |
793 RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( | |
794 *audio_track, true); | |
795 } | |
772 outbound_audio->transport_id = transport_id; | 796 outbound_audio->transport_id = transport_id; |
773 if (voice_sender_info.codec_payload_type) { | 797 if (voice_sender_info.codec_payload_type) { |
774 outbound_audio->codec_id = | 798 outbound_audio->codec_id = |
775 RTCCodecStatsIDFromDirectionMediaAndPayload( | 799 RTCCodecStatsIDFromDirectionMediaAndPayload( |
776 false, true, *voice_sender_info.codec_payload_type); | 800 false, true, *voice_sender_info.codec_payload_type); |
777 } | 801 } |
778 report->AddStats(std::move(outbound_audio)); | 802 report->AddStats(std::move(outbound_audio)); |
779 } | 803 } |
780 } | 804 } |
781 // Video | 805 // Video |
782 if (media_info.video) { | 806 if (track_media_info_map.video_media_info()) { |
783 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 807 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
784 session_stats.proxy_to_transport, *pc_->session()->video_channel()); | 808 session_stats.proxy_to_transport, *pc_->session()->video_channel()); |
785 RTC_DCHECK(!transport_id.empty()); | 809 RTC_DCHECK(!transport_id.empty()); |
786 // Inbound | 810 // Inbound |
787 for (const cricket::VideoReceiverInfo& video_receiver_info : | 811 for (const cricket::VideoReceiverInfo& video_receiver_info : |
788 media_info.video->receivers) { | 812 track_media_info_map.video_media_info()->receivers) { |
789 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 813 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
790 // is fixed. | 814 // is fixed. |
791 if (video_receiver_info.ssrc() == 0) | 815 if (video_receiver_info.ssrc() == 0) |
792 continue; | 816 continue; |
793 std::unique_ptr<RTCInboundRTPStreamStats> inbound_video( | 817 std::unique_ptr<RTCInboundRTPStreamStats> inbound_video( |
794 new RTCInboundRTPStreamStats( | 818 new RTCInboundRTPStreamStats( |
795 RTCInboundRTPStreamStatsIDFromSSRC( | 819 RTCInboundRTPStreamStatsIDFromSSRC( |
796 false, video_receiver_info.ssrc()), | 820 false, video_receiver_info.ssrc()), |
797 timestamp_us)); | 821 timestamp_us)); |
798 SetInboundRTPStreamStatsFromVideoReceiverInfo( | 822 SetInboundRTPStreamStatsFromVideoReceiverInfo( |
799 video_receiver_info, inbound_video.get()); | 823 video_receiver_info, inbound_video.get()); |
824 rtc::scoped_refptr<VideoTrackInterface> video_track = | |
825 track_media_info_map_->GetVideoTrack(video_receiver_info); | |
Taylor Brandstetter
2017/01/09 18:58:10
nit: If you add a DCHECK for remote audio tracks'
hbos
2017/01/10 09:34:09
Nice catch. Done.
| |
826 if (video_track) { | |
827 inbound_video->media_track_id = | |
828 RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( | |
829 *video_track, false); | |
830 } | |
800 inbound_video->transport_id = transport_id; | 831 inbound_video->transport_id = transport_id; |
801 if (video_receiver_info.codec_payload_type) { | 832 if (video_receiver_info.codec_payload_type) { |
802 inbound_video->codec_id = | 833 inbound_video->codec_id = |
803 RTCCodecStatsIDFromDirectionMediaAndPayload( | 834 RTCCodecStatsIDFromDirectionMediaAndPayload( |
804 true, false, *video_receiver_info.codec_payload_type); | 835 true, false, *video_receiver_info.codec_payload_type); |
805 } | 836 } |
806 report->AddStats(std::move(inbound_video)); | 837 report->AddStats(std::move(inbound_video)); |
807 } | 838 } |
808 // Outbound | 839 // Outbound |
809 for (const cricket::VideoSenderInfo& video_sender_info : | 840 for (const cricket::VideoSenderInfo& video_sender_info : |
810 media_info.video->senders) { | 841 track_media_info_map.video_media_info()->senders) { |
811 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 842 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
812 // is fixed. | 843 // is fixed. |
813 if (video_sender_info.ssrc() == 0) | 844 if (video_sender_info.ssrc() == 0) |
814 continue; | 845 continue; |
815 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_video( | 846 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_video( |
816 new RTCOutboundRTPStreamStats( | 847 new RTCOutboundRTPStreamStats( |
817 RTCOutboundRTPStreamStatsIDFromSSRC( | 848 RTCOutboundRTPStreamStatsIDFromSSRC( |
818 false, video_sender_info.ssrc()), | 849 false, video_sender_info.ssrc()), |
819 timestamp_us)); | 850 timestamp_us)); |
820 SetOutboundRTPStreamStatsFromVideoSenderInfo( | 851 SetOutboundRTPStreamStatsFromVideoSenderInfo( |
821 video_sender_info, outbound_video.get()); | 852 video_sender_info, outbound_video.get()); |
853 rtc::scoped_refptr<VideoTrackInterface> video_track = | |
854 track_media_info_map_->GetVideoTrack(video_sender_info); | |
855 if (video_track) { | |
856 outbound_video->media_track_id = | |
857 RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( | |
858 *video_track, true); | |
859 } | |
822 outbound_video->transport_id = transport_id; | 860 outbound_video->transport_id = transport_id; |
823 if (video_sender_info.codec_payload_type) { | 861 if (video_sender_info.codec_payload_type) { |
824 outbound_video->codec_id = | 862 outbound_video->codec_id = |
825 RTCCodecStatsIDFromDirectionMediaAndPayload( | 863 RTCCodecStatsIDFromDirectionMediaAndPayload( |
826 false, false, *video_sender_info.codec_payload_type); | 864 false, false, *video_sender_info.codec_payload_type); |
827 } | 865 } |
828 report->AddStats(std::move(outbound_video)); | 866 report->AddStats(std::move(outbound_video)); |
829 } | 867 } |
830 } | 868 } |
831 } | 869 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
915 if (remote_certificate) { | 953 if (remote_certificate) { |
916 certificate_stats_pair.remote = remote_certificate->GetStats(); | 954 certificate_stats_pair.remote = remote_certificate->GetStats(); |
917 } | 955 } |
918 transport_cert_stats.insert( | 956 transport_cert_stats.insert( |
919 std::make_pair(transport_stats.second.transport_name, | 957 std::make_pair(transport_stats.second.transport_name, |
920 std::move(certificate_stats_pair))); | 958 std::move(certificate_stats_pair))); |
921 } | 959 } |
922 return transport_cert_stats; | 960 return transport_cert_stats; |
923 } | 961 } |
924 | 962 |
925 std::unique_ptr<RTCStatsCollector::MediaInfo> | 963 std::unique_ptr<TrackMediaInfoMap> |
926 RTCStatsCollector::PrepareMediaInfo_s() const { | 964 RTCStatsCollector::PrepareTrackMediaInfoMap_s() const { |
927 RTC_DCHECK(signaling_thread_->IsCurrent()); | 965 RTC_DCHECK(signaling_thread_->IsCurrent()); |
928 std::unique_ptr<MediaInfo> media_info(new MediaInfo()); | 966 std::unique_ptr<cricket::VoiceMediaInfo> voice_media_info; |
929 if (pc_->session()->voice_channel()) { | 967 if (pc_->session()->voice_channel()) { |
930 cricket::VoiceMediaInfo voice_media_info; | 968 voice_media_info.reset(new cricket::VoiceMediaInfo()); |
931 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { | 969 if (!pc_->session()->voice_channel()->GetStats(voice_media_info.get())) { |
932 media_info->voice = rtc::Optional<cricket::VoiceMediaInfo>( | 970 voice_media_info.reset(); |
933 std::move(voice_media_info)); | |
934 } | 971 } |
935 } | 972 } |
973 std::unique_ptr<cricket::VideoMediaInfo> video_media_info; | |
936 if (pc_->session()->video_channel()) { | 974 if (pc_->session()->video_channel()) { |
937 cricket::VideoMediaInfo video_media_info; | 975 video_media_info.reset(new cricket::VideoMediaInfo()); |
938 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { | 976 if (!pc_->session()->video_channel()->GetStats(video_media_info.get())) { |
939 media_info->video = rtc::Optional<cricket::VideoMediaInfo>( | 977 video_media_info.reset(); |
940 std::move(video_media_info)); | |
941 } | 978 } |
942 } | 979 } |
943 return media_info; | 980 std::unique_ptr<TrackMediaInfoMap> track_media_info_map( |
981 new TrackMediaInfoMap(std::move(voice_media_info), | |
982 std::move(video_media_info), | |
983 pc_->GetSenders(), | |
984 pc_->GetReceivers())); | |
985 return track_media_info_map; | |
944 } | 986 } |
945 | 987 |
946 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { | 988 void RTCStatsCollector::OnDataChannelCreated(DataChannel* channel) { |
947 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); | 989 channel->SignalOpened.connect(this, &RTCStatsCollector::OnDataChannelOpened); |
948 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); | 990 channel->SignalClosed.connect(this, &RTCStatsCollector::OnDataChannelClosed); |
949 } | 991 } |
950 | 992 |
951 void RTCStatsCollector::OnDataChannelOpened(DataChannel* channel) { | 993 void RTCStatsCollector::OnDataChannelOpened(DataChannel* channel) { |
952 RTC_DCHECK(signaling_thread_->IsCurrent()); | 994 RTC_DCHECK(signaling_thread_->IsCurrent()); |
953 bool result = internal_record_.opened_data_channels.insert( | 995 bool result = internal_record_.opened_data_channels.insert( |
(...skipping 17 matching lines...) Expand all Loading... | |
971 const std::string& type) { | 1013 const std::string& type) { |
972 return CandidateTypeToRTCIceCandidateType(type); | 1014 return CandidateTypeToRTCIceCandidateType(type); |
973 } | 1015 } |
974 | 1016 |
975 const char* DataStateToRTCDataChannelStateForTesting( | 1017 const char* DataStateToRTCDataChannelStateForTesting( |
976 DataChannelInterface::DataState state) { | 1018 DataChannelInterface::DataState state) { |
977 return DataStateToRTCDataChannelState(state); | 1019 return DataStateToRTCDataChannelState(state); |
978 } | 1020 } |
979 | 1021 |
980 } // namespace webrtc | 1022 } // namespace webrtc |
OLD | NEW |