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

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

Issue 1903193002: Revert 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 CodecSpecificInfo codec_info; 337 RTPVideoHeader rtp_video_header;
338 codec_info.codecType = kVideoCodecVP8; 338 rtp_video_header.codec = kRtpVideoVp8;
339 339
340 for (int i = 0; i < kMinRequiredSamples; ++i) { 340 for (int i = 0; i < kMinRequiredSamples; ++i) {
341 codec_info.codecSpecific.VP8.simulcastIdx = 0; 341 rtp_video_header.simulcastIdx = 0;
342 encoded_image.qp_ = kQpIdx0; 342 encoded_image.qp_ = kQpIdx0;
343 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 343 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
344 codec_info.codecSpecific.VP8.simulcastIdx = 1; 344 rtp_video_header.simulcastIdx = 1;
345 encoded_image.qp_ = kQpIdx1; 345 encoded_image.qp_ = kQpIdx1;
346 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 346 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
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 CodecSpecificInfo codec_info; 365 RTPVideoHeader rtp_video_header;
366 codec_info.codecType = kVideoCodecVP8; 366 rtp_video_header.codec = kRtpVideoVp8;
367 367
368 for (int i = 0; i < kMinRequiredSamples; ++i) { 368 for (int i = 0; i < kMinRequiredSamples; ++i) {
369 codec_info.codecSpecific.VP8.simulcastIdx = 0; 369 rtp_video_header.simulcastIdx = 0;
370 encoded_image.qp_ = kQpIdx0; 370 encoded_image.qp_ = kQpIdx0;
371 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 371 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
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 CodecSpecificInfo codec_info; 381 RTPVideoHeader rtp_video_header;
382 codec_info.codecType = kVideoCodecVP9; 382 rtp_video_header.simulcastIdx = 0;
383 codec_info.codecSpecific.VP9.num_spatial_layers = 2; 383 rtp_video_header.codec = kRtpVideoVp9;
384 rtp_video_header.codecHeader.VP9.num_spatial_layers = 2;
384 385
385 for (int i = 0; i < kMinRequiredSamples; ++i) { 386 for (int i = 0; i < kMinRequiredSamples; ++i) {
386 encoded_image.qp_ = kQpIdx0; 387 encoded_image.qp_ = kQpIdx0;
387 codec_info.codecSpecific.VP9.spatial_idx = 0; 388 rtp_video_header.codecHeader.VP9.spatial_idx = 0;
388 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 389 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
389 encoded_image.qp_ = kQpIdx1; 390 encoded_image.qp_ = kQpIdx1;
390 codec_info.codecSpecific.VP9.spatial_idx = 1; 391 rtp_video_header.codecHeader.VP9.spatial_idx = 1;
391 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 392 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
392 } 393 }
393 statistics_proxy_.reset(); 394 statistics_proxy_.reset();
394 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9.S0")); 395 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9.S0"));
395 EXPECT_EQ(kQpIdx0, 396 EXPECT_EQ(kQpIdx0,
396 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9.S0")); 397 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9.S0"));
397 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9.S1")); 398 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9.S1"));
398 EXPECT_EQ(kQpIdx1, 399 EXPECT_EQ(kQpIdx1,
399 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9.S1")); 400 test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9.S1"));
400 } 401 }
401 402
402 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9OneSpatialLayer) { 403 TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9OneSpatialLayer) {
403 VideoSendStream::Config config(nullptr); 404 VideoSendStream::Config config(nullptr);
404 config.rtp.ssrcs.push_back(kFirstSsrc); 405 config.rtp.ssrcs.push_back(kFirstSsrc);
405 statistics_proxy_.reset(new SendStatisticsProxy( 406 statistics_proxy_.reset(new SendStatisticsProxy(
406 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo)); 407 &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo));
407 408
408 test::ClearHistograms(); 409 test::ClearHistograms();
409 EncodedImage encoded_image; 410 EncodedImage encoded_image;
410 CodecSpecificInfo codec_info; 411 RTPVideoHeader rtp_video_header;
411 codec_info.codecType = kVideoCodecVP9; 412 rtp_video_header.simulcastIdx = 0;
412 codec_info.codecSpecific.VP9.num_spatial_layers = 1; 413 rtp_video_header.codec = kRtpVideoVp9;
414 rtp_video_header.codecHeader.VP9.num_spatial_layers = 1;
413 415
414 for (int i = 0; i < kMinRequiredSamples; ++i) { 416 for (int i = 0; i < kMinRequiredSamples; ++i) {
415 encoded_image.qp_ = kQpIdx0; 417 encoded_image.qp_ = kQpIdx0;
416 codec_info.codecSpecific.VP9.spatial_idx = 0; 418 rtp_video_header.codecHeader.VP9.spatial_idx = 0;
417 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 419 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
418 } 420 }
419 statistics_proxy_.reset(); 421 statistics_proxy_.reset();
420 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9")); 422 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.Encoded.Qp.Vp9"));
421 EXPECT_EQ(kQpIdx0, test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9")); 423 EXPECT_EQ(kQpIdx0, test::LastHistogramSample("WebRTC.Video.Encoded.Qp.Vp9"));
422 } 424 }
423 425
424 TEST_F(SendStatisticsProxyTest, NoSubstreams) { 426 TEST_F(SendStatisticsProxyTest, NoSubstreams) {
425 uint32_t excluded_ssrc = 427 uint32_t excluded_ssrc =
426 std::max( 428 std::max(
427 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), 429 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()),
(...skipping 21 matching lines...) Expand all
449 EXPECT_TRUE(stats.substreams.empty()); 451 EXPECT_TRUE(stats.substreams.empty());
450 } 452 }
451 453
452 TEST_F(SendStatisticsProxyTest, EncodedResolutionTimesOut) { 454 TEST_F(SendStatisticsProxyTest, EncodedResolutionTimesOut) {
453 static const int kEncodedWidth = 123; 455 static const int kEncodedWidth = 123;
454 static const int kEncodedHeight = 81; 456 static const int kEncodedHeight = 81;
455 EncodedImage encoded_image; 457 EncodedImage encoded_image;
456 encoded_image._encodedWidth = kEncodedWidth; 458 encoded_image._encodedWidth = kEncodedWidth;
457 encoded_image._encodedHeight = kEncodedHeight; 459 encoded_image._encodedHeight = kEncodedHeight;
458 460
459 CodecSpecificInfo codec_info; 461 RTPVideoHeader rtp_video_header;
460 codec_info.codecType = kVideoCodecVP8;
461 codec_info.codecSpecific.VP8.simulcastIdx = 0;
462 462
463 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 463 rtp_video_header.simulcastIdx = 0;
464 codec_info.codecSpecific.VP8.simulcastIdx = 1; 464 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
465 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 465 rtp_video_header.simulcastIdx = 1;
466 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
466 467
467 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); 468 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
468 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width); 469 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width);
469 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height); 470 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height);
470 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[1]].width); 471 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[1]].width);
471 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[1]].height); 472 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[1]].height);
472 473
473 // Forward almost to timeout, this should not have removed stats. 474 // Forward almost to timeout, this should not have removed stats.
474 fake_clock_.AdvanceTimeMilliseconds(SendStatisticsProxy::kStatsTimeoutMs - 1); 475 fake_clock_.AdvanceTimeMilliseconds(SendStatisticsProxy::kStatsTimeoutMs - 1);
475 stats = statistics_proxy_->GetStats(); 476 stats = statistics_proxy_->GetStats();
476 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width); 477 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[0]].width);
477 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height); 478 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[0]].height);
478 479
479 // Update the first SSRC with bogus RTCP stats to make sure that encoded 480 // Update the first SSRC with bogus RTCP stats to make sure that encoded
480 // resolution still times out (no global timeout for all stats). 481 // resolution still times out (no global timeout for all stats).
481 RtcpStatistics rtcp_statistics; 482 RtcpStatistics rtcp_statistics;
482 RtcpStatisticsCallback* rtcp_stats = statistics_proxy_.get(); 483 RtcpStatisticsCallback* rtcp_stats = statistics_proxy_.get();
483 rtcp_stats->StatisticsUpdated(rtcp_statistics, config_.rtp.ssrcs[0]); 484 rtcp_stats->StatisticsUpdated(rtcp_statistics, config_.rtp.ssrcs[0]);
484 485
485 // Report stats for second SSRC to make sure it's not outdated along with the 486 // Report stats for second SSRC to make sure it's not outdated along with the
486 // first SSRC. 487 // first SSRC.
487 codec_info.codecSpecific.VP8.simulcastIdx = 1; 488 rtp_video_header.simulcastIdx = 1;
488 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 489 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
489 490
490 // Forward 1 ms, reach timeout, substream 0 should have no resolution 491 // Forward 1 ms, reach timeout, substream 0 should have no resolution
491 // reported, but substream 1 should. 492 // reported, but substream 1 should.
492 fake_clock_.AdvanceTimeMilliseconds(1); 493 fake_clock_.AdvanceTimeMilliseconds(1);
493 stats = statistics_proxy_->GetStats(); 494 stats = statistics_proxy_->GetStats();
494 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[0]].width); 495 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[0]].width);
495 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[0]].height); 496 EXPECT_EQ(0, stats.substreams[config_.rtp.ssrcs[0]].height);
496 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[1]].width); 497 EXPECT_EQ(kEncodedWidth, stats.substreams[config_.rtp.ssrcs[1]].width);
497 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[1]].height); 498 EXPECT_EQ(kEncodedHeight, stats.substreams[config_.rtp.ssrcs[1]].height);
498 } 499 }
499 500
500 TEST_F(SendStatisticsProxyTest, ClearsResolutionFromInactiveSsrcs) { 501 TEST_F(SendStatisticsProxyTest, ClearsResolutionFromInactiveSsrcs) {
501 static const int kEncodedWidth = 123; 502 static const int kEncodedWidth = 123;
502 static const int kEncodedHeight = 81; 503 static const int kEncodedHeight = 81;
503 EncodedImage encoded_image; 504 EncodedImage encoded_image;
504 encoded_image._encodedWidth = kEncodedWidth; 505 encoded_image._encodedWidth = kEncodedWidth;
505 encoded_image._encodedHeight = kEncodedHeight; 506 encoded_image._encodedHeight = kEncodedHeight;
506 507
507 CodecSpecificInfo codec_info; 508 RTPVideoHeader rtp_video_header;
508 codec_info.codecType = kVideoCodecVP8;
509 codec_info.codecSpecific.VP8.simulcastIdx = 0;
510 509
511 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 510 rtp_video_header.simulcastIdx = 0;
512 codec_info.codecSpecific.VP8.simulcastIdx = 1; 511 statistics_proxy_->OnSendEncodedImage(encoded_image, &rtp_video_header);
513 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); 512 rtp_video_header.simulcastIdx = 1;
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