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

Side by Side Diff: media/filters/audio_file_reader.h

Issue 10871051: Convert WebAudio file handlers to use AudioBus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 8 years, 3 months 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_FILTERS_AUDIO_FILE_READER_H_ 5 #ifndef MEDIA_FILTERS_AUDIO_FILE_READER_H_
6 #define MEDIA_FILTERS_AUDIO_FILE_READER_H_ 6 #define MEDIA_FILTERS_AUDIO_FILE_READER_H_
7 7
8 #include <vector> 8 #include <vector>
9 #include "media/filters/ffmpeg_glue.h" 9 #include "media/filters/ffmpeg_glue.h"
10 10
11 struct AVCodec;
12 struct AVCodecContext; 11 struct AVCodecContext;
13 struct AVFormatContext; 12 struct AVFormatContext;
14 13
15 namespace base { class TimeDelta; } 14 namespace base { class TimeDelta; }
16 15
17 namespace media { 16 namespace media {
18 17
18 class AudioBus;
19 class FFmpegURLProtocol; 19 class FFmpegURLProtocol;
20 20
21 class MEDIA_EXPORT AudioFileReader { 21 class MEDIA_EXPORT AudioFileReader {
22 public: 22 public:
23 // Audio file data will be read using the given protocol. 23 // Audio file data will be read using the given protocol.
24 // The AudioFileReader does not take ownership of |protocol| and 24 // The AudioFileReader does not take ownership of |protocol| and
25 // simply maintains a weak reference to it. 25 // simply maintains a weak reference to it.
26 explicit AudioFileReader(FFmpegURLProtocol* protocol); 26 explicit AudioFileReader(FFmpegURLProtocol* protocol);
27 virtual ~AudioFileReader(); 27 virtual ~AudioFileReader();
28 28
29 // Open() reads the audio data format so that the sample_rate(), 29 // Open() reads the audio data format so that the sample_rate(),
30 // channels(), duration(), and number_of_frames() methods can be called. 30 // channels(), duration(), and number_of_frames() methods can be called.
31 // It returns |true| on success. 31 // It returns |true| on success.
32 bool Open(); 32 bool Open();
33 void Close(); 33 void Close();
34 34
35 // After a call to Open(), reads |number_of_frames| into |audio_data|. 35 // After a call to Open(), reads |number_of_frames| into |audio_data|.
36 // |audio_data| must be of the same size as channels(). 36 // |audio_data| must be of the same size as channels().
Chris Rogers 2012/08/24 20:49:28 Please update comment
DaleCurtis 2012/08/24 22:23:22 Done.
37 // The audio data will be decoded as floating-point linear PCM with 37 // The audio data will be decoded as floating-point linear PCM with
38 // a nominal range of -1.0 -> +1.0. 38 // a nominal range of -1.0 -> +1.0.
39 // Returns |true| on success. 39 // Returns |true| on success.
40 bool Read(const std::vector<float*>& audio_data, size_t number_of_frames); 40 bool Read(AudioBus* audio_bus);
41 41
42 // These methods can be called once Open() has been called. 42 // These methods can be called once Open() has been called.
43 int channels() const; 43 int channels() const;
44 int sample_rate() const; 44 int sample_rate() const;
45 base::TimeDelta duration() const; 45 base::TimeDelta duration() const;
46 int64 number_of_frames() const; 46 int64 number_of_frames() const;
47 47
48 private: 48 private:
49 FFmpegURLProtocol* protocol_; 49 FFmpegURLProtocol* protocol_;
50 AVFormatContext* format_context_; 50 AVFormatContext* format_context_;
51 AVCodecContext* codec_context_; 51 AVCodecContext* codec_context_;
52 AVCodec* codec_;
53 52
54 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); 53 DISALLOW_COPY_AND_ASSIGN(AudioFileReader);
55 }; 54 };
56 55
57 } // namespace media 56 } // namespace media
58 57
59 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ 58 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698