Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: media/filters/ffmpeg_video_decoder.h

Issue 8417019: Simplify VideoDecodeEngine interface by making everything synchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for CaptureVideoDecoder Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/video_decoder_config.cc ('k') | media/filters/ffmpeg_video_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ReadCB& callback) OVERRIDE;
39 scoped_refptr<VideoFrame> video_frame) OVERRIDE; 37 virtual const gfx::Size& natural_size() OVERRIDE;
40 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 // Carries out the reading operation scheduled by Read().
66 void OnSeekComplete(const base::Closure& callback); 48 void DoRead(const ReadCB& callback);
67 49
68 // TODO(scherkus): There are two of these to keep read completions 50 // Reads from the demuxer stream with corresponding callback method.
69 // asynchronous and media_unittests passing. Remove. 51 void ReadFromDemuxerStream();
70 void OnReadComplete(const scoped_refptr<Buffer>& buffer); 52 void DecodeBuffer(const scoped_refptr<Buffer>& buffer);
71 void OnReadCompleteTask(const scoped_refptr<Buffer>& buffer);
72 53
73 // Flush the output buffers that we had held in Paused state. 54 // Carries out the decoding operation scheduled by DecodeBuffer().
74 void FlushBuffers(); 55 void DoDecodeBuffer(const scoped_refptr<Buffer>& buffer);
75 56
76 // Injection point for unittest to provide a mock engine. Takes ownership of 57 // Delivers the frame to |read_cb_| and resets the callback.
77 // the provided engine. 58 void DeliverFrame(const scoped_refptr<VideoFrame>& video_frame);
78 virtual void SetVideoDecodeEngineForTest(VideoDecodeEngine* engine);
79 59
80 MessageLoop* message_loop_; 60 MessageLoop* message_loop_;
81 61
82 PtsStream pts_stream_; // Stream of presentation timestamps. 62 PtsStream pts_stream_;
83 DecoderState state_; 63 DecoderState state_;
84 scoped_ptr<VideoDecodeEngine> decode_engine_; 64 scoped_ptr<VideoDecodeEngine> decode_engine_;
85 65
86 base::Closure initialize_callback_;
87 base::Closure uninitialize_callback_;
88 base::Closure flush_callback_;
89 FilterStatusCB seek_cb_;
90 StatisticsCallback statistics_callback_; 66 StatisticsCallback statistics_callback_;
91 67
92 // Hold video frames when flush happens. 68 ReadCB read_cb_;
93 std::deque<scoped_refptr<VideoFrame> > frame_queue_flushed_;
94 69
95 // TODO(scherkus): I think this should be calculated by VideoRenderers based 70 // TODO(scherkus): I think this should be calculated by VideoRenderers based
96 // on information provided by VideoDecoders (i.e., aspect ratio). 71 // on information provided by VideoDecoders (i.e., aspect ratio).
97 gfx::Size natural_size_; 72 gfx::Size natural_size_;
98 73
99 // Pointer to the demuxer stream that will feed us compressed buffers. 74 // Pointer to the demuxer stream that will feed us compressed buffers.
100 scoped_refptr<DemuxerStream> demuxer_stream_; 75 scoped_refptr<DemuxerStream> demuxer_stream_;
101 76
102 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); 77 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder);
103 }; 78 };
104 79
105 } // namespace media 80 } // namespace media
106 81
107 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ 82 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « media/base/video_decoder_config.cc ('k') | media/filters/ffmpeg_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698