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

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

Issue 2916793003: Revert of Wire up BWE stats through WebrtcSession so that they are filled in both for audio and video calls. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « webrtc/pc/statscollector.h ('k') | webrtc/pc/statscollector_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
290 StatsReport* report) { 291 StatsReport* report) {
291 RTC_DCHECK(report->type() == StatsReport::kStatsReportTypeBwe); 292 RTC_DCHECK(report->type() == StatsReport::kStatsReportTypeBwe);
292 293
293 report->set_timestamp(stats_gathering_started); 294 report->set_timestamp(stats_gathering_started);
294 const IntForAdd ints[] = { 295 const IntForAdd ints[] = {
295 { StatsReport::kStatsValueNameAvailableSendBandwidth, 296 { StatsReport::kStatsValueNameAvailableSendBandwidth,
296 info.available_send_bandwidth }, 297 info.available_send_bandwidth },
297 { StatsReport::kStatsValueNameAvailableReceiveBandwidth, 298 { StatsReport::kStatsValueNameAvailableReceiveBandwidth,
298 info.available_recv_bandwidth }, 299 info.available_recv_bandwidth },
299 { StatsReport::kStatsValueNameTargetEncBitrate, info.target_enc_bitrate }, 300 { StatsReport::kStatsValueNameTargetEncBitrate, info.target_enc_bitrate },
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // TODO(pthatcher): Merge PeerConnection and WebRtcSession so there is no 499 // TODO(pthatcher): Merge PeerConnection and WebRtcSession so there is no
499 // pc_->session(). 500 // pc_->session().
500 if (pc_->session()) { 501 if (pc_->session()) {
501 // TODO(tommi): All of these hop over to the worker thread to fetch 502 // TODO(tommi): All of these hop over to the worker thread to fetch
502 // information. We could use an AsyncInvoker to run all of these and post 503 // information. We could use an AsyncInvoker to run all of these and post
503 // the information back to the signaling thread where we can create and 504 // the information back to the signaling thread where we can create and
504 // update stats reports. That would also clean up the threading story a bit 505 // update stats reports. That would also clean up the threading story a bit
505 // since we'd be creating/updating the stats report objects consistently on 506 // since we'd be creating/updating the stats report objects consistently on
506 // the same thread (this class has no locks right now). 507 // the same thread (this class has no locks right now).
507 ExtractSessionInfo(); 508 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 if (pc_->session()->state() == WebRtcSession::State::STATE_CLOSED)
774 return;
775
776 webrtc::Call::Stats call_stats = pc_->session()->GetCallStats();
777 cricket::BandwidthEstimationInfo bwe_info;
778 bwe_info.available_send_bandwidth = call_stats.send_bandwidth_bps;
779 bwe_info.available_recv_bandwidth = call_stats.recv_bandwidth_bps;
780 bwe_info.bucket_delay = call_stats.pacer_delay_ms;
781 // Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc.
782 // TODO(holmer): Also fill this in for audio.
783 if (!pc_->session()->video_channel()) {
784 return;
785 }
786 pc_->session()->video_channel()->FillBitrateInfo(&bwe_info);
787 StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
788 StatsReport* report = reports_.FindOrAddNew(report_id);
789 ExtractStats(bwe_info, stats_gathering_started_, report);
790 }
791
792 void StatsCollector::ExtractVoiceInfo() { 770 void StatsCollector::ExtractVoiceInfo() {
793 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 771 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
794 772
795 if (!pc_->session()->voice_channel()) { 773 if (!pc_->session()->voice_channel()) {
796 return; 774 return;
797 } 775 }
798 cricket::VoiceMediaInfo voice_info; 776 cricket::VoiceMediaInfo voice_info;
799 if (!pc_->session()->voice_channel()->GetStats(&voice_info)) { 777 if (!pc_->session()->voice_channel()->GetStats(&voice_info)) {
800 LOG(LS_ERROR) << "Failed to get voice channel stats."; 778 LOG(LS_ERROR) << "Failed to get voice channel stats.";
801 return; 779 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 proxy_to_transport_, pc_->session()->video_channel()->content_name())); 820 proxy_to_transport_, pc_->session()->video_channel()->content_name()));
843 if (!transport_id.get()) { 821 if (!transport_id.get()) {
844 LOG(LS_ERROR) << "Failed to get transport name for proxy " 822 LOG(LS_ERROR) << "Failed to get transport name for proxy "
845 << pc_->session()->video_channel()->content_name(); 823 << pc_->session()->video_channel()->content_name();
846 return; 824 return;
847 } 825 }
848 ExtractStatsFromList(video_info.receivers, transport_id, this, 826 ExtractStatsFromList(video_info.receivers, transport_id, this,
849 StatsReport::kReceive); 827 StatsReport::kReceive);
850 ExtractStatsFromList(video_info.senders, transport_id, this, 828 ExtractStatsFromList(video_info.senders, transport_id, this,
851 StatsReport::kSend); 829 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 }
852 } 838 }
853 839
854 void StatsCollector::ExtractSenderInfo() { 840 void StatsCollector::ExtractSenderInfo() {
855 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 841 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
856 842
857 for (const auto& sender : pc_->GetSenders()) { 843 for (const auto& sender : pc_->GetSenders()) {
858 // TODO(nisse): SSRC == 0 currently means none. Delete check when 844 // TODO(nisse): SSRC == 0 currently means none. Delete check when
859 // that is fixed. 845 // that is fixed.
860 if (!sender->ssrc()) { 846 if (!sender->ssrc()) {
861 continue; 847 continue;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 StatsReport* report = entry.second; 988 StatsReport* report = entry.second;
1003 report->set_timestamp(stats_gathering_started_); 989 report->set_timestamp(stats_gathering_started_);
1004 } 990 }
1005 } 991 }
1006 992
1007 void StatsCollector::ClearUpdateStatsCacheForTest() { 993 void StatsCollector::ClearUpdateStatsCacheForTest() {
1008 stats_gathering_started_ = 0; 994 stats_gathering_started_ = 0;
1009 } 995 }
1010 996
1011 } // namespace webrtc 997 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/pc/statscollector.h ('k') | webrtc/pc/statscollector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698