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" |
11 #include "media/base/audio_codecs.h" | 11 #include "media/base/audio_codecs.h" |
12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 #include "media/ffmpeg/ffmpeg_deleters.h" |
13 #include "media/filters/ffmpeg_glue.h" | 14 #include "media/filters/ffmpeg_glue.h" |
14 | 15 |
15 struct AVCodecContext; | 16 struct AVCodecContext; |
16 struct AVPacket; | 17 struct AVPacket; |
17 struct AVStream; | 18 struct AVStream; |
18 | 19 |
19 namespace base { class TimeDelta; } | 20 namespace base { class TimeDelta; } |
20 | 21 |
21 namespace media { | 22 namespace media { |
22 | 23 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // Returns true if a packet could be demuxed from the first audio stream in | 69 // Returns true if a packet could be demuxed from the first audio stream in |
69 // the file, |output_packet| will contain the demuxed packet then. | 70 // the file, |output_packet| will contain the demuxed packet then. |
70 bool ReadPacketForTesting(AVPacket* output_packet); | 71 bool ReadPacketForTesting(AVPacket* output_packet); |
71 | 72 |
72 // Seeks to the given point and returns true if successful. |seek_time| will | 73 // Seeks to the given point and returns true if successful. |seek_time| will |
73 // be converted to the stream's time base automatically. | 74 // be converted to the stream's time base automatically. |
74 bool SeekForTesting(base::TimeDelta seek_time); | 75 bool SeekForTesting(base::TimeDelta seek_time); |
75 | 76 |
76 const AVStream* GetAVStreamForTesting() const; | 77 const AVStream* GetAVStreamForTesting() const; |
77 const AVCodecContext* codec_context_for_testing() const { | 78 const AVCodecContext* codec_context_for_testing() const { |
78 return codec_context_; | 79 return codec_context_.get(); |
79 } | 80 } |
80 | 81 |
81 private: | 82 private: |
82 bool OpenDemuxer(); | 83 bool OpenDemuxer(); |
83 bool OpenDecoder(); | 84 bool OpenDecoder(); |
84 bool ReadPacket(AVPacket* output_packet); | 85 bool ReadPacket(AVPacket* output_packet); |
85 | 86 |
| 87 // Destruct |glue_| after |codec_context_|. |
86 std::unique_ptr<FFmpegGlue> glue_; | 88 std::unique_ptr<FFmpegGlue> glue_; |
87 AVCodecContext* codec_context_; | 89 std::unique_ptr<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; |
| 90 |
88 int stream_index_; | 91 int stream_index_; |
89 FFmpegURLProtocol* protocol_; | 92 FFmpegURLProtocol* protocol_; |
90 AudioCodec audio_codec_; | 93 AudioCodec audio_codec_; |
91 int channels_; | 94 int channels_; |
92 int sample_rate_; | 95 int sample_rate_; |
93 | 96 |
94 // AVSampleFormat initially requested; not Chrome's SampleFormat. | 97 // AVSampleFormat initially requested; not Chrome's SampleFormat. |
95 int av_sample_format_; | 98 int av_sample_format_; |
96 | 99 |
97 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); | 100 DISALLOW_COPY_AND_ASSIGN(AudioFileReader); |
98 }; | 101 }; |
99 | 102 |
100 } // namespace media | 103 } // namespace media |
101 | 104 |
102 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ | 105 #endif // MEDIA_FILTERS_AUDIO_FILE_READER_H_ |
OLD | NEW |