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