OLD | NEW |
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 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 void PlayFileAndCheck(const std::string& input_file, | 55 void PlayFileAndCheck(const std::string& input_file, |
56 const std::string& ref_checksum, | 56 const std::string& ref_checksum, |
57 int output_length_ms) { | 57 int output_length_ms) { |
58 const float kScaling = 1; | 58 const float kScaling = 1; |
59 ASSERT_EQ(0, | 59 ASSERT_EQ(0, |
60 player_->StartPlayingFile( | 60 player_->StartPlayingFile( |
61 input_file.c_str(), false, 0, kScaling, 0, 0, NULL)); | 61 input_file.c_str(), false, 0, kScaling, 0, 0, NULL)); |
62 rtc::Md5Digest checksum; | 62 rtc::Md5Digest checksum; |
63 for (int i = 0; i < output_length_ms / 10; ++i) { | 63 for (int i = 0; i < output_length_ms / 10; ++i) { |
64 int16_t out[10 * kSampleRateHz / 1000] = {0}; | 64 int16_t out[10 * kSampleRateHz / 1000] = {0}; |
65 int num_samples; | 65 size_t num_samples; |
66 EXPECT_EQ(0, | 66 EXPECT_EQ(0, |
67 player_->Get10msAudioFromFile(out, num_samples, kSampleRateHz)); | 67 player_->Get10msAudioFromFile(out, num_samples, kSampleRateHz)); |
68 checksum.Update(out, num_samples * sizeof(out[0])); | 68 checksum.Update(out, num_samples * sizeof(out[0])); |
69 if (FLAGS_file_player_output) { | 69 if (FLAGS_file_player_output) { |
70 ASSERT_EQ(static_cast<size_t>(num_samples), | 70 ASSERT_EQ(num_samples, |
71 fwrite(out, sizeof(out[0]), num_samples, output_file_)); | 71 fwrite(out, sizeof(out[0]), num_samples, output_file_)); |
72 } | 72 } |
73 } | 73 } |
74 char checksum_result[rtc::Md5Digest::kSize]; | 74 char checksum_result[rtc::Md5Digest::kSize]; |
75 EXPECT_EQ(rtc::Md5Digest::kSize, | 75 EXPECT_EQ(rtc::Md5Digest::kSize, |
76 checksum.Finish(checksum_result, rtc::Md5Digest::kSize)); | 76 checksum.Finish(checksum_result, rtc::Md5Digest::kSize)); |
77 EXPECT_EQ(ref_checksum, | 77 EXPECT_EQ(ref_checksum, |
78 rtc::hex_encode(checksum_result, sizeof(checksum_result))); | 78 rtc::hex_encode(checksum_result, sizeof(checksum_result))); |
79 } | 79 } |
80 | 80 |
(...skipping 17 matching lines...) Expand all Loading... |
98 test::ResourcePath("utility/encapsulated_pcm16b_8khz", "wav"); | 98 test::ResourcePath("utility/encapsulated_pcm16b_8khz", "wav"); |
99 // The file is longer than this, but keeping the output shorter limits the | 99 // The file is longer than this, but keeping the output shorter limits the |
100 // runtime for the test. | 100 // runtime for the test. |
101 const int kOutputLengthMs = 10000; | 101 const int kOutputLengthMs = 10000; |
102 const std::string kRefChecksum = "e41d7e1dac8aeae9f21e8e03cd7ecd71"; | 102 const std::string kRefChecksum = "e41d7e1dac8aeae9f21e8e03cd7ecd71"; |
103 | 103 |
104 PlayFileAndCheck(kFileName, kRefChecksum, kOutputLengthMs); | 104 PlayFileAndCheck(kFileName, kRefChecksum, kOutputLengthMs); |
105 } | 105 } |
106 | 106 |
107 } // namespace webrtc | 107 } // namespace webrtc |
OLD | NEW |