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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 } | 645 } |
646 // Prepare |track_media_info_map_| for use in | 646 // Prepare |track_media_info_map_| for use in |
647 // |ProducePartialResultsOnNetworkThread| and | 647 // |ProducePartialResultsOnNetworkThread| and |
648 // |ProducePartialResultsOnSignalingThread|. | 648 // |ProducePartialResultsOnSignalingThread|. |
649 track_media_info_map_.reset(PrepareTrackMediaInfoMap_s().release()); | 649 track_media_info_map_.reset(PrepareTrackMediaInfoMap_s().release()); |
650 // Prepare |track_to_id_| for use in |ProducePartialResultsOnNetworkThread|. | 650 // Prepare |track_to_id_| for use in |ProducePartialResultsOnNetworkThread|. |
651 // This avoids a possible deadlock if |MediaStreamTrackInterface::id| is | 651 // This avoids a possible deadlock if |MediaStreamTrackInterface::id| is |
652 // implemented to invoke on the signaling thread. | 652 // implemented to invoke on the signaling thread. |
653 track_to_id_ = PrepareTrackToID_s(); | 653 track_to_id_ = PrepareTrackToID_s(); |
654 | 654 |
655 invoker_.AsyncInvoke<void>(RTC_FROM_HERE, network_thread_, | 655 Call::Stats call_stats = pc_->session()->GetCallStats(); |
Taylor Brandstetter
2017/05/31 17:50:28
This is still resulting in a new, blocking worker
hbos
2017/06/01 11:40:39
Yes, add a TODO.
Other things that are prepared h
| |
656 | |
657 invoker_.AsyncInvoke<void>( | |
658 RTC_FROM_HERE, network_thread_, | |
656 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, | 659 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, |
657 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); | 660 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us, |
661 call_stats)); | |
658 ProducePartialResultsOnSignalingThread(timestamp_us); | 662 ProducePartialResultsOnSignalingThread(timestamp_us); |
659 } | 663 } |
660 } | 664 } |
661 | 665 |
662 void RTCStatsCollector::ClearCachedStatsReport() { | 666 void RTCStatsCollector::ClearCachedStatsReport() { |
663 RTC_DCHECK(signaling_thread_->IsCurrent()); | 667 RTC_DCHECK(signaling_thread_->IsCurrent()); |
664 cached_report_ = nullptr; | 668 cached_report_ = nullptr; |
665 } | 669 } |
666 | 670 |
667 void RTCStatsCollector::WaitForPendingRequest() { | 671 void RTCStatsCollector::WaitForPendingRequest() { |
(...skipping 14 matching lines...) Expand all Loading... | |
682 timestamp_us); | 686 timestamp_us); |
683 | 687 |
684 ProduceDataChannelStats_s(timestamp_us, report.get()); | 688 ProduceDataChannelStats_s(timestamp_us, report.get()); |
685 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); | 689 ProduceMediaStreamAndTrackStats_s(timestamp_us, report.get()); |
686 ProducePeerConnectionStats_s(timestamp_us, report.get()); | 690 ProducePeerConnectionStats_s(timestamp_us, report.get()); |
687 | 691 |
688 AddPartialResults(report); | 692 AddPartialResults(report); |
689 } | 693 } |
690 | 694 |
691 void RTCStatsCollector::ProducePartialResultsOnNetworkThread( | 695 void RTCStatsCollector::ProducePartialResultsOnNetworkThread( |
692 int64_t timestamp_us) { | 696 int64_t timestamp_us, |
697 const Call::Stats& call_stats) { | |
693 RTC_DCHECK(network_thread_->IsCurrent()); | 698 RTC_DCHECK(network_thread_->IsCurrent()); |
694 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( | 699 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( |
695 timestamp_us); | 700 timestamp_us); |
696 | 701 |
697 std::unique_ptr<SessionStats> session_stats = | 702 std::unique_ptr<SessionStats> session_stats = |
698 pc_->session()->GetStats(*channel_name_pairs_); | 703 pc_->session()->GetStats(*channel_name_pairs_); |
699 if (session_stats) { | 704 if (session_stats) { |
700 std::map<std::string, CertificateStatsPair> transport_cert_stats = | 705 std::map<std::string, CertificateStatsPair> transport_cert_stats = |
701 PrepareTransportCertificateStats_n(*session_stats); | 706 PrepareTransportCertificateStats_n(*session_stats); |
702 | 707 |
703 ProduceCertificateStats_n( | 708 ProduceCertificateStats_n( |
704 timestamp_us, transport_cert_stats, report.get()); | 709 timestamp_us, transport_cert_stats, report.get()); |
705 ProduceCodecStats_n( | 710 ProduceCodecStats_n( |
706 timestamp_us, *track_media_info_map_, report.get()); | 711 timestamp_us, *track_media_info_map_, report.get()); |
707 ProduceIceCandidateAndPairStats_n( | 712 ProduceIceCandidateAndPairStats_n(timestamp_us, *session_stats, |
708 timestamp_us, *session_stats, track_media_info_map_->video_media_info(), | 713 track_media_info_map_->video_media_info(), |
709 report.get()); | 714 call_stats, report.get()); |
710 ProduceRTPStreamStats_n( | 715 ProduceRTPStreamStats_n( |
711 timestamp_us, *session_stats, *track_media_info_map_, report.get()); | 716 timestamp_us, *session_stats, *track_media_info_map_, report.get()); |
712 ProduceTransportStats_n( | 717 ProduceTransportStats_n( |
713 timestamp_us, *session_stats, transport_cert_stats, report.get()); | 718 timestamp_us, *session_stats, transport_cert_stats, report.get()); |
714 } | 719 } |
715 | 720 |
716 AddPartialResults(report); | 721 AddPartialResults(report); |
717 } | 722 } |
718 | 723 |
719 void RTCStatsCollector::AddPartialResults( | 724 void RTCStatsCollector::AddPartialResults( |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
828 DataStateToRTCDataChannelState(data_channel->state()); | 833 DataStateToRTCDataChannelState(data_channel->state()); |
829 data_channel_stats->messages_sent = data_channel->messages_sent(); | 834 data_channel_stats->messages_sent = data_channel->messages_sent(); |
830 data_channel_stats->bytes_sent = data_channel->bytes_sent(); | 835 data_channel_stats->bytes_sent = data_channel->bytes_sent(); |
831 data_channel_stats->messages_received = data_channel->messages_received(); | 836 data_channel_stats->messages_received = data_channel->messages_received(); |
832 data_channel_stats->bytes_received = data_channel->bytes_received(); | 837 data_channel_stats->bytes_received = data_channel->bytes_received(); |
833 report->AddStats(std::move(data_channel_stats)); | 838 report->AddStats(std::move(data_channel_stats)); |
834 } | 839 } |
835 } | 840 } |
836 | 841 |
837 void RTCStatsCollector::ProduceIceCandidateAndPairStats_n( | 842 void RTCStatsCollector::ProduceIceCandidateAndPairStats_n( |
838 int64_t timestamp_us, const SessionStats& session_stats, | 843 int64_t timestamp_us, |
839 const cricket::VideoMediaInfo* video_media_info, | 844 const SessionStats& session_stats, |
840 RTCStatsReport* report) const { | 845 const cricket::VideoMediaInfo* video_media_info, |
846 const Call::Stats& call_stats, | |
847 RTCStatsReport* report) const { | |
841 RTC_DCHECK(network_thread_->IsCurrent()); | 848 RTC_DCHECK(network_thread_->IsCurrent()); |
842 for (const auto& transport_stats : session_stats.transport_stats) { | 849 for (const auto& transport_stats : session_stats.transport_stats) { |
843 for (const auto& channel_stats : transport_stats.second.channel_stats) { | 850 for (const auto& channel_stats : transport_stats.second.channel_stats) { |
844 std::string transport_id = RTCTransportStatsIDFromTransportChannel( | 851 std::string transport_id = RTCTransportStatsIDFromTransportChannel( |
845 transport_stats.second.transport_name, channel_stats.component); | 852 transport_stats.second.transport_name, channel_stats.component); |
846 for (const cricket::ConnectionInfo& info : | 853 for (const cricket::ConnectionInfo& info : |
847 channel_stats.connection_infos) { | 854 channel_stats.connection_infos) { |
848 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( | 855 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( |
849 new RTCIceCandidatePairStats( | 856 new RTCIceCandidatePairStats( |
850 RTCIceCandidatePairStatsIDFromConnectionInfo(info), | 857 RTCIceCandidatePairStatsIDFromConnectionInfo(info), |
(...skipping 21 matching lines...) Expand all Loading... | |
872 candidate_pair_stats->bytes_received = | 879 candidate_pair_stats->bytes_received = |
873 static_cast<uint64_t>(info.recv_total_bytes); | 880 static_cast<uint64_t>(info.recv_total_bytes); |
874 candidate_pair_stats->total_round_trip_time = | 881 candidate_pair_stats->total_round_trip_time = |
875 static_cast<double>(info.total_round_trip_time_ms) / | 882 static_cast<double>(info.total_round_trip_time_ms) / |
876 rtc::kNumMillisecsPerSec; | 883 rtc::kNumMillisecsPerSec; |
877 if (info.current_round_trip_time_ms) { | 884 if (info.current_round_trip_time_ms) { |
878 candidate_pair_stats->current_round_trip_time = | 885 candidate_pair_stats->current_round_trip_time = |
879 static_cast<double>(*info.current_round_trip_time_ms) / | 886 static_cast<double>(*info.current_round_trip_time_ms) / |
880 rtc::kNumMillisecsPerSec; | 887 rtc::kNumMillisecsPerSec; |
881 } | 888 } |
882 if (info.best_connection && video_media_info && | 889 if (info.best_connection) { |
883 !video_media_info->bw_estimations.empty()) { | |
884 // The bandwidth estimations we have are for the selected candidate | 890 // The bandwidth estimations we have are for the selected candidate |
885 // pair ("info.best_connection"). | 891 // pair ("info.best_connection"). |
886 RTC_DCHECK_EQ(video_media_info->bw_estimations.size(), 1); | 892 RTC_DCHECK_GE(call_stats.send_bandwidth_bps, 0); |
887 RTC_DCHECK_GE( | 893 RTC_DCHECK_GE(call_stats.recv_bandwidth_bps, 0); |
888 video_media_info->bw_estimations[0].available_send_bandwidth, 0); | 894 if (call_stats.send_bandwidth_bps > 0) { |
889 RTC_DCHECK_GE( | |
890 video_media_info->bw_estimations[0].available_recv_bandwidth, 0); | |
891 if (video_media_info->bw_estimations[0].available_send_bandwidth) { | |
892 candidate_pair_stats->available_outgoing_bitrate = | 895 candidate_pair_stats->available_outgoing_bitrate = |
893 static_cast<double>(video_media_info->bw_estimations[0] | 896 static_cast<double>(call_stats.send_bandwidth_bps); |
894 .available_send_bandwidth); | |
895 } | 897 } |
896 if (video_media_info->bw_estimations[0].available_recv_bandwidth) { | 898 if (call_stats.recv_bandwidth_bps > 0) { |
897 candidate_pair_stats->available_incoming_bitrate = | 899 candidate_pair_stats->available_incoming_bitrate = |
898 static_cast<double>(video_media_info->bw_estimations[0] | 900 static_cast<double>(call_stats.recv_bandwidth_bps); |
899 .available_recv_bandwidth); | |
900 } | 901 } |
901 } | 902 } |
902 candidate_pair_stats->requests_received = | 903 candidate_pair_stats->requests_received = |
903 static_cast<uint64_t>(info.recv_ping_requests); | 904 static_cast<uint64_t>(info.recv_ping_requests); |
904 candidate_pair_stats->requests_sent = static_cast<uint64_t>( | 905 candidate_pair_stats->requests_sent = static_cast<uint64_t>( |
905 info.sent_ping_requests_before_first_response); | 906 info.sent_ping_requests_before_first_response); |
906 candidate_pair_stats->responses_received = | 907 candidate_pair_stats->responses_received = |
907 static_cast<uint64_t>(info.recv_ping_responses); | 908 static_cast<uint64_t>(info.recv_ping_responses); |
908 candidate_pair_stats->responses_sent = | 909 candidate_pair_stats->responses_sent = |
909 static_cast<uint64_t>(info.sent_ping_responses); | 910 static_cast<uint64_t>(info.sent_ping_responses); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1245 const std::string& type) { | 1246 const std::string& type) { |
1246 return CandidateTypeToRTCIceCandidateType(type); | 1247 return CandidateTypeToRTCIceCandidateType(type); |
1247 } | 1248 } |
1248 | 1249 |
1249 const char* DataStateToRTCDataChannelStateForTesting( | 1250 const char* DataStateToRTCDataChannelStateForTesting( |
1250 DataChannelInterface::DataState state) { | 1251 DataChannelInterface::DataState state) { |
1251 return DataStateToRTCDataChannelState(state); | 1252 return DataStateToRTCDataChannelState(state); |
1252 } | 1253 } |
1253 | 1254 |
1254 } // namespace webrtc | 1255 } // namespace webrtc |
OLD | NEW |