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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // simply maintains a weak reference to it. | 31 // simply maintains a weak reference to it. |
32 explicit AudioFileReader(FFmpegURLProtocol* protocol); | 32 explicit AudioFileReader(FFmpegURLProtocol* protocol); |
33 virtual ~AudioFileReader(); | 33 virtual ~AudioFileReader(); |
34 | 34 |
35 // Open() reads the audio data format so that the sample_rate(), | 35 // Open() reads the audio data format so that the sample_rate(), |
36 // channels(), GetDuration(), and GetNumberOfFrames() methods can be called. | 36 // channels(), GetDuration(), and GetNumberOfFrames() methods can be called. |
37 // It returns |true| on success. | 37 // It returns |true| on success. |
38 bool Open(); | 38 bool Open(); |
39 void Close(); | 39 void Close(); |
40 | 40 |
| 41 // Returns true if (an estimated) duration of the audio data is |
| 42 // known. Must be called after Open(); |
| 43 bool HasKnownDuration() const; |
| 44 |
41 // After a call to Open(), attempts to fully fill |audio_bus| with decoded | 45 // After a call to Open(), attempts to fully fill |audio_bus| with decoded |
42 // audio data. Any unfilled frames will be zeroed out. | 46 // audio data. Any unfilled frames will be zeroed out. |
43 // |audio_data| must be of the same size as channels(). | 47 // |audio_data| must be of the same size as channels(). |
44 // The audio data will be decoded as floating-point linear PCM with | 48 // The audio data will be decoded as floating-point linear PCM with |
45 // a nominal range of -1.0 -> +1.0. | 49 // a nominal range of -1.0 -> +1.0. |
46 // Returns the number of sample-frames actually read which will always be | 50 // Returns the number of sample-frames actually read which will always be |
47 // <= audio_bus->frames() | 51 // <= audio_bus->frames() |
48 int Read(AudioBus* audio_bus); | 52 int Read(AudioBus* audio_bus); |
49 | 53 |
| 54 std::unique_ptr<AudioBus> StreamingRead(); |
| 55 |
50 // These methods can be called once Open() has been called. | 56 // These methods can be called once Open() has been called. |
51 int channels() const { return channels_; } | 57 int channels() const { return channels_; } |
52 int sample_rate() const { return sample_rate_; } | 58 int sample_rate() const { return sample_rate_; } |
53 | 59 |
54 // Please note that GetDuration() and GetNumberOfFrames() attempt to be | 60 // Please note that GetDuration() and GetNumberOfFrames() attempt to be |
55 // accurate, but are only estimates. For some encoded formats, the actual | 61 // accurate, but are only estimates. For some encoded formats, the actual |
56 // duration of the file can only be determined once all the file data has been | 62 // duration of the file can only be determined once all the file data has been |
57 // read. The Read() method returns the actual number of sample-frames it has | 63 // read. The Read() method returns the actual number of sample-frames it has |
58 // read. | 64 // read. |
59 base::TimeDelta GetDuration() const; | 65 base::TimeDelta GetDuration() const; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 102 |
97 // AVSampleFormat initially requested; not Chrome's SampleFormat. | 103 // AVSampleFormat initially requested; not Chrome's SampleFormat. |
98 int av_sample_format_; | 104 int av_sample_format_; |
99 | 105 |
100 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); | 106 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); |
101 }; | 107 }; |
102 | 108 |
103 } // namespace media | 109 } // namespace media |
104 | 110 |
105 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ | 111 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ |
OLD | NEW |