Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Danil Chapovalov | b9b146c | 2018-06-15 10:28:07 | [diff] [blame] | 11 | #include "absl/types/optional.h" |
Danil Chapovalov | 99b71df | 2018-10-26 13:57:48 | [diff] [blame] | 12 | #include "api/test/video/function_video_encoder_factory.h" |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 13 | #include "modules/video_coding/codecs/vp8/include/vp8.h" |
Markus Handell | 9bbff07 | 2020-07-07 12:23:18 | [diff] [blame] | 14 | #include "rtc_base/synchronization/mutex.h" |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 15 | #include "system_wrappers/include/metrics.h" |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 16 | #include "test/call_test.h" |
| 17 | #include "test/gtest.h" |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 18 | #include "test/video_test_constants.h" |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
Elad Alon | d8d3248 | 2019-02-18 22:45:57 | [diff] [blame] | 21 | namespace { |
| 22 | enum : int { // The first valid value is 1. |
| 23 | kTransportSequenceNumberExtensionId = 1, |
| 24 | kVideoContentTypeExtensionId, |
| 25 | }; |
| 26 | } // namespace |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 27 | |
| 28 | class HistogramTest : public test::CallTest { |
Elad Alon | d8d3248 | 2019-02-18 22:45:57 | [diff] [blame] | 29 | public: |
| 30 | HistogramTest() { |
| 31 | RegisterRtpExtension(RtpExtension(RtpExtension::kTransportSequenceNumberUri, |
| 32 | kTransportSequenceNumberExtensionId)); |
| 33 | RegisterRtpExtension(RtpExtension(RtpExtension::kVideoContentTypeUri, |
| 34 | kVideoContentTypeExtensionId)); |
| 35 | } |
| 36 | |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 37 | protected: |
| 38 | void VerifyHistogramStats(bool use_rtx, bool use_fec, bool screenshare); |
| 39 | }; |
| 40 | |
| 41 | void HistogramTest::VerifyHistogramStats(bool use_rtx, |
| 42 | bool use_fec, |
| 43 | bool screenshare) { |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 44 | class FrameObserver : public test::EndToEndTest, |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 45 | public rtc::VideoSinkInterface<VideoFrame> { |
| 46 | public: |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 47 | FrameObserver(bool use_rtx, bool use_fec, bool screenshare) |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 48 | : EndToEndTest(test::VideoTestConstants::kLongTimeout), |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 49 | use_rtx_(use_rtx), |
| 50 | use_fec_(use_fec), |
| 51 | screenshare_(screenshare), |
| 52 | // This test uses NACK, so to send FEC we can't use a fake encoder. |
Danil Chapovalov | be9d13a | 2024-03-22 12:33:59 | [diff] [blame] | 53 | encoder_factory_( |
| 54 | [](const Environment& env, const SdpVideoFormat& format) { |
| 55 | return CreateVp8Encoder(env); |
| 56 | }), |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 57 | num_frames_received_(0) {} |
| 58 | |
| 59 | private: |
| 60 | void OnFrame(const VideoFrame& video_frame) override { |
Artem Titov | ab30d72 | 2021-07-27 14:22:11 | [diff] [blame] | 61 | // The RTT is needed to estimate `ntp_time_ms` which is used by |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 62 | // end-to-end delay stats. Therefore, start counting received frames once |
Artem Titov | ab30d72 | 2021-07-27 14:22:11 | [diff] [blame] | 63 | // `ntp_time_ms` is valid. |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 64 | if (video_frame.ntp_time_ms() > 0 && |
| 65 | Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() >= |
| 66 | video_frame.ntp_time_ms()) { |
Markus Handell | 9bbff07 | 2020-07-07 12:23:18 | [diff] [blame] | 67 | MutexLock lock(&mutex_); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 68 | ++num_frames_received_; |
| 69 | } |
| 70 | } |
| 71 | |
Harald Alvestrand | d43af91 | 2023-08-15 11:41:45 | [diff] [blame] | 72 | Action OnSendRtp(rtc::ArrayView<const uint8_t> packet) override { |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 73 | if (MinMetricRunTimePassed() && MinNumberOfFramesReceived()) |
| 74 | observation_complete_.Set(); |
| 75 | |
| 76 | return SEND_PACKET; |
| 77 | } |
| 78 | |
| 79 | bool MinMetricRunTimePassed() { |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 80 | int64_t now_ms = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
Åsa Persson | 81327d5 | 2018-06-05 11:34:33 | [diff] [blame] | 81 | if (!start_runtime_ms_) |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 82 | start_runtime_ms_ = now_ms; |
Åsa Persson | 81327d5 | 2018-06-05 11:34:33 | [diff] [blame] | 83 | |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 84 | int64_t elapsed_sec = (now_ms - *start_runtime_ms_) / 1000; |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 85 | return elapsed_sec > metrics::kMinRunTimeInSeconds * 2; |
| 86 | } |
| 87 | |
| 88 | bool MinNumberOfFramesReceived() const { |
| 89 | const int kMinRequiredHistogramSamples = 200; |
Markus Handell | 9bbff07 | 2020-07-07 12:23:18 | [diff] [blame] | 90 | MutexLock lock(&mutex_); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 91 | return num_frames_received_ > kMinRequiredHistogramSamples; |
| 92 | } |
| 93 | |
| 94 | void ModifyVideoConfigs( |
| 95 | VideoSendStream::Config* send_config, |
Tommi | f6f4543 | 2022-05-20 13:21:20 | [diff] [blame] | 96 | std::vector<VideoReceiveStreamInterface::Config>* receive_configs, |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 97 | VideoEncoderConfig* encoder_config) override { |
| 98 | // NACK |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 99 | send_config->rtp.nack.rtp_history_ms = |
| 100 | test::VideoTestConstants::kNackRtpHistoryMs; |
| 101 | (*receive_configs)[0].rtp.nack.rtp_history_ms = |
| 102 | test::VideoTestConstants::kNackRtpHistoryMs; |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 103 | (*receive_configs)[0].renderer = this; |
| 104 | // FEC |
| 105 | if (use_fec_) { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 106 | send_config->rtp.ulpfec.ulpfec_payload_type = |
| 107 | test::VideoTestConstants::kUlpfecPayloadType; |
| 108 | send_config->rtp.ulpfec.red_payload_type = |
| 109 | test::VideoTestConstants::kRedPayloadType; |
Niels Möller | 4db138e | 2018-04-19 07:04:13 | [diff] [blame] | 110 | send_config->encoder_settings.encoder_factory = &encoder_factory_; |
Niels Möller | 259a497 | 2018-04-05 13:36:51 | [diff] [blame] | 111 | send_config->rtp.payload_name = "VP8"; |
| 112 | encoder_config->codec_type = kVideoCodecVP8; |
Philipp Hancke | bbff58d | 2024-02-27 11:18:33 | [diff] [blame] | 113 | (*receive_configs)[0].decoders[0].video_format = SdpVideoFormat::VP8(); |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 114 | (*receive_configs)[0].rtp.red_payload_type = |
| 115 | test::VideoTestConstants::kRedPayloadType; |
| 116 | (*receive_configs)[0].rtp.ulpfec_payload_type = |
| 117 | test::VideoTestConstants::kUlpfecPayloadType; |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 118 | } |
| 119 | // RTX |
| 120 | if (use_rtx_) { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 121 | send_config->rtp.rtx.ssrcs.push_back( |
| 122 | test::VideoTestConstants::kSendRtxSsrcs[0]); |
| 123 | send_config->rtp.rtx.payload_type = |
| 124 | test::VideoTestConstants::kSendRtxPayloadType; |
| 125 | (*receive_configs)[0].rtp.rtx_ssrc = |
| 126 | test::VideoTestConstants::kSendRtxSsrcs[0]; |
| 127 | (*receive_configs)[0].rtp.rtx_associated_payload_types |
| 128 | [test::VideoTestConstants::kSendRtxPayloadType] = |
| 129 | test::VideoTestConstants::kFakeVideoSendPayloadType; |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 130 | if (use_fec_) { |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 131 | send_config->rtp.ulpfec.red_rtx_payload_type = |
| 132 | test::VideoTestConstants::kRtxRedPayloadType; |
| 133 | (*receive_configs)[0].rtp.rtx_associated_payload_types |
| 134 | [test::VideoTestConstants::kRtxRedPayloadType] = |
| 135 | test::VideoTestConstants::kSendRtxPayloadType; |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | // RTT needed for RemoteNtpTimeEstimator for the receive stream. |
| 139 | (*receive_configs)[0].rtp.rtcp_xr.receiver_reference_time_report = true; |
| 140 | encoder_config->content_type = |
| 141 | screenshare_ ? VideoEncoderConfig::ContentType::kScreen |
| 142 | : VideoEncoderConfig::ContentType::kRealtimeVideo; |
| 143 | } |
| 144 | |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 145 | void PerformTest() override { |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 146 | EXPECT_TRUE(Wait()) << "Timed out waiting for min frames to be received."; |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 147 | } |
| 148 | |
Markus Handell | 9bbff07 | 2020-07-07 12:23:18 | [diff] [blame] | 149 | mutable Mutex mutex_; |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 150 | const bool use_rtx_; |
| 151 | const bool use_fec_; |
| 152 | const bool screenshare_; |
Niels Möller | 4db138e | 2018-04-19 07:04:13 | [diff] [blame] | 153 | test::FunctionVideoEncoderFactory encoder_factory_; |
Danil Chapovalov | b9b146c | 2018-06-15 10:28:07 | [diff] [blame] | 154 | absl::optional<int64_t> start_runtime_ms_; |
Markus Handell | 9bbff07 | 2020-07-07 12:23:18 | [diff] [blame] | 155 | int num_frames_received_ RTC_GUARDED_BY(&mutex_); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 156 | } test(use_rtx, use_fec, screenshare); |
| 157 | |
| 158 | metrics::Reset(); |
| 159 | RunBaseTest(&test); |
| 160 | |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 161 | const std::string video_prefix = |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 162 | screenshare ? "WebRTC.Video.Screenshare." : "WebRTC.Video."; |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 163 | |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 164 | // Verify that stats have been updated once. |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 165 | EXPECT_METRIC_EQ(2, metrics::NumSamples("WebRTC.Call.LifetimeInSeconds")); |
| 166 | EXPECT_METRIC_EQ(1, metrics::NumSamples( |
| 167 | "WebRTC.Call.TimeReceivingVideoRtpPacketsInSeconds")); |
| 168 | EXPECT_METRIC_EQ( |
| 169 | 1, metrics::NumSamples("WebRTC.Call.VideoBitrateReceivedInKbps")); |
| 170 | EXPECT_METRIC_EQ(1, |
| 171 | metrics::NumSamples("WebRTC.Call.RtcpBitrateReceivedInBps")); |
| 172 | EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Call.BitrateReceivedInKbps")); |
| 173 | EXPECT_METRIC_EQ( |
| 174 | 1, metrics::NumSamples("WebRTC.Call.EstimatedSendBitrateInKbps")); |
| 175 | EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Call.PacerBitrateInKbps")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 176 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 177 | EXPECT_METRIC_EQ( |
| 178 | 1, metrics::NumSamples("WebRTC.Video.SendStreamLifetimeInSeconds")); |
| 179 | EXPECT_METRIC_EQ( |
| 180 | 1, metrics::NumSamples("WebRTC.Video.ReceiveStreamLifetimeInSeconds")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 181 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 182 | EXPECT_METRIC_EQ( |
| 183 | 1, metrics::NumSamples("WebRTC.Video.NackPacketsSentPerMinute")); |
| 184 | EXPECT_METRIC_EQ( |
| 185 | 1, metrics::NumSamples(video_prefix + "NackPacketsReceivedPerMinute")); |
| 186 | EXPECT_METRIC_EQ(1, |
| 187 | metrics::NumSamples("WebRTC.Video.FirPacketsSentPerMinute")); |
| 188 | EXPECT_METRIC_EQ( |
| 189 | 1, metrics::NumSamples(video_prefix + "FirPacketsReceivedPerMinute")); |
| 190 | EXPECT_METRIC_EQ(1, |
| 191 | metrics::NumSamples("WebRTC.Video.PliPacketsSentPerMinute")); |
| 192 | EXPECT_METRIC_EQ( |
| 193 | 1, metrics::NumSamples(video_prefix + "PliPacketsReceivedPerMinute")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 194 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 195 | EXPECT_METRIC_EQ( |
| 196 | 1, metrics::NumSamples(video_prefix + "KeyFramesSentInPermille")); |
| 197 | EXPECT_METRIC_EQ( |
| 198 | 1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 199 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 200 | EXPECT_METRIC_EQ( |
| 201 | 1, metrics::NumSamples(video_prefix + "SentPacketsLostInPercent")); |
| 202 | EXPECT_METRIC_EQ( |
| 203 | 1, metrics::NumSamples("WebRTC.Video.ReceivedPacketsLostInPercent")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 204 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 205 | EXPECT_METRIC_EQ(1, metrics::NumSamples(video_prefix + "InputWidthInPixels")); |
| 206 | EXPECT_METRIC_EQ(1, |
| 207 | metrics::NumSamples(video_prefix + "InputHeightInPixels")); |
| 208 | EXPECT_METRIC_EQ(1, metrics::NumSamples(video_prefix + "SentWidthInPixels")); |
| 209 | EXPECT_METRIC_EQ(1, metrics::NumSamples(video_prefix + "SentHeightInPixels")); |
| 210 | EXPECT_METRIC_EQ(1, |
| 211 | metrics::NumSamples(video_prefix + "ReceivedWidthInPixels")); |
| 212 | EXPECT_METRIC_EQ( |
| 213 | 1, metrics::NumSamples(video_prefix + "ReceivedHeightInPixels")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 214 | |
Artem Titov | 0171666 | 2023-04-21 15:35:49 | [diff] [blame] | 215 | EXPECT_METRIC_EQ(1, |
Artem Titov | 8a9f3a8 | 2023-04-25 07:56:49 | [diff] [blame] | 216 | metrics::NumEvents(video_prefix + "InputWidthInPixels", |
| 217 | test::VideoTestConstants::kDefaultWidth)); |
| 218 | EXPECT_METRIC_EQ( |
| 219 | 1, metrics::NumEvents(video_prefix + "InputHeightInPixels", |
| 220 | test::VideoTestConstants::kDefaultHeight)); |
| 221 | EXPECT_METRIC_EQ(1, |
| 222 | metrics::NumEvents(video_prefix + "SentWidthInPixels", |
| 223 | test::VideoTestConstants::kDefaultWidth)); |
| 224 | EXPECT_METRIC_EQ( |
| 225 | 1, metrics::NumEvents(video_prefix + "SentHeightInPixels", |
| 226 | test::VideoTestConstants::kDefaultHeight)); |
| 227 | EXPECT_METRIC_EQ(1, |
| 228 | metrics::NumEvents(video_prefix + "ReceivedWidthInPixels", |
| 229 | test::VideoTestConstants::kDefaultWidth)); |
| 230 | EXPECT_METRIC_EQ( |
| 231 | 1, metrics::NumEvents(video_prefix + "ReceivedHeightInPixels", |
| 232 | test::VideoTestConstants::kDefaultHeight)); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 233 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 234 | EXPECT_METRIC_EQ(1, |
| 235 | metrics::NumSamples(video_prefix + "InputFramesPerSecond")); |
| 236 | EXPECT_METRIC_EQ(1, |
| 237 | metrics::NumSamples(video_prefix + "SentFramesPerSecond")); |
| 238 | EXPECT_METRIC_EQ(1, |
| 239 | metrics::NumSamples("WebRTC.Video.DecodedFramesPerSecond")); |
| 240 | EXPECT_METRIC_EQ(1, |
| 241 | metrics::NumSamples("WebRTC.Video.RenderFramesPerSecond")); |
| 242 | EXPECT_METRIC_EQ(1, |
| 243 | metrics::NumSamples("WebRTC.Video.DelayedFramesToRenderer")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 244 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 245 | EXPECT_METRIC_EQ(1, |
| 246 | metrics::NumSamples("WebRTC.Video.JitterBufferDelayInMs")); |
| 247 | EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.TargetDelayInMs")); |
| 248 | EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.CurrentDelayInMs")); |
| 249 | EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.OnewayDelayInMs")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 250 | |
Harald Alvestrand | 00f1122 | 2023-07-21 07:23:01 | [diff] [blame] | 251 | EXPECT_METRIC_EQ(1, metrics::NumSamples(video_prefix + "EndToEndDelayInMs")); |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 252 | EXPECT_METRIC_EQ(1, |
Harald Alvestrand | 00f1122 | 2023-07-21 07:23:01 | [diff] [blame] | 253 | metrics::NumSamples(video_prefix + "EndToEndDelayMaxInMs")); |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 254 | EXPECT_METRIC_EQ(1, |
Harald Alvestrand | 00f1122 | 2023-07-21 07:23:01 | [diff] [blame] | 255 | metrics::NumSamples(video_prefix + "InterframeDelayInMs")); |
| 256 | EXPECT_METRIC_EQ( |
| 257 | 1, metrics::NumSamples(video_prefix + "InterframeDelayMaxInMs")); |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 258 | EXPECT_METRIC_EQ( |
| 259 | 1, metrics::NumSamples("WebRTC.Video.RenderSqrtPixelsPerSecond")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 260 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 261 | EXPECT_METRIC_EQ(1, metrics::NumSamples(video_prefix + "EncodeTimeInMs")); |
| 262 | EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.DecodeTimeInMs")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 263 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 264 | EXPECT_METRIC_EQ(1, |
| 265 | metrics::NumSamples(video_prefix + "NumberOfPauseEvents")); |
| 266 | EXPECT_METRIC_EQ(1, |
| 267 | metrics::NumSamples(video_prefix + "PausedTimeInPercent")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 268 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 269 | EXPECT_METRIC_EQ(1, metrics::NumSamples(video_prefix + "BitrateSentInKbps")); |
| 270 | EXPECT_METRIC_EQ(1, |
| 271 | metrics::NumSamples("WebRTC.Video.BitrateReceivedInKbps")); |
| 272 | EXPECT_METRIC_EQ( |
| 273 | 1, metrics::NumSamples(video_prefix + "MediaBitrateSentInKbps")); |
| 274 | EXPECT_METRIC_EQ( |
| 275 | 1, metrics::NumSamples("WebRTC.Video.MediaBitrateReceivedInKbps")); |
| 276 | EXPECT_METRIC_EQ( |
| 277 | 1, metrics::NumSamples(video_prefix + "PaddingBitrateSentInKbps")); |
| 278 | EXPECT_METRIC_EQ( |
| 279 | 1, metrics::NumSamples("WebRTC.Video.PaddingBitrateReceivedInKbps")); |
| 280 | EXPECT_METRIC_EQ( |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 281 | 1, metrics::NumSamples(video_prefix + "RetransmittedBitrateSentInKbps")); |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 282 | EXPECT_METRIC_EQ(1, metrics::NumSamples( |
| 283 | "WebRTC.Video.RetransmittedBitrateReceivedInKbps")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 284 | |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 285 | EXPECT_METRIC_EQ(1, metrics::NumSamples("WebRTC.Video.SendDelayInMs")); |
| 286 | EXPECT_METRIC_EQ(1, metrics::NumSamples(video_prefix + "SendSideDelayInMs")); |
| 287 | EXPECT_METRIC_EQ(1, |
| 288 | metrics::NumSamples(video_prefix + "SendSideDelayMaxInMs")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 289 | |
| 290 | int num_rtx_samples = use_rtx ? 1 : 0; |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 291 | EXPECT_METRIC_EQ(num_rtx_samples, |
| 292 | metrics::NumSamples("WebRTC.Video.RtxBitrateSentInKbps")); |
| 293 | EXPECT_METRIC_EQ( |
| 294 | num_rtx_samples, |
| 295 | metrics::NumSamples("WebRTC.Video.RtxBitrateReceivedInKbps")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 296 | |
| 297 | int num_red_samples = use_fec ? 1 : 0; |
Ying Wang | ef3998f | 2019-12-09 12:06:53 | [diff] [blame] | 298 | EXPECT_METRIC_EQ(num_red_samples, |
| 299 | metrics::NumSamples("WebRTC.Video.FecBitrateSentInKbps")); |
| 300 | EXPECT_METRIC_EQ( |
| 301 | num_red_samples, |
| 302 | metrics::NumSamples("WebRTC.Video.FecBitrateReceivedInKbps")); |
| 303 | EXPECT_METRIC_EQ( |
| 304 | num_red_samples, |
| 305 | metrics::NumSamples("WebRTC.Video.ReceivedFecPacketsInPercent")); |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 306 | } |
| 307 | |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 308 | TEST_F(HistogramTest, VerifyStatsWithRtx) { |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 309 | const bool kEnabledRtx = true; |
| 310 | const bool kEnabledRed = false; |
| 311 | const bool kScreenshare = false; |
| 312 | VerifyHistogramStats(kEnabledRtx, kEnabledRed, kScreenshare); |
| 313 | } |
| 314 | |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 315 | TEST_F(HistogramTest, VerifyStatsWithRed) { |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 316 | const bool kEnabledRtx = false; |
| 317 | const bool kEnabledRed = true; |
| 318 | const bool kScreenshare = false; |
| 319 | VerifyHistogramStats(kEnabledRtx, kEnabledRed, kScreenshare); |
| 320 | } |
| 321 | |
Åsa Persson | 5b2b692 | 2018-05-07 07:55:51 | [diff] [blame] | 322 | TEST_F(HistogramTest, VerifyStatsWithScreenshare) { |
Sebastian Jansson | c501713 | 2018-02-02 15:24:16 | [diff] [blame] | 323 | const bool kEnabledRtx = false; |
| 324 | const bool kEnabledRed = false; |
| 325 | const bool kScreenshare = true; |
| 326 | VerifyHistogramStats(kEnabledRtx, kEnabledRed, kScreenshare); |
| 327 | } |
| 328 | |
| 329 | } // namespace webrtc |