| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Implements the Demuxer interface using FFmpeg's libavformat. At this time | 5 // Implements the Demuxer interface using FFmpeg's libavformat. At this time |
| 6 // will support demuxing any audio/video format thrown at it. The streams | 6 // will support demuxing any audio/video format thrown at it. The streams |
| 7 // output mime types audio/x-ffmpeg and video/x-ffmpeg and include an integer | 7 // output mime types audio/x-ffmpeg and video/x-ffmpeg and include an integer |
| 8 // key FFmpegCodecID which contains the CodecID enumeration value. The CodecIDs | 8 // key FFmpegCodecID which contains the CodecID enumeration value. The CodecIDs |
| 9 // can be used to create and initialize the corresponding FFmpeg decoder. | 9 // can be used to create and initialize the corresponding FFmpeg decoder. |
| 10 // | 10 // |
| 11 // FFmpegDemuxer sets the duration of pipeline during initialization by using | 11 // FFmpegDemuxer sets the duration of pipeline during initialization by using |
| 12 // the duration of the longest audio/video stream. | 12 // the duration of the longest audio/video stream. |
| 13 // | 13 // |
| 14 // NOTE: since FFmpegDemuxer reads packets sequentially without seeking, media | 14 // NOTE: since FFmpegDemuxer reads packets sequentially without seeking, media |
| 15 // files with very large drift between audio/video streams may result in | 15 // files with very large drift between audio/video streams may result in |
| 16 // excessive memory consumption. | 16 // excessive memory consumption. |
| 17 // | 17 // |
| 18 // When stopped, FFmpegDemuxer and FFmpegDemuxerStream release all callbacks | 18 // When stopped, FFmpegDemuxer and FFmpegDemuxerStream release all callbacks |
| 19 // and buffered packets. Reads from a stopped FFmpegDemuxerStream will not be | 19 // and buffered packets. Reads from a stopped FFmpegDemuxerStream will not be |
| 20 // replied to. | 20 // replied to. |
| 21 | 21 |
| 22 #ifndef MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 22 #ifndef MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| 23 #define MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 23 #define MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| 24 | 24 |
| 25 #include <deque> | 25 #include <deque> |
| 26 #include <vector> | 26 #include <vector> |
| 27 | 27 |
| 28 #include "base/callback.h" | 28 #include "base/callback.h" |
| 29 #include "base/gtest_prod_util.h" |
| 29 #include "base/waitable_event.h" | 30 #include "base/waitable_event.h" |
| 30 #include "media/base/buffers.h" | 31 #include "media/base/buffers.h" |
| 31 #include "media/base/factory.h" | 32 #include "media/base/factory.h" |
| 32 #include "media/base/filters.h" | 33 #include "media/base/filters.h" |
| 33 #include "media/base/media_format.h" | 34 #include "media/base/media_format.h" |
| 34 #include "media/filters/ffmpeg_glue.h" | 35 #include "media/filters/ffmpeg_glue.h" |
| 35 #include "media/filters/ffmpeg_interfaces.h" | 36 #include "media/filters/ffmpeg_interfaces.h" |
| 36 #include "testing/gtest/include/gtest/gtest_prod.h" | |
| 37 | 37 |
| 38 // FFmpeg forward declarations. | 38 // FFmpeg forward declarations. |
| 39 struct AVFormatContext; | 39 struct AVFormatContext; |
| 40 struct AVPacket; | 40 struct AVPacket; |
| 41 struct AVRational; | 41 struct AVRational; |
| 42 struct AVStream; | 42 struct AVStream; |
| 43 | 43 |
| 44 namespace media { | 44 namespace media { |
| 45 | 45 |
| 46 class BitstreamConverter; | 46 class BitstreamConverter; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 virtual int Read(int size, uint8* data); | 143 virtual int Read(int size, uint8* data); |
| 144 virtual bool GetPosition(int64* position_out); | 144 virtual bool GetPosition(int64* position_out); |
| 145 virtual bool SetPosition(int64 position); | 145 virtual bool SetPosition(int64 position); |
| 146 virtual bool GetSize(int64* size_out); | 146 virtual bool GetSize(int64* size_out); |
| 147 virtual bool IsStreaming(); | 147 virtual bool IsStreaming(); |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 // Only allow a factory to create this class. | 150 // Only allow a factory to create this class. |
| 151 friend class FilterFactoryImpl0<FFmpegDemuxer>; | 151 friend class FilterFactoryImpl0<FFmpegDemuxer>; |
| 152 friend class MockFFmpegDemuxer; | 152 friend class MockFFmpegDemuxer; |
| 153 FRIEND_TEST(FFmpegDemuxerTest, ProtocolRead); | 153 FRIEND_TEST_ALL_PREFIXES(FFmpegDemuxerTest, ProtocolRead); |
| 154 | 154 |
| 155 FFmpegDemuxer(); | 155 FFmpegDemuxer(); |
| 156 virtual ~FFmpegDemuxer(); | 156 virtual ~FFmpegDemuxer(); |
| 157 | 157 |
| 158 // Carries out initialization on the demuxer thread. | 158 // Carries out initialization on the demuxer thread. |
| 159 void InitializeTask(DataSource* data_source, FilterCallback* callback); | 159 void InitializeTask(DataSource* data_source, FilterCallback* callback); |
| 160 | 160 |
| 161 // Carries out a seek on the demuxer thread. | 161 // Carries out a seek on the demuxer thread. |
| 162 void SeekTask(base::TimeDelta time, FilterCallback* callback); | 162 void SeekTask(base::TimeDelta time, FilterCallback* callback); |
| 163 | 163 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // If true, then it's our first seek and we won't call av_read_frame(). It's | 230 // If true, then it's our first seek and we won't call av_read_frame(). It's |
| 231 // a hack to get around some issue with FFmpeg. | 231 // a hack to get around some issue with FFmpeg. |
| 232 bool first_seek_hack_; | 232 bool first_seek_hack_; |
| 233 | 233 |
| 234 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 234 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 } // namespace media | 237 } // namespace media |
| 238 | 238 |
| 239 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 239 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| OLD | NEW |