Chromium Code Reviews| 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_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/memory/scoped_ptr.h" | |
| 10 #include "media/base/filters.h" | 11 #include "media/base/filters.h" |
| 11 #include "media/base/pts_stream.h" | 12 #include "media/base/pts_stream.h" |
| 12 #include "media/video/video_decode_engine.h" | |
| 13 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
| 14 | 14 |
| 15 class MessageLoop; | 15 class MessageLoop; |
| 16 | 16 |
| 17 namespace media { | 17 namespace media { |
| 18 | 18 |
| 19 class VideoDecodeEngine; | 19 class VideoDecodeEngine; |
| 20 | 20 |
| 21 class MEDIA_EXPORT FFmpegVideoDecoder | 21 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { |
| 22 : public VideoDecoder, | |
| 23 public VideoDecodeEngine::EventHandler { | |
| 24 public: | 22 public: |
| 25 explicit FFmpegVideoDecoder(MessageLoop* message_loop); | 23 explicit FFmpegVideoDecoder(MessageLoop* message_loop); |
| 26 virtual ~FFmpegVideoDecoder(); | 24 virtual ~FFmpegVideoDecoder(); |
| 27 | 25 |
| 28 // Filter implementation. | 26 // Filter implementation. |
| 29 virtual void Stop(const base::Closure& callback) OVERRIDE; | 27 virtual void Stop(const base::Closure& callback) OVERRIDE; |
| 30 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb) OVERRIDE; | 28 virtual void Seek(base::TimeDelta time, const FilterStatusCB& cb) OVERRIDE; |
| 31 virtual void Pause(const base::Closure& callback) OVERRIDE; | 29 virtual void Pause(const base::Closure& callback) OVERRIDE; |
| 32 virtual void Flush(const base::Closure& callback) OVERRIDE; | 30 virtual void Flush(const base::Closure& callback) OVERRIDE; |
| 33 | 31 |
| 34 // VideoDecoder implementation. | 32 // VideoDecoder implementation. |
| 35 virtual void Initialize(DemuxerStream* demuxer_stream, | 33 virtual void Initialize(DemuxerStream* demuxer_stream, |
| 36 const base::Closure& callback, | 34 const base::Closure& callback, |
| 37 const StatisticsCallback& stats_callback) OVERRIDE; | 35 const StatisticsCallback& stats_callback) OVERRIDE; |
| 38 virtual void ProduceVideoFrame( | 36 virtual void Read(const FrameReadyCB& callback); OVERRIDE; |
|
Ami GONE FROM CHROMIUM
2011/11/01 22:17:40
This is part of some other CL, right? Note that f
scherkus (not reviewing)
2011/11/03 04:55:59
Not sure what you mean -- this is replacing Produc
Ami GONE FROM CHROMIUM
2011/11/03 16:40:00
Now I'm not sure what I meant, either. nm.
| |
| 39 scoped_refptr<VideoFrame> video_frame) OVERRIDE; | |
| 40 virtual gfx::Size natural_size() OVERRIDE; | 37 virtual gfx::Size natural_size() OVERRIDE; |
| 41 | 38 |
| 42 private: | 39 private: |
| 43 // VideoDecodeEngine::EventHandler interface. | |
| 44 virtual void OnInitializeComplete(bool success) OVERRIDE; | |
| 45 virtual void OnUninitializeComplete() OVERRIDE; | |
| 46 virtual void OnFlushComplete() OVERRIDE; | |
| 47 virtual void OnSeekComplete() OVERRIDE; | |
| 48 virtual void OnError() OVERRIDE; | |
| 49 virtual void ProduceVideoSample(scoped_refptr<Buffer> buffer) OVERRIDE; | |
| 50 virtual void ConsumeVideoFrame( | |
| 51 scoped_refptr<VideoFrame> frame, | |
| 52 const PipelineStatistics& statistics) OVERRIDE; | |
| 53 | |
| 54 enum DecoderState { | 40 enum DecoderState { |
| 55 kUnInitialized, | 41 kUninitialized, |
| 56 kInitializing, | |
| 57 kNormal, | 42 kNormal, |
| 58 kFlushCodec, | 43 kFlushCodec, |
| 59 kDecodeFinished, | 44 kDecodeFinished, |
| 60 kPausing, | |
| 61 kFlushing, | |
| 62 kStopped | |
| 63 }; | 45 }; |
| 64 | 46 |
| 65 void OnFlushComplete(const base::Closure& callback); | 47 void DoDecodeBuffer(const scoped_refptr<Buffer>& buffer); |
| 66 void OnSeekComplete(const base::Closure& callback); | |
| 67 void OnReadComplete(Buffer* buffer); | |
| 68 | 48 |
| 69 // TODO(jiesun): until demuxer pass scoped_refptr<Buffer>: we could not merge | 49 // Reads from the demuxer stream with corresponding callback method. |
| 70 // this with OnReadComplete | 50 void ReadFromDemuxerStream(); |
| 71 void OnReadCompleteTask(scoped_refptr<Buffer> buffer); | 51 void DecodeBuffer(Buffer* buffer); |
| 72 | 52 |
| 73 // Flush the output buffers that we had held in Paused state. | 53 // Delivers the frame to |frame_ready_cb_| and resets the callback. |
| 74 void FlushBuffers(); | 54 void DeliverFrame(const scoped_refptr<VideoFrame>& video_frame); |
| 75 | |
| 76 // Injection point for unittest to provide a mock engine. Takes ownership of | |
| 77 // the provided engine. | |
| 78 virtual void SetVideoDecodeEngineForTest(VideoDecodeEngine* engine); | |
| 79 | 55 |
| 80 MessageLoop* message_loop_; | 56 MessageLoop* message_loop_; |
| 81 | 57 |
| 82 PtsStream pts_stream_; // Stream of presentation timestamps. | 58 PtsStream pts_stream_; |
| 83 DecoderState state_; | 59 DecoderState state_; |
| 84 scoped_ptr<VideoDecodeEngine> decode_engine_; | 60 scoped_ptr<VideoDecodeEngine> decode_engine_; |
| 85 | 61 |
| 86 base::Closure initialize_callback_; | |
| 87 base::Closure uninitialize_callback_; | |
| 88 base::Closure flush_callback_; | |
| 89 FilterStatusCB seek_cb_; | |
| 90 StatisticsCallback statistics_callback_; | 62 StatisticsCallback statistics_callback_; |
| 91 | 63 |
| 92 // Hold video frames when flush happens. | 64 FrameReadyCB frame_ready_cb_; |
| 93 std::deque<scoped_refptr<VideoFrame> > frame_queue_flushed_; | |
| 94 | 65 |
| 95 // TODO(scherkus): I think this should be calculated by VideoRenderers based | 66 // TODO(scherkus): I think this should be calculated by VideoRenderers based |
| 96 // on information provided by VideoDecoders (i.e., aspect ratio). | 67 // on information provided by VideoDecoders (i.e., aspect ratio). |
| 97 gfx::Size natural_size_; | 68 gfx::Size natural_size_; |
| 98 | 69 |
| 99 // Pointer to the demuxer stream that will feed us compressed buffers. | 70 // Pointer to the demuxer stream that will feed us compressed buffers. |
| 100 scoped_refptr<DemuxerStream> demuxer_stream_; | 71 scoped_refptr<DemuxerStream> demuxer_stream_; |
| 101 | 72 |
| 102 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); | 73 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); |
| 103 }; | 74 }; |
| 104 | 75 |
| 105 } // namespace media | 76 } // namespace media |
| 106 | 77 |
| 107 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ | 78 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
| OLD | NEW |