| 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 #ifndef MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
| 6 #define MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ | 6 #define MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "media/base/filters.h" | 12 #include "media/base/filters.h" |
| 13 #include "media/base/pts_heap.h" | 13 #include "media/base/pts_heap.h" |
| 14 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
| 15 #include "media/filters/decoder_base.h" | 15 #include "media/filters/decoder_base.h" |
| 16 #include "media/video/video_decode_engine.h" | 16 #include "media/video/video_decode_engine.h" |
| 17 | 17 |
| 18 // FFmpeg types. | 18 // FFmpeg types. |
| 19 struct AVRational; | 19 struct AVRational; |
| 20 | 20 |
| 21 namespace media { | 21 namespace media { |
| 22 | 22 |
| 23 class VideoDecodeEngine; | 23 class VideoDecodeEngine; |
| 24 | 24 |
| 25 class FFmpegVideoDecoder : public VideoDecoder, | 25 class FFmpegVideoDecoder : public VideoDecoder, |
| 26 public VideoDecodeEngine::EventHandler { | 26 public VideoDecodeEngine::EventHandler { |
| 27 public: | 27 public: |
| 28 explicit FFmpegVideoDecoder(VideoDecodeContext* decode_context); | 28 explicit FFmpegVideoDecoder(MessageLoop* message_loop, |
| 29 VideoDecodeContext* decode_context); |
| 29 virtual ~FFmpegVideoDecoder(); | 30 virtual ~FFmpegVideoDecoder(); |
| 30 | 31 |
| 31 // Filter implementation. | 32 // Filter implementation. |
| 32 virtual void Stop(FilterCallback* callback); | 33 virtual void Stop(FilterCallback* callback); |
| 33 virtual void Seek(base::TimeDelta time, FilterCallback* callback); | 34 virtual void Seek(base::TimeDelta time, FilterCallback* callback); |
| 34 virtual void Pause(FilterCallback* callback); | 35 virtual void Pause(FilterCallback* callback); |
| 35 virtual void Flush(FilterCallback* callback); | 36 virtual void Flush(FilterCallback* callback); |
| 36 | 37 |
| 37 // Decoder implementation. | 38 // Decoder implementation. |
| 38 virtual void Initialize(DemuxerStream* demuxer_stream, | 39 virtual void Initialize(DemuxerStream* demuxer_stream, |
| 39 FilterCallback* callback); | 40 FilterCallback* callback); |
| 40 virtual const MediaFormat& media_format(); | 41 virtual const MediaFormat& media_format(); |
| 41 virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> video_frame); | 42 virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> video_frame); |
| 42 virtual bool ProvidesBuffer(); | 43 virtual bool ProvidesBuffer(); |
| 43 | 44 |
| 45 MessageLoop* message_loop(); |
| 46 |
| 44 private: | 47 private: |
| 45 // VideoDecodeEngine::EventHandler interface. | 48 // VideoDecodeEngine::EventHandler interface. |
| 46 virtual void OnInitializeComplete(const VideoCodecInfo& info); | 49 virtual void OnInitializeComplete(const VideoCodecInfo& info); |
| 47 virtual void OnUninitializeComplete(); | 50 virtual void OnUninitializeComplete(); |
| 48 virtual void OnFlushComplete(); | 51 virtual void OnFlushComplete(); |
| 49 virtual void OnSeekComplete(); | 52 virtual void OnSeekComplete(); |
| 50 virtual void OnError(); | 53 virtual void OnError(); |
| 51 virtual void OnFormatChange(VideoStreamInfo stream_info); | 54 virtual void OnFormatChange(VideoStreamInfo stream_info); |
| 52 virtual void ProduceVideoSample(scoped_refptr<Buffer> buffer); | 55 virtual void ProduceVideoSample(scoped_refptr<Buffer> buffer); |
| 53 virtual void ConsumeVideoFrame(scoped_refptr<VideoFrame> frame); | 56 virtual void ConsumeVideoFrame(scoped_refptr<VideoFrame> frame); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // reserved as a last-ditch effort. | 105 // reserved as a last-ditch effort. |
| 103 virtual TimeTuple FindPtsAndDuration(const AVRational& time_base, | 106 virtual TimeTuple FindPtsAndDuration(const AVRational& time_base, |
| 104 PtsHeap* pts_heap, | 107 PtsHeap* pts_heap, |
| 105 const TimeTuple& last_pts, | 108 const TimeTuple& last_pts, |
| 106 const VideoFrame* frame); | 109 const VideoFrame* frame); |
| 107 | 110 |
| 108 // Injection point for unittest to provide a mock engine. Takes ownership of | 111 // Injection point for unittest to provide a mock engine. Takes ownership of |
| 109 // the provided engine. | 112 // the provided engine. |
| 110 virtual void SetVideoDecodeEngineForTest(VideoDecodeEngine* engine); | 113 virtual void SetVideoDecodeEngineForTest(VideoDecodeEngine* engine); |
| 111 | 114 |
| 115 MessageLoop* message_loop_; |
| 112 size_t width_; | 116 size_t width_; |
| 113 size_t height_; | 117 size_t height_; |
| 114 MediaFormat media_format_; | 118 MediaFormat media_format_; |
| 115 | 119 |
| 116 PtsHeap pts_heap_; // Heap of presentation timestamps. | 120 PtsHeap pts_heap_; // Heap of presentation timestamps. |
| 117 TimeTuple last_pts_; | 121 TimeTuple last_pts_; |
| 118 scoped_ptr<AVRational> time_base_; // Pointer to avoid needing full type. | 122 scoped_ptr<AVRational> time_base_; // Pointer to avoid needing full type. |
| 119 DecoderState state_; | 123 DecoderState state_; |
| 120 scoped_ptr<VideoDecodeEngine> decode_engine_; | 124 scoped_ptr<VideoDecodeEngine> decode_engine_; |
| 121 scoped_ptr<VideoDecodeContext> decode_context_; | 125 scoped_ptr<VideoDecodeContext> decode_context_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 132 | 136 |
| 133 // Pointer to the demuxer stream that will feed us compressed buffers. | 137 // Pointer to the demuxer stream that will feed us compressed buffers. |
| 134 scoped_refptr<DemuxerStream> demuxer_stream_; | 138 scoped_refptr<DemuxerStream> demuxer_stream_; |
| 135 | 139 |
| 136 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); | 140 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); |
| 137 }; | 141 }; |
| 138 | 142 |
| 139 } // namespace media | 143 } // namespace media |
| 140 | 144 |
| 141 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ | 145 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
| OLD | NEW |