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

Side by Side Diff: webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc

Issue 1172163004: Reformat existing code. There should be no functional effects. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 6 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 #include "webrtc/modules/audio_coding/main/acm2/acm_receive_test.h" 11 #include "webrtc/modules/audio_coding/main/acm2/acm_receive_test.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <stdio.h> 14 #include <stdio.h>
15 15
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" 17 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
18 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h" 18 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h"
19 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" 19 #include "webrtc/modules/audio_coding/neteq/tools/packet.h"
20 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" 20 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 namespace test { 23 namespace test {
24 24
25 AcmReceiveTest::AcmReceiveTest(PacketSource* packet_source, 25 AcmReceiveTest::AcmReceiveTest(PacketSource* packet_source,
26 AudioSink* audio_sink, 26 AudioSink* audio_sink,
27 int output_freq_hz, 27 int output_freq_hz,
28 NumOutputChannels exptected_output_channels) 28 NumOutputChannels expected_output_channels)
29 : clock_(0), 29 : clock_(0),
30 packet_source_(packet_source), 30 packet_source_(packet_source),
31 audio_sink_(audio_sink), 31 audio_sink_(audio_sink),
32 output_freq_hz_(output_freq_hz), 32 output_freq_hz_(output_freq_hz),
33 exptected_output_channels_(exptected_output_channels) { 33 expected_output_channels_(expected_output_channels) {
34 webrtc::AudioCoding::Config config; 34 webrtc::AudioCoding::Config config;
35 config.clock = &clock_; 35 config.clock = &clock_;
36 config.playout_frequency_hz = output_freq_hz_; 36 config.playout_frequency_hz = output_freq_hz_;
37 acm_.reset(webrtc::AudioCoding::Create(config)); 37 acm_.reset(webrtc::AudioCoding::Create(config));
38 } 38 }
39 39
40 void AcmReceiveTest::RegisterDefaultCodecs() { 40 void AcmReceiveTest::RegisterDefaultCodecs() {
41 ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kOpus, 120)); 41 ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kOpus, 120));
42 ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kISAC, 103)); 42 ASSERT_TRUE(acm_->RegisterReceiveCodec(acm2::ACMCodecDB::kISAC, 103));
43 #ifndef WEBRTC_ANDROID 43 #ifndef WEBRTC_ANDROID
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 void AcmReceiveTest::Run() { 88 void AcmReceiveTest::Run() {
89 for (rtc::scoped_ptr<Packet> packet(packet_source_->NextPacket()); packet; 89 for (rtc::scoped_ptr<Packet> packet(packet_source_->NextPacket()); packet;
90 packet.reset(packet_source_->NextPacket())) { 90 packet.reset(packet_source_->NextPacket())) {
91 // Pull audio until time to insert packet. 91 // Pull audio until time to insert packet.
92 while (clock_.TimeInMilliseconds() < packet->time_ms()) { 92 while (clock_.TimeInMilliseconds() < packet->time_ms()) {
93 AudioFrame output_frame; 93 AudioFrame output_frame;
94 EXPECT_TRUE(acm_->Get10MsAudio(&output_frame)); 94 EXPECT_TRUE(acm_->Get10MsAudio(&output_frame));
95 EXPECT_EQ(output_freq_hz_, output_frame.sample_rate_hz_); 95 EXPECT_EQ(output_freq_hz_, output_frame.sample_rate_hz_);
96 const int samples_per_block = output_freq_hz_ * 10 / 1000; 96 const int samples_per_block = output_freq_hz_ * 10 / 1000;
97 EXPECT_EQ(samples_per_block, output_frame.samples_per_channel_); 97 EXPECT_EQ(samples_per_block, output_frame.samples_per_channel_);
98 if (exptected_output_channels_ != kArbitraryChannels) { 98 if (expected_output_channels_ != kArbitraryChannels) {
99 if (output_frame.speech_type_ == webrtc::AudioFrame::kPLC) { 99 if (output_frame.speech_type_ == webrtc::AudioFrame::kPLC) {
100 // Don't check number of channels for PLC output, since each test run 100 // Don't check number of channels for PLC output, since each test run
101 // usually starts with a short period of mono PLC before decoding the 101 // usually starts with a short period of mono PLC before decoding the
102 // first packet. 102 // first packet.
103 } else { 103 } else {
104 EXPECT_EQ(exptected_output_channels_, output_frame.num_channels_); 104 EXPECT_EQ(expected_output_channels_, output_frame.num_channels_);
105 } 105 }
106 } 106 }
107 ASSERT_TRUE(audio_sink_->WriteAudioFrame(output_frame)); 107 ASSERT_TRUE(audio_sink_->WriteAudioFrame(output_frame));
108 clock_.AdvanceTimeMilliseconds(10); 108 clock_.AdvanceTimeMilliseconds(10);
109 } 109 }
110 110
111 // Insert packet after converting from RTPHeader to WebRtcRTPHeader. 111 // Insert packet after converting from RTPHeader to WebRtcRTPHeader.
112 WebRtcRTPHeader header; 112 WebRtcRTPHeader header;
113 header.header = packet->header(); 113 header.header = packet->header();
114 header.frameType = kAudioFrameSpeech; 114 header.frameType = kAudioFrameSpeech;
115 memset(&header.type.Audio, 0, sizeof(RTPAudioHeader)); 115 memset(&header.type.Audio, 0, sizeof(RTPAudioHeader));
116 EXPECT_TRUE(acm_->InsertPacket(packet->payload(), 116 EXPECT_TRUE(acm_->InsertPacket(packet->payload(),
117 packet->payload_length_bytes(), 117 packet->payload_length_bytes(),
118 header)) 118 header))
119 << "Failure when inserting packet:" << std::endl 119 << "Failure when inserting packet:" << std::endl
120 << " PT = " << static_cast<int>(header.header.payloadType) << std::endl 120 << " PT = " << static_cast<int>(header.header.payloadType) << std::endl
121 << " TS = " << header.header.timestamp << std::endl 121 << " TS = " << header.header.timestamp << std::endl
122 << " SN = " << header.header.sequenceNumber; 122 << " SN = " << header.header.sequenceNumber;
123 } 123 }
124 } 124 }
125 125
126 } // namespace test 126 } // namespace test
127 } // namespace webrtc 127 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698