Implement googContentType GetStats metric reported on receive side.
Reported per video stream as a string.
BUG=webrtc:8174
Review-Url: https://codereview.webrtc.org/3009793002
Cr-Original-Commit-Position: refs/heads/master@{#19667}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 2e1b40bdf63743b07388628707c4b8e349495807
diff --git a/api/statstypes.cc b/api/statstypes.cc
index 29a171e..714d36b 100644
--- a/api/statstypes.cc
+++ b/api/statstypes.cc
@@ -460,6 +460,8 @@
return "googComponent";
case kStatsValueNameContentName:
return "googContentName";
+ case kStatsValueNameContentType:
+ return "googContentType";
case kStatsValueNameCpuLimitedResolution:
return "googCpuLimitedResolution";
case kStatsValueNameDecodingCTSG:
diff --git a/api/statstypes.h b/api/statstypes.h
index 1cc5cda..42e3601 100644
--- a/api/statstypes.h
+++ b/api/statstypes.h
@@ -108,7 +108,6 @@
kStatsValueNameDataChannelId,
kStatsValueNameFramesDecoded,
kStatsValueNameFramesEncoded,
- kStatsValueNameInterframeDelayMaxMs, // Max over last 10 seconds.
kStatsValueNameMediaType,
kStatsValueNamePacketsLost,
kStatsValueNamePacketsReceived,
@@ -149,6 +148,7 @@
kStatsValueNameCodecName,
kStatsValueNameComponent,
kStatsValueNameContentName,
+ kStatsValueNameContentType,
kStatsValueNameCpuLimitedResolution,
kStatsValueNameCurrentDelayMs,
kStatsValueNameDecodeMs,
@@ -184,6 +184,7 @@
kStatsValueNameFrameWidthReceived,
kStatsValueNameFrameWidthSent,
kStatsValueNameInitiator,
+ kStatsValueNameInterframeDelayMaxMs, // Max over last 10 seconds.
kStatsValueNameIssuerId,
kStatsValueNameJitterBufferMs,
kStatsValueNameJitterReceived,
diff --git a/api/video/video_content_type.cc b/api/video/video_content_type.cc
index 278b57c..351cfee 100644
--- a/api/video/video_content_type.cc
+++ b/api/video/video_content_type.cc
@@ -90,5 +90,9 @@
// Any 6-bit value is allowed.
return value < (1 << kTotalBitsSize);
}
+
+const char* ToString(const VideoContentType& content_type) {
+ return IsScreenshare(content_type) ? "screen" : "realtime";
+}
} // namespace videocontenttypehelpers
} // namespace webrtc
diff --git a/api/video/video_content_type.h b/api/video/video_content_type.h
index 6f6bbe8..8addb13 100644
--- a/api/video/video_content_type.h
+++ b/api/video/video_content_type.h
@@ -13,6 +13,8 @@
#include <stdint.h>
+#include <string>
+
namespace webrtc {
enum class VideoContentType : uint8_t {
@@ -32,6 +34,8 @@
bool IsScreenshare(const VideoContentType& content_type);
bool IsValidContentType(uint8_t value);
+
+ const char* ToString(const VideoContentType& content_type);
} // namespace videocontenttypehelpers
} // namespace webrtc
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index ef1c715..e51184e 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -88,6 +88,8 @@
int width = 0;
int height = 0;
+ VideoContentType content_type = VideoContentType::UNSPECIFIED;
+
int sync_offset_ms = std::numeric_limits<int>::max();
uint32_t ssrc = 0;
diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h
index 1ab4123..5aae309 100644
--- a/media/base/mediachannel.h
+++ b/media/base/mediachannel.h
@@ -771,6 +771,7 @@
frames_decoded(0),
frames_rendered(0),
interframe_delay_max_ms(-1),
+ content_type(webrtc::VideoContentType::UNSPECIFIED),
decode_ms(0),
max_decode_ms(0),
jitter_buffer_ms(0),
@@ -802,6 +803,8 @@
rtc::Optional<uint64_t> qp_sum;
int64_t interframe_delay_max_ms;
+ webrtc::VideoContentType content_type;
+
// All stats below are gathered per-VideoReceiver, but some will be correlated
// across MediaStreamTracks. NOTE(hta): when sinking stats into per-SSRC
// structures, reflect this in the new layout.
diff --git a/media/engine/webrtcvideoengine.cc b/media/engine/webrtcvideoengine.cc
index cb6f1ce..fd27be4 100644
--- a/media/engine/webrtcvideoengine.cc
+++ b/media/engine/webrtcvideoengine.cc
@@ -2418,6 +2418,8 @@
info.interframe_delay_max_ms = stats.interframe_delay_max_ms;
+ info.content_type = stats.content_type;
+
info.codec_name = GetCodecNameFromPayloadType(stats.current_payload_type);
info.firs_sent = stats.rtcp_packet_type_counts.fir_packets;
diff --git a/pc/statscollector.cc b/pc/statscollector.cc
index 97bae3d..0458e82 100644
--- a/pc/statscollector.cc
+++ b/pc/statscollector.cc
@@ -272,6 +272,10 @@
report->AddInt64(StatsReport::kStatsValueNameInterframeDelayMaxMs,
info.interframe_delay_max_ms);
+
+ report->AddString(
+ StatsReport::kStatsValueNameContentType,
+ webrtc::videocontenttypehelpers::ToString(info.content_type));
}
void ExtractStats(const cricket::VideoSenderInfo& info, StatsReport* report) {
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index 2448bad..ff4c6fe 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -501,6 +501,7 @@
stats_.interframe_delay_max_ms =
interframe_delay_max_moving_.Max(now_ms).value_or(-1);
stats_.timing_frame_info = timing_frame_info_counter_.Max(now_ms);
+ stats_.content_type = last_content_type_;
return stats_;
}
diff --git a/video/receive_statistics_proxy_unittest.cc b/video/receive_statistics_proxy_unittest.cc
index 0b8b3a6..068b221 100644
--- a/video/receive_statistics_proxy_unittest.cc
+++ b/video/receive_statistics_proxy_unittest.cc
@@ -98,6 +98,21 @@
statistics_proxy_->GetStats().qp_sum);
}
+TEST_F(ReceiveStatisticsProxyTest, ReportsContentType) {
+ const std::string kRealtimeString("realtime");
+ const std::string kScreenshareString("screen");
+ EXPECT_EQ(kRealtimeString, videocontenttypehelpers::ToString(
+ statistics_proxy_->GetStats().content_type));
+ statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
+ VideoContentType::SCREENSHARE);
+ EXPECT_EQ(kScreenshareString, videocontenttypehelpers::ToString(
+ statistics_proxy_->GetStats().content_type));
+ statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
+ VideoContentType::UNSPECIFIED);
+ EXPECT_EQ(kRealtimeString, videocontenttypehelpers::ToString(
+ statistics_proxy_->GetStats().content_type));
+}
+
TEST_F(ReceiveStatisticsProxyTest, ReportsMaxInterframeDelay) {
const int64_t kInterframeDelayMs1 = 100;
const int64_t kInterframeDelayMs2 = 200;