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

Side by Side Diff: media/video/video_decode_engine.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/video/ffmpeg_video_decode_engine_unittest.cc ('k') | no next file » | 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_VIDEO_VIDEO_DECODE_ENGINE_H_ 5 #ifndef MEDIA_VIDEO_VIDEO_DECODE_ENGINE_H_
6 #define MEDIA_VIDEO_VIDEO_DECODE_ENGINE_H_ 6 #define MEDIA_VIDEO_VIDEO_DECODE_ENGINE_H_
7 7
8 #include "base/callback.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "media/base/media_export.h" 9 #include "media/base/media_export.h"
11 #include "media/base/video_decoder_config.h"
12 #include "media/base/video_frame.h"
13 10
14 namespace media { 11 namespace media {
15 12
16 class Buffer; 13 class Buffer;
17 struct PipelineStatistics; 14 class VideoDecoderConfig;
15 class VideoFrame;
18 16
19 class MEDIA_EXPORT VideoDecodeEngine { 17 class MEDIA_EXPORT VideoDecodeEngine {
20 public: 18 public:
21 struct MEDIA_EXPORT EventHandler {
22 public:
23 virtual ~EventHandler() {}
24 virtual void OnInitializeComplete(bool success) = 0;
25 virtual void OnUninitializeComplete() = 0;
26 virtual void OnFlushComplete() = 0;
27 virtual void OnSeekComplete() = 0;
28 virtual void OnError() = 0;
29
30 // TODO(hclam): The following two methods shouldn't belong to this class
31 // because they are not video decode events but used to send decoded
32 // video frames and request video packets.
33 //
34 // Signal the user of VideoDecodeEngine to provide a video sample.
35 //
36 // In the normal running state, this method is called by the video decode
37 // engine to request video samples used for decoding.
38 //
39 // In the case when the video decode engine is flushing, this method is
40 // called to return video samples acquired by the video decode engine.
41 //
42 // |buffer| can be NULL in which case this method call is purely for
43 // requesting new video samples. If |buffer| is non-NULL, the buffer is
44 // returned to the owner at the same time as a request for video sample
45 // is made.
46 virtual void ProduceVideoSample(scoped_refptr<Buffer> buffer) = 0;
47
48 // Signal the user of VideoDecodeEngine that a video frame is ready to
49 // be consumed or a video frame is returned to the owner.
50 //
51 // In the normal running state, this method is called to signal that
52 // |frame| contains a decoded video frame and is ready to be used.
53 //
54 // In the case of flushing and video frame is provided externally, this
55 // method is called to return the video frame object to the owner.
56 // The content of the video frame may be invalid.
57 virtual void ConsumeVideoFrame(scoped_refptr<VideoFrame> frame,
58 const PipelineStatistics& statistics) = 0;
59 };
60
61 virtual ~VideoDecodeEngine() {} 19 virtual ~VideoDecodeEngine() {}
62 20
63 // Initialize the engine with specified configuration. 21 // Initialize the engine with specified configuration, returning true if
64 // 22 // successful.
65 // Engine should call EventHandler::OnInitializeDone() whether the 23 virtual bool Initialize(const VideoDecoderConfig& config) = 0;
66 // initialization operation finished successfully or not.
67 virtual void Initialize(EventHandler* event_handler,
68 const VideoDecoderConfig& config) = 0;
69 24
70 // Uninitialize the engine. Engine should destroy all resources and call 25 // Uninitialize the engine, freeing all resources. Calls to Flush() or
71 // EventHandler::OnUninitializeComplete(). 26 // Decode() will have no effect afterwards.
72 virtual void Uninitialize() = 0; 27 virtual void Uninitialize() = 0;
73 28
74 // Flush the engine. Engine should return all the buffers to owner ( which 29 // Decode the encoded video data and store the result (if any) into
75 // could be itself. ) then call EventHandler::OnFlushDone(). 30 // |video_frame|. Note that a frame may not always be produced if the
31 // decode engine has insufficient encoded data. In such circumstances,
32 // additional calls to Decode() may be required.
33 //
34 // Returns true if decoding was successful (includes zero length input and end
35 // of stream), false if a decoding error occurred.
36 virtual bool Decode(const scoped_refptr<Buffer>& buffer,
37 scoped_refptr<VideoFrame>* video_frame) = 0;
38
39 // Discard all pending data that has yet to be returned via Decode().
76 virtual void Flush() = 0; 40 virtual void Flush() = 0;
77
78 // This method is used as a signal for the decode engine to preroll and
79 // issue read requests after Flush() is made.
80 virtual void Seek() = 0;
81
82 // Provide a video sample to be used by the video decode engine.
83 //
84 // This method is called in response to ProvideVideoSample() called to the
85 // user.
86 virtual void ConsumeVideoSample(scoped_refptr<Buffer> buffer) = 0;
87
88 // Signal the video decode engine to produce a video frame or return the
89 // video frame object to the video decode engine.
90 //
91 // In the normal running state, this method is called by the user of the
92 // video decode engine to request a decoded video frame. If |frame| is
93 // NULL the video decode engine should allocate a video frame object.
94 // Otherwise video decode engine should try to use the video frame object
95 // provided as output.
96 //
97 // In flushing state and video frames are allocated internally this method
98 // is called by the user to return the video frame object.
99 //
100 // In response to this method call, ConsumeVideoFrame() is called with a
101 // video frame object containing decoded video content.
102 virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> frame) = 0;
103 }; 41 };
104 42
105 } // namespace media 43 } // namespace media
106 44
107 #endif // MEDIA_VIDEO_VIDEO_DECODE_ENGINE_H_ 45 #endif // MEDIA_VIDEO_VIDEO_DECODE_ENGINE_H_
OLDNEW
« no previous file with comments | « media/video/ffmpeg_video_decode_engine_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698