OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
770 void StatsCollector::ExtractVoiceInfo() { | 792 void StatsCollector::ExtractVoiceInfo() { |
771 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); | 793 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
772 | 794 |
773 if (!pc_->session()->voice_channel()) { | 795 if (!pc_->session()->voice_channel()) { |
774 return; | 796 return; |
775 } | 797 } |
776 cricket::VoiceMediaInfo voice_info; | 798 cricket::VoiceMediaInfo voice_info; |
777 if (!pc_->session()->voice_channel()->GetStats(&voice_info)) { | 799 if (!pc_->session()->voice_channel()->GetStats(&voice_info)) { |
778 LOG(LS_ERROR) << "Failed to get voice channel stats."; | 800 LOG(LS_ERROR) << "Failed to get voice channel stats."; |
779 return; | 801 return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 proxy_to_transport_, pc_->session()->video_channel()->content_name())); | 842 proxy_to_transport_, pc_->session()->video_channel()->content_name())); |
821 if (!transport_id.get()) { | 843 if (!transport_id.get()) { |
822 LOG(LS_ERROR) << "Failed to get transport name for proxy " | 844 LOG(LS_ERROR) << "Failed to get transport name for proxy " |
823 << pc_->session()->video_channel()->content_name(); | 845 << pc_->session()->video_channel()->content_name(); |
824 return; | 846 return; |
825 } | 847 } |
826 ExtractStatsFromList(video_info.receivers, transport_id, this, | 848 ExtractStatsFromList(video_info.receivers, transport_id, this, |
827 StatsReport::kReceive); | 849 StatsReport::kReceive); |
828 ExtractStatsFromList(video_info.senders, transport_id, this, | 850 ExtractStatsFromList(video_info.senders, transport_id, this, |
829 StatsReport::kSend); | 851 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 } | 852 } |
839 | 853 |
840 void StatsCollector::ExtractSenderInfo() { | 854 void StatsCollector::ExtractSenderInfo() { |
841 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); | 855 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
842 | 856 |
843 for (const auto& sender : pc_->GetSenders()) { | 857 for (const auto& sender : pc_->GetSenders()) { |
844 // TODO(nisse): SSRC == 0 currently means none. Delete check when | 858 // TODO(nisse): SSRC == 0 currently means none. Delete check when |
845 // that is fixed. | 859 // that is fixed. |
846 if (!sender->ssrc()) { | 860 if (!sender->ssrc()) { |
847 continue; | 861 continue; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 StatsReport* report = entry.second; | 1002 StatsReport* report = entry.second; |
989 report->set_timestamp(stats_gathering_started_); | 1003 report->set_timestamp(stats_gathering_started_); |
990 } | 1004 } |
991 } | 1005 } |
992 | 1006 |
993 void StatsCollector::ClearUpdateStatsCacheForTest() { | 1007 void StatsCollector::ClearUpdateStatsCacheForTest() { |
994 stats_gathering_started_ = 0; | 1008 stats_gathering_started_ = 0; |
995 } | 1009 } |
996 | 1010 |
997 } // namespace webrtc | 1011 } // namespace webrtc |
OLD | NEW |