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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 SpeechType* speech_type) override { | 427 SpeechType* speech_type) override { |
428 for (size_t i = 0; i < encoded_len; ++i) { | 428 for (size_t i = 0; i < encoded_len; ++i) { |
429 decoded[i] = next_value_++; | 429 decoded[i] = next_value_++; |
430 } | 430 } |
431 *speech_type = kSpeech; | 431 *speech_type = kSpeech; |
432 return encoded_len; | 432 return encoded_len; |
433 } | 433 } |
434 | 434 |
435 void Reset() override { next_value_ = 1; } | 435 void Reset() override { next_value_ = 1; } |
436 | 436 |
| 437 int SampleRateHz() const override { return kSampleRateHz; } |
| 438 |
437 size_t Channels() const override { return 1; } | 439 size_t Channels() const override { return 1; } |
438 | 440 |
439 uint16_t next_value() const { return next_value_; } | 441 uint16_t next_value() const { return next_value_; } |
440 | 442 |
441 private: | 443 private: |
442 int16_t next_value_; | 444 int16_t next_value_; |
443 } decoder_; | 445 } decoder_; |
444 | 446 |
445 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 447 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
446 &decoder_, NetEqDecoder::kDecoderPCM16B, | 448 &decoder_, NetEqDecoder::kDecoderPCM16B, |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 class MockAudioDecoder : public AudioDecoder { | 803 class MockAudioDecoder : public AudioDecoder { |
802 public: | 804 public: |
803 // TODO(nisse): Valid overrides commented out, because the gmock | 805 // TODO(nisse): Valid overrides commented out, because the gmock |
804 // methods don't use any override declarations, and we want to avoid | 806 // methods don't use any override declarations, and we want to avoid |
805 // warnings from -Winconsistent-missing-override. See | 807 // warnings from -Winconsistent-missing-override. See |
806 // http://crbug.com/428099. | 808 // http://crbug.com/428099. |
807 void Reset() /* override */ {} | 809 void Reset() /* override */ {} |
808 MOCK_CONST_METHOD2(PacketDuration, int(const uint8_t*, size_t)); | 810 MOCK_CONST_METHOD2(PacketDuration, int(const uint8_t*, size_t)); |
809 MOCK_METHOD5(DecodeInternal, int(const uint8_t*, size_t, int, int16_t*, | 811 MOCK_METHOD5(DecodeInternal, int(const uint8_t*, size_t, int, int16_t*, |
810 SpeechType*)); | 812 SpeechType*)); |
| 813 int SampleRateHz() const /* override */ { return kSampleRateHz; } |
811 size_t Channels() const /* override */ { return kChannels; } | 814 size_t Channels() const /* override */ { return kChannels; } |
812 } decoder_; | 815 } decoder_; |
813 | 816 |
814 const uint8_t kFirstPayloadValue = 1; | 817 const uint8_t kFirstPayloadValue = 1; |
815 const uint8_t kSecondPayloadValue = 2; | 818 const uint8_t kSecondPayloadValue = 2; |
816 | 819 |
817 EXPECT_CALL(decoder_, PacketDuration(Pointee(kFirstPayloadValue), | 820 EXPECT_CALL(decoder_, PacketDuration(Pointee(kFirstPayloadValue), |
818 kPayloadLengthBytes)) | 821 kPayloadLengthBytes)) |
819 .Times(AtLeast(1)) | 822 .Times(AtLeast(1)) |
820 .WillRepeatedly(Return(kNetEqMaxFrameSize + 1)); | 823 .WillRepeatedly(Return(kNetEqMaxFrameSize + 1)); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 ASSERT_TRUE(tick_timer_); | 1209 ASSERT_TRUE(tick_timer_); |
1207 EXPECT_EQ(0u, tick_timer_->ticks()); | 1210 EXPECT_EQ(0u, tick_timer_->ticks()); |
1208 AudioFrame output; | 1211 AudioFrame output; |
1209 bool muted; | 1212 bool muted; |
1210 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 1213 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
1211 EXPECT_EQ(1u, tick_timer_->ticks()); | 1214 EXPECT_EQ(1u, tick_timer_->ticks()); |
1212 } | 1215 } |
1213 | 1216 |
1214 class Decoder120ms : public AudioDecoder { | 1217 class Decoder120ms : public AudioDecoder { |
1215 public: | 1218 public: |
1216 Decoder120ms(SpeechType speech_type) | 1219 Decoder120ms(int sample_rate_hz, SpeechType speech_type) |
1217 : next_value_(1), | 1220 : sample_rate_hz_(sample_rate_hz), |
| 1221 next_value_(1), |
1218 speech_type_(speech_type) {} | 1222 speech_type_(speech_type) {} |
1219 | 1223 |
1220 int DecodeInternal(const uint8_t* encoded, | 1224 int DecodeInternal(const uint8_t* encoded, |
1221 size_t encoded_len, | 1225 size_t encoded_len, |
1222 int sample_rate_hz, | 1226 int sample_rate_hz, |
1223 int16_t* decoded, | 1227 int16_t* decoded, |
1224 SpeechType* speech_type) override { | 1228 SpeechType* speech_type) override { |
| 1229 EXPECT_EQ(sample_rate_hz_, sample_rate_hz); |
1225 size_t decoded_len = | 1230 size_t decoded_len = |
1226 rtc::CheckedDivExact(sample_rate_hz, 1000) * 120 * Channels(); | 1231 rtc::CheckedDivExact(sample_rate_hz, 1000) * 120 * Channels(); |
1227 for (size_t i = 0; i < decoded_len; ++i) { | 1232 for (size_t i = 0; i < decoded_len; ++i) { |
1228 decoded[i] = next_value_++; | 1233 decoded[i] = next_value_++; |
1229 } | 1234 } |
1230 *speech_type = speech_type_; | 1235 *speech_type = speech_type_; |
1231 return decoded_len; | 1236 return decoded_len; |
1232 } | 1237 } |
1233 | 1238 |
1234 void Reset() override { next_value_ = 1; } | 1239 void Reset() override { next_value_ = 1; } |
| 1240 int SampleRateHz() const override { return sample_rate_hz_; } |
1235 size_t Channels() const override { return 2; } | 1241 size_t Channels() const override { return 2; } |
1236 | 1242 |
1237 private: | 1243 private: |
| 1244 int sample_rate_hz_; |
1238 int16_t next_value_; | 1245 int16_t next_value_; |
1239 SpeechType speech_type_; | 1246 SpeechType speech_type_; |
1240 }; | 1247 }; |
1241 | 1248 |
1242 class NetEqImplTest120ms : public NetEqImplTest { | 1249 class NetEqImplTest120ms : public NetEqImplTest { |
1243 protected: | 1250 protected: |
1244 NetEqImplTest120ms() : NetEqImplTest() {} | 1251 NetEqImplTest120ms() : NetEqImplTest() {} |
1245 virtual ~NetEqImplTest120ms() {} | 1252 virtual ~NetEqImplTest120ms() {} |
1246 | 1253 |
1247 void CreateInstanceNoMocks() { | 1254 void CreateInstanceNoMocks() { |
(...skipping 27 matching lines...) Expand all Loading... |
1275 rtp_header.header.sequenceNumber = sequence_number_; | 1282 rtp_header.header.sequenceNumber = sequence_number_; |
1276 rtp_header.header.timestamp = timestamp; | 1283 rtp_header.header.timestamp = timestamp; |
1277 rtp_header.header.ssrc = 15; | 1284 rtp_header.header.ssrc = 15; |
1278 const size_t kPayloadLengthBytes = 1; // This can be arbitrary. | 1285 const size_t kPayloadLengthBytes = 1; // This can be arbitrary. |
1279 uint8_t payload[kPayloadLengthBytes] = {0}; | 1286 uint8_t payload[kPayloadLengthBytes] = {0}; |
1280 EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload, 10)); | 1287 EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload, 10)); |
1281 sequence_number_++; | 1288 sequence_number_++; |
1282 } | 1289 } |
1283 | 1290 |
1284 void Register120msCodec(AudioDecoder::SpeechType speech_type) { | 1291 void Register120msCodec(AudioDecoder::SpeechType speech_type) { |
1285 decoder_.reset(new Decoder120ms(speech_type)); | 1292 decoder_.reset(new Decoder120ms(kSamplingFreq_, speech_type)); |
1286 ASSERT_EQ(2u, decoder_->Channels()); | 1293 ASSERT_EQ(2u, decoder_->Channels()); |
1287 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1294 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
1288 decoder_.get(), NetEqDecoder::kDecoderOpus_2ch, | 1295 decoder_.get(), NetEqDecoder::kDecoderOpus_2ch, |
1289 "120ms codec", kPayloadType, kSamplingFreq_)); | 1296 "120ms codec", kPayloadType, kSamplingFreq_)); |
1290 } | 1297 } |
1291 | 1298 |
1292 std::unique_ptr<Decoder120ms> decoder_; | 1299 std::unique_ptr<Decoder120ms> decoder_; |
1293 AudioFrame output_; | 1300 AudioFrame output_; |
1294 const uint32_t kPayloadType = 17; | 1301 const uint32_t kPayloadType = 17; |
1295 const uint32_t kSamplingFreq_ = 48000; | 1302 const uint32_t kSamplingFreq_ = 48000; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) | 1432 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) |
1426 .Times(1) | 1433 .Times(1) |
1427 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); | 1434 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); |
1428 | 1435 |
1429 bool muted; | 1436 bool muted; |
1430 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); | 1437 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
1431 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); | 1438 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); |
1432 } | 1439 } |
1433 | 1440 |
1434 }// namespace webrtc | 1441 }// namespace webrtc |
OLD | NEW |