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 ExtractCapturerInfo(); | |
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::ExtractCapturerInfo() { | |
831 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); | |
832 | |
833 rtc::scoped_refptr<StreamCollectionInterface> streams = pc_->local_streams(); | |
834 for (size_t i = 0; i < streams->count(); i++) { | |
835 for (auto track : streams->at(i)->GetVideoTracks()) { | |
836 VideoTrackSourceInterface* source = track->GetSource(); | |
837 VideoTrackSourceInterface::VideoSourceInfo info; | |
838 if (source->GetInfo(&info)) { | |
839 // TODO(nisse): What id to use??? | |
pthatcher1
2016/03/24 18:10:25
Based on the code here:
https://code.google.com/p
nisse-webrtc
2016/03/29 08:36:32
Nice idea. I implemented that. A few questions:
| |
840 StatsReport* report = reports_.FindOrAddNew(StatsReport::Id()); | |
841 report->AddInt(StatsReport::kStatsValueNameFrameWidthInput, | |
842 info.input_width); | |
843 report->AddInt(StatsReport::kStatsValueNameFrameHeightInput, | |
844 info.input_height); | |
845 } | |
846 } | |
847 } | |
848 } | |
849 | |
831 void StatsCollector::ExtractDataInfo() { | 850 void StatsCollector::ExtractDataInfo() { |
832 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); | 851 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
833 | 852 |
834 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; | 853 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
835 | 854 |
836 for (const auto& dc : pc_->sctp_data_channels()) { | 855 for (const auto& dc : pc_->sctp_data_channels()) { |
837 StatsReport::Id id(StatsReport::NewTypedIntId( | 856 StatsReport::Id id(StatsReport::NewTypedIntId( |
838 StatsReport::kStatsReportTypeDataChannel, dc->id())); | 857 StatsReport::kStatsReportTypeDataChannel, dc->id())); |
839 StatsReport* report = reports_.ReplaceOrAddNew(id); | 858 StatsReport* report = reports_.ReplaceOrAddNew(id); |
840 report->set_timestamp(stats_gathering_started_); | 859 report->set_timestamp(stats_gathering_started_); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
938 StatsReport* report = entry.second; | 957 StatsReport* report = entry.second; |
939 report->set_timestamp(stats_gathering_started_); | 958 report->set_timestamp(stats_gathering_started_); |
940 } | 959 } |
941 } | 960 } |
942 | 961 |
943 void StatsCollector::ClearUpdateStatsCacheForTest() { | 962 void StatsCollector::ClearUpdateStatsCacheForTest() { |
944 stats_gathering_started_ = 0; | 963 stats_gathering_started_ = 0; |
945 } | 964 } |
946 | 965 |
947 } // namespace webrtc | 966 } // namespace webrtc |
OLD | NEW |