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

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

Issue 2863123002: Wire up BWE stats through WebrtcSession so that they are filled in both for audio and video calls. (Closed)
Patch Set: 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 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 { StatsReport::kStatsValueNameFramesEncoded, info.frames_encoded }, 280 { StatsReport::kStatsValueNameFramesEncoded, info.frames_encoded },
281 }; 281 };
282 282
283 for (const auto& i : ints) 283 for (const auto& i : ints)
284 report->AddInt(i.name, i.value); 284 report->AddInt(i.name, i.value);
285 report->AddString(StatsReport::kStatsValueNameMediaType, "video"); 285 report->AddString(StatsReport::kStatsValueNameMediaType, "video");
286 } 286 }
287 287
288 void ExtractStats(const cricket::BandwidthEstimationInfo& info, 288 void ExtractStats(const cricket::BandwidthEstimationInfo& info,
289 double stats_gathering_started, 289 double stats_gathering_started,
290 PeerConnectionInterface::StatsOutputLevel level,
291 StatsReport* report) { 290 StatsReport* report) {
292 RTC_DCHECK(report->type() == StatsReport::kStatsReportTypeBwe); 291 RTC_DCHECK(report->type() == StatsReport::kStatsReportTypeBwe);
293 292
294 report->set_timestamp(stats_gathering_started); 293 report->set_timestamp(stats_gathering_started);
295 const IntForAdd ints[] = { 294 const IntForAdd ints[] = {
296 { StatsReport::kStatsValueNameAvailableSendBandwidth, 295 { StatsReport::kStatsValueNameAvailableSendBandwidth,
297 info.available_send_bandwidth }, 296 info.available_send_bandwidth },
298 { StatsReport::kStatsValueNameAvailableReceiveBandwidth, 297 { StatsReport::kStatsValueNameAvailableReceiveBandwidth,
299 info.available_recv_bandwidth }, 298 info.available_recv_bandwidth },
300 { StatsReport::kStatsValueNameTargetEncBitrate, info.target_enc_bitrate }, 299 { StatsReport::kStatsValueNameTargetEncBitrate, info.target_enc_bitrate },
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // TODO(pthatcher): Merge PeerConnection and WebRtcSession so there is no 498 // TODO(pthatcher): Merge PeerConnection and WebRtcSession so there is no
500 // pc_->session(). 499 // pc_->session().
501 if (pc_->session()) { 500 if (pc_->session()) {
502 // TODO(tommi): All of these hop over to the worker thread to fetch 501 // TODO(tommi): All of these hop over to the worker thread to fetch
503 // information. We could use an AsyncInvoker to run all of these and post 502 // information. We could use an AsyncInvoker to run all of these and post
504 // the information back to the signaling thread where we can create and 503 // the information back to the signaling thread where we can create and
505 // update stats reports. That would also clean up the threading story a bit 504 // update stats reports. That would also clean up the threading story a bit
506 // since we'd be creating/updating the stats report objects consistently on 505 // since we'd be creating/updating the stats report objects consistently on
507 // the same thread (this class has no locks right now). 506 // the same thread (this class has no locks right now).
508 ExtractSessionInfo(); 507 ExtractSessionInfo();
508 ExtractBweInfo();
509 ExtractVoiceInfo(); 509 ExtractVoiceInfo();
510 ExtractVideoInfo(level); 510 ExtractVideoInfo(level);
511 ExtractSenderInfo(); 511 ExtractSenderInfo();
512 ExtractDataInfo(); 512 ExtractDataInfo();
513 UpdateTrackReports(); 513 UpdateTrackReports();
514 } 514 }
515 } 515 }
516 516
517 StatsReport* StatsCollector::PrepareReport( 517 StatsReport* StatsCollector::PrepareReport(
518 bool local, 518 bool local,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 if (info.best_connection) { 760 if (info.best_connection) {
761 channel_report->AddId( 761 channel_report->AddId(
762 StatsReport::kStatsValueNameSelectedCandidatePairId, 762 StatsReport::kStatsValueNameSelectedCandidatePairId,
763 connection_report->id()); 763 connection_report->id());
764 } 764 }
765 } 765 }
766 } 766 }
767 } 767 }
768 } 768 }
769 769
770 void StatsCollector::ExtractBweInfo() {
771 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
772
773 webrtc::Call::Stats call_stats = pc_->session()->GetCallStats();
774 cricket::BandwidthEstimationInfo bwe_info;
775 bwe_info.available_send_bandwidth = call_stats.send_bandwidth_bps;
776 bwe_info.available_recv_bandwidth = call_stats.recv_bandwidth_bps;
777 bwe_info.bucket_delay = call_stats.pacer_delay_ms;
778 // Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc.
779 // TODO(holmer): Also fill this in for audio.
780 if (!pc_->session()->video_channel()) {
781 return;
782 }
783 pc_->session()->video_channel()->FillBitrateInfo(&bwe_info);
784 StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
785 StatsReport* report = reports_.FindOrAddNew(report_id);
786 ExtractStats(bwe_info, stats_gathering_started_, report);
787 }
788
770 void StatsCollector::ExtractVoiceInfo() { 789 void StatsCollector::ExtractVoiceInfo() {
771 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 790 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
772 791
773 if (!pc_->session()->voice_channel()) { 792 if (!pc_->session()->voice_channel()) {
774 return; 793 return;
775 } 794 }
776 cricket::VoiceMediaInfo voice_info; 795 cricket::VoiceMediaInfo voice_info;
777 if (!pc_->session()->voice_channel()->GetStats(&voice_info)) { 796 if (!pc_->session()->voice_channel()->GetStats(&voice_info)) {
778 LOG(LS_ERROR) << "Failed to get voice channel stats."; 797 LOG(LS_ERROR) << "Failed to get voice channel stats.";
779 return; 798 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 proxy_to_transport_, pc_->session()->video_channel()->content_name())); 839 proxy_to_transport_, pc_->session()->video_channel()->content_name()));
821 if (!transport_id.get()) { 840 if (!transport_id.get()) {
822 LOG(LS_ERROR) << "Failed to get transport name for proxy " 841 LOG(LS_ERROR) << "Failed to get transport name for proxy "
823 << pc_->session()->video_channel()->content_name(); 842 << pc_->session()->video_channel()->content_name();
824 return; 843 return;
825 } 844 }
826 ExtractStatsFromList(video_info.receivers, transport_id, this, 845 ExtractStatsFromList(video_info.receivers, transport_id, this,
827 StatsReport::kReceive); 846 StatsReport::kReceive);
828 ExtractStatsFromList(video_info.senders, transport_id, this, 847 ExtractStatsFromList(video_info.senders, transport_id, this,
829 StatsReport::kSend); 848 StatsReport::kSend);
830 if (video_info.bw_estimations.size() != 1) {
831 LOG(LS_ERROR) << "BWEs count: " << video_info.bw_estimations.size();
832 } else {
833 StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
834 StatsReport* report = reports_.FindOrAddNew(report_id);
835 ExtractStats(
836 video_info.bw_estimations[0], stats_gathering_started_, level, report);
837 }
838 } 849 }
839 850
840 void StatsCollector::ExtractSenderInfo() { 851 void StatsCollector::ExtractSenderInfo() {
841 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 852 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
842 853
843 for (const auto& sender : pc_->GetSenders()) { 854 for (const auto& sender : pc_->GetSenders()) {
844 // TODO(nisse): SSRC == 0 currently means none. Delete check when 855 // TODO(nisse): SSRC == 0 currently means none. Delete check when
845 // that is fixed. 856 // that is fixed.
846 if (!sender->ssrc()) { 857 if (!sender->ssrc()) {
847 continue; 858 continue;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 StatsReport* report = entry.second; 999 StatsReport* report = entry.second;
989 report->set_timestamp(stats_gathering_started_); 1000 report->set_timestamp(stats_gathering_started_);
990 } 1001 }
991 } 1002 }
992 1003
993 void StatsCollector::ClearUpdateStatsCacheForTest() { 1004 void StatsCollector::ClearUpdateStatsCacheForTest() {
994 stats_gathering_started_ = 0; 1005 stats_gathering_started_ = 0;
995 } 1006 }
996 1007
997 } // namespace webrtc 1008 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698