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