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

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc

Issue 1992763002: Moved injection of AudioDecoderFactory into voe::Channel. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@audio-decoder-factory-injections-1
Patch Set: Addressed nit. Created 4 years, 7 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #include <memory> 11 #include <memory>
12 12
13 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" 13 #include "webrtc/modules/audio_coding/neteq/include/neteq.h"
14 #include "webrtc/modules/audio_coding/neteq/neteq_impl.h" 14 #include "webrtc/modules/audio_coding/neteq/neteq_impl.h"
15 15
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webrtc/base/safe_conversions.h" 18 #include "webrtc/base/safe_conversions.h"
19 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
19 #include "webrtc/modules/audio_coding/neteq/accelerate.h" 20 #include "webrtc/modules/audio_coding/neteq/accelerate.h"
20 #include "webrtc/modules/audio_coding/neteq/expand.h" 21 #include "webrtc/modules/audio_coding/neteq/expand.h"
21 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h" 22 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
22 #include "webrtc/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h" 23 #include "webrtc/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h"
23 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h" 24 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h"
24 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_manager.h" 25 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_manager.h"
25 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_peak_detector.h" 26 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_peak_detector.h"
26 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h" 27 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h"
27 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h" 28 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h"
28 #include "webrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h" 29 #include "webrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h"
(...skipping 23 matching lines...) Expand all
52 int DeletePacketsAndReturnOk(PacketList* packet_list) { 53 int DeletePacketsAndReturnOk(PacketList* packet_list) {
53 PacketBuffer::DeleteAllPackets(packet_list); 54 PacketBuffer::DeleteAllPackets(packet_list);
54 return PacketBuffer::kOK; 55 return PacketBuffer::kOK;
55 } 56 }
56 57
57 class NetEqImplTest : public ::testing::Test { 58 class NetEqImplTest : public ::testing::Test {
58 protected: 59 protected:
59 NetEqImplTest() { config_.sample_rate_hz = 8000; } 60 NetEqImplTest() { config_.sample_rate_hz = 8000; }
60 61
61 void CreateInstance() { 62 void CreateInstance() {
62 NetEqImpl::Dependencies deps(config_); 63 NetEqImpl::Dependencies deps(config_, CreateBuiltinAudioDecoderFactory());
63 64
64 // Get a local pointer to NetEq's TickTimer object. 65 // Get a local pointer to NetEq's TickTimer object.
65 tick_timer_ = deps.tick_timer.get(); 66 tick_timer_ = deps.tick_timer.get();
66 67
67 if (use_mock_buffer_level_filter_) { 68 if (use_mock_buffer_level_filter_) {
68 std::unique_ptr<MockBufferLevelFilter> mock(new MockBufferLevelFilter); 69 std::unique_ptr<MockBufferLevelFilter> mock(new MockBufferLevelFilter);
69 mock_buffer_level_filter_ = mock.get(); 70 mock_buffer_level_filter_ = mock.get();
70 deps.buffer_level_filter = std::move(mock); 71 deps.buffer_level_filter = std::move(mock);
71 } 72 }
72 buffer_level_filter_ = deps.buffer_level_filter.get(); 73 buffer_level_filter_ = deps.buffer_level_filter.get();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 MockPayloadSplitter* mock_payload_splitter_ = nullptr; 199 MockPayloadSplitter* mock_payload_splitter_ = nullptr;
199 PayloadSplitter* payload_splitter_ = nullptr; 200 PayloadSplitter* payload_splitter_ = nullptr;
200 bool use_mock_payload_splitter_ = true; 201 bool use_mock_payload_splitter_ = true;
201 }; 202 };
202 203
203 204
204 // This tests the interface class NetEq. 205 // This tests the interface class NetEq.
205 // TODO(hlundin): Move to separate file? 206 // TODO(hlundin): Move to separate file?
206 TEST(NetEq, CreateAndDestroy) { 207 TEST(NetEq, CreateAndDestroy) {
207 NetEq::Config config; 208 NetEq::Config config;
208 NetEq* neteq = NetEq::Create(config); 209 NetEq* neteq = NetEq::Create(config, CreateBuiltinAudioDecoderFactory());
209 delete neteq; 210 delete neteq;
210 } 211 }
211 212
212 TEST_F(NetEqImplTest, RegisterPayloadType) { 213 TEST_F(NetEqImplTest, RegisterPayloadType) {
213 CreateInstance(); 214 CreateInstance();
214 uint8_t rtp_payload_type = 0; 215 uint8_t rtp_payload_type = 0;
215 NetEqDecoder codec_type = NetEqDecoder::kDecoderPCMu; 216 NetEqDecoder codec_type = NetEqDecoder::kDecoderPCMu;
216 const std::string kCodecName = "Robert\'); DROP TABLE Students;"; 217 const std::string kCodecName = "Robert\'); DROP TABLE Students;";
217 EXPECT_CALL(*mock_decoder_database_, 218 EXPECT_CALL(*mock_decoder_database_,
218 RegisterPayload(rtp_payload_type, codec_type, kCodecName)); 219 RegisterPayload(rtp_payload_type, codec_type, kCodecName));
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) 1414 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _))
1414 .Times(1) 1415 .Times(1)
1415 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); 1416 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2)));
1416 1417
1417 bool muted; 1418 bool muted;
1418 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); 1419 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted));
1419 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); 1420 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test());
1420 } 1421 }
1421 1422
1422 }// namespace webrtc 1423 }// namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.cc ('k') | webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698