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

Unified 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: Address comments from Peter and Taylor. Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/api/statscollector.cc
diff --git a/webrtc/api/statscollector.cc b/webrtc/api/statscollector.cc
index d77953b3bed1d49bb75a3be6a35c5d10f91c382b..0821ffffbafe8ac3b13f40a20512e673ec11fc64 100644
--- a/webrtc/api/statscollector.cc
+++ b/webrtc/api/statscollector.cc
@@ -236,11 +236,9 @@ void ExtractStats(const cricket::VideoSenderInfo& info, StatsReport* report) {
{ StatsReport::kStatsValueNameEncodeUsagePercent,
info.encode_usage_percent },
{ StatsReport::kStatsValueNameFirsReceived, info.firs_rcvd },
- { StatsReport::kStatsValueNameFrameHeightInput, info.input_frame_height },
{ StatsReport::kStatsValueNameFrameHeightSent, info.send_frame_height },
{ StatsReport::kStatsValueNameFrameRateInput, info.framerate_input },
{ StatsReport::kStatsValueNameFrameRateSent, info.framerate_sent },
- { StatsReport::kStatsValueNameFrameWidthInput, info.input_frame_width },
{ StatsReport::kStatsValueNameFrameWidthSent, info.send_frame_width },
{ StatsReport::kStatsValueNameNacksReceived, info.nacks_rcvd },
{ StatsReport::kStatsValueNamePacketsLost, info.packets_lost },
@@ -474,6 +472,7 @@ StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
ExtractSessionInfo();
ExtractVoiceInfo();
ExtractVideoInfo(level);
+ ExtractSenderInfo();
ExtractDataInfo();
UpdateTrackReports();
}
@@ -828,6 +827,38 @@ void StatsCollector::ExtractVideoInfo(
}
}
+void StatsCollector::ExtractSenderInfo() {
+ RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+
+ for (const auto& sender : pc_->GetSenders()) {
+ if (!sender->ssrc()) {
+ continue;
+ }
+ const rtc::scoped_refptr<MediaStreamTrackInterface> track(sender->track());
+ if (!track || track->kind() != MediaStreamTrackInterface::kVideoKind) {
+ continue;
+ }
+ // Safe, because kind() == kVideoKind implies a subclass of
+ // VideoTrackInterface; see mediastreaminterface.h.
+ VideoTrackSourceInterface* source =
+ static_cast<VideoTrackInterface*>(track.get())->GetSource();
+
+ VideoTrackSourceInterface::Stats stats;
+ if (!source->GetStats(&stats)) {
+ continue;
+ }
+ const StatsReport::Id stats_id =
+ StatsReport::NewIdWithDirection(StatsReport::kStatsReportTypeSsrc,
+ rtc::ToString<uint32_t>(sender->ssrc()),
+ StatsReport::kSend);
+ StatsReport* report = reports_.FindOrAddNew(stats_id);
+ report->AddInt(StatsReport::kStatsValueNameFrameWidthInput,
+ stats.input_width);
+ report->AddInt(StatsReport::kStatsValueNameFrameHeightInput,
+ stats.input_height);
+ }
+}
+
void StatsCollector::ExtractDataInfo() {
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());

Powered by Google App Engine
This is Rietveld 408576698