OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (!real_audio) { | 104 if (!real_audio) { |
105 VerifyMixedOutput(max_output_value, min_output_value); | 105 VerifyMixedOutput(max_output_value, min_output_value); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 private: | 109 private: |
110 // Generate input file with constant values equal to |input_value|. The file | 110 // Generate input file with constant values equal to |input_value|. The file |
111 // will be twice the duration of the test. | 111 // will be twice the duration of the test. |
112 void GenerateInputFile(int16_t input_value) { | 112 void GenerateInputFile(int16_t input_value) { |
113 FILE* input_file = fopen(input_filename_.c_str(), "wb"); | 113 FILE* input_file = fopen(input_filename_.c_str(), "wb"); |
114 ASSERT_TRUE(input_file != NULL); | 114 ASSERT_TRUE(input_file != nullptr); |
115 for (int i = 0; i < kInSampleRateHz / 1000 * (kTestDurationMs * 2); i++) { | 115 for (int i = 0; i < kInSampleRateHz / 1000 * (kTestDurationMs * 2); i++) { |
116 ASSERT_EQ(1u, fwrite(&input_value, sizeof(input_value), 1, input_file)); | 116 ASSERT_EQ(1u, fwrite(&input_value, sizeof(input_value), 1, input_file)); |
117 } | 117 } |
118 ASSERT_EQ(0, fclose(input_file)); | 118 ASSERT_EQ(0, fclose(input_file)); |
119 } | 119 } |
120 | 120 |
121 void VerifyMixedOutput(int16_t max_output_value, int16_t min_output_value) { | 121 void VerifyMixedOutput(int16_t max_output_value, int16_t min_output_value) { |
122 // Verify the mixed output. | 122 // Verify the mixed output. |
123 FILE* output_file = fopen(output_filename_.c_str(), "rb"); | 123 FILE* output_file = fopen(output_filename_.c_str(), "rb"); |
124 ASSERT_TRUE(output_file != NULL); | 124 ASSERT_TRUE(output_file != nullptr); |
125 int16_t output_value = 0; | 125 int16_t output_value = 0; |
126 int samples_read = 0; | 126 int samples_read = 0; |
127 while (fread(&output_value, sizeof(output_value), 1, output_file) == 1) { | 127 while (fread(&output_value, sizeof(output_value), 1, output_file) == 1) { |
128 samples_read++; | 128 samples_read++; |
129 std::ostringstream trace_stream; | 129 std::ostringstream trace_stream; |
130 trace_stream << samples_read << " samples read"; | 130 trace_stream << samples_read << " samples read"; |
131 SCOPED_TRACE(trace_stream.str()); | 131 SCOPED_TRACE(trace_stream.str()); |
132 ASSERT_LE(output_value, max_output_value); | 132 ASSERT_LE(output_value, max_output_value); |
133 ASSERT_GE(output_value, min_output_value); | 133 ASSERT_GE(output_value, min_output_value); |
134 } | 134 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 for (size_t i = 0; i < streams.size(); ++i) { | 196 for (size_t i = 0; i < streams.size(); ++i) { |
197 EXPECT_EQ(0, voe_base_->StopSend(streams[i])); | 197 EXPECT_EQ(0, voe_base_->StopSend(streams[i])); |
198 EXPECT_EQ(0, voe_base_->StopPlayout(streams[i])); | 198 EXPECT_EQ(0, voe_base_->StopPlayout(streams[i])); |
199 EXPECT_EQ(0, voe_network_->DeRegisterExternalTransport(streams[i])); | 199 EXPECT_EQ(0, voe_network_->DeRegisterExternalTransport(streams[i])); |
200 EXPECT_EQ(0, voe_base_->DeleteChannel(streams[i])); | 200 EXPECT_EQ(0, voe_base_->DeleteChannel(streams[i])); |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 int GetFileDurationMs(const char* file_name) { | 204 int GetFileDurationMs(const char* file_name) { |
205 FILE* fid = fopen(file_name, "rb"); | 205 FILE* fid = fopen(file_name, "rb"); |
206 EXPECT_FALSE(fid == NULL); | 206 EXPECT_FALSE(fid == nullptr); |
207 fseek(fid, 0, SEEK_END); | 207 fseek(fid, 0, SEEK_END); |
208 int size = ftell(fid); | 208 int size = ftell(fid); |
209 EXPECT_NE(-1, size); | 209 EXPECT_NE(-1, size); |
210 fclose(fid); | 210 fclose(fid); |
211 // Divided by 2 due to 2 bytes/sample. | 211 // Divided by 2 due to 2 bytes/sample. |
212 return size * 1000 / kRecSampleRateHz / 2; | 212 return size * 1000 / kRecSampleRateHz / 2; |
213 } | 213 } |
214 | 214 |
215 std::string input_filename_; | 215 std::string input_filename_; |
216 const std::string output_filename_; | 216 const std::string output_filename_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 TEST_F(MixingTest, VerifyStereoAndMonoMixing) { | 278 TEST_F(MixingTest, VerifyStereoAndMonoMixing) { |
279 const int16_t kInputValue = 1000; | 279 const int16_t kInputValue = 1000; |
280 const int16_t kExpectedOutput = kInputValue * 2; | 280 const int16_t kExpectedOutput = kInputValue * 2; |
281 RunMixingTest(2, 0, 1, false, kInputValue, 1.1 * kExpectedOutput, | 281 RunMixingTest(2, 0, 1, false, kInputValue, 1.1 * kExpectedOutput, |
282 // Lower than 0.9 due to observed flakiness on bots. | 282 // Lower than 0.9 due to observed flakiness on bots. |
283 0.8 * kExpectedOutput, kCodecL16); | 283 0.8 * kExpectedOutput, kCodecL16); |
284 } | 284 } |
285 | 285 |
286 } // namespace webrtc | 286 } // namespace webrtc |
OLD | NEW |