Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: webrtc/modules/audio_coding/codecs/opus/audio_encoder_mutable_opus_test.cc

Issue 1184313002: Add AudioEncoder::GetTargetBitrate (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing GN compile Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/codecs/opus/audio_encoder_mutable_opus_test.cc
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_mutable_opus_test.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_mutable_opus_test.cc
index ed3f52fff7f42052c2a1568a9746a60cffada84e..3a083985df754b0e87eb266bd4d462cb06d7571f 100644
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_mutable_opus_test.cc
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_mutable_opus_test.cc
@@ -79,6 +79,30 @@ TEST_F(AudioEncoderMutableOpusTest, ToggleDtx) {
// Turn off DTX.
EXPECT_TRUE(encoder_->SetDtx(false));
}
+
+TEST_F(AudioEncoderMutableOpusTest, SetBitrate) {
+ CreateCodec(1);
+ // Constants are replicated from audio_encoder_opus.cc.
+ const int kMinBitrateBps = 500;
+ const int kMaxBitrateBps = 512000;
+ // Set a too low bitrate.
+ encoder_->SetTargetBitrate(kMinBitrateBps - 1);
+ EXPECT_EQ(kMinBitrateBps, encoder_->GetTargetBitrate());
+ // Set a too high bitrate.
+ encoder_->SetTargetBitrate(kMaxBitrateBps + 1);
+ EXPECT_EQ(kMaxBitrateBps, encoder_->GetTargetBitrate());
+ // Set the minimum rate.
+ encoder_->SetTargetBitrate(kMinBitrateBps);
+ EXPECT_EQ(kMinBitrateBps, encoder_->GetTargetBitrate());
+ // Set the maximum rate.
+ encoder_->SetTargetBitrate(kMaxBitrateBps);
+ EXPECT_EQ(kMaxBitrateBps, encoder_->GetTargetBitrate());
+ // Set rates from 1000 up to 32000 bps.
+ for (int rate = 1000; rate <= 32000; rate += 1000) {
+ encoder_->SetTargetBitrate(rate);
+ EXPECT_EQ(rate, encoder_->GetTargetBitrate());
+ }
+}
#endif // WEBRTC_CODEC_OPUS
} // namespace acm2

Powered by Google App Engine
This is Rietveld 408576698