| 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 |
| 11 #include <math.h> | 11 #include <math.h> |
| 12 #include <stdio.h> | 12 #include <stdio.h> |
| 13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" | 14 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" |
| 15 #include "webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h" | 15 #include "webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h" |
| 16 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h" | 16 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h" |
| 17 #include "webrtc/modules/audio_coding/neteq/tools/output_wav_file.h" | 17 #include "webrtc/modules/audio_coding/neteq/tools/output_wav_file.h" |
| 18 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" | 18 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" |
| 19 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
| 20 | 20 |
| 21 using std::string; | |
| 22 | |
| 23 namespace webrtc { | 21 namespace webrtc { |
| 24 namespace test { | 22 namespace test { |
| 25 | 23 |
| 26 const uint8_t kPayloadType = 95; | 24 const uint8_t kPayloadType = 95; |
| 27 const int kOutputSizeMs = 10; | 25 const int kOutputSizeMs = 10; |
| 28 const int kInitSeed = 0x12345678; | 26 const int kInitSeed = 0x12345678; |
| 29 const int kPacketLossTimeUnitMs = 10; | 27 const int kPacketLossTimeUnitMs = 10; |
| 30 | 28 |
| 31 // Common validator for file names. | 29 // Common validator for file names. |
| 32 static bool ValidateFilename(const string& value, bool write) { | 30 static bool ValidateFilename(const std::string& value, bool write) { |
| 33 FILE* fid = write ? fopen(value.c_str(), "wb") : fopen(value.c_str(), "rb"); | 31 FILE* fid = write ? fopen(value.c_str(), "wb") : fopen(value.c_str(), "rb"); |
| 34 if (fid == nullptr) | 32 if (fid == nullptr) |
| 35 return false; | 33 return false; |
| 36 fclose(fid); | 34 fclose(fid); |
| 37 return true; | 35 return true; |
| 38 } | 36 } |
| 39 | 37 |
| 40 // Define switch for input file name. | 38 // Define switch for input file name. |
| 41 static bool ValidateInFilename(const char* flagname, const string& value) { | 39 static bool ValidateInFilename(const char* flagname, const std::string& value) { |
| 42 if (!ValidateFilename(value, false)) { | 40 if (!ValidateFilename(value, false)) { |
| 43 printf("Invalid input filename."); | 41 printf("Invalid input filename."); |
| 44 return false; | 42 return false; |
| 45 } | 43 } |
| 46 return true; | 44 return true; |
| 47 } | 45 } |
| 48 | 46 |
| 49 DEFINE_string( | 47 DEFINE_string( |
| 50 in_filename, | 48 in_filename, |
| 51 ResourcePath("audio_coding/speech_mono_16kHz", "pcm"), | 49 ResourcePath("audio_coding/speech_mono_16kHz", "pcm"), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 75 printf("Invalid number of channels, current support only 1."); | 73 printf("Invalid number of channels, current support only 1."); |
| 76 return false; | 74 return false; |
| 77 } | 75 } |
| 78 | 76 |
| 79 DEFINE_int32(channels, 1, "Number of channels in input audio."); | 77 DEFINE_int32(channels, 1, "Number of channels in input audio."); |
| 80 | 78 |
| 81 static const bool channels_dummy = | 79 static const bool channels_dummy = |
| 82 RegisterFlagValidator(&FLAGS_channels, &ValidateChannels); | 80 RegisterFlagValidator(&FLAGS_channels, &ValidateChannels); |
| 83 | 81 |
| 84 // Define switch for output file name. | 82 // Define switch for output file name. |
| 85 static bool ValidateOutFilename(const char* flagname, const string& value) { | 83 static bool ValidateOutFilename(const char* flagname, |
| 84 const std::string& value) { |
| 86 if (!ValidateFilename(value, true)) { | 85 if (!ValidateFilename(value, true)) { |
| 87 printf("Invalid output filename."); | 86 printf("Invalid output filename."); |
| 88 return false; | 87 return false; |
| 89 } | 88 } |
| 90 return true; | 89 return true; |
| 91 } | 90 } |
| 92 | 91 |
| 93 DEFINE_string(out_filename, | 92 DEFINE_string(out_filename, |
| 94 OutputPath() + "neteq_quality_test_out.pcm", | 93 OutputPath() + "neteq_quality_test_out.pcm", |
| 95 "Name of output audio file."); | 94 "Name of output audio file."); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 } | 431 } |
| 433 } | 432 } |
| 434 Log() << "Average bit rate was " | 433 Log() << "Average bit rate was " |
| 435 << 8.0f * total_payload_size_bytes_ / FLAGS_runtime_ms | 434 << 8.0f * total_payload_size_bytes_ / FLAGS_runtime_ms |
| 436 << " kbps" | 435 << " kbps" |
| 437 << std::endl; | 436 << std::endl; |
| 438 } | 437 } |
| 439 | 438 |
| 440 } // namespace test | 439 } // namespace test |
| 441 } // namespace webrtc | 440 } // namespace webrtc |
| OLD | NEW |