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

Side by Side Diff: webrtc/modules/audio_coding/neteq/tools/neteq_external_decoder_test.cc

Issue 1949533002: WIP: Move the creation of AudioCodecFactory into PeerConnectionFactory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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) 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 "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webrtc/base/format_macros.h" 16 #include "webrtc/base/format_macros.h"
16 17
17 namespace webrtc { 18 namespace webrtc {
18 namespace test { 19 namespace test {
19 20
20 NetEqExternalDecoderTest::NetEqExternalDecoderTest(NetEqDecoder codec, 21 NetEqExternalDecoderTest::NetEqExternalDecoderTest(NetEqDecoder codec,
21 AudioDecoder* decoder) 22 AudioDecoder* decoder)
22 : codec_(codec), 23 : codec_(codec),
23 decoder_(decoder), 24 decoder_(decoder),
24 sample_rate_hz_(CodecSampleRateHz(codec_)), 25 sample_rate_hz_(CodecSampleRateHz(codec_)),
25 channels_(decoder_->Channels()) { 26 channels_(decoder_->Channels()) {
26 NetEq::Config config; 27 NetEq::Config config;
27 config.sample_rate_hz = sample_rate_hz_; 28 config.sample_rate_hz = sample_rate_hz_;
28 neteq_.reset(NetEq::Create(config)); 29 neteq_.reset(NetEq::Create(config, CreateBuiltinAudioDecoderFactory()));
29 printf("%" PRIuS "\n", channels_); 30 printf("%" PRIuS "\n", channels_);
30 } 31 }
31 32
32 void NetEqExternalDecoderTest::Init() { 33 void NetEqExternalDecoderTest::Init() {
33 ASSERT_EQ(NetEq::kOK, 34 ASSERT_EQ(NetEq::kOK,
34 neteq_->RegisterExternalDecoder(decoder_, codec_, name_, 35 neteq_->RegisterExternalDecoder(decoder_, codec_, name_,
35 kPayloadType, sample_rate_hz_)); 36 kPayloadType, sample_rate_hz_));
36 } 37 }
37 38
38 void NetEqExternalDecoderTest::InsertPacket( 39 void NetEqExternalDecoderTest::InsertPacket(
39 WebRtcRTPHeader rtp_header, 40 WebRtcRTPHeader rtp_header,
40 rtc::ArrayView<const uint8_t> payload, 41 rtc::ArrayView<const uint8_t> payload,
41 uint32_t receive_timestamp) { 42 uint32_t receive_timestamp) {
42 ASSERT_EQ(NetEq::kOK, 43 ASSERT_EQ(NetEq::kOK,
43 neteq_->InsertPacket(rtp_header, payload, receive_timestamp)); 44 neteq_->InsertPacket(rtp_header, payload, receive_timestamp));
44 } 45 }
45 46
46 void NetEqExternalDecoderTest::GetOutputAudio(AudioFrame* output) { 47 void NetEqExternalDecoderTest::GetOutputAudio(AudioFrame* output) {
47 // Get audio from regular instance. 48 // Get audio from regular instance.
48 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(output)); 49 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(output));
49 EXPECT_EQ(channels_, output->num_channels_); 50 EXPECT_EQ(channels_, output->num_channels_);
50 EXPECT_EQ(static_cast<size_t>(kOutputLengthMs * sample_rate_hz_ / 1000), 51 EXPECT_EQ(static_cast<size_t>(kOutputLengthMs * sample_rate_hz_ / 1000),
51 output->samples_per_channel_); 52 output->samples_per_channel_);
52 EXPECT_EQ(sample_rate_hz_, neteq_->last_output_sample_rate_hz()); 53 EXPECT_EQ(sample_rate_hz_, neteq_->last_output_sample_rate_hz());
53 } 54 }
54 55
55 } // namespace test 56 } // namespace test
56 } // namespace webrtc 57 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698