OLD | NEW |
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 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "webrtc/modules/audio_coding/neteq/accelerate.h" | 21 #include "webrtc/modules/audio_coding/neteq/accelerate.h" |
22 #include "webrtc/modules/audio_coding/neteq/expand.h" | 22 #include "webrtc/modules/audio_coding/neteq/expand.h" |
23 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h" | 23 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h" |
24 #include "webrtc/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h" | 24 #include "webrtc/modules/audio_coding/neteq/mock/mock_buffer_level_filter.h" |
25 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h" | 25 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h" |
26 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_manager.h" | 26 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_manager.h" |
27 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_peak_detector.h" | 27 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_peak_detector.h" |
28 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h" | 28 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h" |
29 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h" | 29 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_tone_generator.h" |
30 #include "webrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h" | 30 #include "webrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h" |
31 #include "webrtc/modules/audio_coding/neteq/mock/mock_payload_splitter.h" | 31 #include "webrtc/modules/audio_coding/neteq/mock/mock_red_payload_splitter.h" |
32 #include "webrtc/modules/audio_coding/neteq/preemptive_expand.h" | 32 #include "webrtc/modules/audio_coding/neteq/preemptive_expand.h" |
33 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h" | 33 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h" |
34 #include "webrtc/modules/audio_coding/neteq/timestamp_scaler.h" | 34 #include "webrtc/modules/audio_coding/neteq/timestamp_scaler.h" |
35 #include "webrtc/modules/include/module_common_types.h" | 35 #include "webrtc/modules/include/module_common_types.h" |
36 | 36 |
37 using ::testing::AtLeast; | 37 using ::testing::AtLeast; |
38 using ::testing::Return; | 38 using ::testing::Return; |
39 using ::testing::ReturnNull; | 39 using ::testing::ReturnNull; |
40 using ::testing::_; | 40 using ::testing::_; |
41 using ::testing::SetArgPointee; | 41 using ::testing::SetArgPointee; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 if (use_mock_packet_buffer_) { | 118 if (use_mock_packet_buffer_) { |
119 std::unique_ptr<MockPacketBuffer> mock( | 119 std::unique_ptr<MockPacketBuffer> mock( |
120 new MockPacketBuffer(config_.max_packets_in_buffer, tick_timer_)); | 120 new MockPacketBuffer(config_.max_packets_in_buffer, tick_timer_)); |
121 mock_packet_buffer_ = mock.get(); | 121 mock_packet_buffer_ = mock.get(); |
122 deps.packet_buffer = std::move(mock); | 122 deps.packet_buffer = std::move(mock); |
123 } | 123 } |
124 packet_buffer_ = deps.packet_buffer.get(); | 124 packet_buffer_ = deps.packet_buffer.get(); |
125 | 125 |
126 if (use_mock_payload_splitter_) { | 126 if (use_mock_payload_splitter_) { |
127 std::unique_ptr<MockPayloadSplitter> mock(new MockPayloadSplitter); | 127 std::unique_ptr<MockRedPayloadSplitter> mock(new MockRedPayloadSplitter); |
128 mock_payload_splitter_ = mock.get(); | 128 mock_payload_splitter_ = mock.get(); |
129 deps.payload_splitter = std::move(mock); | 129 deps.red_payload_splitter = std::move(mock); |
130 } | 130 } |
131 payload_splitter_ = deps.payload_splitter.get(); | 131 red_payload_splitter_ = deps.red_payload_splitter.get(); |
132 | 132 |
133 deps.timestamp_scaler = std::unique_ptr<TimestampScaler>( | 133 deps.timestamp_scaler = std::unique_ptr<TimestampScaler>( |
134 new TimestampScaler(*deps.decoder_database.get())); | 134 new TimestampScaler(*deps.decoder_database.get())); |
135 | 135 |
136 neteq_.reset(new NetEqImpl(config_, std::move(deps))); | 136 neteq_.reset(new NetEqImpl(config_, std::move(deps))); |
137 ASSERT_TRUE(neteq_ != NULL); | 137 ASSERT_TRUE(neteq_ != NULL); |
138 } | 138 } |
139 | 139 |
140 void UseNoMocks() { | 140 void UseNoMocks() { |
141 ASSERT_TRUE(neteq_ == NULL) << "Must call UseNoMocks before CreateInstance"; | 141 ASSERT_TRUE(neteq_ == NULL) << "Must call UseNoMocks before CreateInstance"; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool use_mock_delay_manager_ = true; | 190 bool use_mock_delay_manager_ = true; |
191 MockDtmfBuffer* mock_dtmf_buffer_ = nullptr; | 191 MockDtmfBuffer* mock_dtmf_buffer_ = nullptr; |
192 DtmfBuffer* dtmf_buffer_ = nullptr; | 192 DtmfBuffer* dtmf_buffer_ = nullptr; |
193 bool use_mock_dtmf_buffer_ = true; | 193 bool use_mock_dtmf_buffer_ = true; |
194 MockDtmfToneGenerator* mock_dtmf_tone_generator_ = nullptr; | 194 MockDtmfToneGenerator* mock_dtmf_tone_generator_ = nullptr; |
195 DtmfToneGenerator* dtmf_tone_generator_ = nullptr; | 195 DtmfToneGenerator* dtmf_tone_generator_ = nullptr; |
196 bool use_mock_dtmf_tone_generator_ = true; | 196 bool use_mock_dtmf_tone_generator_ = true; |
197 MockPacketBuffer* mock_packet_buffer_ = nullptr; | 197 MockPacketBuffer* mock_packet_buffer_ = nullptr; |
198 PacketBuffer* packet_buffer_ = nullptr; | 198 PacketBuffer* packet_buffer_ = nullptr; |
199 bool use_mock_packet_buffer_ = true; | 199 bool use_mock_packet_buffer_ = true; |
200 MockPayloadSplitter* mock_payload_splitter_ = nullptr; | 200 MockRedPayloadSplitter* mock_payload_splitter_ = nullptr; |
201 PayloadSplitter* payload_splitter_ = nullptr; | 201 RedPayloadSplitter* red_payload_splitter_ = nullptr; |
202 bool use_mock_payload_splitter_ = true; | 202 bool use_mock_payload_splitter_ = true; |
203 }; | 203 }; |
204 | 204 |
205 | 205 |
206 // This tests the interface class NetEq. | 206 // This tests the interface class NetEq. |
207 // TODO(hlundin): Move to separate file? | 207 // TODO(hlundin): Move to separate file? |
208 TEST(NetEq, CreateAndDestroy) { | 208 TEST(NetEq, CreateAndDestroy) { |
209 NetEq::Config config; | 209 NetEq::Config config; |
210 NetEq* neteq = NetEq::Create(config, CreateBuiltinAudioDecoderFactory()); | 210 NetEq* neteq = NetEq::Create(config, CreateBuiltinAudioDecoderFactory()); |
211 delete neteq; | 211 delete neteq; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // Expectations when the second packet is inserted. Slightly different. | 319 // Expectations when the second packet is inserted. Slightly different. |
320 EXPECT_CALL(*mock_delay_manager_, | 320 EXPECT_CALL(*mock_delay_manager_, |
321 LastDecoderType(NetEqDecoder::kDecoderPCMu)) | 321 LastDecoderType(NetEqDecoder::kDecoderPCMu)) |
322 .Times(1); | 322 .Times(1); |
323 EXPECT_CALL(*mock_delay_manager_, last_pack_cng_or_dtmf()) | 323 EXPECT_CALL(*mock_delay_manager_, last_pack_cng_or_dtmf()) |
324 .WillOnce(Return(0)); | 324 .WillOnce(Return(0)); |
325 EXPECT_CALL(*mock_delay_manager_, SetPacketAudioLength(30)) | 325 EXPECT_CALL(*mock_delay_manager_, SetPacketAudioLength(30)) |
326 .WillOnce(Return(0)); | 326 .WillOnce(Return(0)); |
327 } | 327 } |
328 | 328 |
329 // Expectations for payload splitter. | |
330 EXPECT_CALL(*mock_payload_splitter_, SplitFec(_, _)) | |
331 .Times(2) | |
332 .WillRepeatedly(Return(PayloadSplitter::kOK)); | |
333 | |
334 // Insert first packet. | 329 // Insert first packet. |
335 neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime); | 330 neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime); |
336 | 331 |
337 // Insert second packet. | 332 // Insert second packet. |
338 rtp_header.header.timestamp += 160; | 333 rtp_header.header.timestamp += 160; |
339 rtp_header.header.sequenceNumber += 1; | 334 rtp_header.header.sequenceNumber += 1; |
340 neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime + 155); | 335 neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime + 155); |
341 } | 336 } |
342 | 337 |
343 TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { | 338 TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) | 1416 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) |
1422 .Times(1) | 1417 .Times(1) |
1423 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); | 1418 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); |
1424 | 1419 |
1425 bool muted; | 1420 bool muted; |
1426 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); | 1421 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
1427 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); | 1422 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); |
1428 } | 1423 } |
1429 | 1424 |
1430 }// namespace webrtc | 1425 }// namespace webrtc |
OLD | NEW |