Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_ | 5 #ifndef MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_ |
| 6 #define MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_ | 6 #define MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "base/time/time.h" | |
| 10 #include "media/audio/audio_parameters.h" | |
| 9 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
| 10 | 12 |
| 11 namespace media { | 13 namespace media { |
| 12 | 14 |
| 13 class AudioBus; | 15 class AudioBus; |
| 14 | 16 |
| 15 // This class provides the input from wav file format. See | 17 // This class provides the input from wav file format. See |
| 16 // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ | 18 // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ |
| 17 class MEDIA_EXPORT WavAudioHandler { | 19 class MEDIA_EXPORT WavAudioHandler { |
| 18 public: | 20 public: |
| 19 explicit WavAudioHandler(const base::StringPiece& wav_data); | 21 explicit WavAudioHandler(const base::StringPiece& wav_data); |
| 20 virtual ~WavAudioHandler(); | 22 virtual ~WavAudioHandler(); |
| 21 | 23 |
| 22 // Returns true when cursor points to the end of the track. | 24 // Returns true when cursor points to the end of the track. |
| 23 bool AtEnd(size_t cursor) const; | 25 bool AtEnd(size_t cursor) const; |
| 24 | 26 |
| 25 // Copies the audio data to |bus| starting from the |cursor| and in | 27 // Copies the audio data to |bus| starting from the |cursor| and in |
| 26 // the case of success stores the number of written bytes in | 28 // the case of success stores the number of written bytes in |
| 27 // |bytes_written|. |bytes_written| should not be NULL. | 29 // |bytes_written|. |bytes_written| should not be NULL. |
| 28 bool CopyTo(AudioBus* bus, size_t cursor, size_t* bytes_written) const; | 30 bool CopyTo(AudioBus* bus, size_t cursor, size_t* bytes_written) const; |
| 29 | 31 |
| 30 int size() const { return data_.size(); } | 32 int GetByteRate() const; |
|
DaleCurtis
2013/12/18 21:20:21
Looks unused? Does this end up being different tha
ygorshenin1
2013/12/19 15:42:29
Done.
| |
| 31 uint16 num_channels() const { return num_channels_; } | 33 const AudioParameters& params() const { return params_; } |
| 32 uint32 sample_rate() const { return sample_rate_; } | 34 const base::TimeDelta& duration() const { return duration_; } |
|
DaleCurtis
2013/12/18 21:20:21
TimeDelta can be passed by value efficiently, so n
ygorshenin1
2013/12/19 15:42:29
Fixed to return by value now.
| |
| 33 uint32 byte_rate() const { return byte_rate_; } | 35 const base::StringPiece& data() const { return data_; } |
|
DaleCurtis
2013/12/18 21:20:21
I don't think this should be exposed. I don't see
ygorshenin1
2013/12/19 15:42:29
It's used once in wav_audio_handler_unittest.cc, f
| |
| 34 uint16 bits_per_sample() const { return bits_per_sample_; } | |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 // Parses a chunk of wav format data. Returns the length of the chunk. | 38 // Parses a chunk of wav format data. Returns the length of the chunk. |
| 38 int ParseSubChunk(const base::StringPiece& data); | 39 int ParseSubChunk(const base::StringPiece& data); |
| 39 | 40 |
| 40 // Parses the 'fmt' section chunk and stores |params_|. | 41 // Parses the 'fmt' section chunk and stores |params_|. |
| 41 bool ParseFmtChunk(const base::StringPiece& data); | 42 bool ParseFmtChunk(const base::StringPiece& data); |
| 42 | 43 |
| 43 // Parses the 'data' section chunk and stores |data_|. | 44 // Parses the 'data' section chunk and stores |data_|. |
| 44 bool ParseDataChunk(const base::StringPiece& data); | 45 bool ParseDataChunk(const base::StringPiece& data); |
| 45 | 46 |
| 46 // Data part of the |wav_data_|. | 47 // Data part of the |wav_data_|. |
| 47 base::StringPiece data_; | 48 base::StringPiece data_; |
| 48 | 49 |
| 49 uint16 num_channels_; | 50 base::TimeDelta duration_; |
| 50 uint32 sample_rate_; | 51 AudioParameters params_; |
| 51 uint32 byte_rate_; | |
| 52 uint16 bits_per_sample_; | |
| 53 int bytes_per_sample_; | |
| 54 int bytes_per_frame_; | |
| 55 }; | 52 }; |
| 56 | 53 |
| 57 } // namespace media | 54 } // namespace media |
| 58 | 55 |
| 59 #endif // MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_ | 56 #endif // MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_ |
| OLD | NEW |