OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 // Test to verify correct operation for externally created decoders. | 11 // Test to verify correct operation for externally created decoders. |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | 15 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
| 16 #include "webrtc/common_types.h" |
16 #include "webrtc/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h" | 17 #include "webrtc/modules/audio_coding/neteq/mock/mock_external_decoder_pcm16b.h" |
17 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" | 18 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" |
18 #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" | 19 #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" |
19 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" | 20 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" |
20 #include "webrtc/modules/include/module_common_types.h" | 21 #include "webrtc/modules/include/module_common_types.h" |
21 #include "webrtc/test/gmock.h" | 22 #include "webrtc/test/gmock.h" |
22 #include "webrtc/test/testsupport/fileutils.h" | 23 #include "webrtc/test/testsupport/fileutils.h" |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 | 26 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 std::ostringstream ss; | 124 std::ostringstream ss; |
124 ss << "Lap number " << k << "."; | 125 ss << "Lap number " << k << "."; |
125 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. | 126 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
126 // Compare mono and multi-channel. | 127 // Compare mono and multi-channel. |
127 ASSERT_NO_FATAL_FAILURE(GetAndVerifyOutput()); | 128 ASSERT_NO_FATAL_FAILURE(GetAndVerifyOutput()); |
128 | 129 |
129 time_now += kOutputLengthMs; | 130 time_now += kOutputLengthMs; |
130 } | 131 } |
131 } | 132 } |
132 | 133 |
133 void InsertPacket(WebRtcRTPHeader rtp_header, | 134 void InsertPacket(RTPHeader rtp_header, |
134 rtc::ArrayView<const uint8_t> payload, | 135 rtc::ArrayView<const uint8_t> payload, |
135 uint32_t receive_timestamp) override { | 136 uint32_t receive_timestamp) override { |
136 EXPECT_CALL( | 137 EXPECT_CALL(*external_decoder_, |
137 *external_decoder_, | 138 IncomingPacket(_, payload.size(), rtp_header.sequenceNumber, |
138 IncomingPacket(_, payload.size(), rtp_header.header.sequenceNumber, | 139 rtp_header.timestamp, receive_timestamp)); |
139 rtp_header.header.timestamp, receive_timestamp)); | |
140 NetEqExternalDecoderTest::InsertPacket(rtp_header, payload, | 140 NetEqExternalDecoderTest::InsertPacket(rtp_header, payload, |
141 receive_timestamp); | 141 receive_timestamp); |
142 } | 142 } |
143 | 143 |
144 MockExternalPcm16B* external_decoder() { return external_decoder_.get(); } | 144 MockExternalPcm16B* external_decoder() { return external_decoder_.get(); } |
145 | 145 |
146 void ResetRtpGenerator(test::RtpGenerator* rtp_generator) { | 146 void ResetRtpGenerator(test::RtpGenerator* rtp_generator) { |
147 rtp_generator_.reset(rtp_generator); | 147 rtp_generator_.reset(rtp_generator); |
148 } | 148 } |
149 | 149 |
150 int samples_per_ms() const { return samples_per_ms_; } | 150 int samples_per_ms() const { return samples_per_ms_; } |
151 private: | 151 private: |
152 std::unique_ptr<MockExternalPcm16B> external_decoder_; | 152 std::unique_ptr<MockExternalPcm16B> external_decoder_; |
153 int samples_per_ms_; | 153 int samples_per_ms_; |
154 size_t frame_size_samples_; | 154 size_t frame_size_samples_; |
155 std::unique_ptr<test::RtpGenerator> rtp_generator_; | 155 std::unique_ptr<test::RtpGenerator> rtp_generator_; |
156 int16_t* input_; | 156 int16_t* input_; |
157 uint8_t* encoded_; | 157 uint8_t* encoded_; |
158 size_t payload_size_bytes_; | 158 size_t payload_size_bytes_; |
159 uint32_t last_send_time_; | 159 uint32_t last_send_time_; |
160 uint32_t last_arrival_time_; | 160 uint32_t last_arrival_time_; |
161 std::unique_ptr<test::InputAudioFile> input_file_; | 161 std::unique_ptr<test::InputAudioFile> input_file_; |
162 WebRtcRTPHeader rtp_header_; | 162 RTPHeader rtp_header_; |
163 }; | 163 }; |
164 | 164 |
165 // This test encodes a few packets of PCM16b 32 kHz data and inserts it into two | 165 // This test encodes a few packets of PCM16b 32 kHz data and inserts it into two |
166 // different NetEq instances. The first instance uses the internal version of | 166 // different NetEq instances. The first instance uses the internal version of |
167 // the decoder object, while the second one uses an externally created decoder | 167 // the decoder object, while the second one uses an externally created decoder |
168 // object (ExternalPcm16B wrapped in MockExternalPcm16B, both defined above). | 168 // object (ExternalPcm16B wrapped in MockExternalPcm16B, both defined above). |
169 // The test verifies that the output from both instances match. | 169 // The test verifies that the output from both instances match. |
170 class NetEqExternalVsInternalDecoderTest : public NetEqExternalDecoderUnitTest, | 170 class NetEqExternalVsInternalDecoderTest : public NetEqExternalDecoderUnitTest, |
171 public ::testing::Test { | 171 public ::testing::Test { |
172 protected: | 172 protected: |
(...skipping 26 matching lines...) Expand all Loading... |
199 | 199 |
200 // Get audio from external decoder instance. | 200 // Get audio from external decoder instance. |
201 GetOutputAudio(&output_); | 201 GetOutputAudio(&output_); |
202 | 202 |
203 for (size_t i = 0; i < output_.samples_per_channel_; ++i) { | 203 for (size_t i = 0; i < output_.samples_per_channel_; ++i) { |
204 ASSERT_EQ(output_.data_[i], output_internal_.data_[i]) | 204 ASSERT_EQ(output_.data_[i], output_internal_.data_[i]) |
205 << "Diff in sample " << i << "."; | 205 << "Diff in sample " << i << "."; |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 void InsertPacket(WebRtcRTPHeader rtp_header, | 209 void InsertPacket(RTPHeader rtp_header, |
210 rtc::ArrayView<const uint8_t> payload, | 210 rtc::ArrayView<const uint8_t> payload, |
211 uint32_t receive_timestamp) override { | 211 uint32_t receive_timestamp) override { |
212 // Insert packet in internal decoder. | 212 // Insert packet in internal decoder. |
213 ASSERT_EQ(NetEq::kOK, neteq_internal_->InsertPacket( | 213 ASSERT_EQ(NetEq::kOK, neteq_internal_->InsertPacket(rtp_header, payload, |
214 rtp_header.header, payload, receive_timestamp)); | 214 receive_timestamp)); |
215 | 215 |
216 // Insert packet in external decoder instance. | 216 // Insert packet in external decoder instance. |
217 NetEqExternalDecoderUnitTest::InsertPacket(rtp_header, payload, | 217 NetEqExternalDecoderUnitTest::InsertPacket(rtp_header, payload, |
218 receive_timestamp); | 218 receive_timestamp); |
219 } | 219 } |
220 | 220 |
221 int NumExpectedDecodeCalls(int num_loops) override { return num_loops; } | 221 int NumExpectedDecodeCalls(int num_loops) override { return num_loops; } |
222 | 222 |
223 private: | 223 private: |
224 int sample_rate_hz_; | 224 int sample_rate_hz_; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 kStartSeqeunceNumber, | 445 kStartSeqeunceNumber, |
446 kStartTimestamp, | 446 kStartTimestamp, |
447 kJumpFromTimestamp, | 447 kJumpFromTimestamp, |
448 kJumpToTimestamp)); | 448 kJumpToTimestamp)); |
449 | 449 |
450 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. | 450 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. |
451 EXPECT_EQ(kRecovered, test_state_); | 451 EXPECT_EQ(kRecovered, test_state_); |
452 } | 452 } |
453 | 453 |
454 } // namespace webrtc | 454 } // namespace webrtc |
OLD | NEW |