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

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

Issue 1827023002: Get VideoCapturer stats via VideoTrackSourceInterface in StatsCollector, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Move logic back to StatsCollector, with an explicit cast to VideoTrackInterface* Created 4 years, 8 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/api/statscollector.h ('k') | webrtc/api/videocapturertracksource.h » ('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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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()) {
pthatcher1 2016/03/30 16:48:43 const auto& sender
nisse-webrtc 2016/03/31 06:31:22 Done.
834 const rtc::scoped_refptr<MediaStreamTrackInterface> track(sender->track());
835 if (!track || track->kind() != MediaStreamTrackInterface::kVideoKind)
Taylor Brandstetter 2016/03/30 17:42:32 nit: {}s
nisse-webrtc 2016/03/31 06:31:22 Done.
836 continue;
837
838 VideoTrackSourceInterface *source =
pthatcher1 2016/03/30 16:48:43 VideoTrackSourceInterface* source
nisse-webrtc 2016/03/31 06:31:22 Done.
839 static_cast<VideoTrackInterface*>(track.get())->GetSource();
pthatcher1 2016/03/30 16:48:43 I agree with the decision that you and Tommi made
nisse-webrtc 2016/03/31 06:31:22 Done. We're not using dynamic_cast<>? This must be
840
841 VideoTrackSourceInterface::Stats stats;
842 if (source->GetStats(&stats)) {
pthatcher1 2016/03/30 16:48:43 I'd prefer: if (!source->GetStats(&stats)) { c
nisse-webrtc 2016/03/31 06:31:22 Done.
843 const StatsReport::Id stats_id =
844 StatsReport::NewIdWithDirection(StatsReport::kStatsReportTypeSsrc,
845 rtc::ToString<uint32_t>(sender->ssrc()),
Taylor Brandstetter 2016/03/30 17:42:32 It's possible that a sender doesn't have an SSRC (
nisse-webrtc 2016/03/31 06:31:22 I added it as a separate "if"; no need to fiddle w
Taylor Brandstetter 2016/03/31 18:25:03 We should change it to an rtc::Optional in that ca
nisse-webrtc 2016/04/01 06:28:28 If possible, it would be even clearer if ssrc is a
Taylor Brandstetter 2016/04/01 18:28:40 Yes, it is reasonable. Through the API you can use
846 StatsReport::kSend);
847 StatsReport* report = reports_.FindOrAddNew(stats_id);
848 report->AddInt(StatsReport::kStatsValueNameFrameWidthInput,
849 stats.input_width);
850 report->AddInt(StatsReport::kStatsValueNameFrameHeightInput,
851 stats.input_height);
852 }
853 }
854 }
855
831 void StatsCollector::ExtractDataInfo() { 856 void StatsCollector::ExtractDataInfo() {
832 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 857 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
833 858
834 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; 859 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
835 860
836 for (const auto& dc : pc_->sctp_data_channels()) { 861 for (const auto& dc : pc_->sctp_data_channels()) {
837 StatsReport::Id id(StatsReport::NewTypedIntId( 862 StatsReport::Id id(StatsReport::NewTypedIntId(
838 StatsReport::kStatsReportTypeDataChannel, dc->id())); 863 StatsReport::kStatsReportTypeDataChannel, dc->id()));
839 StatsReport* report = reports_.ReplaceOrAddNew(id); 864 StatsReport* report = reports_.ReplaceOrAddNew(id);
840 report->set_timestamp(stats_gathering_started_); 865 report->set_timestamp(stats_gathering_started_);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 StatsReport* report = entry.second; 963 StatsReport* report = entry.second;
939 report->set_timestamp(stats_gathering_started_); 964 report->set_timestamp(stats_gathering_started_);
940 } 965 }
941 } 966 }
942 967
943 void StatsCollector::ClearUpdateStatsCacheForTest() { 968 void StatsCollector::ClearUpdateStatsCacheForTest() {
944 stats_gathering_started_ = 0; 969 stats_gathering_started_ = 0;
945 } 970 }
946 971
947 } // namespace webrtc 972 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/statscollector.h ('k') | webrtc/api/videocapturertracksource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698