| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_CAST_TEST_UTILITY_AUDIO_UTILITY_H_ | 5 #ifndef MEDIA_CAST_TEST_UTILITY_AUDIO_UTILITY_H_ |
| 6 #define MEDIA_CAST_TEST_UTILITY_AUDIO_UTILITY_H_ | 6 #define MEDIA_CAST_TEST_UTILITY_AUDIO_UTILITY_H_ |
| 7 | 7 |
| 8 #include "media/audio/simple_sources.h" | 8 #include "media/audio/simple_sources.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Convenience function to convert an |audio_bus| to its equivalent | 49 // Convenience function to convert an |audio_bus| to its equivalent |
| 50 // PcmAudioFrame. | 50 // PcmAudioFrame. |
| 51 // TODO(miu): Remove this once all code has migrated to use AudioBus. See | 51 // TODO(miu): Remove this once all code has migrated to use AudioBus. See |
| 52 // comment in media/cast/cast_config.h. | 52 // comment in media/cast/cast_config.h. |
| 53 scoped_ptr<PcmAudioFrame> ToPcmAudioFrame(const AudioBus& audio_bus, | 53 scoped_ptr<PcmAudioFrame> ToPcmAudioFrame(const AudioBus& audio_bus, |
| 54 int sample_rate); | 54 int sample_rate); |
| 55 | 55 |
| 56 // Assuming |samples| contains a single-frequency sine wave (and maybe some | 56 // Assuming |samples| contains a single-frequency sine wave (and maybe some |
| 57 // low-amplitude noise), count the number of times the sine wave crosses | 57 // low-amplitude noise), count the number of times the sine wave crosses |
| 58 // zero. | 58 // zero. |
| 59 int CountZeroCrossings(const float* samples, int len); |
| 60 // DEPRECATED: |
| 59 int CountZeroCrossings(const std::vector<int16>& samples); | 61 int CountZeroCrossings(const std::vector<int16>& samples); |
| 60 | 62 |
| 61 // Encode |timestamp| into the samples pointed to by 'samples' in a way | 63 // Encode |timestamp| into the samples pointed to by 'samples' in a way |
| 62 // that should be decodable even after compressing/decompressing the audio. | 64 // that should be decodable even after compressing/decompressing the audio. |
| 63 // Assumes 48Khz sampling rate and needs at least 240 samples. Returns | 65 // Assumes 48Khz sampling rate and needs at least 240 samples. Returns |
| 64 // false if |samples| is too small. If more than 240 samples are available, | 66 // false if |samples| is too small. If more than 240 samples are available, |
| 65 // then the timestamp will be repeated. |sample_offset| should contain how | 67 // then the timestamp will be repeated. |sample_offset| should contain how |
| 66 // many samples has been encoded so far, so that we can make smooth | 68 // many samples has been encoded so far, so that we can make smooth |
| 67 // transitions between encoded chunks. | 69 // transitions between encoded chunks. |
| 68 // See audio_utility.cc for details on how the encoding is done. | 70 // See audio_utility.cc for details on how the encoding is done. |
| 69 bool EncodeTimestamp(uint16 timestamp, | 71 bool EncodeTimestamp(uint16 timestamp, |
| 70 size_t sample_offset, | 72 size_t sample_offset, |
| 71 std::vector<int16>* samples); | 73 std::vector<int16>* samples); |
| 72 | 74 |
| 73 // Decode a timestamp encoded with EncodeTimestamp. Returns true if a | 75 // Decode a timestamp encoded with EncodeTimestamp. Returns true if a |
| 74 // timestamp was found in |samples|. | 76 // timestamp was found in |samples|. |
| 75 bool DecodeTimestamp(const std::vector<int16>& samples, uint16* timestamp); | 77 bool DecodeTimestamp(const std::vector<int16>& samples, uint16* timestamp); |
| 76 | 78 |
| 77 } // namespace cast | 79 } // namespace cast |
| 78 } // namespace media | 80 } // namespace media |
| 79 | 81 |
| 80 #endif // MEDIA_CAST_TEST_UTILITY_AUDIO_UTILITY_H_ | 82 #endif // MEDIA_CAST_TEST_UTILITY_AUDIO_UTILITY_H_ |
| OLD | NEW |