Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 EXPECT_TRUE( | 433 EXPECT_TRUE( |
| 434 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 434 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
| 435 | 435 |
| 436 FakeVideoCapturer capturer; | 436 FakeVideoCapturer capturer; |
| 437 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); | 437 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer)); |
| 438 capturer.Start(cricket::VideoFormat(1280, 720, | 438 capturer.Start(cricket::VideoFormat(1280, 720, |
| 439 cricket::VideoFormat::FpsToInterval(60), | 439 cricket::VideoFormat::FpsToInterval(60), |
| 440 cricket::FOURCC_I420)); | 440 cricket::FOURCC_I420)); |
| 441 channel->SetSend(true); | 441 channel->SetSend(true); |
| 442 | 442 |
| 443 FakeCall* call = factory.GetCall(); | 443 FakeVideoSendStream* stream = factory.GetCall()->GetVideoSendStreams()[0]; |
| 444 std::vector<FakeVideoSendStream*> streams = call->GetVideoSendStreams(); | |
| 445 FakeVideoSendStream* stream = streams[0]; | |
| 446 | 444 |
| 447 int64_t timestamp; | |
| 448 int64_t last_timestamp; | |
| 449 | 445 |
| 450 EXPECT_TRUE(capturer.CaptureFrame()); | 446 EXPECT_TRUE(capturer.CaptureFrame()); |
| 451 last_timestamp = stream->GetLastTimestamp(); | 447 int64_t last_timestamp = stream->GetLastTimestamp(); |
| 452 for (int i = 0; i < 10; i++) { | 448 for (int i = 0; i < 10; i++) { |
| 453 EXPECT_TRUE(capturer.CaptureFrame()); | 449 EXPECT_TRUE(capturer.CaptureFrame()); |
| 454 timestamp = stream->GetLastTimestamp(); | 450 int64_t timestamp = stream->GetLastTimestamp(); |
| 455 int64_t interval = timestamp - last_timestamp; | 451 int64_t interval = timestamp - last_timestamp; |
| 456 | 452 |
| 457 // Precision changes from nanosecond to millisecond. | 453 // Precision changes from nanosecond to millisecond. |
| 458 // Allow error to be no more than 1. | 454 // Allow error to be no more than 1. |
| 459 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(60) / 1E6, interval, 1); | 455 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(60) / 1E6, interval, 1); |
| 460 | 456 |
| 461 last_timestamp = timestamp; | 457 last_timestamp = timestamp; |
| 462 } | 458 } |
| 463 | 459 |
| 464 capturer.Start(cricket::VideoFormat(1280, 720, | 460 capturer.Start(cricket::VideoFormat(1280, 720, |
| 465 cricket::VideoFormat::FpsToInterval(30), | 461 cricket::VideoFormat::FpsToInterval(30), |
| 466 cricket::FOURCC_I420)); | 462 cricket::FOURCC_I420)); |
| 467 | 463 |
| 468 EXPECT_TRUE(capturer.CaptureFrame()); | 464 EXPECT_TRUE(capturer.CaptureFrame()); |
| 469 last_timestamp = stream->GetLastTimestamp(); | 465 last_timestamp = stream->GetLastTimestamp(); |
| 470 for (int i = 0; i < 10; i++) { | 466 for (int i = 0; i < 10; i++) { |
| 471 EXPECT_TRUE(capturer.CaptureFrame()); | 467 EXPECT_TRUE(capturer.CaptureFrame()); |
| 472 timestamp = stream->GetLastTimestamp(); | 468 int64_t timestamp = stream->GetLastTimestamp(); |
| 473 int64_t interval = timestamp - last_timestamp; | 469 int64_t interval = timestamp - last_timestamp; |
| 474 | 470 |
| 475 // Precision changes from nanosecond to millisecond. | 471 // Precision changes from nanosecond to millisecond. |
| 476 // Allow error to be no more than 1. | 472 // Allow error to be no more than 1. |
| 477 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(30) / 1E6, interval, 1); | 473 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(30) / 1E6, interval, 1); |
| 478 | 474 |
| 479 last_timestamp = timestamp; | 475 last_timestamp = timestamp; |
| 480 } | 476 } |
| 481 | 477 |
| 482 // Remove stream previously added to free the external encoder instance. | 478 // Remove stream previously added to free the external encoder instance. |
| 483 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | 479 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); |
| 484 } | 480 } |
| 485 | 481 |
| 482 TEST_F(WebRtcVideoEngine2Test, | |
| 483 ProducesIncreasingTimestampsWithResetInputSources) { | |
| 484 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | |
| 485 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | |
| 486 std::vector<cricket::VideoCodec> codecs; | |
| 487 codecs.push_back(kVp8Codec); | |
| 488 | |
| 489 FakeCallFactory factory; | |
| 490 engine_.SetCallFactory(&factory); | |
| 491 rtc::scoped_ptr<VideoMediaChannel> channel( | |
| 492 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | |
| 493 | |
| 494 EXPECT_TRUE( | |
| 495 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | |
| 496 channel->SetSend(true); | |
| 497 FakeVideoSendStream* stream = factory.GetCall()->GetVideoSendStreams()[0]; | |
| 498 | |
| 499 FakeVideoCapturer capturer1; | |
| 500 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer1)); | |
| 501 | |
| 502 cricket::CapturedFrame frame; | |
| 503 frame.width = 1280; | |
| 504 frame.height = 720; | |
| 505 frame.fourcc = cricket::FOURCC_I420; | |
| 506 frame.data_size = cricket::VideoFrame::SizeOf(frame.width, frame.height); | |
| 507 rtc::scoped_ptr<char[]> data(new char[frame.data_size]); | |
| 508 frame.data = data.get(); | |
| 509 memset(frame.data, 1, frame.data_size); | |
| 510 frame.elapsed_time = 0; | |
| 511 const int kInitialTimestamp = 1234; | |
| 512 frame.time_stamp = kInitialTimestamp; | |
| 513 | |
| 514 // Deliver initial frame. | |
| 515 capturer1.SignalCapturedFrame(&frame); | |
| 516 // Deliver next frame 1 second later. | |
| 517 frame.time_stamp += rtc::kNumNanosecsPerSec; | |
| 518 rtc::Thread::Current()->SleepMs(1000); | |
| 519 capturer1.SignalCapturedFrame(&frame); | |
| 520 | |
| 521 int64_t capturer1_last_timestamp = stream->GetLastTimestamp(); | |
| 522 // Reset input source, should still be continuous even though input-frame | |
| 523 // timestamp is less than before. | |
| 524 FakeVideoCapturer capturer2; | |
| 525 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer2)); | |
| 526 | |
| 527 rtc::Thread::Current()->SleepMs(1); | |
| 528 frame.time_stamp = kInitialTimestamp; | |
|
stefan-webrtc
2015/09/14 15:21:49
Make this smaller than kInitialTimestamp to clarif
pbos-webrtc
2015/09/14 15:34:49
Done.
| |
| 529 capturer2.SignalCapturedFrame(&frame); | |
| 530 | |
| 531 // New timestamp should be at least 1ms in the future and not old. | |
| 532 EXPECT_GT(stream->GetLastTimestamp(), capturer1_last_timestamp); | |
| 533 | |
| 534 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | |
| 535 } | |
| 536 | |
| 486 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( | 537 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( |
| 487 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 538 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 488 const std::vector<VideoCodec>& codecs) { | 539 const std::vector<VideoCodec>& codecs) { |
| 489 engine_.SetExternalEncoderFactory(encoder_factory); | 540 engine_.SetExternalEncoderFactory(encoder_factory); |
| 490 engine_.Init(); | 541 engine_.Init(); |
| 491 | 542 |
| 492 VideoMediaChannel* channel = | 543 VideoMediaChannel* channel = |
| 493 engine_.CreateChannel(cricket::VideoOptions(), NULL); | 544 engine_.CreateChannel(cricket::VideoOptions(), NULL); |
| 494 EXPECT_TRUE(channel->SetSendCodecs(codecs)); | 545 EXPECT_TRUE(channel->SetSendCodecs(codecs)); |
| 495 | 546 |
| (...skipping 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3190 // Ensures that the correct settings are applied to the codec when two temporal | 3241 // Ensures that the correct settings are applied to the codec when two temporal |
| 3191 // layer screencasting is enabled, and that the correct simulcast settings are | 3242 // layer screencasting is enabled, and that the correct simulcast settings are |
| 3192 // reapplied when disabling screencasting. | 3243 // reapplied when disabling screencasting. |
| 3193 TEST_F(WebRtcVideoChannel2SimulcastTest, | 3244 TEST_F(WebRtcVideoChannel2SimulcastTest, |
| 3194 DISABLED_TwoTemporalLayerScreencastSettings) { | 3245 DISABLED_TwoTemporalLayerScreencastSettings) { |
| 3195 // TODO(pbos): Implement. | 3246 // TODO(pbos): Implement. |
| 3196 FAIL() << "Not implemented."; | 3247 FAIL() << "Not implemented."; |
| 3197 } | 3248 } |
| 3198 | 3249 |
| 3199 } // namespace cricket | 3250 } // namespace cricket |
| OLD | NEW |