Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: media/filters/audio_file_reader.h

Issue 311373004: Consolidate and improve audio decoding test for all decoders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. DEPS roll. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
14 struct AVDictionary;
13 struct AVPacket; 15 struct AVPacket;
16 struct AVStream;
14 17
15 namespace base { class TimeDelta; } 18 namespace base { class TimeDelta; }
16 19
17 namespace media { 20 namespace media {
18 21
19 class AudioBus; 22 class AudioBus;
20 class FFmpegGlue;
21 class FFmpegURLProtocol; 23 class FFmpegURLProtocol;
22 24
23 class MEDIA_EXPORT AudioFileReader { 25 class MEDIA_EXPORT AudioFileReader {
24 public: 26 public:
25 // Audio file data will be read using the given protocol. 27 // Audio file data will be read using the given protocol.
26 // The AudioFileReader does not take ownership of |protocol| and 28 // The AudioFileReader does not take ownership of |protocol| and
27 // simply maintains a weak reference to it. 29 // simply maintains a weak reference to it.
28 explicit AudioFileReader(FFmpegURLProtocol* protocol); 30 explicit AudioFileReader(FFmpegURLProtocol* protocol);
29 virtual ~AudioFileReader(); 31 virtual ~AudioFileReader();
30 32
(...skipping 17 matching lines...) Expand all
48 int sample_rate() const { return sample_rate_; } 50 int sample_rate() const { return sample_rate_; }
49 51
50 // Please note that GetDuration() and GetNumberOfFrames() attempt to be 52 // Please note that GetDuration() and GetNumberOfFrames() attempt to be
51 // accurate, but are only estimates. For some encoded formats, the actual 53 // 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 54 // 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 55 // read. The Read() method returns the actual number of sample-frames it has
54 // read. 56 // read.
55 base::TimeDelta GetDuration() const; 57 base::TimeDelta GetDuration() const;
56 int GetNumberOfFrames() const; 58 int GetNumberOfFrames() const;
57 59
58 // Helper methods which allows AudioFileReader to double as a test utility for 60 // 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 61 // as a test utility for demuxing audio files.
60 // first audio stream in the file, |output_packet| will contain the demuxed 62 // --------------------------------------------------------------------------
61 // packet then. 63
64 // Returns true if a packet could be demuxed from the first audio stream in
65 // the file, |output_packet| will contain the demuxed packet then.
62 bool ReadPacketForTesting(AVPacket* output_packet); 66 bool ReadPacketForTesting(AVPacket* output_packet);
63 67
68 // Seeks to the given point and returns true if successful. |seek_time| will
69 // be converted to the stream's time base automatically.
70 bool SeekForTesting(base::TimeDelta seek_time);
71
64 const AVCodecContext* codec_context_for_testing() const { 72 const AVCodecContext* codec_context_for_testing() const {
65 return codec_context_; 73 return codec_context_;
66 } 74 }
67 75
76 const AVFormatContext* format_context_for_testing() const {
77 return glue_->format_context();
78 }
79
80 // The stream index of the first audio stream; see AVFormatContext.streams[].
81 const int stream_index_for_testing() const {
82 return stream_index_;
83 }
84
68 private: 85 private:
69 bool ReadPacket(AVPacket* output_packet); 86 bool ReadPacket(AVPacket* output_packet);
70 87
71 scoped_ptr<FFmpegGlue> glue_; 88 scoped_ptr<FFmpegGlue> glue_;
72 AVCodecContext* codec_context_; 89 AVCodecContext* codec_context_;
73 int stream_index_; 90 int stream_index_;
74 FFmpegURLProtocol* protocol_; 91 FFmpegURLProtocol* protocol_;
75 int channels_; 92 int channels_;
76 int sample_rate_; 93 int sample_rate_;
77 94
78 // AVSampleFormat initially requested; not Chrome's SampleFormat. 95 // AVSampleFormat initially requested; not Chrome's SampleFormat.
79 int av_sample_format_; 96 int av_sample_format_;
80 97
81 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); 98 DISALLOW_COPY_AND_ASSIGN(AudioFileReader);
82 }; 99 };
83 100
84 } // namespace media 101 } // namespace media
85 102
86 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ 103 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698