OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 // Allow error to be no more than 1. | 476 // Allow error to be no more than 1. |
477 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(30) / 1E6, interval, 1); | 477 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(30) / 1E6, interval, 1); |
478 | 478 |
479 last_timestamp = timestamp; | 479 last_timestamp = timestamp; |
480 } | 480 } |
481 | 481 |
482 // Remove stream previously added to free the external encoder instance. | 482 // Remove stream previously added to free the external encoder instance. |
483 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | 483 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); |
484 } | 484 } |
485 | 485 |
486 // TODO(nisse): This test should be no longer needed when the | |
perkj_webrtc
2016/04/08 14:52:18
why not?
nisse-webrtc
2016/04/11 06:58:56
Because it should be the responsibility of whoever
| |
487 // timestamp_us refactoring is done. | |
486 TEST_F(WebRtcVideoEngine2Test, | 488 TEST_F(WebRtcVideoEngine2Test, |
487 ProducesIncreasingTimestampsWithResetInputSources) { | 489 ProducesIncreasingTimestampsWithResetInputSources) { |
488 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | 490 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; |
489 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | 491 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
490 std::vector<cricket::VideoCodec> codecs; | 492 std::vector<cricket::VideoCodec> codecs; |
491 codecs.push_back(kVp8Codec); | 493 codecs.push_back(kVp8Codec); |
492 | 494 |
493 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); | 495 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); |
494 call_.reset(fake_call); | 496 call_.reset(fake_call); |
495 std::unique_ptr<VideoMediaChannel> channel( | 497 std::unique_ptr<VideoMediaChannel> channel( |
496 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | 498 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); |
497 | 499 |
498 EXPECT_TRUE( | 500 EXPECT_TRUE( |
499 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 501 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
500 channel->SetSend(true); | 502 channel->SetSend(true); |
501 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; | 503 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; |
502 | 504 |
503 FakeVideoCapturer capturer1; | 505 FakeVideoCapturer capturer1; |
504 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer1)); | 506 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer1)); |
505 | 507 |
506 cricket::CapturedFrame frame; | 508 cricket::CapturedFrame frame; |
507 frame.width = 1280; | 509 frame.width = 1280; |
508 frame.height = 720; | 510 frame.height = 720; |
509 frame.fourcc = cricket::FOURCC_I420; | 511 frame.fourcc = cricket::FOURCC_I420; |
510 frame.data_size = frame.width * frame.height + | 512 frame.data_size = frame.width * frame.height + |
511 2 * ((frame.width + 1) / 2) * ((frame.height + 1) / 2); | 513 2 * ((frame.width + 1) / 2) * ((frame.height + 1) / 2); |
512 std::unique_ptr<char[]> data(new char[frame.data_size]); | 514 std::unique_ptr<char[]> data(new char[frame.data_size]); |
513 frame.data = data.get(); | 515 frame.data = data.get(); |
514 memset(frame.data, 1, frame.data_size); | 516 memset(frame.data, 1, frame.data_size); |
515 const int kInitialTimestamp = 123456; | 517 int64_t initial_timestamp = rtc::TimeNanos(); |
516 frame.time_stamp = kInitialTimestamp; | 518 frame.time_stamp = initial_timestamp; |
517 | 519 |
518 // Deliver initial frame. | 520 // Deliver initial frame. |
519 capturer1.SignalCapturedFrame(&frame); | 521 capturer1.SignalCapturedFrame(&frame); |
520 // Deliver next frame 1 second later. | 522 // Deliver next frame 1 second later. |
521 frame.time_stamp += rtc::kNumNanosecsPerSec; | 523 frame.time_stamp += rtc::kNumNanosecsPerSec; |
522 rtc::Thread::Current()->SleepMs(1000); | 524 rtc::Thread::Current()->SleepMs(1000); |
523 capturer1.SignalCapturedFrame(&frame); | 525 capturer1.SignalCapturedFrame(&frame); |
524 | 526 |
525 int64_t capturer1_last_timestamp = stream->GetLastTimestamp(); | 527 int64_t capturer1_last_timestamp = stream->GetLastTimestamp(); |
526 // Reset input source, should still be continuous even though input-frame | 528 // Reset input source, should still be continuous even though input-frame |
527 // timestamp is less than before. | 529 // timestamp is less than before. |
528 FakeVideoCapturer capturer2; | 530 FakeVideoCapturer capturer2; |
529 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer2)); | 531 EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer2)); |
530 | 532 |
531 rtc::Thread::Current()->SleepMs(1); | 533 rtc::Thread::Current()->SleepMs(1); |
532 // Deliver with a timestamp (10 seconds) before the previous initial one, | 534 // Deliver with a timestamp (10 seconds) before the previous initial one, |
533 // these should not be related at all anymore and it should still work fine. | 535 // these should not be related at all anymore and it should still work fine. |
534 frame.time_stamp = kInitialTimestamp - 10000; | 536 frame.time_stamp = initial_timestamp - 10 * rtc::kNumNanosecsPerSec;; |
535 capturer2.SignalCapturedFrame(&frame); | 537 capturer2.SignalCapturedFrame(&frame); |
536 | 538 |
537 // New timestamp should be at least 1ms in the future and not old. | 539 // New timestamp should be at least 1ms in the future and not old. |
538 EXPECT_GT(stream->GetLastTimestamp(), capturer1_last_timestamp); | 540 EXPECT_GT(stream->GetLastTimestamp(), capturer1_last_timestamp); |
539 | 541 |
540 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | 542 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); |
541 } | 543 } |
542 | 544 |
543 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( | 545 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( |
544 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 546 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
(...skipping 3037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3582 } | 3584 } |
3583 | 3585 |
3584 // Test that we normalize send codec format size in simulcast. | 3586 // Test that we normalize send codec format size in simulcast. |
3585 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3587 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
3586 cricket::VideoCodec codec(kVp8Codec270p); | 3588 cricket::VideoCodec codec(kVp8Codec270p); |
3587 codec.width += 1; | 3589 codec.width += 1; |
3588 codec.height += 1; | 3590 codec.height += 1; |
3589 VerifySimulcastSettings(codec, 2, 2); | 3591 VerifySimulcastSettings(codec, 2, 2); |
3590 } | 3592 } |
3591 } // namespace cricket | 3593 } // namespace cricket |
OLD | NEW |