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

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: recycling: vanquished 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
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 {
Ami GONE FROM CHROMIUM 2011/11/01 22:17:40 <SheddingHappyTears/>
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 compressed video data and store the result (if any) into
Ami GONE FROM CHROMIUM 2011/11/01 22:17:40 s/compressed/encoded/ (here and below)
scherkus (not reviewing) 2011/11/03 04:55:59 Done.
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 compressed data. In such circumstances,
32 // additional calls to Decode() may be required.
Ami GONE FROM CHROMIUM 2011/11/01 22:17:40 what if a buffer contains multiple frames? (smells
scherkus (not reviewing) 2011/11/03 04:55:59 Not sure how most of libavcodec handles that case.
33 //
34 // Returns true if operation was successful, false if an error occurred.
Ami GONE FROM CHROMIUM 2011/11/01 22:17:40 More explicitly: false if decode error happens, tr
scherkus (not reviewing) 2011/11/03 04:55:59 Done.
35 virtual bool Decode(scoped_refptr<Buffer> buffer,
Ami GONE FROM CHROMIUM 2011/11/01 22:17:40 Should this be a const&?
scherkus (not reviewing) 2011/11/03 04:55:59 Done.
36 scoped_refptr<VideoFrame>* video_frame) = 0;
37
38 // Flush the internal state of the engine.
Ami GONE FROM CHROMIUM 2011/11/01 22:17:40 Explicitly: drop pending encoded data that hasn't
scherkus (not reviewing) 2011/11/03 04:55:59 Done.
76 virtual void Flush() = 0; 39 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 }; 40 };
104 41
105 } // namespace media 42 } // namespace media
106 43
107 #endif // MEDIA_VIDEO_VIDEO_DECODE_ENGINE_H_ 44 #endif // MEDIA_VIDEO_VIDEO_DECODE_ENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698