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