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

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

Issue 2021063002: NetEq decoder database: Don't keep track of sample rate for builtin decoders (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@decoder-samp-rate
Patch Set: explicit capture Created 4 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 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/codecs/builtin_audio_decoder_factory.h"
20 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
20 #include "webrtc/modules/audio_coding/neteq/accelerate.h" 21 #include "webrtc/modules/audio_coding/neteq/accelerate.h"
21 #include "webrtc/modules/audio_coding/neteq/expand.h" 22 #include "webrtc/modules/audio_coding/neteq/expand.h"
22 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h" 23 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
23 #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"
24 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h" 25 #include "webrtc/modules/audio_coding/neteq/mock/mock_decoder_database.h"
25 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_manager.h" 26 #include "webrtc/modules/audio_coding/neteq/mock/mock_delay_manager.h"
26 #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"
27 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h" 28 #include "webrtc/modules/audio_coding/neteq/mock/mock_dtmf_buffer.h"
28 #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"
29 #include "webrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h" 30 #include "webrtc/modules/audio_coding/neteq/mock/mock_packet_buffer.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 const uint32_t kFirstTimestamp = 0x12345678; 238 const uint32_t kFirstTimestamp = 0x12345678;
238 const uint32_t kSsrc = 0x87654321; 239 const uint32_t kSsrc = 0x87654321;
239 const uint32_t kFirstReceiveTime = 17; 240 const uint32_t kFirstReceiveTime = 17;
240 uint8_t payload[kPayloadLength] = {0}; 241 uint8_t payload[kPayloadLength] = {0};
241 WebRtcRTPHeader rtp_header; 242 WebRtcRTPHeader rtp_header;
242 rtp_header.header.payloadType = kPayloadType; 243 rtp_header.header.payloadType = kPayloadType;
243 rtp_header.header.sequenceNumber = kFirstSequenceNumber; 244 rtp_header.header.sequenceNumber = kFirstSequenceNumber;
244 rtp_header.header.timestamp = kFirstTimestamp; 245 rtp_header.header.timestamp = kFirstTimestamp;
245 rtp_header.header.ssrc = kSsrc; 246 rtp_header.header.ssrc = kSsrc;
246 247
247 // Create a mock decoder object. 248 rtc::scoped_refptr<MockAudioDecoderFactory> mock_decoder_factory(
248 MockAudioDecoder mock_decoder; 249 new rtc::RefCountedObject<MockAudioDecoderFactory>);
249 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); 250 EXPECT_CALL(*mock_decoder_factory, MakeAudioDecoderMock(_, _))
250 // BWE update function called with first packet. 251 .WillOnce(Invoke([kPayloadLength, kFirstSequenceNumber, kFirstTimestamp,
251 EXPECT_CALL(mock_decoder, IncomingPacket(_, 252 kFirstReceiveTime](const SdpAudioFormat& format,
252 kPayloadLength, 253 std::unique_ptr<AudioDecoder>* dec) {
253 kFirstSequenceNumber, 254 EXPECT_EQ("pcmu", format.name);
254 kFirstTimestamp, 255
255 kFirstReceiveTime)); 256 std::unique_ptr<MockAudioDecoder> mock_decoder(new MockAudioDecoder);
256 // BWE update function called with second packet. 257 EXPECT_CALL(*mock_decoder, Channels()).WillRepeatedly(Return(1));
257 EXPECT_CALL(mock_decoder, IncomingPacket(_, 258 EXPECT_CALL(*mock_decoder, SampleRateHz()).WillRepeatedly(Return(8000));
258 kPayloadLength, 259 // BWE update function called with first packet.
259 kFirstSequenceNumber + 1, 260 EXPECT_CALL(*mock_decoder,
260 kFirstTimestamp + 160, 261 IncomingPacket(_, kPayloadLength, kFirstSequenceNumber,
261 kFirstReceiveTime + 155)); 262 kFirstTimestamp, kFirstReceiveTime));
262 EXPECT_CALL(mock_decoder, Die()).Times(1); // Called when deleted. 263 // BWE update function called with second packet.
264 EXPECT_CALL(
265 *mock_decoder,
266 IncomingPacket(_, kPayloadLength, kFirstSequenceNumber + 1,
267 kFirstTimestamp + 160, kFirstReceiveTime + 155));
268 EXPECT_CALL(*mock_decoder, Die()).Times(1); // Called when deleted.
269
270 *dec = std::move(mock_decoder);
271 }));
272 DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, "");
263 273
264 // Expectations for decoder database. 274 // Expectations for decoder database.
265 EXPECT_CALL(*mock_decoder_database_, IsRed(kPayloadType)) 275 EXPECT_CALL(*mock_decoder_database_, IsRed(kPayloadType))
266 .WillRepeatedly(Return(false)); // This is not RED. 276 .WillRepeatedly(Return(false)); // This is not RED.
267 EXPECT_CALL(*mock_decoder_database_, CheckPayloadTypes(_)) 277 EXPECT_CALL(*mock_decoder_database_, CheckPayloadTypes(_))
268 .Times(2) 278 .Times(2)
269 .WillRepeatedly(Return(DecoderDatabase::kOK)); // Payload type is valid. 279 .WillRepeatedly(Return(DecoderDatabase::kOK)); // Payload type is valid.
270 EXPECT_CALL(*mock_decoder_database_, IsDtmf(kPayloadType)) 280 EXPECT_CALL(*mock_decoder_database_, IsDtmf(kPayloadType))
271 .WillRepeatedly(Return(false)); // This is not DTMF. 281 .WillRepeatedly(Return(false)); // This is not DTMF.
272 EXPECT_CALL(*mock_decoder_database_, GetDecoder(kPayloadType)) 282 EXPECT_CALL(*mock_decoder_database_, GetDecoder(kPayloadType))
273 .Times(3) 283 .Times(3)
274 .WillRepeatedly(Return(&mock_decoder)); 284 .WillRepeatedly(
285 Invoke([&info, mock_decoder_factory](uint8_t payload_type) {
286 return info.GetDecoder(mock_decoder_factory);
287 }));
275 EXPECT_CALL(*mock_decoder_database_, IsComfortNoise(kPayloadType)) 288 EXPECT_CALL(*mock_decoder_database_, IsComfortNoise(kPayloadType))
276 .WillRepeatedly(Return(false)); // This is not CNG. 289 .WillRepeatedly(Return(false)); // This is not CNG.
277 DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, "", 8000,
278 nullptr);
279 EXPECT_CALL(*mock_decoder_database_, GetDecoderInfo(kPayloadType)) 290 EXPECT_CALL(*mock_decoder_database_, GetDecoderInfo(kPayloadType))
280 .WillRepeatedly(Return(&info)); 291 .WillRepeatedly(Return(&info));
281 292
282 // Expectations for packet buffer. 293 // Expectations for packet buffer.
283 EXPECT_CALL(*mock_packet_buffer_, NumPacketsInBuffer()) 294 EXPECT_CALL(*mock_packet_buffer_, NumPacketsInBuffer())
284 .WillOnce(Return(0)) // First packet. 295 .WillOnce(Return(0)) // First packet.
285 .WillOnce(Return(1)) // Second packet. 296 .WillOnce(Return(1)) // Second packet.
286 .WillOnce(Return(2)); // Second packet, checking after it was inserted. 297 .WillOnce(Return(2)); // Second packet, checking after it was inserted.
287 EXPECT_CALL(*mock_packet_buffer_, Empty()) 298 EXPECT_CALL(*mock_packet_buffer_, Empty())
288 .WillOnce(Return(false)); // Called once after first packet is inserted. 299 .WillOnce(Return(false)); // Called once after first packet is inserted.
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) 1425 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _))
1415 .Times(1) 1426 .Times(1)
1416 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); 1427 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2)));
1417 1428
1418 bool muted; 1429 bool muted;
1419 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); 1430 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted));
1420 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); 1431 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test());
1421 } 1432 }
1422 1433
1423 }// namespace webrtc 1434 }// namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.cc ('k') | webrtc/modules/audio_coding/neteq/neteq_network_stats_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698