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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 (info.adapt_reason & 0x1) > 0); | 229 (info.adapt_reason & 0x1) > 0); |
230 report->AddBoolean(StatsReport::kStatsValueNameViewLimitedResolution, | 230 report->AddBoolean(StatsReport::kStatsValueNameViewLimitedResolution, |
231 (info.adapt_reason & 0x4) > 0); | 231 (info.adapt_reason & 0x4) > 0); |
232 | 232 |
233 const IntForAdd ints[] = { | 233 const IntForAdd ints[] = { |
234 { StatsReport::kStatsValueNameAdaptationChanges, info.adapt_changes }, | 234 { StatsReport::kStatsValueNameAdaptationChanges, info.adapt_changes }, |
235 { StatsReport::kStatsValueNameAvgEncodeMs, info.avg_encode_ms }, | 235 { StatsReport::kStatsValueNameAvgEncodeMs, info.avg_encode_ms }, |
236 { StatsReport::kStatsValueNameEncodeUsagePercent, | 236 { StatsReport::kStatsValueNameEncodeUsagePercent, |
237 info.encode_usage_percent }, | 237 info.encode_usage_percent }, |
238 { StatsReport::kStatsValueNameFirsReceived, info.firs_rcvd }, | 238 { StatsReport::kStatsValueNameFirsReceived, info.firs_rcvd }, |
239 { StatsReport::kStatsValueNameFrameHeightInput, info.input_frame_height }, | |
240 { StatsReport::kStatsValueNameFrameHeightSent, info.send_frame_height }, | 239 { StatsReport::kStatsValueNameFrameHeightSent, info.send_frame_height }, |
241 { StatsReport::kStatsValueNameFrameRateInput, info.framerate_input }, | 240 { StatsReport::kStatsValueNameFrameRateInput, info.framerate_input }, |
242 { StatsReport::kStatsValueNameFrameRateSent, info.framerate_sent }, | 241 { StatsReport::kStatsValueNameFrameRateSent, info.framerate_sent }, |
243 { StatsReport::kStatsValueNameFrameWidthInput, info.input_frame_width }, | |
244 { StatsReport::kStatsValueNameFrameWidthSent, info.send_frame_width }, | 242 { StatsReport::kStatsValueNameFrameWidthSent, info.send_frame_width }, |
245 { StatsReport::kStatsValueNameNacksReceived, info.nacks_rcvd }, | 243 { StatsReport::kStatsValueNameNacksReceived, info.nacks_rcvd }, |
246 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, | 244 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, |
247 { StatsReport::kStatsValueNamePacketsSent, info.packets_sent }, | 245 { StatsReport::kStatsValueNamePacketsSent, info.packets_sent }, |
248 { StatsReport::kStatsValueNamePlisReceived, info.plis_rcvd }, | 246 { StatsReport::kStatsValueNamePlisReceived, info.plis_rcvd }, |
249 }; | 247 }; |
250 | 248 |
251 for (const auto& i : ints) | 249 for (const auto& i : ints) |
252 report->AddInt(i.name, i.value); | 250 report->AddInt(i.name, i.value); |
253 report->AddString(StatsReport::kStatsValueNameMediaType, "video"); | 251 report->AddString(StatsReport::kStatsValueNameMediaType, "video"); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 if (pc_->session()) { | 465 if (pc_->session()) { |
468 // TODO(tommi): All of these hop over to the worker thread to fetch | 466 // TODO(tommi): All of these hop over to the worker thread to fetch |
469 // information. We could use an AsyncInvoker to run all of these and post | 467 // information. We could use an AsyncInvoker to run all of these and post |
470 // the information back to the signaling thread where we can create and | 468 // the information back to the signaling thread where we can create and |
471 // update stats reports. That would also clean up the threading story a bit | 469 // update stats reports. That would also clean up the threading story a bit |
472 // since we'd be creating/updating the stats report objects consistently on | 470 // since we'd be creating/updating the stats report objects consistently on |
473 // the same thread (this class has no locks right now). | 471 // the same thread (this class has no locks right now). |
474 ExtractSessionInfo(); | 472 ExtractSessionInfo(); |
475 ExtractVoiceInfo(); | 473 ExtractVoiceInfo(); |
476 ExtractVideoInfo(level); | 474 ExtractVideoInfo(level); |
| 475 ExtractSenderInfo(); |
477 ExtractDataInfo(); | 476 ExtractDataInfo(); |
478 UpdateTrackReports(); | 477 UpdateTrackReports(); |
479 } | 478 } |
480 } | 479 } |
481 | 480 |
482 StatsReport* StatsCollector::PrepareReport( | 481 StatsReport* StatsCollector::PrepareReport( |
483 bool local, | 482 bool local, |
484 uint32_t ssrc, | 483 uint32_t ssrc, |
485 const StatsReport::Id& transport_id, | 484 const StatsReport::Id& transport_id, |
486 StatsReport::Direction direction) { | 485 StatsReport::Direction direction) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 if (video_info.bw_estimations.size() != 1) { | 820 if (video_info.bw_estimations.size() != 1) { |
822 LOG(LS_ERROR) << "BWEs count: " << video_info.bw_estimations.size(); | 821 LOG(LS_ERROR) << "BWEs count: " << video_info.bw_estimations.size(); |
823 } else { | 822 } else { |
824 StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId()); | 823 StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId()); |
825 StatsReport* report = reports_.FindOrAddNew(report_id); | 824 StatsReport* report = reports_.FindOrAddNew(report_id); |
826 ExtractStats( | 825 ExtractStats( |
827 video_info.bw_estimations[0], stats_gathering_started_, level, report); | 826 video_info.bw_estimations[0], stats_gathering_started_, level, report); |
828 } | 827 } |
829 } | 828 } |
830 | 829 |
| 830 void StatsCollector::ExtractSenderInfo() { |
| 831 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
| 832 |
| 833 for (const auto& sender : pc_->GetSenders()) { |
| 834 // TODO(nisse): SSRC == 0 currently means none. Delete check when |
| 835 // that is fixed. |
| 836 if (!sender->ssrc()) { |
| 837 continue; |
| 838 } |
| 839 const rtc::scoped_refptr<MediaStreamTrackInterface> track(sender->track()); |
| 840 if (!track || track->kind() != MediaStreamTrackInterface::kVideoKind) { |
| 841 continue; |
| 842 } |
| 843 // Safe, because kind() == kVideoKind implies a subclass of |
| 844 // VideoTrackInterface; see mediastreaminterface.h. |
| 845 VideoTrackSourceInterface* source = |
| 846 static_cast<VideoTrackInterface*>(track.get())->GetSource(); |
| 847 |
| 848 VideoTrackSourceInterface::Stats stats; |
| 849 if (!source->GetStats(&stats)) { |
| 850 continue; |
| 851 } |
| 852 const StatsReport::Id stats_id = StatsReport::NewIdWithDirection( |
| 853 StatsReport::kStatsReportTypeSsrc, |
| 854 rtc::ToString<uint32_t>(sender->ssrc()), StatsReport::kSend); |
| 855 StatsReport* report = reports_.FindOrAddNew(stats_id); |
| 856 report->AddInt(StatsReport::kStatsValueNameFrameWidthInput, |
| 857 stats.input_width); |
| 858 report->AddInt(StatsReport::kStatsValueNameFrameHeightInput, |
| 859 stats.input_height); |
| 860 } |
| 861 } |
| 862 |
831 void StatsCollector::ExtractDataInfo() { | 863 void StatsCollector::ExtractDataInfo() { |
832 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); | 864 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
833 | 865 |
834 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; | 866 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
835 | 867 |
836 for (const auto& dc : pc_->sctp_data_channels()) { | 868 for (const auto& dc : pc_->sctp_data_channels()) { |
837 StatsReport::Id id(StatsReport::NewTypedIntId( | 869 StatsReport::Id id(StatsReport::NewTypedIntId( |
838 StatsReport::kStatsReportTypeDataChannel, dc->id())); | 870 StatsReport::kStatsReportTypeDataChannel, dc->id())); |
839 StatsReport* report = reports_.ReplaceOrAddNew(id); | 871 StatsReport* report = reports_.ReplaceOrAddNew(id); |
840 report->set_timestamp(stats_gathering_started_); | 872 report->set_timestamp(stats_gathering_started_); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 StatsReport* report = entry.second; | 970 StatsReport* report = entry.second; |
939 report->set_timestamp(stats_gathering_started_); | 971 report->set_timestamp(stats_gathering_started_); |
940 } | 972 } |
941 } | 973 } |
942 | 974 |
943 void StatsCollector::ClearUpdateStatsCacheForTest() { | 975 void StatsCollector::ClearUpdateStatsCacheForTest() { |
944 stats_gathering_started_ = 0; | 976 stats_gathering_started_ = 0; |
945 } | 977 } |
946 | 978 |
947 } // namespace webrtc | 979 } // namespace webrtc |
OLD | NEW |