| 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 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 next_arrival_time = GetArrivalTime(next_send_time); | 98 next_arrival_time = GetArrivalTime(next_send_time); |
| 99 } while (Lost()); // If lost, immediately read the next packet. | 99 } while (Lost()); // If lost, immediately read the next packet. |
| 100 | 100 |
| 101 EXPECT_CALL(*external_decoder_, | 101 EXPECT_CALL(*external_decoder_, |
| 102 Decode(_, payload_size_bytes_, 1000 * samples_per_ms_, _, _, _)) | 102 Decode(_, payload_size_bytes_, 1000 * samples_per_ms_, _, _, _)) |
| 103 .Times(NumExpectedDecodeCalls(num_loops)); | 103 .Times(NumExpectedDecodeCalls(num_loops)); |
| 104 | 104 |
| 105 uint32_t time_now = 0; | 105 uint32_t time_now = 0; |
| 106 for (int k = 0; k < num_loops; ++k) { | 106 for (int k = 0; k < num_loops; ++k) { |
| 107 while (time_now >= next_arrival_time) { | 107 while (time_now >= next_arrival_time) { |
| 108 InsertPacket(rtp_header_, encoded_, payload_size_bytes_, | 108 InsertPacket(rtp_header_, rtc::ArrayView<const uint8_t>( |
| 109 encoded_, payload_size_bytes_), |
| 109 next_arrival_time); | 110 next_arrival_time); |
| 110 // Get next input packet. | 111 // Get next input packet. |
| 111 do { | 112 do { |
| 112 next_send_time = GetNewPacket(); | 113 next_send_time = GetNewPacket(); |
| 113 next_arrival_time = GetArrivalTime(next_send_time); | 114 next_arrival_time = GetArrivalTime(next_send_time); |
| 114 } while (Lost()); // If lost, immediately read the next packet. | 115 } while (Lost()); // If lost, immediately read the next packet. |
| 115 } | 116 } |
| 116 | 117 |
| 117 std::ostringstream ss; | 118 std::ostringstream ss; |
| 118 ss << "Lap number " << k << "."; | 119 ss << "Lap number " << k << "."; |
| 119 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. | 120 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
| 120 // Compare mono and multi-channel. | 121 // Compare mono and multi-channel. |
| 121 ASSERT_NO_FATAL_FAILURE(GetAndVerifyOutput()); | 122 ASSERT_NO_FATAL_FAILURE(GetAndVerifyOutput()); |
| 122 | 123 |
| 123 time_now += kOutputLengthMs; | 124 time_now += kOutputLengthMs; |
| 124 } | 125 } |
| 125 } | 126 } |
| 126 | 127 |
| 127 void InsertPacket(WebRtcRTPHeader rtp_header, const uint8_t* payload, | 128 void InsertPacket(WebRtcRTPHeader rtp_header, |
| 128 size_t payload_size_bytes, | 129 rtc::ArrayView<const uint8_t> payload, |
| 129 uint32_t receive_timestamp) override { | 130 uint32_t receive_timestamp) override { |
| 130 EXPECT_CALL(*external_decoder_, | 131 EXPECT_CALL( |
| 131 IncomingPacket(_, | 132 *external_decoder_, |
| 132 payload_size_bytes, | 133 IncomingPacket(_, payload.size(), rtp_header.header.sequenceNumber, |
| 133 rtp_header.header.sequenceNumber, | 134 rtp_header.header.timestamp, receive_timestamp)); |
| 134 rtp_header.header.timestamp, | |
| 135 receive_timestamp)); | |
| 136 NetEqExternalDecoderTest::InsertPacket(rtp_header, payload, | 135 NetEqExternalDecoderTest::InsertPacket(rtp_header, payload, |
| 137 payload_size_bytes, | |
| 138 receive_timestamp); | 136 receive_timestamp); |
| 139 } | 137 } |
| 140 | 138 |
| 141 MockExternalPcm16B* external_decoder() { return external_decoder_.get(); } | 139 MockExternalPcm16B* external_decoder() { return external_decoder_.get(); } |
| 142 | 140 |
| 143 void ResetRtpGenerator(test::RtpGenerator* rtp_generator) { | 141 void ResetRtpGenerator(test::RtpGenerator* rtp_generator) { |
| 144 rtp_generator_.reset(rtp_generator); | 142 rtp_generator_.reset(rtp_generator); |
| 145 } | 143 } |
| 146 | 144 |
| 147 int samples_per_ms() const { return samples_per_ms_; } | 145 int samples_per_ms() const { return samples_per_ms_; } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 201 |
| 204 // Get audio from external decoder instance. | 202 // Get audio from external decoder instance. |
| 205 samples_per_channel = GetOutputAudio(kMaxBlockSize, output_, &output_type); | 203 samples_per_channel = GetOutputAudio(kMaxBlockSize, output_, &output_type); |
| 206 | 204 |
| 207 for (size_t i = 0; i < samples_per_channel; ++i) { | 205 for (size_t i = 0; i < samples_per_channel; ++i) { |
| 208 ASSERT_EQ(output_[i], output_internal_[i]) << | 206 ASSERT_EQ(output_[i], output_internal_[i]) << |
| 209 "Diff in sample " << i << "."; | 207 "Diff in sample " << i << "."; |
| 210 } | 208 } |
| 211 } | 209 } |
| 212 | 210 |
| 213 void InsertPacket(WebRtcRTPHeader rtp_header, const uint8_t* payload, | 211 void InsertPacket(WebRtcRTPHeader rtp_header, |
| 214 size_t payload_size_bytes, | 212 rtc::ArrayView<const uint8_t> payload, |
| 215 uint32_t receive_timestamp) override { | 213 uint32_t receive_timestamp) override { |
| 216 // Insert packet in internal decoder. | 214 // Insert packet in internal decoder. |
| 217 ASSERT_EQ( | 215 ASSERT_EQ(NetEq::kOK, neteq_internal_->InsertPacket(rtp_header, payload, |
| 218 NetEq::kOK, | 216 receive_timestamp)); |
| 219 neteq_internal_->InsertPacket( | |
| 220 rtp_header, payload, payload_size_bytes, receive_timestamp)); | |
| 221 | 217 |
| 222 // Insert packet in external decoder instance. | 218 // Insert packet in external decoder instance. |
| 223 NetEqExternalDecoderUnitTest::InsertPacket(rtp_header, payload, | 219 NetEqExternalDecoderUnitTest::InsertPacket(rtp_header, payload, |
| 224 payload_size_bytes, | |
| 225 receive_timestamp); | 220 receive_timestamp); |
| 226 } | 221 } |
| 227 | 222 |
| 228 int NumExpectedDecodeCalls(int num_loops) override { return num_loops; } | 223 int NumExpectedDecodeCalls(int num_loops) override { return num_loops; } |
| 229 | 224 |
| 230 private: | 225 private: |
| 231 int sample_rate_hz_; | 226 int sample_rate_hz_; |
| 232 rtc::scoped_ptr<NetEq> neteq_internal_; | 227 rtc::scoped_ptr<NetEq> neteq_internal_; |
| 233 int16_t output_internal_[kMaxBlockSize]; | 228 int16_t output_internal_[kMaxBlockSize]; |
| 234 int16_t output_[kMaxBlockSize]; | 229 int16_t output_[kMaxBlockSize]; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 kStartSeqeunceNumber, | 449 kStartSeqeunceNumber, |
| 455 kStartTimestamp, | 450 kStartTimestamp, |
| 456 kJumpFromTimestamp, | 451 kJumpFromTimestamp, |
| 457 kJumpToTimestamp)); | 452 kJumpToTimestamp)); |
| 458 | 453 |
| 459 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. | 454 RunTest(130); // Run 130 laps @ 10 ms each in the test loop. |
| 460 EXPECT_EQ(kRecovered, test_state_); | 455 EXPECT_EQ(kRecovered, test_state_); |
| 461 } | 456 } |
| 462 | 457 |
| 463 } // namespace webrtc | 458 } // namespace webrtc |
| OLD | NEW |