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

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

Issue 1319683002: AudioDecoder: Replace Init() with Reset() (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@buffer
Patch Set: review fixes Created 5 years, 3 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
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 size_t /* max_decoded_bytes */, 437 size_t /* max_decoded_bytes */,
438 int16_t* decoded, 438 int16_t* decoded,
439 SpeechType* speech_type) override { 439 SpeechType* speech_type) override {
440 for (size_t i = 0; i < encoded_len; ++i) { 440 for (size_t i = 0; i < encoded_len; ++i) {
441 decoded[i] = next_value_++; 441 decoded[i] = next_value_++;
442 } 442 }
443 *speech_type = kSpeech; 443 *speech_type = kSpeech;
444 return encoded_len; 444 return encoded_len;
445 } 445 }
446 446
447 virtual int Init() { 447 void Reset() override { next_value_ = 1; }
448 next_value_ = 1;
449 return 0;
450 }
451 448
452 size_t Channels() const override { return 1; } 449 size_t Channels() const override { return 1; }
453 450
454 uint16_t next_value() const { return next_value_; } 451 uint16_t next_value() const { return next_value_; }
455 452
456 private: 453 private:
457 int16_t next_value_; 454 int16_t next_value_;
458 } decoder_; 455 } decoder_;
459 456
460 EXPECT_EQ(NetEq::kOK, 457 EXPECT_EQ(NetEq::kOK,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 const size_t kPayloadLengthBytes = kPayloadLengthSamples; 514 const size_t kPayloadLengthBytes = kPayloadLengthSamples;
518 uint8_t payload[kPayloadLengthBytes] = {0}; 515 uint8_t payload[kPayloadLengthBytes] = {0};
519 WebRtcRTPHeader rtp_header; 516 WebRtcRTPHeader rtp_header;
520 rtp_header.header.payloadType = kPayloadType; 517 rtp_header.header.payloadType = kPayloadType;
521 rtp_header.header.sequenceNumber = 0x1234; 518 rtp_header.header.sequenceNumber = 0x1234;
522 rtp_header.header.timestamp = 0x12345678; 519 rtp_header.header.timestamp = 0x12345678;
523 rtp_header.header.ssrc = 0x87654321; 520 rtp_header.header.ssrc = 0x87654321;
524 521
525 // Create a mock decoder object. 522 // Create a mock decoder object.
526 MockAudioDecoder mock_decoder; 523 MockAudioDecoder mock_decoder;
527 EXPECT_CALL(mock_decoder, Init()).WillRepeatedly(Return(0)); 524 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return());
528 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); 525 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1));
529 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) 526 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _))
530 .WillRepeatedly(Return(0)); 527 .WillRepeatedly(Return(0));
531 int16_t dummy_output[kPayloadLengthSamples] = {0}; 528 int16_t dummy_output[kPayloadLengthSamples] = {0};
532 // The below expectation will make the mock decoder write 529 // The below expectation will make the mock decoder write
533 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. 530 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech.
534 EXPECT_CALL(mock_decoder, 531 EXPECT_CALL(mock_decoder,
535 Decode(Pointee(0), kPayloadLengthBytes, kSampleRateHz, _, _, _)) 532 Decode(Pointee(0), kPayloadLengthBytes, kSampleRateHz, _, _, _))
536 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, 533 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output,
537 dummy_output + kPayloadLengthSamples), 534 dummy_output + kPayloadLengthSamples),
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 int16_t dummy_output[kPayloadLengthSamples] = {0}; 680 int16_t dummy_output[kPayloadLengthSamples] = {0};
684 681
685 WebRtcRTPHeader rtp_header; 682 WebRtcRTPHeader rtp_header;
686 rtp_header.header.payloadType = kPayloadType; 683 rtp_header.header.payloadType = kPayloadType;
687 rtp_header.header.sequenceNumber = 0x1234; 684 rtp_header.header.sequenceNumber = 0x1234;
688 rtp_header.header.timestamp = 0x12345678; 685 rtp_header.header.timestamp = 0x12345678;
689 rtp_header.header.ssrc = 0x87654321; 686 rtp_header.header.ssrc = 0x87654321;
690 687
691 // Create a mock decoder object. 688 // Create a mock decoder object.
692 MockAudioDecoder mock_decoder; 689 MockAudioDecoder mock_decoder;
693 EXPECT_CALL(mock_decoder, Init()).WillRepeatedly(Return(0)); 690 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return());
694 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); 691 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1));
695 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) 692 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _))
696 .WillRepeatedly(Return(0)); 693 .WillRepeatedly(Return(0));
697 694
698 // Pointee(x) verifies that first byte of the payload equals x, this makes it 695 // Pointee(x) verifies that first byte of the payload equals x, this makes it
699 // possible to verify that the correct payload is fed to Decode(). 696 // possible to verify that the correct payload is fed to Decode().
700 EXPECT_CALL(mock_decoder, Decode(Pointee(0), kPayloadLengthBytes, 697 EXPECT_CALL(mock_decoder, Decode(Pointee(0), kPayloadLengthBytes,
701 kSampleRateKhz * 1000, _, _, _)) 698 kSampleRateKhz * 1000, _, _, _))
702 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, 699 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output,
703 dummy_output + kPayloadLengthSamples), 700 dummy_output + kPayloadLengthSamples),
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 uint8_t payload[kPayloadLengthBytes]= {0}; 819 uint8_t payload[kPayloadLengthBytes]= {0};
823 int16_t dummy_output[kPayloadLengthSamples * kChannels] = {0}; 820 int16_t dummy_output[kPayloadLengthSamples * kChannels] = {0};
824 WebRtcRTPHeader rtp_header; 821 WebRtcRTPHeader rtp_header;
825 rtp_header.header.payloadType = kPayloadType; 822 rtp_header.header.payloadType = kPayloadType;
826 rtp_header.header.sequenceNumber = 0x1234; 823 rtp_header.header.sequenceNumber = 0x1234;
827 rtp_header.header.timestamp = 0x12345678; 824 rtp_header.header.timestamp = 0x12345678;
828 rtp_header.header.ssrc = 0x87654321; 825 rtp_header.header.ssrc = 0x87654321;
829 826
830 class MockAudioDecoder : public AudioDecoder { 827 class MockAudioDecoder : public AudioDecoder {
831 public: 828 public:
832 int Init() override { 829 void Reset() override {}
833 return 0;
834 }
835 MOCK_CONST_METHOD2(PacketDuration, int(const uint8_t*, size_t)); 830 MOCK_CONST_METHOD2(PacketDuration, int(const uint8_t*, size_t));
836 MOCK_METHOD5(DecodeInternal, int(const uint8_t*, size_t, int, int16_t*, 831 MOCK_METHOD5(DecodeInternal, int(const uint8_t*, size_t, int, int16_t*,
837 SpeechType*)); 832 SpeechType*));
838 size_t Channels() const override { return kChannels; } 833 size_t Channels() const override { return kChannels; }
839 } decoder_; 834 } decoder_;
840 835
841 const uint8_t kFirstPayloadValue = 1; 836 const uint8_t kFirstPayloadValue = 1;
842 const uint8_t kSecondPayloadValue = 2; 837 const uint8_t kSecondPayloadValue = 2;
843 838
844 EXPECT_CALL(decoder_, PacketDuration(Pointee(kFirstPayloadValue), 839 EXPECT_CALL(decoder_, PacketDuration(Pointee(kFirstPayloadValue),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 EXPECT_EQ(kChannels, num_channels); 896 EXPECT_EQ(kChannels, num_channels);
902 897
903 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(kMaxOutputSize, output, 898 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(kMaxOutputSize, output,
904 &samples_per_channel, &num_channels, 899 &samples_per_channel, &num_channels,
905 &type)); 900 &type));
906 EXPECT_EQ(kMaxOutputSize, samples_per_channel * kChannels); 901 EXPECT_EQ(kMaxOutputSize, samples_per_channel * kChannels);
907 EXPECT_EQ(kChannels, num_channels); 902 EXPECT_EQ(kChannels, num_channels);
908 } 903 }
909 904
910 } // namespace webrtc 905 } // 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