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" |
11 | 11 |
12 struct AVCodecContext; | 12 struct AVCodecContext; |
| 13 struct AVPacket; |
13 | 14 |
14 namespace base { class TimeDelta; } | 15 namespace base { class TimeDelta; } |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 | 18 |
18 class AudioBus; | 19 class AudioBus; |
19 class FFmpegGlue; | 20 class FFmpegGlue; |
20 class FFmpegURLProtocol; | 21 class FFmpegURLProtocol; |
21 | 22 |
22 class MEDIA_EXPORT AudioFileReader { | 23 class MEDIA_EXPORT AudioFileReader { |
(...skipping 24 matching lines...) Expand all Loading... |
47 int sample_rate() const { return sample_rate_; } | 48 int sample_rate() const { return sample_rate_; } |
48 | 49 |
49 // Please note that GetDuration() and GetNumberOfFrames() attempt to be | 50 // Please note that GetDuration() and GetNumberOfFrames() attempt to be |
50 // accurate, but are only estimates. For some encoded formats, the actual | 51 // accurate, but are only estimates. For some encoded formats, the actual |
51 // duration of the file can only be determined once all the file data has been | 52 // duration of the file can only be determined once all the file data has been |
52 // read. The Read() method returns the actual number of sample-frames it has | 53 // read. The Read() method returns the actual number of sample-frames it has |
53 // read. | 54 // read. |
54 base::TimeDelta GetDuration() const; | 55 base::TimeDelta GetDuration() const; |
55 int GetNumberOfFrames() const; | 56 int GetNumberOfFrames() const; |
56 | 57 |
| 58 // Helper methods which allows AudioFileReader to double as a test utility for |
| 59 // demuxing audio files. Returns true if a packet could be demuxed from the |
| 60 // first audio stream in the file, |output_packet| will contain the demuxed |
| 61 // packet then. |
| 62 bool ReadPacketForTesting(AVPacket* output_packet); |
| 63 |
| 64 const AVCodecContext* codec_context_for_testing() const { |
| 65 return codec_context_; |
| 66 } |
| 67 |
57 private: | 68 private: |
| 69 bool ReadPacket(AVPacket* output_packet); |
| 70 |
58 scoped_ptr<FFmpegGlue> glue_; | 71 scoped_ptr<FFmpegGlue> glue_; |
59 AVCodecContext* codec_context_; | 72 AVCodecContext* codec_context_; |
60 int stream_index_; | 73 int stream_index_; |
61 FFmpegURLProtocol* protocol_; | 74 FFmpegURLProtocol* protocol_; |
62 int channels_; | 75 int channels_; |
63 int sample_rate_; | 76 int sample_rate_; |
64 | 77 |
65 // AVSampleFormat initially requested; not Chrome's SampleFormat. | 78 // AVSampleFormat initially requested; not Chrome's SampleFormat. |
66 int av_sample_format_; | 79 int av_sample_format_; |
67 | 80 |
68 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); | 81 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); |
69 }; | 82 }; |
70 | 83 |
71 } // namespace media | 84 } // namespace media |
72 | 85 |
73 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ | 86 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ |
OLD | NEW |