Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: webrtc/pc/rtcstatscollector.cc

Issue 2863123002: Wire up BWE stats through WebrtcSession so that they are filled in both for audio and video calls. (Closed)
Patch Set: Comments addressed, generalized InvokeOnWorker(). Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 689 }
690 690
691 void RTCStatsCollector::ProducePartialResultsOnNetworkThread( 691 void RTCStatsCollector::ProducePartialResultsOnNetworkThread(
692 int64_t timestamp_us) { 692 int64_t timestamp_us) {
693 RTC_DCHECK(network_thread_->IsCurrent()); 693 RTC_DCHECK(network_thread_->IsCurrent());
694 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create( 694 rtc::scoped_refptr<RTCStatsReport> report = RTCStatsReport::Create(
695 timestamp_us); 695 timestamp_us);
696 696
697 std::unique_ptr<SessionStats> session_stats = 697 std::unique_ptr<SessionStats> session_stats =
698 pc_->session()->GetStats(*channel_name_pairs_); 698 pc_->session()->GetStats(*channel_name_pairs_);
699 Call::Stats call_stats = pc_->session()->GetCallStats();
hbos 2017/05/09 12:48:14 Is this OK? Here we are on the worker thread, but
holmer 2017/05/30 14:44:28 Made sure the necessary thread hop is done.
699 if (session_stats) { 700 if (session_stats) {
700 std::map<std::string, CertificateStatsPair> transport_cert_stats = 701 std::map<std::string, CertificateStatsPair> transport_cert_stats =
701 PrepareTransportCertificateStats_n(*session_stats); 702 PrepareTransportCertificateStats_n(*session_stats);
702 703
703 ProduceCertificateStats_n( 704 ProduceCertificateStats_n(
704 timestamp_us, transport_cert_stats, report.get()); 705 timestamp_us, transport_cert_stats, report.get());
705 ProduceCodecStats_n( 706 ProduceCodecStats_n(
706 timestamp_us, *track_media_info_map_, report.get()); 707 timestamp_us, *track_media_info_map_, report.get());
707 ProduceIceCandidateAndPairStats_n( 708 ProduceIceCandidateAndPairStats_n(timestamp_us, *session_stats,
708 timestamp_us, *session_stats, track_media_info_map_->video_media_info(), 709 track_media_info_map_->video_media_info(),
709 report.get()); 710 call_stats, report.get());
710 ProduceRTPStreamStats_n( 711 ProduceRTPStreamStats_n(
711 timestamp_us, *session_stats, *track_media_info_map_, report.get()); 712 timestamp_us, *session_stats, *track_media_info_map_, report.get());
712 ProduceTransportStats_n( 713 ProduceTransportStats_n(
713 timestamp_us, *session_stats, transport_cert_stats, report.get()); 714 timestamp_us, *session_stats, transport_cert_stats, report.get());
714 } 715 }
715 716
716 AddPartialResults(report); 717 AddPartialResults(report);
717 } 718 }
718 719
719 void RTCStatsCollector::AddPartialResults( 720 void RTCStatsCollector::AddPartialResults(
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 DataStateToRTCDataChannelState(data_channel->state()); 829 DataStateToRTCDataChannelState(data_channel->state());
829 data_channel_stats->messages_sent = data_channel->messages_sent(); 830 data_channel_stats->messages_sent = data_channel->messages_sent();
830 data_channel_stats->bytes_sent = data_channel->bytes_sent(); 831 data_channel_stats->bytes_sent = data_channel->bytes_sent();
831 data_channel_stats->messages_received = data_channel->messages_received(); 832 data_channel_stats->messages_received = data_channel->messages_received();
832 data_channel_stats->bytes_received = data_channel->bytes_received(); 833 data_channel_stats->bytes_received = data_channel->bytes_received();
833 report->AddStats(std::move(data_channel_stats)); 834 report->AddStats(std::move(data_channel_stats));
834 } 835 }
835 } 836 }
836 837
837 void RTCStatsCollector::ProduceIceCandidateAndPairStats_n( 838 void RTCStatsCollector::ProduceIceCandidateAndPairStats_n(
838 int64_t timestamp_us, const SessionStats& session_stats, 839 int64_t timestamp_us,
839 const cricket::VideoMediaInfo* video_media_info, 840 const SessionStats& session_stats,
840 RTCStatsReport* report) const { 841 const cricket::VideoMediaInfo* video_media_info,
842 const Call::Stats& call_stats,
843 RTCStatsReport* report) const {
841 RTC_DCHECK(network_thread_->IsCurrent()); 844 RTC_DCHECK(network_thread_->IsCurrent());
842 for (const auto& transport_stats : session_stats.transport_stats) { 845 for (const auto& transport_stats : session_stats.transport_stats) {
843 for (const auto& channel_stats : transport_stats.second.channel_stats) { 846 for (const auto& channel_stats : transport_stats.second.channel_stats) {
844 std::string transport_id = RTCTransportStatsIDFromTransportChannel( 847 std::string transport_id = RTCTransportStatsIDFromTransportChannel(
845 transport_stats.second.transport_name, channel_stats.component); 848 transport_stats.second.transport_name, channel_stats.component);
846 for (const cricket::ConnectionInfo& info : 849 for (const cricket::ConnectionInfo& info :
847 channel_stats.connection_infos) { 850 channel_stats.connection_infos) {
848 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats( 851 std::unique_ptr<RTCIceCandidatePairStats> candidate_pair_stats(
849 new RTCIceCandidatePairStats( 852 new RTCIceCandidatePairStats(
850 RTCIceCandidatePairStatsIDFromConnectionInfo(info), 853 RTCIceCandidatePairStatsIDFromConnectionInfo(info),
(...skipping 21 matching lines...) Expand all
872 candidate_pair_stats->bytes_received = 875 candidate_pair_stats->bytes_received =
873 static_cast<uint64_t>(info.recv_total_bytes); 876 static_cast<uint64_t>(info.recv_total_bytes);
874 candidate_pair_stats->total_round_trip_time = 877 candidate_pair_stats->total_round_trip_time =
875 static_cast<double>(info.total_round_trip_time_ms) / 878 static_cast<double>(info.total_round_trip_time_ms) /
876 rtc::kNumMillisecsPerSec; 879 rtc::kNumMillisecsPerSec;
877 if (info.current_round_trip_time_ms) { 880 if (info.current_round_trip_time_ms) {
878 candidate_pair_stats->current_round_trip_time = 881 candidate_pair_stats->current_round_trip_time =
879 static_cast<double>(*info.current_round_trip_time_ms) / 882 static_cast<double>(*info.current_round_trip_time_ms) /
880 rtc::kNumMillisecsPerSec; 883 rtc::kNumMillisecsPerSec;
881 } 884 }
882 if (info.best_connection && video_media_info && 885 if (info.best_connection) {
883 !video_media_info->bw_estimations.empty()) {
884 // The bandwidth estimations we have are for the selected candidate 886 // The bandwidth estimations we have are for the selected candidate
885 // pair ("info.best_connection"). 887 // pair ("info.best_connection").
886 RTC_DCHECK_EQ(video_media_info->bw_estimations.size(), 1); 888 RTC_DCHECK_GE(call_stats.send_bandwidth_bps, 0);
887 RTC_DCHECK_GE( 889 RTC_DCHECK_GE(call_stats.recv_bandwidth_bps, 0);
888 video_media_info->bw_estimations[0].available_send_bandwidth, 0); 890 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 = 891 candidate_pair_stats->available_outgoing_bitrate =
893 static_cast<double>(video_media_info->bw_estimations[0] 892 static_cast<double>(call_stats.send_bandwidth_bps);
894 .available_send_bandwidth);
895 } 893 }
896 if (video_media_info->bw_estimations[0].available_recv_bandwidth) { 894 if (call_stats.recv_bandwidth_bps > 0) {
897 candidate_pair_stats->available_incoming_bitrate = 895 candidate_pair_stats->available_incoming_bitrate =
898 static_cast<double>(video_media_info->bw_estimations[0] 896 static_cast<double>(call_stats.recv_bandwidth_bps);
hbos 2017/05/09 12:48:14 It would be nice to turn these into rtc::Optional<
holmer 2017/05/30 14:44:28 I don't think it will be trivial since it will aff
899 .available_recv_bandwidth);
900 } 897 }
901 } 898 }
902 candidate_pair_stats->requests_received = 899 candidate_pair_stats->requests_received =
903 static_cast<uint64_t>(info.recv_ping_requests); 900 static_cast<uint64_t>(info.recv_ping_requests);
904 candidate_pair_stats->requests_sent = static_cast<uint64_t>( 901 candidate_pair_stats->requests_sent = static_cast<uint64_t>(
905 info.sent_ping_requests_before_first_response); 902 info.sent_ping_requests_before_first_response);
906 candidate_pair_stats->responses_received = 903 candidate_pair_stats->responses_received =
907 static_cast<uint64_t>(info.recv_ping_responses); 904 static_cast<uint64_t>(info.recv_ping_responses);
908 candidate_pair_stats->responses_sent = 905 candidate_pair_stats->responses_sent =
909 static_cast<uint64_t>(info.sent_ping_responses); 906 static_cast<uint64_t>(info.sent_ping_responses);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 const std::string& type) { 1242 const std::string& type) {
1246 return CandidateTypeToRTCIceCandidateType(type); 1243 return CandidateTypeToRTCIceCandidateType(type);
1247 } 1244 }
1248 1245
1249 const char* DataStateToRTCDataChannelStateForTesting( 1246 const char* DataStateToRTCDataChannelStateForTesting(
1250 DataChannelInterface::DataState state) { 1247 DataChannelInterface::DataState state) {
1251 return DataStateToRTCDataChannelState(state); 1248 return DataStateToRTCDataChannelState(state);
1252 } 1249 }
1253 1250
1254 } // namespace webrtc 1251 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698