| 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 #include "media/filters/ffmpeg_glue.h" |
| 11 | 12 |
| 12 struct AVCodecContext; | 13 struct AVCodecContext; |
| 13 struct AVPacket; | 14 struct AVPacket; |
| 15 struct AVStream; |
| 14 | 16 |
| 15 namespace base { class TimeDelta; } | 17 namespace base { class TimeDelta; } |
| 16 | 18 |
| 17 namespace media { | 19 namespace media { |
| 18 | 20 |
| 19 class AudioBus; | 21 class AudioBus; |
| 20 class FFmpegGlue; | |
| 21 class FFmpegURLProtocol; | 22 class FFmpegURLProtocol; |
| 22 | 23 |
| 23 class MEDIA_EXPORT AudioFileReader { | 24 class MEDIA_EXPORT AudioFileReader { |
| 24 public: | 25 public: |
| 25 // Audio file data will be read using the given protocol. | 26 // Audio file data will be read using the given protocol. |
| 26 // The AudioFileReader does not take ownership of |protocol| and | 27 // The AudioFileReader does not take ownership of |protocol| and |
| 27 // simply maintains a weak reference to it. | 28 // simply maintains a weak reference to it. |
| 28 explicit AudioFileReader(FFmpegURLProtocol* protocol); | 29 explicit AudioFileReader(FFmpegURLProtocol* protocol); |
| 29 virtual ~AudioFileReader(); | 30 virtual ~AudioFileReader(); |
| 30 | 31 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 48 int sample_rate() const { return sample_rate_; } | 49 int sample_rate() const { return sample_rate_; } |
| 49 | 50 |
| 50 // Please note that GetDuration() and GetNumberOfFrames() attempt to be | 51 // Please note that GetDuration() and GetNumberOfFrames() attempt to be |
| 51 // accurate, but are only estimates. For some encoded formats, the actual | 52 // accurate, but are only estimates. For some encoded formats, the actual |
| 52 // duration of the file can only be determined once all the file data has been | 53 // duration of the file can only be determined once all the file data has been |
| 53 // read. The Read() method returns the actual number of sample-frames it has | 54 // read. The Read() method returns the actual number of sample-frames it has |
| 54 // read. | 55 // read. |
| 55 base::TimeDelta GetDuration() const; | 56 base::TimeDelta GetDuration() const; |
| 56 int GetNumberOfFrames() const; | 57 int GetNumberOfFrames() const; |
| 57 | 58 |
| 58 // Helper methods which allows AudioFileReader to double as a test utility for | 59 // The methods below are helper methods which allow AudioFileReader to double |
| 59 // demuxing audio files. Returns true if a packet could be demuxed from the | 60 // as a test utility for demuxing audio files. |
| 60 // first audio stream in the file, |output_packet| will contain the demuxed | 61 // -------------------------------------------------------------------------- |
| 61 // packet then. | 62 |
| 63 // Similar to Open() but does not initialize the decoder. |
| 64 bool OpenDemuxerForTesting(); |
| 65 |
| 66 // Returns true if a packet could be demuxed from the first audio stream in |
| 67 // the file, |output_packet| will contain the demuxed packet then. |
| 62 bool ReadPacketForTesting(AVPacket* output_packet); | 68 bool ReadPacketForTesting(AVPacket* output_packet); |
| 63 | 69 |
| 70 // Seeks to the given point and returns true if successful. |seek_time| will |
| 71 // be converted to the stream's time base automatically. |
| 72 bool SeekForTesting(base::TimeDelta seek_time); |
| 73 |
| 74 const AVStream* GetAVStreamForTesting() const; |
| 64 const AVCodecContext* codec_context_for_testing() const { | 75 const AVCodecContext* codec_context_for_testing() const { |
| 65 return codec_context_; | 76 return codec_context_; |
| 66 } | 77 } |
| 67 | 78 |
| 68 private: | 79 private: |
| 80 bool OpenDemuxer(); |
| 81 bool OpenDecoder(); |
| 69 bool ReadPacket(AVPacket* output_packet); | 82 bool ReadPacket(AVPacket* output_packet); |
| 70 | 83 |
| 71 scoped_ptr<FFmpegGlue> glue_; | 84 scoped_ptr<FFmpegGlue> glue_; |
| 72 AVCodecContext* codec_context_; | 85 AVCodecContext* codec_context_; |
| 73 int stream_index_; | 86 int stream_index_; |
| 74 FFmpegURLProtocol* protocol_; | 87 FFmpegURLProtocol* protocol_; |
| 75 int channels_; | 88 int channels_; |
| 76 int sample_rate_; | 89 int sample_rate_; |
| 77 | 90 |
| 78 // AVSampleFormat initially requested; not Chrome's SampleFormat. | 91 // AVSampleFormat initially requested; not Chrome's SampleFormat. |
| 79 int av_sample_format_; | 92 int av_sample_format_; |
| 80 | 93 |
| 81 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); | 94 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); |
| 82 }; | 95 }; |
| 83 | 96 |
| 84 } // namespace media | 97 } // namespace media |
| 85 | 98 |
| 86 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ | 99 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ |
| OLD | NEW |