OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 | 11 |
12 #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" | 12 #include "webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.h" |
13 | 13 |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "webrtc/base/format_macros.h" |
15 | 16 |
16 namespace webrtc { | 17 namespace webrtc { |
17 namespace test { | 18 namespace test { |
18 | 19 |
19 NetEqExternalDecoderTest::NetEqExternalDecoderTest(NetEqDecoder codec, | 20 NetEqExternalDecoderTest::NetEqExternalDecoderTest(NetEqDecoder codec, |
20 AudioDecoder* decoder) | 21 AudioDecoder* decoder) |
21 : codec_(codec), | 22 : codec_(codec), |
22 decoder_(decoder), | 23 decoder_(decoder), |
23 sample_rate_hz_(CodecSampleRateHz(codec_)), | 24 sample_rate_hz_(CodecSampleRateHz(codec_)), |
24 channels_(static_cast<int>(decoder_->Channels())) { | 25 channels_(decoder_->Channels()) { |
25 NetEq::Config config; | 26 NetEq::Config config; |
26 config.sample_rate_hz = sample_rate_hz_; | 27 config.sample_rate_hz = sample_rate_hz_; |
27 neteq_.reset(NetEq::Create(config)); | 28 neteq_.reset(NetEq::Create(config)); |
28 printf("%d\n", channels_); | 29 printf("%" PRIuS "\n", channels_); |
29 } | 30 } |
30 | 31 |
31 void NetEqExternalDecoderTest::Init() { | 32 void NetEqExternalDecoderTest::Init() { |
32 ASSERT_EQ(NetEq::kOK, | 33 ASSERT_EQ(NetEq::kOK, |
33 neteq_->RegisterExternalDecoder(decoder_, codec_, name_, | 34 neteq_->RegisterExternalDecoder(decoder_, codec_, name_, |
34 kPayloadType, sample_rate_hz_)); | 35 kPayloadType, sample_rate_hz_)); |
35 } | 36 } |
36 | 37 |
37 void NetEqExternalDecoderTest::InsertPacket( | 38 void NetEqExternalDecoderTest::InsertPacket( |
38 WebRtcRTPHeader rtp_header, | 39 WebRtcRTPHeader rtp_header, |
39 rtc::ArrayView<const uint8_t> payload, | 40 rtc::ArrayView<const uint8_t> payload, |
40 uint32_t receive_timestamp) { | 41 uint32_t receive_timestamp) { |
41 ASSERT_EQ(NetEq::kOK, | 42 ASSERT_EQ(NetEq::kOK, |
42 neteq_->InsertPacket(rtp_header, payload, receive_timestamp)); | 43 neteq_->InsertPacket(rtp_header, payload, receive_timestamp)); |
43 } | 44 } |
44 | 45 |
45 size_t NetEqExternalDecoderTest::GetOutputAudio(size_t max_length, | 46 size_t NetEqExternalDecoderTest::GetOutputAudio(size_t max_length, |
46 int16_t* output, | 47 int16_t* output, |
47 NetEqOutputType* output_type) { | 48 NetEqOutputType* output_type) { |
48 // Get audio from regular instance. | 49 // Get audio from regular instance. |
49 size_t samples_per_channel; | 50 size_t samples_per_channel; |
50 int num_channels; | 51 size_t num_channels; |
51 EXPECT_EQ(NetEq::kOK, | 52 EXPECT_EQ(NetEq::kOK, |
52 neteq_->GetAudio(max_length, | 53 neteq_->GetAudio(max_length, |
53 output, | 54 output, |
54 &samples_per_channel, | 55 &samples_per_channel, |
55 &num_channels, | 56 &num_channels, |
56 output_type)); | 57 output_type)); |
57 EXPECT_EQ(channels_, num_channels); | 58 EXPECT_EQ(channels_, num_channels); |
58 EXPECT_EQ(static_cast<size_t>(kOutputLengthMs * sample_rate_hz_ / 1000), | 59 EXPECT_EQ(static_cast<size_t>(kOutputLengthMs * sample_rate_hz_ / 1000), |
59 samples_per_channel); | 60 samples_per_channel); |
60 EXPECT_EQ(sample_rate_hz_, neteq_->last_output_sample_rate_hz()); | 61 EXPECT_EQ(sample_rate_hz_, neteq_->last_output_sample_rate_hz()); |
61 return samples_per_channel; | 62 return samples_per_channel; |
62 } | 63 } |
63 | 64 |
64 } // namespace test | 65 } // namespace test |
65 } // namespace webrtc | 66 } // namespace webrtc |
OLD | NEW |