OLD | NEW |
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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 time_to_reconfigure_(false, false), | 641 time_to_reconfigure_(false, false), |
642 encoder_inits_(0), | 642 encoder_inits_(0), |
643 last_set_bitrate_(0), | 643 last_set_bitrate_(0), |
644 send_stream_(nullptr) {} | 644 send_stream_(nullptr) {} |
645 | 645 |
646 int32_t InitEncode(const VideoCodec* config, | 646 int32_t InitEncode(const VideoCodec* config, |
647 int32_t number_of_cores, | 647 int32_t number_of_cores, |
648 size_t max_payload_size) override { | 648 size_t max_payload_size) override { |
649 ++encoder_inits_; | 649 ++encoder_inits_; |
650 if (encoder_inits_ == 1) { | 650 if (encoder_inits_ == 1) { |
| 651 // First time initialization. Frame size is not known. |
| 652 EXPECT_EQ(kInitialBitrateKbps, config->startBitrate) |
| 653 << "Encoder not initialized at expected bitrate."; |
| 654 } else if (encoder_inits_ == 2) { |
651 // First time initialization. Frame size is known. | 655 // First time initialization. Frame size is known. |
652 // |expected_bitrate| is affected by bandwidth estimation before the | |
653 // first frame arrives to the encoder. | |
654 uint32_t expected_bitrate = | |
655 last_set_bitrate_ > 0 ? last_set_bitrate_ : kInitialBitrateKbps; | |
656 EXPECT_EQ(expected_bitrate, config->startBitrate) | |
657 << "Encoder not initialized at expected bitrate."; | |
658 EXPECT_EQ(kDefaultWidth, config->width); | 656 EXPECT_EQ(kDefaultWidth, config->width); |
659 EXPECT_EQ(kDefaultHeight, config->height); | 657 EXPECT_EQ(kDefaultHeight, config->height); |
660 } else if (encoder_inits_ == 2) { | 658 } else if (encoder_inits_ == 3) { |
661 EXPECT_EQ(2 * kDefaultWidth, config->width); | 659 EXPECT_EQ(2 * kDefaultWidth, config->width); |
662 EXPECT_EQ(2 * kDefaultHeight, config->height); | 660 EXPECT_EQ(2 * kDefaultHeight, config->height); |
663 EXPECT_GE(last_set_bitrate_, kReconfigureThresholdKbps); | 661 EXPECT_GE(last_set_bitrate_, kReconfigureThresholdKbps); |
664 EXPECT_NEAR(config->startBitrate, | 662 EXPECT_NEAR(config->startBitrate, |
665 last_set_bitrate_, | 663 last_set_bitrate_, |
666 kPermittedReconfiguredBitrateDiffKbps) | 664 kPermittedReconfiguredBitrateDiffKbps) |
667 << "Encoder reconfigured with bitrate too far away from last set."; | 665 << "Encoder reconfigured with bitrate too far away from last set."; |
668 observation_complete_.Set(); | 666 observation_complete_.Set(); |
669 } | 667 } |
670 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); | 668 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); |
671 } | 669 } |
672 | 670 |
673 int32_t SetRates(uint32_t new_target_bitrate_kbps, | 671 int32_t SetRates(uint32_t new_target_bitrate_kbps, |
674 uint32_t framerate) override { | 672 uint32_t framerate) override { |
675 last_set_bitrate_ = new_target_bitrate_kbps; | 673 last_set_bitrate_ = new_target_bitrate_kbps; |
676 if (encoder_inits_ == 1 && | 674 if (encoder_inits_ == 2 && |
677 new_target_bitrate_kbps > kReconfigureThresholdKbps) { | 675 new_target_bitrate_kbps > kReconfigureThresholdKbps) { |
678 time_to_reconfigure_.Set(); | 676 time_to_reconfigure_.Set(); |
679 } | 677 } |
680 return FakeEncoder::SetRates(new_target_bitrate_kbps, framerate); | 678 return FakeEncoder::SetRates(new_target_bitrate_kbps, framerate); |
681 } | 679 } |
682 | 680 |
683 Call::Config GetSenderCallConfig() override { | 681 Call::Config GetSenderCallConfig() override { |
684 Call::Config config = EndToEndTest::GetSenderCallConfig(); | 682 Call::Config config = EndToEndTest::GetSenderCallConfig(); |
685 config.event_log = &event_log_; | 683 config.event_log = &event_log_; |
686 config.bitrate_config.start_bitrate_bps = kInitialBitrateKbps * 1000; | 684 config.bitrate_config.start_bitrate_bps = kInitialBitrateKbps * 1000; |
687 return config; | 685 return config; |
688 } | 686 } |
689 | 687 |
690 void ModifyVideoConfigs( | 688 void ModifyVideoConfigs( |
691 VideoSendStream::Config* send_config, | 689 VideoSendStream::Config* send_config, |
692 std::vector<VideoReceiveStream::Config>* receive_configs, | 690 std::vector<VideoReceiveStream::Config>* receive_configs, |
693 VideoEncoderConfig* encoder_config) override { | 691 VideoEncoderConfig* encoder_config) override { |
694 send_config->encoder_settings.encoder = this; | 692 send_config->encoder_settings.encoder = this; |
695 encoder_config->max_bitrate_bps = 2 * kReconfigureThresholdKbps * 1000; | |
696 encoder_config->video_stream_factory = | 693 encoder_config->video_stream_factory = |
697 new rtc::RefCountedObject<VideoStreamFactory>(); | 694 new rtc::RefCountedObject<VideoStreamFactory>(); |
698 | 695 |
699 encoder_config_ = encoder_config->Copy(); | 696 encoder_config_ = encoder_config->Copy(); |
700 } | 697 } |
701 | 698 |
702 void OnVideoStreamsCreated( | 699 void OnVideoStreamsCreated( |
703 VideoSendStream* send_stream, | 700 VideoSendStream* send_stream, |
704 const std::vector<VideoReceiveStream*>& receive_streams) override { | 701 const std::vector<VideoReceiveStream*>& receive_streams) override { |
705 send_stream_ = send_stream; | 702 send_stream_ = send_stream; |
(...skipping 20 matching lines...) Expand all Loading... |
726 uint32_t last_set_bitrate_; | 723 uint32_t last_set_bitrate_; |
727 VideoSendStream* send_stream_; | 724 VideoSendStream* send_stream_; |
728 test::FrameGeneratorCapturer* frame_generator_; | 725 test::FrameGeneratorCapturer* frame_generator_; |
729 VideoEncoderConfig encoder_config_; | 726 VideoEncoderConfig encoder_config_; |
730 } test; | 727 } test; |
731 | 728 |
732 RunBaseTest(&test); | 729 RunBaseTest(&test); |
733 } | 730 } |
734 | 731 |
735 } // namespace webrtc | 732 } // namespace webrtc |
OLD | NEW |