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

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

Issue 1905583002: Reland of Deprecate VCMPacketizationCallback::SendData and use EncodedImageCallback instead. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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/video/send_statistics_proxy.cc ('k') | webrtc/video/video_receive_stream.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
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 EXPECT_EQ(0, test::NumHistogramSamples("WebRTC.Video.InputWidthInPixels")); 327 EXPECT_EQ(0, test::NumHistogramSamples("WebRTC.Video.InputWidthInPixels"));
328 328
329 // Switch to screenshare, real-time stats should be updated. 329 // Switch to screenshare, real-time stats should be updated.
330 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); 330 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen);
331 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.InputWidthInPixels")); 331 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.InputWidthInPixels"));
332 } 332 }
333 333
334 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8) { 334 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8) {
335 test::ClearHistograms(); 335 test::ClearHistograms();
336 EncodedImage encoded_image; 336 EncodedImage encoded_image;
337 RTPVideoHeader rtp_video_header; 337 CodecSpecificInfo codec_info;
338 rtp_video_header.codec = kRtpVideoVp8; 338 codec_info.codecType = kVideoCodecVP8;
339 339
340 for (int i = 0; i < kMinRequiredSamples; ++i) { 340 for (int i = 0; i < kMinRequiredSamples; ++i) {
341 rtp_video_header.simulcastIdx = 0; 341 codec_info.codecSpecific.VP8.simulcastIdx = 0;
342 encoded_image.qp_ = kQpIdx0; 342 encoded_image.qp_ = kQpIdx0;
343 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header); 343 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
344 rtp_video_header.simulcastIdx = 1; 344 codec_info.codecSpecific.VP8.simulcastIdx = 1;
345 encoded_image.qp_ = kQpIdx1; 345 encoded_image.qp_ = kQpIdx1;
346 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header); 346 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
347 } 347 }
348 statistics_proxy_.reset(); 348 statistics_proxy_.reset();
349 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp8.S0")); 349 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp8.S0"));
350 EXPECT_EQ(kQpIdx0, 350 EXPECT_EQ(kQpIdx0,
351 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp8.S0")); 351 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp8.S0"));
352 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp8.S1")); 352 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp8.S1"));
353 EXPECT_EQ(kQpIdx1, 353 EXPECT_EQ(kQpIdx1,
354 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp8.S1")); 354 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp8.S1"));
355 } 355 }
356 356
357 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8OneSsrc) { 357 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8OneSsrc) {
358 VideoSendStream::Config config(nullptr); 358 VideoSendStream::Config config(nullptr);
359 config.rtp.ssrcs.push_back(kFirstSsrc); 359 config.rtp.ssrcs.push_back(kFirstSsrc);
360 statistics_proxy_.reset(new SendStatisticsProxy( 360 statistics_proxy_.reset(new SendStatisticsProxy(
361 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo)); 361 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo));
362 362
363 test::ClearHistograms(); 363 test::ClearHistograms();
364 EncodedImage encoded_image; 364 EncodedImage encoded_image;
365 RTPVideoHeader rtp_video_header; 365 CodecSpecificInfo codec_info;
366 rtp_video_header.codec = kRtpVideoVp8; 366 codec_info.codecType = kVideoCodecVP8;
367 367
368 for (int i = 0; i < kMinRequiredSamples; ++i) { 368 for (int i = 0; i < kMinRequiredSamples; ++i) {
369 rtp_video_header.simulcastIdx = 0; 369 codec_info.codecSpecific.VP8.simulcastIdx = 0;
370 encoded_image.qp_ = kQpIdx0; 370 encoded_image.qp_ = kQpIdx0;
371 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header); 371 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
372 } 372 }
373 statistics_proxy_.reset(); 373 statistics_proxy_.reset();
374 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp8")); 374 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp8"));
375 EXPECT_EQ(kQpIdx0, test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp8")); 375 EXPECT_EQ(kQpIdx0, test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp8"));
376 } 376 }
377 377
378 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9) { 378 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9) {
379 test::ClearHistograms(); 379 test::ClearHistograms();
380 EncodedImage encoded_image; 380 EncodedImage encoded_image;
381 RTPVideoHeader rtp_video_header; 381 CodecSpecificInfo codec_info;
382 rtp_video_header.simulcastIdx = 0; 382 codec_info.codecType = kVideoCodecVP9;
383 rtp_video_header.codec = kRtpVideoVp9; 383 codec_info.codecSpecific.VP9.num_spatial_layers = 2;
384 rtp_video_header.codecHeader.VP9.num_spatial_layers = 2;
385 384
386 for (int i = 0; i < kMinRequiredSamples; ++i) { 385 for (int i = 0; i < kMinRequiredSamples; ++i) {
387 encoded_image.qp_ = kQpIdx0; 386 encoded_image.qp_ = kQpIdx0;
388 rtp_video_header.codecHeader.VP9.spatial_idx = 0; 387 codec_info.codecSpecific.VP9.spatial_idx = 0;
389 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header); 388 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
390 encoded_image.qp_ = kQpIdx1; 389 encoded_image.qp_ = kQpIdx1;
391 rtp_video_header.codecHeader.VP9.spatial_idx = 1; 390 codec_info.codecSpecific.VP9.spatial_idx = 1;
392 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header); 391 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
393 } 392 }
394 statistics_proxy_.reset(); 393 statistics_proxy_.reset();
395 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9.S0")); 394 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9.S0"));
396 EXPECT_EQ(kQpIdx0, 395 EXPECT_EQ(kQpIdx0,
397 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9.S0")); 396 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9.S0"));
398 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9.S1")); 397 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9.S1"));
399 EXPECT_EQ(kQpIdx1, 398 EXPECT_EQ(kQpIdx1,
400 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9.S1")); 399 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9.S1"));
401 } 400 }
402 401
403 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9OneSpatialLayer) { 402 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9OneSpatialLayer) {
404 VideoSendStream::Config config(nullptr); 403 VideoSendStream::Config config(nullptr);
405 config.rtp.ssrcs.push_back(kFirstSsrc); 404 config.rtp.ssrcs.push_back(kFirstSsrc);
406 statistics_proxy_.reset(new SendStatisticsProxy( 405 statistics_proxy_.reset(new SendStatisticsProxy(
407 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo)); 406 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo));
408 407
409 test::ClearHistograms(); 408 test::ClearHistograms();
410 EncodedImage encoded_image; 409 EncodedImage encoded_image;
411 RTPVideoHeader rtp_video_header; 410 CodecSpecificInfo codec_info;
412 rtp_video_header.simulcastIdx = 0; 411 codec_info.codecType = kVideoCodecVP9;
413 rtp_video_header.codec = kRtpVideoVp9; 412 codec_info.codecSpecific.VP9.num_spatial_layers = 1;
414 rtp_video_header.codecHeader.VP9.num_spatial_layers = 1;
415 413
416 for (int i = 0; i < kMinRequiredSamples; ++i) { 414 for (int i = 0; i < kMinRequiredSamples; ++i) {
417 encoded_image.qp_ = kQpIdx0; 415 encoded_image.qp_ = kQpIdx0;
418 rtp_video_header.codecHeader.VP9.spatial_idx = 0; 416 codec_info.codecSpecific.VP9.spatial_idx = 0;
419 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header); 417 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
420 } 418 }
421 statistics_proxy_.reset(); 419 statistics_proxy_.reset();
422 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9")); 420 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9"));
423 EXPECT_EQ(kQpIdx0, test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9")); 421 EXPECT_EQ(kQpIdx0, test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9"));
424 } 422 }
425 423
426 TEST_F(SendStatisticsProxyTest, NoSubstreams) { 424 TEST_F(SendStatisticsProxyTest, NoSubstreams) {
427 uint32_t excluded_ssrc = 425 uint32_t excluded_ssrc =
428 std::max( 426 std::max(
429 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), 427 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()),
(...skipping 21 matching lines...) Expand all
451 EXPECT_TRUE(stats.substreams.empty()); 449 EXPECT_TRUE(stats.substreams.empty());
452 } 450 }
453 451
454 TEST_F(SendStatisticsProxyTest, EncodedResolutionTimesOut) { 452 TEST_F(SendStatisticsProxyTest, EncodedResolutionTimesOut) {
455 static const int kEncodedWidth = 123; 453 static const int kEncodedWidth = 123;
456 static const int kEncodedHeight = 81; 454 static const int kEncodedHeight = 81;
457 EncodedImage encoded_image; 455 EncodedImage encoded_image;
458 encoded_image._encodedWidth = kEncodedWidth; 456 encoded_image._encodedWidth = kEncodedWidth;
459 encoded_image._encodedHeight = kEncodedHeight; 457 encoded_image._encodedHeight = kEncodedHeight;
460 458
461 RTPVideoHeader rtp_video_header; 459 CodecSpecificInfo codec_info;
460 codec_info.codecType = kVideoCodecVP8;
461 codec_info.codecSpecific.VP8.simulcastIdx = 0;
462 462
463 rtp_video_header.simulcastIdx = 0; 463 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
464 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header); 464 codec_info.codecSpecific.VP8.simulcastIdx = 1;
465 rtp_video_header.simulcastIdx = 1; 465 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
466 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
467 466
468 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); 467 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
469 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width); 468 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width);
470 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height); 469 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height);
471 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[1]].width); 470 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[1]].width);
472 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[1]].height); 471 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[1]].height);
473 472
474 // Forward almost to timeout, this should not have removed stats. 473 // Forward almost to timeout, this should not have removed stats.
475 fake_clock_.AdvanceTimeMilliseconds(SendStatisticsProxy::kStatsTimeoutMs - 1); 474 fake_clock_.AdvanceTimeMilliseconds(SendStatisticsProxy::kStatsTimeoutMs - 1);
476 stats = statistics_proxy_->GetStats(); 475 stats = statistics_proxy_->GetStats();
477 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width); 476 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width);
478 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height); 477 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height);
479 478
480 // Update the first SSRC with bogus RTCP stats to make sure that encoded 479 // Update the first SSRC with bogus RTCP stats to make sure that encoded
481 // resolution still times out (no global timeout for all stats). 480 // resolution still times out (no global timeout for all stats).
482 RtcpStatistics rtcp_statistics; 481 RtcpStatistics rtcp_statistics;
483 RtcpStatisticsCallback* rtcp_stats = statistics_proxy_.get(); 482 RtcpStatisticsCallback* rtcp_stats = statistics_proxy_.get();
484 rtcp_stats->StatisticsUpdated(rtcp_statistics, config_.rtp.ssrcs[0]); 483 rtcp_stats->StatisticsUpdated(rtcp_statistics, config_.rtp.ssrcs[0]);
485 484
486 // Report stats for second SSRC to make sure it's not outdated along with the 485 // Report stats for second SSRC to make sure it's not outdated along with the
487 // first SSRC. 486 // first SSRC.
488 rtp_video_header.simulcastIdx = 1; 487 codec_info.codecSpecific.VP8.simulcastIdx = 1;
489 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header); 488 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
490 489
491 // Forward 1 ms, reach timeout, substream 0 should have no resolution 490 // Forward 1 ms, reach timeout, substream 0 should have no resolution
492 // reported, but substream 1 should. 491 // reported, but substream 1 should.
493 fake_clock_.AdvanceTimeMilliseconds(1); 492 fake_clock_.AdvanceTimeMilliseconds(1);
494 stats = statistics_proxy_->GetStats(); 493 stats = statistics_proxy_->GetStats();
495 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[0]].width); 494 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[0]].width);
496 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[0]].height); 495 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[0]].height);
497 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[1]].width); 496 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[1]].width);
498 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[1]].height); 497 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[1]].height);
499 } 498 }
500 499
501 TEST_F(SendStatisticsProxyTest, ClearsResolutionFromInactiveSsrcs) { 500 TEST_F(SendStatisticsProxyTest, ClearsResolutionFromInactiveSsrcs) {
502 static const int kEncodedWidth = 123; 501 static const int kEncodedWidth = 123;
503 static const int kEncodedHeight = 81; 502 static const int kEncodedHeight = 81;
504 EncodedImage encoded_image; 503 EncodedImage encoded_image;
505 encoded_image._encodedWidth = kEncodedWidth; 504 encoded_image._encodedWidth = kEncodedWidth;
506 encoded_image._encodedHeight = kEncodedHeight; 505 encoded_image._encodedHeight = kEncodedHeight;
507 506
508 RTPVideoHeader rtp_video_header; 507 CodecSpecificInfo codec_info;
508 codec_info.codecType = kVideoCodecVP8;
509 codec_info.codecSpecific.VP8.simulcastIdx = 0;
509 510
510 rtp_video_header.simulcastIdx = 0; 511 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
511 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header); 512 codec_info.codecSpecific.VP8.simulcastIdx = 1;
512 rtp_video_header.simulcastIdx = 1; 513 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
513 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
514 514
515 statistics_proxy_->OnInactiveSsrc(config_.rtp.ssrcs[1]); 515 statistics_proxy_->OnInactiveSsrc(config_.rtp.ssrcs[1]);
516 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); 516 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
517 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width); 517 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width);
518 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height); 518 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height);
519 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].width); 519 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].width);
520 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].height); 520 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[1]].height);
521 } 521 }
522 522
523 TEST_F(SendStatisticsProxyTest, ClearsBitratesFromInactiveSsrcs) { 523 TEST_F(SendStatisticsProxyTest, ClearsBitratesFromInactiveSsrcs) {
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 749
750 EXPECT_EQ(1, test::NumHistogramSamples( 750 EXPECT_EQ(1, test::NumHistogramSamples(
751 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); 751 "WebRTC.Video.Screenshare.FecBitrateSentInKbps"));
752 EXPECT_EQ(static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / 752 EXPECT_EQ(static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) /
753 metrics::kMinRunTimeInSeconds / 1000), 753 metrics::kMinRunTimeInSeconds / 1000),
754 test::LastHistogramSample( 754 test::LastHistogramSample(
755 "WebRTC.Video.Screenshare.FecBitrateSentInKbps")); 755 "WebRTC.Video.Screenshare.FecBitrateSentInKbps"));
756 } 756 }
757 757
758 } // namespace webrtc 758 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/send_statistics_proxy.cc ('k') | webrtc/video/video_receive_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698