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 // Prepare |call_stats_| here since GetCallStats() will hop to the worker |
| 656 // thread. |
| 657 // TODO(holmer): To avoid the hop we could move BWE and BWE stats to the |
| 658 // network thread, where it more naturally belongs. |
| 659 call_stats_ = pc_->session()->GetCallStats(); |
| 660 |
| 661 invoker_.AsyncInvoke<void>( |
| 662 RTC_FROM_HERE, network_thread_, |
656 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, | 663 rtc::Bind(&RTCStatsCollector::ProducePartialResultsOnNetworkThread, |
657 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); | 664 rtc::scoped_refptr<RTCStatsCollector>(this), timestamp_us)); |
658 ProducePartialResultsOnSignalingThread(timestamp_us); | 665 ProducePartialResultsOnSignalingThread(timestamp_us); |
659 } | 666 } |
660 } | 667 } |
661 | 668 |
662 void RTCStatsCollector::ClearCachedStatsReport() { | 669 void RTCStatsCollector::ClearCachedStatsReport() { |
663 RTC_DCHECK(signaling_thread_->IsCurrent()); | 670 RTC_DCHECK(signaling_thread_->IsCurrent()); |
664 cached_report_ = nullptr; | 671 cached_report_ = nullptr; |
665 } | 672 } |
666 | 673 |
667 void RTCStatsCollector::WaitForPendingRequest() { | 674 void RTCStatsCollector::WaitForPendingRequest() { |
(...skipping 29 matching lines...) Expand all Loading... |
697 std::unique_ptr<SessionStats> session_stats = | 704 std::unique_ptr<SessionStats> session_stats = |
698 pc_->session()->GetStats(*channel_name_pairs_); | 705 pc_->session()->GetStats(*channel_name_pairs_); |
699 if (session_stats) { | 706 if (session_stats) { |
700 std::map<std::string, CertificateStatsPair> transport_cert_stats = | 707 std::map<std::string, CertificateStatsPair> transport_cert_stats = |
701 PrepareTransportCertificateStats_n(*session_stats); | 708 PrepareTransportCertificateStats_n(*session_stats); |
702 | 709 |
703 ProduceCertificateStats_n( | 710 ProduceCertificateStats_n( |
704 timestamp_us, transport_cert_stats, report.get()); | 711 timestamp_us, transport_cert_stats, report.get()); |
705 ProduceCodecStats_n( | 712 ProduceCodecStats_n( |
706 timestamp_us, *track_media_info_map_, report.get()); | 713 timestamp_us, *track_media_info_map_, report.get()); |
707 ProduceIceCandidateAndPairStats_n( | 714 ProduceIceCandidateAndPairStats_n(timestamp_us, *session_stats, |
708 timestamp_us, *session_stats, track_media_info_map_->video_media_info(), | 715 track_media_info_map_->video_media_info(), |
709 report.get()); | 716 call_stats_, report.get()); |
710 ProduceRTPStreamStats_n( | 717 ProduceRTPStreamStats_n( |
711 timestamp_us, *session_stats, *track_media_info_map_, report.get()); | 718 timestamp_us, *session_stats, *track_media_info_map_, report.get()); |
712 ProduceTransportStats_n( | 719 ProduceTransportStats_n( |
713 timestamp_us, *session_stats, transport_cert_stats, report.get()); | 720 timestamp_us, *session_stats, transport_cert_stats, report.get()); |
714 } | 721 } |
715 | 722 |
716 AddPartialResults(report); | 723 AddPartialResults(report); |
717 } | 724 } |
718 | 725 |
719 void RTCStatsCollector::AddPartialResults( | 726 void RTCStatsCollector::AddPartialResults( |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 DataStateToRTCDataChannelState(data_channel->state()); | 835 DataStateToRTCDataChannelState(data_channel->state()); |
829 data_channel_stats->messages_sent = data_channel->messages_sent(); | 836 data_channel_stats->messages_sent = data_channel->messages_sent(); |
830 data_channel_stats->bytes_sent = data_channel->bytes_sent(); | 837 data_channel_stats->bytes_sent = data_channel->bytes_sent(); |
831 data_channel_stats->messages_received = data_channel->messages_received(); | 838 data_channel_stats->messages_received = data_channel->messages_received(); |
832 data_channel_stats->bytes_received = data_channel->bytes_received(); | 839 data_channel_stats->bytes_received = data_channel->bytes_received(); |
833 report->AddStats(std::move(data_channel_stats)); | 840 report->AddStats(std::move(data_channel_stats)); |
834 } | 841 } |
835 } | 842 } |
836 | 843 |
837 void RTCStatsCollector::ProduceIceCandidateAndPairStats_n( | 844 void RTCStatsCollector::ProduceIceCandidateAndPairStats_n( |
838 int64_t timestamp_us, const SessionStats& session_stats, | 845 int64_t timestamp_us, |
839 const cricket::VideoMediaInfo* video_media_info, | 846 const SessionStats& session_stats, |
840 RTCStatsReport* report) const { | 847 const cricket::VideoMediaInfo* video_media_info, |
| 848 const Call::Stats& call_stats, |
| 849 RTCStatsReport* report) const { |
841 RTC_DCHECK(network_thread_->IsCurrent()); | 850 RTC_DCHECK(network_thread_->IsCurrent()); |
842 for (const auto& transport_stats : session_stats.transport_stats) { | 851 for (const auto& transport_stats : session_stats.transport_stats) { |
843 for (const auto& channel_stats : transport_stats.second.channel_stats) { | 852 for (const auto& channel_stats : transport_stats.second.channel_stats) { |
844 std::string transport_id = RTCTransportStatsIDFromTransportChannel( | 853 std::string transport_id = RTCTransportStatsIDFromTransportChannel( |
845 transport_stats.second.transport_name, channel_stats.component); | 854 transport_stats.second.transport_name, channel_stats.component); |
846 for (const cricket::ConnectionInfo& info : | 855 for (const cricket::ConnectionInfo& info : |
847 channel_stats.connection_infos) { | 856 channel_stats.connection_infos) { |
848 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( | 857 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( |
849 new RTCIceCandidatePairStats( | 858 new RTCIceCandidatePairStats( |
850 RTCIceCandidatePairStatsIDFromConnectionInfo(info), | 859 RTCIceCandidatePairStatsIDFromConnectionInfo(info), |
(...skipping 21 matching lines...) Expand all Loading... |
872 candidate_pair_stats->bytes_received = | 881 candidate_pair_stats->bytes_received = |
873 static_cast<uint64_t>(info.recv_total_bytes); | 882 static_cast<uint64_t>(info.recv_total_bytes); |
874 candidate_pair_stats->total_round_trip_time = | 883 candidate_pair_stats->total_round_trip_time = |
875 static_cast<double>(info.total_round_trip_time_ms) / | 884 static_cast<double>(info.total_round_trip_time_ms) / |
876 rtc::kNumMillisecsPerSec; | 885 rtc::kNumMillisecsPerSec; |
877 if (info.current_round_trip_time_ms) { | 886 if (info.current_round_trip_time_ms) { |
878 candidate_pair_stats->current_round_trip_time = | 887 candidate_pair_stats->current_round_trip_time = |
879 static_cast<double>(*info.current_round_trip_time_ms) / | 888 static_cast<double>(*info.current_round_trip_time_ms) / |
880 rtc::kNumMillisecsPerSec; | 889 rtc::kNumMillisecsPerSec; |
881 } | 890 } |
882 if (info.best_connection && video_media_info && | 891 if (info.best_connection) { |
883 !video_media_info->bw_estimations.empty()) { | |
884 // The bandwidth estimations we have are for the selected candidate | 892 // The bandwidth estimations we have are for the selected candidate |
885 // pair ("info.best_connection"). | 893 // pair ("info.best_connection"). |
886 RTC_DCHECK_EQ(video_media_info->bw_estimations.size(), 1); | 894 RTC_DCHECK_GE(call_stats.send_bandwidth_bps, 0); |
887 RTC_DCHECK_GE( | 895 RTC_DCHECK_GE(call_stats.recv_bandwidth_bps, 0); |
888 video_media_info->bw_estimations[0].available_send_bandwidth, 0); | 896 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 = | 897 candidate_pair_stats->available_outgoing_bitrate = |
893 static_cast<double>(video_media_info->bw_estimations[0] | 898 static_cast<double>(call_stats.send_bandwidth_bps); |
894 .available_send_bandwidth); | |
895 } | 899 } |
896 if (video_media_info->bw_estimations[0].available_recv_bandwidth) { | 900 if (call_stats.recv_bandwidth_bps > 0) { |
897 candidate_pair_stats->available_incoming_bitrate = | 901 candidate_pair_stats->available_incoming_bitrate = |
898 static_cast<double>(video_media_info->bw_estimations[0] | 902 static_cast<double>(call_stats.recv_bandwidth_bps); |
899 .available_recv_bandwidth); | |
900 } | 903 } |
901 } | 904 } |
902 candidate_pair_stats->requests_received = | 905 candidate_pair_stats->requests_received = |
903 static_cast<uint64_t>(info.recv_ping_requests); | 906 static_cast<uint64_t>(info.recv_ping_requests); |
904 candidate_pair_stats->requests_sent = static_cast<uint64_t>( | 907 candidate_pair_stats->requests_sent = static_cast<uint64_t>( |
905 info.sent_ping_requests_before_first_response); | 908 info.sent_ping_requests_before_first_response); |
906 candidate_pair_stats->responses_received = | 909 candidate_pair_stats->responses_received = |
907 static_cast<uint64_t>(info.recv_ping_responses); | 910 static_cast<uint64_t>(info.recv_ping_responses); |
908 candidate_pair_stats->responses_sent = | 911 candidate_pair_stats->responses_sent = |
909 static_cast<uint64_t>(info.sent_ping_responses); | 912 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) { | 1248 const std::string& type) { |
1246 return CandidateTypeToRTCIceCandidateType(type); | 1249 return CandidateTypeToRTCIceCandidateType(type); |
1247 } | 1250 } |
1248 | 1251 |
1249 const char* DataStateToRTCDataChannelStateForTesting( | 1252 const char* DataStateToRTCDataChannelStateForTesting( |
1250 DataChannelInterface::DataState state) { | 1253 DataChannelInterface::DataState state) { |
1251 return DataStateToRTCDataChannelState(state); | 1254 return DataStateToRTCDataChannelState(state); |
1252 } | 1255 } |
1253 | 1256 |
1254 } // namespace webrtc | 1257 } // namespace webrtc |
OLD | NEW |