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

Side by Side Diff: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc

Issue 2745473003: Resolve cyclic dependency between audio network adaptor and event log api (Closed)
Patch Set: Revert "Activated checks for rtc_event_log_api" Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 new MockSmoothingFilter()); 80 new MockSmoothingFilter());
81 states.mock_bitrate_smoother = bitrate_smoother.get(); 81 states.mock_bitrate_smoother = bitrate_smoother.get();
82 states.simulated_clock.reset(new SimulatedClock(kInitialTimeUs)); 82 states.simulated_clock.reset(new SimulatedClock(kInitialTimeUs));
83 states.config.clock = states.simulated_clock.get(); 83 states.config.clock = states.simulated_clock.get();
84 84
85 states.encoder.reset(new AudioEncoderOpus(states.config, std::move(creator), 85 states.encoder.reset(new AudioEncoderOpus(states.config, std::move(creator),
86 std::move(bitrate_smoother))); 86 std::move(bitrate_smoother)));
87 return states; 87 return states;
88 } 88 }
89 89
90 AudioNetworkAdaptor::EncoderRuntimeConfig CreateEncoderRuntimeConfig() { 90 AudioEncoderRuntimeConfig CreateEncoderRuntimeConfig() {
91 constexpr int kBitrate = 40000; 91 constexpr int kBitrate = 40000;
92 constexpr int kFrameLength = 60; 92 constexpr int kFrameLength = 60;
93 constexpr bool kEnableFec = true; 93 constexpr bool kEnableFec = true;
94 constexpr bool kEnableDtx = false; 94 constexpr bool kEnableDtx = false;
95 constexpr size_t kNumChannels = 1; 95 constexpr size_t kNumChannels = 1;
96 constexpr float kPacketLossFraction = 0.1f; 96 constexpr float kPacketLossFraction = 0.1f;
97 AudioNetworkAdaptor::EncoderRuntimeConfig config; 97 AudioEncoderRuntimeConfig config;
98 config.bitrate_bps = rtc::Optional<int>(kBitrate); 98 config.bitrate_bps = rtc::Optional<int>(kBitrate);
99 config.frame_length_ms = rtc::Optional<int>(kFrameLength); 99 config.frame_length_ms = rtc::Optional<int>(kFrameLength);
100 config.enable_fec = rtc::Optional<bool>(kEnableFec); 100 config.enable_fec = rtc::Optional<bool>(kEnableFec);
101 config.enable_dtx = rtc::Optional<bool>(kEnableDtx); 101 config.enable_dtx = rtc::Optional<bool>(kEnableDtx);
102 config.num_channels = rtc::Optional<size_t>(kNumChannels); 102 config.num_channels = rtc::Optional<size_t>(kNumChannels);
103 config.uplink_packet_loss_fraction = 103 config.uplink_packet_loss_fraction =
104 rtc::Optional<float>(kPacketLossFraction); 104 rtc::Optional<float>(kPacketLossFraction);
105 return config; 105 return config;
106 } 106 }
107 107
108 void CheckEncoderRuntimeConfig( 108 void CheckEncoderRuntimeConfig(const AudioEncoderOpus* encoder,
109 const AudioEncoderOpus* encoder, 109 const AudioEncoderRuntimeConfig& config) {
110 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) {
111 EXPECT_EQ(*config.bitrate_bps, encoder->GetTargetBitrate()); 110 EXPECT_EQ(*config.bitrate_bps, encoder->GetTargetBitrate());
112 EXPECT_EQ(*config.frame_length_ms, encoder->next_frame_length_ms()); 111 EXPECT_EQ(*config.frame_length_ms, encoder->next_frame_length_ms());
113 EXPECT_EQ(*config.enable_fec, encoder->fec_enabled()); 112 EXPECT_EQ(*config.enable_fec, encoder->fec_enabled());
114 EXPECT_EQ(*config.enable_dtx, encoder->GetDtx()); 113 EXPECT_EQ(*config.enable_dtx, encoder->GetDtx());
115 EXPECT_EQ(*config.num_channels, encoder->num_channels_to_encode()); 114 EXPECT_EQ(*config.num_channels, encoder->num_channels_to_encode());
116 } 115 }
117 116
118 // Create 10ms audio data blocks for a total packet size of "packet_size_ms". 117 // Create 10ms audio data blocks for a total packet size of "packet_size_ms".
119 std::unique_ptr<test::AudioLoop> Create10msAudioBlocks( 118 std::unique_ptr<test::AudioLoop> Create10msAudioBlocks(
120 const std::unique_ptr<AudioEncoderOpus>& encoder, 119 const std::unique_ptr<AudioEncoderOpus>& encoder,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // Bitrate above hysteresis window. Expect lower complexity. 464 // Bitrate above hysteresis window. Expect lower complexity.
466 config.bitrate_bps = rtc::Optional<int>(14001); 465 config.bitrate_bps = rtc::Optional<int>(14001);
467 EXPECT_EQ(rtc::Optional<int>(6), config.GetNewComplexity()); 466 EXPECT_EQ(rtc::Optional<int>(6), config.GetNewComplexity());
468 } 467 }
469 468
470 TEST(AudioEncoderOpusTest, EmptyConfigDoesNotAffectEncoderSettings) { 469 TEST(AudioEncoderOpusTest, EmptyConfigDoesNotAffectEncoderSettings) {
471 auto states = CreateCodec(2); 470 auto states = CreateCodec(2);
472 states.encoder->EnableAudioNetworkAdaptor("", nullptr, nullptr); 471 states.encoder->EnableAudioNetworkAdaptor("", nullptr, nullptr);
473 472
474 auto config = CreateEncoderRuntimeConfig(); 473 auto config = CreateEncoderRuntimeConfig();
475 AudioNetworkAdaptor::EncoderRuntimeConfig empty_config; 474 AudioEncoderRuntimeConfig empty_config;
476 475
477 EXPECT_CALL(**states.mock_audio_network_adaptor, GetEncoderRuntimeConfig()) 476 EXPECT_CALL(**states.mock_audio_network_adaptor, GetEncoderRuntimeConfig())
478 .WillOnce(Return(config)) 477 .WillOnce(Return(config))
479 .WillOnce(Return(empty_config)); 478 .WillOnce(Return(empty_config));
480 479
481 constexpr size_t kOverhead = 64; 480 constexpr size_t kOverhead = 64;
482 EXPECT_CALL(**states.mock_audio_network_adaptor, SetOverhead(kOverhead)) 481 EXPECT_CALL(**states.mock_audio_network_adaptor, SetOverhead(kOverhead))
483 .Times(2); 482 .Times(2);
484 states.encoder->OnReceivedOverhead(kOverhead); 483 states.encoder->OnReceivedOverhead(kOverhead);
485 states.encoder->OnReceivedOverhead(kOverhead); 484 states.encoder->OnReceivedOverhead(kOverhead);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 539
541 // Should encode now. 540 // Should encode now.
542 states.encoder->Encode(rtp_timestamp, audio_frames->GetNextBlock(), 541 states.encoder->Encode(rtp_timestamp, audio_frames->GetNextBlock(),
543 &encoded); 542 &encoded);
544 EXPECT_GT(encoded.size(), 0u); 543 EXPECT_GT(encoded.size(), 0u);
545 encoded.Clear(); 544 encoded.Clear();
546 } 545 }
547 } 546 }
548 547
549 } // namespace webrtc 548 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/audio_network_adaptor/mock/mock_debug_dump_writer.h ('k') | webrtc/tools/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698