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 14 matching lines...) Expand all Loading... |
25 #include "webrtc/modules/audio_coding/main/test/utility.h" | 25 #include "webrtc/modules/audio_coding/main/test/utility.h" |
26 #include "webrtc/system_wrappers/interface/event_wrapper.h" | 26 #include "webrtc/system_wrappers/interface/event_wrapper.h" |
27 #include "webrtc/test/testsupport/fileutils.h" | 27 #include "webrtc/test/testsupport/fileutils.h" |
28 #include "webrtc/test/testsupport/gtest_disable.h" | 28 #include "webrtc/test/testsupport/gtest_disable.h" |
29 | 29 |
30 namespace webrtc { | 30 namespace webrtc { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 double FrameRms(AudioFrame& frame) { | 34 double FrameRms(AudioFrame& frame) { |
35 int samples = frame.num_channels_ * frame.samples_per_channel_; | 35 size_t samples = frame.num_channels_ * frame.samples_per_channel_; |
36 double rms = 0; | 36 double rms = 0; |
37 for (int n = 0; n < samples; ++n) | 37 for (size_t n = 0; n < samples; ++n) |
38 rms += frame.data_[n] * frame.data_[n]; | 38 rms += frame.data_[n] * frame.data_[n]; |
39 rms /= samples; | 39 rms /= samples; |
40 rms = sqrt(rms); | 40 rms = sqrt(rms); |
41 return rms; | 41 return rms; |
42 } | 42 } |
43 | 43 |
44 } | 44 } |
45 | 45 |
46 class InitialPlayoutDelayTest : public ::testing::Test { | 46 class InitialPlayoutDelayTest : public ::testing::Test { |
47 protected: | 47 protected: |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 private: | 126 private: |
127 void Run(CodecInst codec, int initial_delay_ms) { | 127 void Run(CodecInst codec, int initial_delay_ms) { |
128 AudioFrame in_audio_frame; | 128 AudioFrame in_audio_frame; |
129 AudioFrame out_audio_frame; | 129 AudioFrame out_audio_frame; |
130 int num_frames = 0; | 130 int num_frames = 0; |
131 const int kAmp = 10000; | 131 const int kAmp = 10000; |
132 in_audio_frame.sample_rate_hz_ = codec.plfreq; | 132 in_audio_frame.sample_rate_hz_ = codec.plfreq; |
133 in_audio_frame.num_channels_ = codec.channels; | 133 in_audio_frame.num_channels_ = codec.channels; |
134 in_audio_frame.samples_per_channel_ = codec.plfreq / 100; // 10 ms. | 134 in_audio_frame.samples_per_channel_ = codec.plfreq / 100; // 10 ms. |
135 int samples = in_audio_frame.num_channels_ * | 135 size_t samples = in_audio_frame.num_channels_ * |
136 in_audio_frame.samples_per_channel_; | 136 in_audio_frame.samples_per_channel_; |
137 for (int n = 0; n < samples; ++n) { | 137 for (size_t n = 0; n < samples; ++n) { |
138 in_audio_frame.data_[n] = kAmp; | 138 in_audio_frame.data_[n] = kAmp; |
139 } | 139 } |
140 | 140 |
141 uint32_t timestamp = 0; | 141 uint32_t timestamp = 0; |
142 double rms = 0; | 142 double rms = 0; |
143 ASSERT_EQ(0, acm_a_->RegisterSendCodec(codec)); | 143 ASSERT_EQ(0, acm_a_->RegisterSendCodec(codec)); |
144 acm_b_->SetInitialPlayoutDelay(initial_delay_ms); | 144 acm_b_->SetInitialPlayoutDelay(initial_delay_ms); |
145 while (rms < kAmp / 2) { | 145 while (rms < kAmp / 2) { |
146 in_audio_frame.timestamp_ = timestamp; | 146 in_audio_frame.timestamp_ = timestamp; |
147 timestamp += static_cast<uint32_t>(in_audio_frame.samples_per_channel_); | 147 timestamp += static_cast<uint32_t>(in_audio_frame.samples_per_channel_); |
(...skipping 18 matching lines...) Expand all Loading... |
166 | 166 |
167 TEST_F(InitialPlayoutDelayTest, SwbMono) { SwbMono(); } | 167 TEST_F(InitialPlayoutDelayTest, SwbMono) { SwbMono(); } |
168 | 168 |
169 TEST_F(InitialPlayoutDelayTest, NbStereo) { NbStereo(); } | 169 TEST_F(InitialPlayoutDelayTest, NbStereo) { NbStereo(); } |
170 | 170 |
171 TEST_F(InitialPlayoutDelayTest, WbStereo) { WbStereo(); } | 171 TEST_F(InitialPlayoutDelayTest, WbStereo) { WbStereo(); } |
172 | 172 |
173 TEST_F(InitialPlayoutDelayTest, SwbStereo) { SwbStereo(); } | 173 TEST_F(InitialPlayoutDelayTest, SwbStereo) { SwbStereo(); } |
174 | 174 |
175 } // namespace webrtc | 175 } // namespace webrtc |
OLD | NEW |