Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / media / audio / sounds / wav_audio_handler.h
blob82b5cc5f842d53553d922a9c5609d7a9ba65e775
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_
6 #define MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_
8 #include "base/strings/string_piece.h"
9 #include "base/time/time.h"
10 #include "media/audio/audio_parameters.h"
11 #include "media/base/media_export.h"
13 namespace media {
15 class AudioBus;
17 // This class provides the input from wav file format. See
18 // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
19 class MEDIA_EXPORT WavAudioHandler {
20 public:
21 explicit WavAudioHandler(const base::StringPiece& wav_data);
22 virtual ~WavAudioHandler();
24 // Returns true when cursor points to the end of the track.
25 bool AtEnd(size_t cursor) const;
27 // Copies the audio data to |bus| starting from the |cursor| and in
28 // the case of success stores the number of written bytes in
29 // |bytes_written|. |bytes_written| should not be NULL.
30 bool CopyTo(AudioBus* bus, size_t cursor, size_t* bytes_written) const;
32 const AudioParameters& params() const { return params_; }
33 const base::StringPiece& data() const { return data_; }
35 private:
36 // Parses a chunk of wav format data. Returns the length of the chunk.
37 int ParseSubChunk(const base::StringPiece& data);
39 // Parses the 'fmt' section chunk and stores |params_|.
40 bool ParseFmtChunk(const base::StringPiece& data);
42 // Parses the 'data' section chunk and stores |data_|.
43 bool ParseDataChunk(const base::StringPiece& data);
45 // Data part of the |wav_data_|.
46 base::StringPiece data_;
48 AudioParameters params_;
50 uint16 num_channels_;
51 uint32 sample_rate_;
52 uint16 bits_per_sample_;
55 } // namespace media
57 #endif // MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_