OLD | NEW |
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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class MEDIA_EXPORT AudioFileReader { | 22 class MEDIA_EXPORT AudioFileReader { |
23 public: | 23 public: |
24 // Audio file data will be read using the given protocol. | 24 // Audio file data will be read using the given protocol. |
25 // The AudioFileReader does not take ownership of |protocol| and | 25 // The AudioFileReader does not take ownership of |protocol| and |
26 // simply maintains a weak reference to it. | 26 // simply maintains a weak reference to it. |
27 explicit AudioFileReader(FFmpegURLProtocol* protocol); | 27 explicit AudioFileReader(FFmpegURLProtocol* protocol); |
28 virtual ~AudioFileReader(); | 28 virtual ~AudioFileReader(); |
29 | 29 |
30 // Open() reads the audio data format so that the sample_rate(), | 30 // Open() reads the audio data format so that the sample_rate(), |
31 // channels(), duration(), and number_of_frames() methods can be called. | 31 // channels(), GetDuration(), and GetNumberOfFrames() methods can be called. |
32 // It returns |true| on success. | 32 // It returns |true| on success. |
33 bool Open(); | 33 bool Open(); |
34 void Close(); | 34 void Close(); |
35 | 35 |
36 // After a call to Open(), attempts to fully fill |audio_bus| with decoded | 36 // After a call to Open(), attempts to fully fill |audio_bus| with decoded |
37 // audio data. Any unfilled frames will be zeroed out. | 37 // audio data. Any unfilled frames will be zeroed out. |
38 // |audio_data| must be of the same size as channels(). | 38 // |audio_data| must be of the same size as channels(). |
39 // The audio data will be decoded as floating-point linear PCM with | 39 // The audio data will be decoded as floating-point linear PCM with |
40 // a nominal range of -1.0 -> +1.0. | 40 // a nominal range of -1.0 -> +1.0. |
41 // Returns the number of sample-frames actually read which will always be | 41 // Returns the number of sample-frames actually read which will always be |
42 // <= audio_bus->frames() | 42 // <= audio_bus->frames() |
43 int Read(AudioBus* audio_bus); | 43 int Read(AudioBus* audio_bus); |
44 | 44 |
45 // These methods can be called once Open() has been called. | 45 // These methods can be called once Open() has been called. |
46 int channels() const { return channels_; } | 46 int channels() const { return channels_; } |
47 int sample_rate() const { return sample_rate_; } | 47 int sample_rate() const { return sample_rate_; } |
48 | 48 |
49 // Please note that duration() and number_of_frames() attempt to be accurate, | 49 // Please note that GetDuration() and GetNumberOfFrames() attempt to be |
50 // but are only estimates. For some encoded formats, the actual duration | 50 // accurate, but are only estimates. For some encoded formats, the actual |
51 // of the file can only be determined once all the file data has been read. | 51 // duration of the file can only be determined once all the file data has been |
52 // The Read() method returns the actual number of sample-frames it has read. | 52 // read. The Read() method returns the actual number of sample-frames it has |
53 base::TimeDelta duration() const; | 53 // read. |
54 int64 number_of_frames() const; | 54 base::TimeDelta GetDuration() const; |
| 55 int GetNumberOfFrames() const; |
55 | 56 |
56 private: | 57 private: |
57 scoped_ptr<FFmpegGlue> glue_; | 58 scoped_ptr<FFmpegGlue> glue_; |
58 AVCodecContext* codec_context_; | 59 AVCodecContext* codec_context_; |
59 int stream_index_; | 60 int stream_index_; |
60 FFmpegURLProtocol* protocol_; | 61 FFmpegURLProtocol* protocol_; |
61 int channels_; | 62 int channels_; |
62 int sample_rate_; | 63 int sample_rate_; |
63 | 64 |
64 // AVSampleFormat initially requested; not Chrome's SampleFormat. | 65 // AVSampleFormat initially requested; not Chrome's SampleFormat. |
65 int av_sample_format_; | 66 int av_sample_format_; |
66 | 67 |
67 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); | 68 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); |
68 }; | 69 }; |
69 | 70 |
70 } // namespace media | 71 } // namespace media |
71 | 72 |
72 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ | 73 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ |
OLD | NEW |