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

Side by Side Diff: webrtc/video/send_statistics_proxy_unittest.cc

Issue 2304363002: Let ViEEncoder express resolution requests as Sinkwants (Closed)
Patch Set: Rebased. Created 4 years, 1 month 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/video/send_statistics_proxy.cc ('k') | webrtc/video/video_quality_test.cc » ('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 (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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
11 #include "webrtc/video/send_statistics_proxy.h" 11 #include "webrtc/video/send_statistics_proxy.h"
12 12
13 #include <map> 13 #include <map>
14 #include <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/system_wrappers/include/metrics.h" 18 #include "webrtc/system_wrappers/include/metrics.h"
19 #include "webrtc/system_wrappers/include/metrics_default.h" 19 #include "webrtc/system_wrappers/include/metrics_default.h"
20 #include "webrtc/test/gtest.h" 20 #include "webrtc/test/gtest.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 namespace { 23 namespace {
24 const uint32_t kFirstSsrc = 17; 24 const uint32_t kFirstSsrc = 17;
25 const uint32_t kSecondSsrc = 42; 25 const uint32_t kSecondSsrc = 42;
26 const uint32_t kFirstRtxSsrc = 18; 26 const uint32_t kFirstRtxSsrc = 18;
27 const uint32_t kSecondRtxSsrc = 43; 27 const uint32_t kSecondRtxSsrc = 43;
28 28
29 const int kMinRequiredSamples = 200;
30 const int kQpIdx0 = 21; 29 const int kQpIdx0 = 21;
31 const int kQpIdx1 = 39; 30 const int kQpIdx1 = 39;
32 } // namespace 31 } // namespace
33 32
34 class SendStatisticsProxyTest : public ::testing::Test { 33 class SendStatisticsProxyTest : public ::testing::Test {
35 public: 34 public:
36 SendStatisticsProxyTest() 35 SendStatisticsProxyTest()
37 : fake_clock_(1234), config_(GetTestConfig()), avg_delay_ms_(0), 36 : fake_clock_(1234), config_(GetTestConfig()), avg_delay_ms_(0),
38 max_delay_ms_(0) {} 37 max_delay_ms_(0) {}
39 virtual ~SendStatisticsProxyTest() {} 38 virtual ~SendStatisticsProxyTest() {}
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 encoded_image.qp_ = -1; 329 encoded_image.qp_ = -1;
331 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum); 330 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
332 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 331 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
333 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum); 332 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
334 } 333 }
335 334
336 TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { 335 TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) {
337 const int kWidth = 640; 336 const int kWidth = 640;
338 const int kHeight = 480; 337 const int kHeight = 480;
339 338
340 for (int i = 0; i < kMinRequiredSamples; ++i) 339 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
341 statistics_proxy_->OnIncomingFrame(kWidth, kHeight); 340 statistics_proxy_->OnIncomingFrame(kWidth, kHeight);
342 341
343 // No switch, stats should not be updated. 342 // No switch, stats should not be updated.
344 VideoEncoderConfig config; 343 VideoEncoderConfig config;
345 config.content_type = VideoEncoderConfig::ContentType::kRealtimeVideo; 344 config.content_type = VideoEncoderConfig::ContentType::kRealtimeVideo;
346 statistics_proxy_->OnEncoderReconfigured(config, 50); 345 statistics_proxy_->OnEncoderReconfigured(config, 50);
347 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); 346 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InputWidthInPixels"));
348 347
349 // Switch to screenshare, real-time stats should be updated. 348 // Switch to screenshare, real-time stats should be updated.
350 config.content_type = VideoEncoderConfig::ContentType::kScreen; 349 config.content_type = VideoEncoderConfig::ContentType::kScreen;
351 statistics_proxy_->OnEncoderReconfigured(config, 50); 350 statistics_proxy_->OnEncoderReconfigured(config, 50);
352 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); 351 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InputWidthInPixels"));
353 } 352 }
354 353
354 TEST_F(SendStatisticsProxyTest, CpuLimitedResolutionUpdated) {
355 const int kWidth = 640;
356 const int kHeight = 480;
357
358 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
359 statistics_proxy_->OnIncomingFrame(kWidth, kHeight);
360
361 statistics_proxy_->OnCpuRestrictedResolutionChanged(true);
362
363 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
364 statistics_proxy_->OnIncomingFrame(kWidth, kHeight);
365
366 statistics_proxy_.reset();
367 EXPECT_EQ(1,
368 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent"));
369 EXPECT_EQ(
370 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50));
371 }
372
355 TEST_F(SendStatisticsProxyTest, LifetimeHistogramIsUpdated) { 373 TEST_F(SendStatisticsProxyTest, LifetimeHistogramIsUpdated) {
356 const int64_t kTimeSec = 3; 374 const int64_t kTimeSec = 3;
357 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000); 375 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000);
358 statistics_proxy_.reset(); 376 statistics_proxy_.reset();
359 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.SendStreamLifetimeInSeconds")); 377 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.SendStreamLifetimeInSeconds"));
360 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendStreamLifetimeInSeconds", 378 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendStreamLifetimeInSeconds",
361 kTimeSec)); 379 kTimeSec));
362 } 380 }
363 381
364 TEST_F(SendStatisticsProxyTest, CodecTypeHistogramIsUpdated) { 382 TEST_F(SendStatisticsProxyTest, CodecTypeHistogramIsUpdated) {
365 fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); 383 fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000);
366 statistics_proxy_.reset(); 384 statistics_proxy_.reset();
367 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoder.CodecType")); 385 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoder.CodecType"));
368 } 386 }
369 387
370 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8) { 388 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8) {
371 EncodedImage encoded_image; 389 EncodedImage encoded_image;
372 CodecSpecificInfo codec_info; 390 CodecSpecificInfo codec_info;
373 codec_info.codecType = kVideoCodecVP8; 391 codec_info.codecType = kVideoCodecVP8;
374 392
375 for (int i = 0; i < kMinRequiredSamples; ++i) { 393 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
376 codec_info.codecSpecific.VP8.simulcastIdx = 0; 394 codec_info.codecSpecific.VP8.simulcastIdx = 0;
377 encoded_image.qp_ = kQpIdx0; 395 encoded_image.qp_ = kQpIdx0;
378 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 396 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
379 codec_info.codecSpecific.VP8.simulcastIdx = 1; 397 codec_info.codecSpecific.VP8.simulcastIdx = 1;
380 encoded_image.qp_ = kQpIdx1; 398 encoded_image.qp_ = kQpIdx1;
381 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 399 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
382 } 400 }
383 statistics_proxy_.reset(); 401 statistics_proxy_.reset();
384 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp8.S0")); 402 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp8.S0"));
385 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp8.S0", kQpIdx0)); 403 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp8.S0", kQpIdx0));
386 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp8.S1")); 404 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp8.S1"));
387 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp8.S1", kQpIdx1)); 405 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp8.S1", kQpIdx1));
388 } 406 }
389 407
390 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8OneSsrc) { 408 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8OneSsrc) {
391 VideoSendStream::Config config(nullptr); 409 VideoSendStream::Config config(nullptr);
392 config.rtp.ssrcs.push_back(kFirstSsrc); 410 config.rtp.ssrcs.push_back(kFirstSsrc);
393 statistics_proxy_.reset(new SendStatisticsProxy( 411 statistics_proxy_.reset(new SendStatisticsProxy(
394 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo)); 412 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo));
395 413
396 EncodedImage encoded_image; 414 EncodedImage encoded_image;
397 CodecSpecificInfo codec_info; 415 CodecSpecificInfo codec_info;
398 codec_info.codecType = kVideoCodecVP8; 416 codec_info.codecType = kVideoCodecVP8;
399 417
400 for (int i = 0; i < kMinRequiredSamples; ++i) { 418 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
401 codec_info.codecSpecific.VP8.simulcastIdx = 0; 419 codec_info.codecSpecific.VP8.simulcastIdx = 0;
402 encoded_image.qp_ = kQpIdx0; 420 encoded_image.qp_ = kQpIdx0;
403 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 421 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
404 } 422 }
405 statistics_proxy_.reset(); 423 statistics_proxy_.reset();
406 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp8")); 424 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp8"));
407 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp8", kQpIdx0)); 425 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp8", kQpIdx0));
408 } 426 }
409 427
410 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9) { 428 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9) {
411 EncodedImage encoded_image; 429 EncodedImage encoded_image;
412 CodecSpecificInfo codec_info; 430 CodecSpecificInfo codec_info;
413 codec_info.codecType = kVideoCodecVP9; 431 codec_info.codecType = kVideoCodecVP9;
414 codec_info.codecSpecific.VP9.num_spatial_layers = 2; 432 codec_info.codecSpecific.VP9.num_spatial_layers = 2;
415 433
416 for (int i = 0; i < kMinRequiredSamples; ++i) { 434 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
417 encoded_image.qp_ = kQpIdx0; 435 encoded_image.qp_ = kQpIdx0;
418 codec_info.codecSpecific.VP9.spatial_idx = 0; 436 codec_info.codecSpecific.VP9.spatial_idx = 0;
419 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 437 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
420 encoded_image.qp_ = kQpIdx1; 438 encoded_image.qp_ = kQpIdx1;
421 codec_info.codecSpecific.VP9.spatial_idx = 1; 439 codec_info.codecSpecific.VP9.spatial_idx = 1;
422 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 440 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
423 } 441 }
424 statistics_proxy_.reset(); 442 statistics_proxy_.reset();
425 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp9.S0")); 443 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp9.S0"));
426 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9.S0", kQpIdx0)); 444 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9.S0", kQpIdx0));
427 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp9.S1")); 445 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp9.S1"));
428 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9.S1", kQpIdx1)); 446 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9.S1", kQpIdx1));
429 } 447 }
430 448
431 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9OneSpatialLayer) { 449 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9OneSpatialLayer) {
432 VideoSendStream::Config config(nullptr); 450 VideoSendStream::Config config(nullptr);
433 config.rtp.ssrcs.push_back(kFirstSsrc); 451 config.rtp.ssrcs.push_back(kFirstSsrc);
434 statistics_proxy_.reset(new SendStatisticsProxy( 452 statistics_proxy_.reset(new SendStatisticsProxy(
435 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo)); 453 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo));
436 454
437 EncodedImage encoded_image; 455 EncodedImage encoded_image;
438 CodecSpecificInfo codec_info; 456 CodecSpecificInfo codec_info;
439 codec_info.codecType = kVideoCodecVP9; 457 codec_info.codecType = kVideoCodecVP9;
440 codec_info.codecSpecific.VP9.num_spatial_layers = 1; 458 codec_info.codecSpecific.VP9.num_spatial_layers = 1;
441 459
442 for (int i = 0; i < kMinRequiredSamples; ++i) { 460 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
443 encoded_image.qp_ = kQpIdx0; 461 encoded_image.qp_ = kQpIdx0;
444 codec_info.codecSpecific.VP9.spatial_idx = 0; 462 codec_info.codecSpecific.VP9.spatial_idx = 0;
445 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 463 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
446 } 464 }
447 statistics_proxy_.reset(); 465 statistics_proxy_.reset();
448 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp9")); 466 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp9"));
449 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9", kQpIdx0)); 467 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9", kQpIdx0));
450 } 468 }
451 469
452 TEST_F(SendStatisticsProxyTest, 470 TEST_F(SendStatisticsProxyTest,
453 BandwidthLimitedHistogramsNotUpdatedWhenDisabled) { 471 BandwidthLimitedHistogramsNotUpdatedWhenDisabled) {
454 EncodedImage encoded_image; 472 EncodedImage encoded_image;
455 // encoded_image.adapt_reason_.bw_resolutions_disabled by default: -1 473 // encoded_image.adapt_reason_.bw_resolutions_disabled by default: -1
456 for (int i = 0; i < kMinRequiredSamples; ++i) 474 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
457 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 475 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
458 476
459 // Histograms are updated when the statistics_proxy_ is deleted. 477 // Histograms are updated when the statistics_proxy_ is deleted.
460 statistics_proxy_.reset(); 478 statistics_proxy_.reset();
461 EXPECT_EQ(0, metrics::NumSamples( 479 EXPECT_EQ(0, metrics::NumSamples(
462 "WebRTC.Video.BandwidthLimitedResolutionInPercent")); 480 "WebRTC.Video.BandwidthLimitedResolutionInPercent"));
463 EXPECT_EQ(0, metrics::NumSamples( 481 EXPECT_EQ(0, metrics::NumSamples(
464 "WebRTC.Video.BandwidthLimitedResolutionsDisabled")); 482 "WebRTC.Video.BandwidthLimitedResolutionsDisabled"));
465 } 483 }
466 484
467 TEST_F(SendStatisticsProxyTest, 485 TEST_F(SendStatisticsProxyTest,
468 BandwidthLimitedHistogramsUpdatedWhenEnabled_NoResolutionDisabled) { 486 BandwidthLimitedHistogramsUpdatedWhenEnabled_NoResolutionDisabled) {
469 const int kResolutionsDisabled = 0; 487 const int kResolutionsDisabled = 0;
470 EncodedImage encoded_image; 488 EncodedImage encoded_image;
471 encoded_image.adapt_reason_.bw_resolutions_disabled = kResolutionsDisabled; 489 encoded_image.adapt_reason_.bw_resolutions_disabled = kResolutionsDisabled;
472 for (int i = 0; i < kMinRequiredSamples; ++i) 490 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
473 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 491 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
474 492
475 // Histograms are updated when the statistics_proxy_ is deleted. 493 // Histograms are updated when the statistics_proxy_ is deleted.
476 statistics_proxy_.reset(); 494 statistics_proxy_.reset();
477 EXPECT_EQ(1, metrics::NumSamples( 495 EXPECT_EQ(1, metrics::NumSamples(
478 "WebRTC.Video.BandwidthLimitedResolutionInPercent")); 496 "WebRTC.Video.BandwidthLimitedResolutionInPercent"));
479 EXPECT_EQ(1, metrics::NumEvents( 497 EXPECT_EQ(1, metrics::NumEvents(
480 "WebRTC.Video.BandwidthLimitedResolutionInPercent", 0)); 498 "WebRTC.Video.BandwidthLimitedResolutionInPercent", 0));
481 // No resolution disabled. 499 // No resolution disabled.
482 EXPECT_EQ(0, metrics::NumSamples( 500 EXPECT_EQ(0, metrics::NumSamples(
483 "WebRTC.Video.BandwidthLimitedResolutionsDisabled")); 501 "WebRTC.Video.BandwidthLimitedResolutionsDisabled"));
484 } 502 }
485 503
486 TEST_F(SendStatisticsProxyTest, 504 TEST_F(SendStatisticsProxyTest,
487 BandwidthLimitedHistogramsUpdatedWhenEnabled_OneResolutionDisabled) { 505 BandwidthLimitedHistogramsUpdatedWhenEnabled_OneResolutionDisabled) {
488 const int kResolutionsDisabled = 1; 506 const int kResolutionsDisabled = 1;
489 EncodedImage encoded_image; 507 EncodedImage encoded_image;
490 encoded_image.adapt_reason_.bw_resolutions_disabled = kResolutionsDisabled; 508 encoded_image.adapt_reason_.bw_resolutions_disabled = kResolutionsDisabled;
491 for (int i = 0; i < kMinRequiredSamples; ++i) 509 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
492 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 510 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
493 511
494 // Histograms are updated when the statistics_proxy_ is deleted. 512 // Histograms are updated when the statistics_proxy_ is deleted.
495 statistics_proxy_.reset(); 513 statistics_proxy_.reset();
496 EXPECT_EQ(1, metrics::NumSamples( 514 EXPECT_EQ(1, metrics::NumSamples(
497 "WebRTC.Video.BandwidthLimitedResolutionInPercent")); 515 "WebRTC.Video.BandwidthLimitedResolutionInPercent"));
498 EXPECT_EQ(1, metrics::NumEvents( 516 EXPECT_EQ(1, metrics::NumEvents(
499 "WebRTC.Video.BandwidthLimitedResolutionInPercent", 100)); 517 "WebRTC.Video.BandwidthLimitedResolutionInPercent", 100));
500 // Resolutions disabled. 518 // Resolutions disabled.
501 EXPECT_EQ(1, metrics::NumSamples( 519 EXPECT_EQ(1, metrics::NumSamples(
502 "WebRTC.Video.BandwidthLimitedResolutionsDisabled")); 520 "WebRTC.Video.BandwidthLimitedResolutionsDisabled"));
503 EXPECT_EQ( 521 EXPECT_EQ(
504 1, metrics::NumEvents("WebRTC.Video.BandwidthLimitedResolutionsDisabled", 522 1, metrics::NumEvents("WebRTC.Video.BandwidthLimitedResolutionsDisabled",
505 kResolutionsDisabled)); 523 kResolutionsDisabled));
506 } 524 }
507 525
508 TEST_F(SendStatisticsProxyTest, 526 TEST_F(SendStatisticsProxyTest,
509 QualityLimitedHistogramsNotUpdatedWhenDisabled) { 527 QualityLimitedHistogramsNotUpdatedWhenDisabled) {
510 EncodedImage encoded_image; 528 EncodedImage encoded_image;
511 // encoded_image.adapt_reason_.quality_resolution_downscales disabled by 529 // encoded_image.adapt_reason_.quality_resolution_downscales disabled by
512 // default: -1 530 // default: -1
513 for (int i = 0; i < kMinRequiredSamples; ++i) 531 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
514 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 532 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
515 533
516 // Histograms are updated when the statistics_proxy_ is deleted. 534 // Histograms are updated when the statistics_proxy_ is deleted.
517 statistics_proxy_.reset(); 535 statistics_proxy_.reset();
518 EXPECT_EQ( 536 EXPECT_EQ(
519 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); 537 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent"));
520 EXPECT_EQ(0, metrics::NumSamples( 538 EXPECT_EQ(0, metrics::NumSamples(
521 "WebRTC.Video.QualityLimitedResolutionDownscales")); 539 "WebRTC.Video.QualityLimitedResolutionDownscales"));
522 } 540 }
523 541
524 TEST_F(SendStatisticsProxyTest, 542 TEST_F(SendStatisticsProxyTest,
525 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) { 543 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) {
526 const int kDownscales = 0; 544 const int kDownscales = 0;
527 EncodedImage encoded_image; 545 EncodedImage encoded_image;
528 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; 546 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales;
529 for (int i = 0; i < kMinRequiredSamples; ++i) 547 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
530 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 548 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
531 549
532 // Histograms are updated when the statistics_proxy_ is deleted. 550 // Histograms are updated when the statistics_proxy_ is deleted.
533 statistics_proxy_.reset(); 551 statistics_proxy_.reset();
534 EXPECT_EQ( 552 EXPECT_EQ(
535 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); 553 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent"));
536 EXPECT_EQ(1, metrics::NumEvents( 554 EXPECT_EQ(1, metrics::NumEvents(
537 "WebRTC.Video.QualityLimitedResolutionInPercent", 0)); 555 "WebRTC.Video.QualityLimitedResolutionInPercent", 0));
538 // No resolution downscale. 556 // No resolution downscale.
539 EXPECT_EQ(0, metrics::NumSamples( 557 EXPECT_EQ(0, metrics::NumSamples(
540 "WebRTC.Video.QualityLimitedResolutionDownscales")); 558 "WebRTC.Video.QualityLimitedResolutionDownscales"));
541 } 559 }
542 560
543 TEST_F(SendStatisticsProxyTest, 561 TEST_F(SendStatisticsProxyTest,
544 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) { 562 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) {
545 const int kDownscales = 2; 563 const int kDownscales = 2;
546 EncodedImage encoded_image; 564 EncodedImage encoded_image;
547 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; 565 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales;
548 for (int i = 0; i < kMinRequiredSamples; ++i) 566 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
549 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 567 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
550 568
551 // Histograms are updated when the statistics_proxy_ is deleted. 569 // Histograms are updated when the statistics_proxy_ is deleted.
552 statistics_proxy_.reset(); 570 statistics_proxy_.reset();
553 EXPECT_EQ( 571 EXPECT_EQ(
554 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); 572 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent"));
555 EXPECT_EQ(1, metrics::NumEvents( 573 EXPECT_EQ(1, metrics::NumEvents(
556 "WebRTC.Video.QualityLimitedResolutionInPercent", 100)); 574 "WebRTC.Video.QualityLimitedResolutionInPercent", 100));
557 // Resolution downscales. 575 // Resolution downscales.
558 EXPECT_EQ(1, metrics::NumSamples( 576 EXPECT_EQ(1, metrics::NumSamples(
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 949
932 EXPECT_EQ( 950 EXPECT_EQ(
933 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); 951 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps"));
934 EXPECT_EQ(1, metrics::NumEvents( 952 EXPECT_EQ(1, metrics::NumEvents(
935 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", 953 "WebRTC.Video.Screenshare.FecBitrateSentInKbps",
936 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / 954 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) /
937 metrics::kMinRunTimeInSeconds / 1000))); 955 metrics::kMinRunTimeInSeconds / 1000)));
938 } 956 }
939 957
940 } // namespace webrtc 958 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/send_statistics_proxy.cc ('k') | webrtc/video/video_quality_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698