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

Side by Side Diff: media/base/video_decoder.h

Issue 331863004: Revert 276344 "Add callback in VideoDecoder and AudioDecoder to ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2049/src/
Patch Set: Created 6 years, 6 months 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/mock_filters.h ('k') | media/base/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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BASE_VIDEO_DECODER_H_ 5 #ifndef MEDIA_BASE_VIDEO_DECODER_H_
6 #define MEDIA_BASE_VIDEO_DECODER_H_ 6 #define MEDIA_BASE_VIDEO_DECODER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
11 #include "media/base/pipeline_status.h" 11 #include "media/base/pipeline_status.h"
12 #include "ui/gfx/size.h" 12 #include "ui/gfx/size.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 class DecoderBuffer; 16 class DecoderBuffer;
17 class VideoDecoderConfig; 17 class VideoDecoderConfig;
18 class VideoFrame; 18 class VideoFrame;
19 19
20 class MEDIA_EXPORT VideoDecoder { 20 class MEDIA_EXPORT VideoDecoder {
21 public: 21 public:
22 // Status codes for decode operations on VideoDecoder. 22 // Status codes for decode operations on VideoDecoder.
23 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums 23 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums
24 // match, break them into a decoder_status.h. 24 // match, break them into a decoder_status.h.
25 enum Status { 25 enum Status {
26 kOk, // Everything went as planned. 26 kOk, // Everything went as planned.
27 kAborted, // Decode was aborted as a result of Reset() being called. 27 kAborted, // Decode was aborted as a result of Reset() being called.
28 kNotEnoughData, // Not enough data to produce a video frame.
28 kDecodeError, // Decoding error happened. 29 kDecodeError, // Decoding error happened.
29 kDecryptError // Decrypting error happened. 30 kDecryptError // Decrypting error happened.
30 }; 31 };
31 32
32 // Callback to return decode frames.
33 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> OutputCB;
34
35 // Callback type for Decode(). Called after the decoder has completed decoding
36 // corresponding DecoderBuffer, indicating that it's ready to accept another
37 // buffer to decode.
38 typedef base::Callback<void(Status status)> DecodeCB;
39
40 VideoDecoder(); 33 VideoDecoder();
41 virtual ~VideoDecoder(); 34 virtual ~VideoDecoder();
42 35
43 // Initializes a VideoDecoder with the given |config|, executing the 36 // Initializes a VideoDecoder with the given |config|, executing the
44 // |status_cb| upon completion. |output_cb| is called for each output frame 37 // |status_cb| upon completion.
45 // decoded by Decode().
46 // 38 //
47 // Note: 39 // Note:
48 // 1) The VideoDecoder will be reinitialized if it was initialized before. 40 // 1) The VideoDecoder will be reinitialized if it was initialized before.
49 // Upon reinitialization, all internal buffered frames will be dropped. 41 // Upon reinitialization, all internal buffered frames will be dropped.
50 // 2) This method should not be called during pending decode, reset or stop. 42 // 2) This method should not be called during pending decode, reset or stop.
51 // 3) No VideoDecoder calls except for Stop() should be made before 43 // 3) No VideoDecoder calls except for Stop() should be made before
52 // |status_cb| is executed. 44 // |status_cb| is executed.
53 virtual void Initialize(const VideoDecoderConfig& config, 45 virtual void Initialize(const VideoDecoderConfig& config,
54 bool low_delay, 46 bool low_delay,
55 const PipelineStatusCB& status_cb, 47 const PipelineStatusCB& status_cb) = 0;
56 const OutputCB& output_cb) = 0;
57 48
58 // Requests a |buffer| to be decoded. The status of the decoder and decoded 49 // Requests a |buffer| to be decoded. The status of the decoder and decoded
59 // frame are returned via the provided callback. Some decoders may allow 50 // frame are returned via the provided callback. Some decoders may allow
60 // decoding multiple buffers in parallel. Callers should call 51 // decoding multiple buffers in parallel. Callers should call
61 // GetMaxDecodeRequests() to get number of buffers that may be decoded in 52 // GetMaxDecodeRequests() to get number of buffers that may be decoded in
62 // parallel. Decoder must call |decode_cb| in the same order in which Decode() 53 // parallel. Decoder must call |decode_cb| in the same order in which Decode()
63 // is called. 54 // is called.
64 // 55 //
65 // Implementations guarantee that the callback will not be called from within 56 // Implementations guarantee that the callback will not be called from within
66 // this method and that |decode_cb| will not be blocked on the following 57 // this method and that |decode_cb| will not be blocked on the following
67 // Decode() calls (i.e. |decode_cb| will be called even Decode() is never 58 // Decode() calls (i.e. |decode_cb| will be called even Decode() is never
68 // called again). 59 // called again).
69 // 60 //
70 // After decoding is finished the decoder calls |output_cb| specified in 61 // If the returned status is kOk:
71 // Initialize() for each decoded frame. |output_cb| may be called before or 62 // - Non-EOS (end of stream) frame contains decoded video data.
72 // after |decode_cb|. 63 // - EOS frame indicates the end of the stream.
73 // 64 // Otherwise the returned frame must be NULL.
74 // If |buffer| is an EOS buffer then the decoder must be flushed, i.e. 65 typedef base::Callback<void(Status,
75 // |output_cb| must be called for each frame pending in the queue and 66 const scoped_refptr<VideoFrame>&)> DecodeCB;
76 // |decode_cb| must be called after that.
77 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 67 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
78 const DecodeCB& decode_cb) = 0; 68 const DecodeCB& decode_cb) = 0;
79 69
80 // Resets decoder state. All pending Decode() requests will be finished or 70 // Some VideoDecoders may queue up multiple VideoFrames from a single
81 // aborted before |closure| is called. 71 // DecoderBuffer, if we have any such queued frames this will return the next
72 // one. Otherwise we return a NULL VideoFrame.
73 //
74 // TODO(xhwang): Revisit this method.
75 virtual scoped_refptr<VideoFrame> GetDecodeOutput();
76
77 // Resets decoder state, fulfilling all pending DecodeCB and dropping extra
78 // queued decoded data. After this call, the decoder is back to an initialized
79 // clean state.
82 // Note: No VideoDecoder calls should be made before |closure| is executed. 80 // Note: No VideoDecoder calls should be made before |closure| is executed.
83 virtual void Reset(const base::Closure& closure) = 0; 81 virtual void Reset(const base::Closure& closure) = 0;
84 82
85 // Stops decoder, fires any pending callbacks and sets the decoder to an 83 // Stops decoder, fires any pending callbacks and sets the decoder to an
86 // uninitialized state. A VideoDecoder cannot be re-initialized after it has 84 // uninitialized state. A VideoDecoder cannot be re-initialized after it has
87 // been stopped. 85 // been stopped.
88 // Note that if Initialize() is pending or has finished successfully, Stop() 86 // Note that if Initialize() is pending or has finished successfully, Stop()
89 // must be called before destructing the decoder. 87 // must be called before destructing the decoder.
90 virtual void Stop() = 0; 88 virtual void Stop() = 0;
91 89
92 // Returns true if the decoder needs bitstream conversion before decoding. 90 // Returns true if the decoder needs bitstream conversion before decoding.
93 virtual bool NeedsBitstreamConversion() const; 91 virtual bool NeedsBitstreamConversion() const;
94 92
95 // Returns true if the decoder currently has the ability to decode and return 93 // Returns true if the decoder currently has the ability to decode and return
96 // a VideoFrame. Most implementations can allocate a new VideoFrame and hence 94 // a VideoFrame. Most implementations can allocate a new VideoFrame and hence
97 // this will always return true. Override and return false for decoders that 95 // this will always return true. Override and return false for decoders that
98 // use a fixed set of VideoFrames for decoding. 96 // use a fixed set of VideoFrames for decoding.
99 virtual bool CanReadWithoutStalling() const; 97 virtual bool CanReadWithoutStalling() const;
100 98
101 // Returns maximum number of parallel decode requests. 99 // Returns maximum number of parallel decode requests.
102 virtual int GetMaxDecodeRequests() const; 100 virtual int GetMaxDecodeRequests() const;
103 101
104 private: 102 private:
105 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); 103 DISALLOW_COPY_AND_ASSIGN(VideoDecoder);
106 }; 104 };
107 105
108 } // namespace media 106 } // namespace media
109 107
110 #endif // MEDIA_BASE_VIDEO_DECODER_H_ 108 #endif // MEDIA_BASE_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « media/base/mock_filters.h ('k') | media/base/video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698