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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 // Allow error to be no more than 1. | 520 // Allow error to be no more than 1. |
521 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(30) / 1E6, interval, 1); | 521 EXPECT_NEAR(cricket::VideoFormat::FpsToInterval(30) / 1E6, interval, 1); |
522 | 522 |
523 last_timestamp = timestamp; | 523 last_timestamp = timestamp; |
524 } | 524 } |
525 | 525 |
526 // Remove stream previously added to free the external encoder instance. | 526 // Remove stream previously added to free the external encoder instance. |
527 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | 527 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); |
528 } | 528 } |
529 | 529 |
530 TEST_F(WebRtcVideoEngine2Test, | |
531 ProducesIncreasingTimestampsWithResetInputSources) { | |
532 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | |
533 encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); | |
534 std::vector<cricket::VideoCodec> codecs; | |
535 codecs.push_back(kVp8Codec); | |
536 | |
537 FakeCall* fake_call = new FakeCall(webrtc::Call::Config()); | |
538 call_.reset(fake_call); | |
539 std::unique_ptr<VideoMediaChannel> channel( | |
540 SetUpForExternalEncoderFactory(&encoder_factory, codecs)); | |
541 | |
542 EXPECT_TRUE( | |
543 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | |
544 channel->SetSend(true); | |
545 FakeVideoSendStream* stream = fake_call->GetVideoSendStreams()[0]; | |
546 | |
547 FakeVideoCapturer capturer1; | |
548 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer1)); | |
549 | |
550 cricket::CapturedFrame frame; | |
551 frame.width = 1280; | |
552 frame.height = 720; | |
553 frame.fourcc = cricket::FOURCC_I420; | |
554 frame.data_size = frame.width * frame.height + | |
555 2 * ((frame.width + 1) / 2) * ((frame.height + 1) / 2); | |
556 std::unique_ptr<char[]> data(new char[frame.data_size]); | |
557 frame.data = data.get(); | |
558 memset(frame.data, 1, frame.data_size); | |
559 int64_t initial_timestamp = rtc::TimeNanos(); | |
560 frame.time_stamp = initial_timestamp; | |
561 | |
562 // Deliver initial frame. | |
563 capturer1.SignalCapturedFrame(&frame); | |
564 // Deliver next frame 1 second later. | |
565 frame.time_stamp += rtc::kNumNanosecsPerSec; | |
566 rtc::Thread::Current()->SleepMs(1000); | |
567 capturer1.SignalCapturedFrame(&frame); | |
568 | |
569 int64_t capturer1_last_timestamp = stream->GetLastTimestamp(); | |
570 // Reset input source, should still be continuous even though input-frame | |
571 // timestamp is less than before. | |
572 FakeVideoCapturer capturer2; | |
573 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, nullptr, &capturer2)); | |
574 | |
575 rtc::Thread::Current()->SleepMs(1); | |
576 // Deliver with a timestamp (10 seconds) before the previous initial one, | |
577 // these should not be related at all anymore and it should still work fine. | |
578 frame.time_stamp = initial_timestamp - 10 * rtc::kNumNanosecsPerSec; | |
579 capturer2.SignalCapturedFrame(&frame); | |
580 | |
581 // New timestamp should be at least 1ms in the future and not old. | |
582 EXPECT_GT(stream->GetLastTimestamp(), capturer1_last_timestamp); | |
583 | |
584 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | |
585 } | |
586 | |
587 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( | 530 VideoMediaChannel* WebRtcVideoEngine2Test::SetUpForExternalEncoderFactory( |
588 cricket::WebRtcVideoEncoderFactory* encoder_factory, | 531 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
589 const std::vector<VideoCodec>& codecs) { | 532 const std::vector<VideoCodec>& codecs) { |
590 engine_.SetExternalEncoderFactory(encoder_factory); | 533 engine_.SetExternalEncoderFactory(encoder_factory); |
591 engine_.Init(); | 534 engine_.Init(); |
592 | 535 |
593 VideoMediaChannel* channel = | 536 VideoMediaChannel* channel = |
594 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions()); | 537 engine_.CreateChannel(call_.get(), MediaConfig(), VideoOptions()); |
595 cricket::VideoSendParameters parameters; | 538 cricket::VideoSendParameters parameters; |
596 parameters.codecs = codecs; | 539 parameters.codecs = codecs; |
(...skipping 3251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3848 } | 3791 } |
3849 | 3792 |
3850 // Test that we normalize send codec format size in simulcast. | 3793 // Test that we normalize send codec format size in simulcast. |
3851 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3794 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
3852 cricket::VideoCodec codec(kVp8Codec270p); | 3795 cricket::VideoCodec codec(kVp8Codec270p); |
3853 codec.width += 1; | 3796 codec.width += 1; |
3854 codec.height += 1; | 3797 codec.height += 1; |
3855 VerifySimulcastSettings(codec, 2, 2); | 3798 VerifySimulcastSettings(codec, 2, 2); |
3856 } | 3799 } |
3857 } // namespace cricket | 3800 } // namespace cricket |
OLD | NEW |