| 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 622 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 633     } | 633     } | 
| 634   }; | 634   }; | 
| 635 | 635 | 
| 636   class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder { | 636   class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder { | 
| 637    public: | 637    public: | 
| 638     BitrateObserver() | 638     BitrateObserver() | 
| 639         : EndToEndTest(kDefaultTimeoutMs), | 639         : EndToEndTest(kDefaultTimeoutMs), | 
| 640           FakeEncoder(Clock::GetRealTimeClock()), | 640           FakeEncoder(Clock::GetRealTimeClock()), | 
| 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_kbps_(0), | 
| 644           send_stream_(nullptr) {} | 644           send_stream_(nullptr), | 
|  | 645           frame_generator_(nullptr) {} | 
| 645 | 646 | 
| 646     int32_t InitEncode(const VideoCodec* config, | 647     int32_t InitEncode(const VideoCodec* config, | 
| 647                        int32_t number_of_cores, | 648                        int32_t number_of_cores, | 
| 648                        size_t max_payload_size) override { | 649                        size_t max_payload_size) override { | 
| 649       ++encoder_inits_; | 650       ++encoder_inits_; | 
| 650       if (encoder_inits_ == 1) { | 651       if (encoder_inits_ == 1) { | 
| 651         // First time initialization. Frame size is known. | 652         // First time initialization. Frame size is known. | 
| 652         // |expected_bitrate| is affected by bandwidth estimation before the | 653         // |expected_bitrate| is affected by bandwidth estimation before the | 
| 653         // first frame arrives to the encoder. | 654         // first frame arrives to the encoder. | 
| 654         uint32_t expected_bitrate = | 655         uint32_t expected_bitrate = last_set_bitrate_kbps_ > 0 | 
| 655             last_set_bitrate_ > 0 ? last_set_bitrate_ : kInitialBitrateKbps; | 656                                         ? last_set_bitrate_kbps_ | 
|  | 657                                         : kInitialBitrateKbps; | 
| 656         EXPECT_EQ(expected_bitrate, config->startBitrate) | 658         EXPECT_EQ(expected_bitrate, config->startBitrate) | 
| 657             << "Encoder not initialized at expected bitrate."; | 659             << "Encoder not initialized at expected bitrate."; | 
| 658         EXPECT_EQ(kDefaultWidth, config->width); | 660         EXPECT_EQ(kDefaultWidth, config->width); | 
| 659         EXPECT_EQ(kDefaultHeight, config->height); | 661         EXPECT_EQ(kDefaultHeight, config->height); | 
| 660       } else if (encoder_inits_ == 2) { | 662       } else if (encoder_inits_ == 2) { | 
| 661         EXPECT_EQ(2 * kDefaultWidth, config->width); | 663         EXPECT_EQ(2 * kDefaultWidth, config->width); | 
| 662         EXPECT_EQ(2 * kDefaultHeight, config->height); | 664         EXPECT_EQ(2 * kDefaultHeight, config->height); | 
| 663         EXPECT_GE(last_set_bitrate_, kReconfigureThresholdKbps); | 665         EXPECT_GE(last_set_bitrate_kbps_, kReconfigureThresholdKbps); | 
| 664         EXPECT_NEAR(config->startBitrate, | 666         EXPECT_NEAR(config->startBitrate, last_set_bitrate_kbps_, | 
| 665                     last_set_bitrate_, |  | 
| 666                     kPermittedReconfiguredBitrateDiffKbps) | 667                     kPermittedReconfiguredBitrateDiffKbps) | 
| 667             << "Encoder reconfigured with bitrate too far away from last set."; | 668             << "Encoder reconfigured with bitrate too far away from last set."; | 
| 668         observation_complete_.Set(); | 669         observation_complete_.Set(); | 
| 669       } | 670       } | 
| 670       return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); | 671       return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); | 
| 671     } | 672     } | 
| 672 | 673 | 
| 673     int32_t SetRates(uint32_t new_target_bitrate_kbps, | 674     int32_t SetRateAllocation(const BitrateAllocation& rate_allocation, | 
| 674                      uint32_t framerate) override { | 675                               uint32_t framerate) override { | 
| 675       last_set_bitrate_ = new_target_bitrate_kbps; | 676       last_set_bitrate_kbps_ = rate_allocation.get_sum_kbps(); | 
| 676       if (encoder_inits_ == 1 && | 677       if (encoder_inits_ == 1 && | 
| 677           new_target_bitrate_kbps > kReconfigureThresholdKbps) { | 678           rate_allocation.get_sum_kbps() > kReconfigureThresholdKbps) { | 
| 678         time_to_reconfigure_.Set(); | 679         time_to_reconfigure_.Set(); | 
| 679       } | 680       } | 
| 680       return FakeEncoder::SetRates(new_target_bitrate_kbps, framerate); | 681       return FakeEncoder::SetRateAllocation(rate_allocation, framerate); | 
| 681     } | 682     } | 
| 682 | 683 | 
| 683     Call::Config GetSenderCallConfig() override { | 684     Call::Config GetSenderCallConfig() override { | 
| 684       Call::Config config = EndToEndTest::GetSenderCallConfig(); | 685       Call::Config config = EndToEndTest::GetSenderCallConfig(); | 
| 685       config.event_log = &event_log_; | 686       config.event_log = &event_log_; | 
| 686       config.bitrate_config.start_bitrate_bps = kInitialBitrateKbps * 1000; | 687       config.bitrate_config.start_bitrate_bps = kInitialBitrateKbps * 1000; | 
| 687       return config; | 688       return config; | 
| 688     } | 689     } | 
| 689 | 690 | 
| 690     void ModifyVideoConfigs( | 691     void ModifyVideoConfigs( | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 716       frame_generator_->ChangeResolution(kDefaultWidth * 2, kDefaultHeight * 2); | 717       frame_generator_->ChangeResolution(kDefaultWidth * 2, kDefaultHeight * 2); | 
| 717       send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); | 718       send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); | 
| 718       EXPECT_TRUE(Wait()) | 719       EXPECT_TRUE(Wait()) | 
| 719           << "Timed out while waiting for a couple of high bitrate estimates " | 720           << "Timed out while waiting for a couple of high bitrate estimates " | 
| 720              "after reconfiguring the send stream."; | 721              "after reconfiguring the send stream."; | 
| 721     } | 722     } | 
| 722 | 723 | 
| 723    private: | 724    private: | 
| 724     rtc::Event time_to_reconfigure_; | 725     rtc::Event time_to_reconfigure_; | 
| 725     int encoder_inits_; | 726     int encoder_inits_; | 
| 726     uint32_t last_set_bitrate_; | 727     uint32_t last_set_bitrate_kbps_; | 
| 727     VideoSendStream* send_stream_; | 728     VideoSendStream* send_stream_; | 
| 728     test::FrameGeneratorCapturer* frame_generator_; | 729     test::FrameGeneratorCapturer* frame_generator_; | 
| 729     VideoEncoderConfig encoder_config_; | 730     VideoEncoderConfig encoder_config_; | 
| 730   } test; | 731   } test; | 
| 731 | 732 | 
| 732   RunBaseTest(&test); | 733   RunBaseTest(&test); | 
| 733 } | 734 } | 
| 734 | 735 | 
| 735 }  // namespace webrtc | 736 }  // namespace webrtc | 
| OLD | NEW | 
|---|