| 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 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 const int kEncodeDelayMs = 35; | 521 const int kEncodeDelayMs = 35; |
| 522 TestCpuOveruse(LoadObserver::kOveruse, kEncodeDelayMs); | 522 TestCpuOveruse(LoadObserver::kOveruse, kEncodeDelayMs); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { | 525 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { |
| 526 static const int kMaxEncodeBitrateKbps = 30; | 526 static const int kMaxEncodeBitrateKbps = 30; |
| 527 static const int kMinTransmitBitrateBps = 150000; | 527 static const int kMinTransmitBitrateBps = 150000; |
| 528 static const int kMinAcceptableTransmitBitrate = 130; | 528 static const int kMinAcceptableTransmitBitrate = 130; |
| 529 static const int kMaxAcceptableTransmitBitrate = 170; | 529 static const int kMaxAcceptableTransmitBitrate = 170; |
| 530 static const int kNumBitrateObservationsInRange = 100; | 530 static const int kNumBitrateObservationsInRange = 100; |
| 531 static const int kAcceptableBitrateErrorMargin = 15; // +- 7 |
| 531 class BitrateObserver : public test::EndToEndTest, public PacketReceiver { | 532 class BitrateObserver : public test::EndToEndTest, public PacketReceiver { |
| 532 public: | 533 public: |
| 533 explicit BitrateObserver(bool using_min_transmit_bitrate) | 534 explicit BitrateObserver(bool using_min_transmit_bitrate) |
| 534 : EndToEndTest(kLongTimeoutMs), | 535 : EndToEndTest(kLongTimeoutMs), |
| 535 send_stream_(nullptr), | 536 send_stream_(nullptr), |
| 536 send_transport_receiver_(nullptr), | 537 send_transport_receiver_(nullptr), |
| 537 pad_to_min_bitrate_(using_min_transmit_bitrate), | 538 pad_to_min_bitrate_(using_min_transmit_bitrate), |
| 538 num_bitrate_observations_in_range_(0) {} | 539 num_bitrate_observations_in_range_(0) {} |
| 539 | 540 |
| 540 private: | 541 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 560 static_cast<size_t>(bitrate_kbps), | 561 static_cast<size_t>(bitrate_kbps), |
| 561 "kbps", | 562 "kbps", |
| 562 false); | 563 false); |
| 563 if (pad_to_min_bitrate_) { | 564 if (pad_to_min_bitrate_) { |
| 564 if (bitrate_kbps > kMinAcceptableTransmitBitrate && | 565 if (bitrate_kbps > kMinAcceptableTransmitBitrate && |
| 565 bitrate_kbps < kMaxAcceptableTransmitBitrate) { | 566 bitrate_kbps < kMaxAcceptableTransmitBitrate) { |
| 566 ++num_bitrate_observations_in_range_; | 567 ++num_bitrate_observations_in_range_; |
| 567 } | 568 } |
| 568 } else { | 569 } else { |
| 569 // Expect bitrate stats to roughly match the max encode bitrate. | 570 // Expect bitrate stats to roughly match the max encode bitrate. |
| 570 if (bitrate_kbps > kMaxEncodeBitrateKbps - 5 && | 571 if (bitrate_kbps > (kMaxEncodeBitrateKbps - |
| 571 bitrate_kbps < kMaxEncodeBitrateKbps + 5) { | 572 kAcceptableBitrateErrorMargin / 2) && |
| 573 bitrate_kbps < (kMaxEncodeBitrateKbps + |
| 574 kAcceptableBitrateErrorMargin / 2)) { |
| 572 ++num_bitrate_observations_in_range_; | 575 ++num_bitrate_observations_in_range_; |
| 573 } | 576 } |
| 574 } | 577 } |
| 575 if (num_bitrate_observations_in_range_ == | 578 if (num_bitrate_observations_in_range_ == |
| 576 kNumBitrateObservationsInRange) | 579 kNumBitrateObservationsInRange) |
| 577 observation_complete_->Set(); | 580 observation_complete_->Set(); |
| 578 } | 581 } |
| 579 } | 582 } |
| 580 return send_transport_receiver_->DeliverPacket(media_type, packet, | 583 return send_transport_receiver_->DeliverPacket(media_type, packet, |
| 581 length); | 584 length); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 static const uint32_t kInitialBitrateKbps = 400; | 625 static const uint32_t kInitialBitrateKbps = 400; |
| 623 static const uint32_t kReconfigureThresholdKbps = 600; | 626 static const uint32_t kReconfigureThresholdKbps = 600; |
| 624 static const uint32_t kPermittedReconfiguredBitrateDiffKbps = 100; | 627 static const uint32_t kPermittedReconfiguredBitrateDiffKbps = 100; |
| 625 | 628 |
| 626 class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder { | 629 class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder { |
| 627 public: | 630 public: |
| 628 BitrateObserver() | 631 BitrateObserver() |
| 629 : EndToEndTest(kDefaultTimeoutMs), | 632 : EndToEndTest(kDefaultTimeoutMs), |
| 630 FakeEncoder(Clock::GetRealTimeClock()), | 633 FakeEncoder(Clock::GetRealTimeClock()), |
| 631 time_to_reconfigure_(webrtc::EventWrapper::Create()), | 634 time_to_reconfigure_(webrtc::EventWrapper::Create()), |
| 632 encoder_inits_(0) {} | 635 encoder_inits_(0), |
| 636 last_set_bitrate_(0), |
| 637 send_stream_(nullptr) {} |
| 633 | 638 |
| 634 int32_t InitEncode(const VideoCodec* config, | 639 int32_t InitEncode(const VideoCodec* config, |
| 635 int32_t number_of_cores, | 640 int32_t number_of_cores, |
| 636 size_t max_payload_size) override { | 641 size_t max_payload_size) override { |
| 637 if (encoder_inits_ == 0) { | 642 if (encoder_inits_ == 0) { |
| 638 EXPECT_EQ(kInitialBitrateKbps, config->startBitrate) | 643 EXPECT_EQ(kInitialBitrateKbps, config->startBitrate) |
| 639 << "Encoder not initialized at expected bitrate."; | 644 << "Encoder not initialized at expected bitrate."; |
| 640 } | 645 } |
| 641 ++encoder_inits_; | 646 ++encoder_inits_; |
| 642 if (encoder_inits_ == 2) { | 647 if (encoder_inits_ == 2) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 int encoder_inits_; | 704 int encoder_inits_; |
| 700 uint32_t last_set_bitrate_; | 705 uint32_t last_set_bitrate_; |
| 701 VideoSendStream* send_stream_; | 706 VideoSendStream* send_stream_; |
| 702 VideoEncoderConfig encoder_config_; | 707 VideoEncoderConfig encoder_config_; |
| 703 } test; | 708 } test; |
| 704 | 709 |
| 705 RunBaseTest(&test); | 710 RunBaseTest(&test); |
| 706 } | 711 } |
| 707 | 712 |
| 708 } // namespace webrtc | 713 } // namespace webrtc |
| OLD | NEW |