Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Side by Side Diff: media/audio/sounds/wav_parser.h

Issue 115693004: Added volume adjust sound behind the flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_PARSER_H_
6 #define MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_ 6 #define MEDIA_AUDIO_SOUNDS_WAV_PARSER_H_
7 7
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/time/time.h"
9 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
10 11
11 namespace media { 12 namespace media {
12 13
13 class AudioBus;
14
15 // This class provides the input from wav file format. See 14 // This class provides the input from wav file format. See
16 // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ 15 // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
17 class MEDIA_EXPORT WavAudioHandler { 16 class MEDIA_EXPORT WavParser {
18 public: 17 public:
19 explicit WavAudioHandler(const base::StringPiece& wav_data); 18 explicit WavParser(const base::StringPiece& wav_data);
20 virtual ~WavAudioHandler(); 19 virtual ~WavParser();
21 20
22 // Returns true when cursor points to the end of the track.
23 bool AtEnd(size_t cursor) const;
24
25 // Copies the audio data to |bus| starting from the |cursor| and in
26 // the case of success stores the number of written bytes in
27 // |bytes_written|. |bytes_written| should not be NULL.
28 bool CopyTo(AudioBus* bus, size_t cursor, size_t* bytes_written) const;
29
30 int size() const { return data_.size(); }
31 uint16 num_channels() const { return num_channels_; } 21 uint16 num_channels() const { return num_channels_; }
DaleCurtis 2013/12/17 19:28:52 At this point it'd just be easier to expose an aud
ygorshenin1 2013/12/18 14:33:12 Done.
32 uint32 sample_rate() const { return sample_rate_; } 22 uint32 sample_rate() const { return sample_rate_; }
33 uint32 byte_rate() const { return byte_rate_; } 23 uint32 byte_rate() const { return byte_rate_; }
34 uint16 bits_per_sample() const { return bits_per_sample_; } 24 uint16 bits_per_sample() const { return bits_per_sample_; }
25 int bytes_per_sample() const { return bytes_per_sample_; }
26 int bytes_per_frame() const { return bytes_per_frame_; }
27 const base::TimeDelta& duration() const { return duration_; }
28 const base::StringPiece& data() const { return data_; }
35 29
36 private: 30 private:
37 // Parses a chunk of wav format data. Returns the length of the chunk. 31 // Parses a chunk of wav format data. Returns the length of the chunk.
38 int ParseSubChunk(const base::StringPiece& data); 32 int ParseSubChunk(const base::StringPiece& data);
39 33
40 // Parses the 'fmt' section chunk and stores |params_|. 34 // Parses the 'fmt' section chunk and stores |params_|.
41 bool ParseFmtChunk(const base::StringPiece& data); 35 bool ParseFmtChunk(const base::StringPiece& data);
42 36
43 // Parses the 'data' section chunk and stores |data_|. 37 // Parses the 'data' section chunk and stores |data_|.
44 bool ParseDataChunk(const base::StringPiece& data); 38 bool ParseDataChunk(const base::StringPiece& data);
45 39
46 // Data part of the |wav_data_|. 40 // Data part of the |wav_data_|.
47 base::StringPiece data_; 41 base::StringPiece data_;
48 42
49 uint16 num_channels_; 43 uint16 num_channels_;
50 uint32 sample_rate_; 44 uint32 sample_rate_;
51 uint32 byte_rate_; 45 uint32 byte_rate_;
52 uint16 bits_per_sample_; 46 uint16 bits_per_sample_;
53 int bytes_per_sample_; 47 int bytes_per_sample_;
54 int bytes_per_frame_; 48 int bytes_per_frame_;
49 base::TimeDelta duration_;
55 }; 50 };
56 51
57 } // namespace media 52 } // namespace media
58 53
59 #endif // MEDIA_AUDIO_SOUNDS_WAV_AUDIO_HANDLER_H_ 54 #endif // MEDIA_AUDIO_SOUNDS_WAV_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698