OLD | NEW |
---|---|
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" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 // Note: | 39 // Note: |
40 // 1) The VideoDecoder will be reinitialized if it was initialized before. | 40 // 1) The VideoDecoder will be reinitialized if it was initialized before. |
41 // Upon reinitialization, all internal buffered frames will be dropped. | 41 // Upon reinitialization, all internal buffered frames will be dropped. |
42 // 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. |
43 // 3) No VideoDecoder calls except for Stop() should be made before | 43 // 3) No VideoDecoder calls except for Stop() should be made before |
44 // |status_cb| is executed. | 44 // |status_cb| is executed. |
45 virtual void Initialize(const VideoDecoderConfig& config, | 45 virtual void Initialize(const VideoDecoderConfig& config, |
46 const PipelineStatusCB& status_cb) = 0; | 46 const PipelineStatusCB& status_cb) = 0; |
47 | 47 |
48 // Requests a |buffer| to be decoded. The status of the decoder and decoded | 48 // Requests a |buffer| to be decoded. The status of the decoder and decoded |
49 // frame are returned via the provided callback. Only one decode may be in | 49 // frame are returned via the provided callback. Some decoders may allow |
50 // flight at any given time. | 50 // decoding multiple buffers in parallel. Callers should call |
51 // GetMaxDecodeRequests() to get number of parallel that may be decoded in | |
xhwang
2014/04/29 20:01:26
s/parallel/buffers ?
Sergey Ulanov
2014/04/30 18:56:52
Done.
| |
52 // parallel. Decoder must call |decode_cb| in the same order in which Decode() | |
53 // is called. | |
51 // | 54 // |
52 // Implementations guarantee that the callback will not be called from within | 55 // Implementations guarantee that the callback will not be called from within |
53 // this method. | 56 // this method. |
54 // | 57 // |
55 // If the returned status is kOk: | 58 // If the returned status is kOk: |
56 // - Non-EOS (end of stream) frame contains decoded video data. | 59 // - Non-EOS (end of stream) frame contains decoded video data. |
57 // - EOS frame indicates the end of the stream. | 60 // - EOS frame indicates the end of the stream. |
58 // Otherwise the returned frame must be NULL. | 61 // Otherwise the returned frame must be NULL. |
59 typedef base::Callback<void(Status, | 62 typedef base::Callback<void(Status, |
60 const scoped_refptr<VideoFrame>&)> DecodeCB; | 63 const scoped_refptr<VideoFrame>&)> DecodeCB; |
61 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 64 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
62 const DecodeCB& decode_cb) = 0; | 65 const DecodeCB& decode_cb) = 0; |
63 | 66 |
64 // Some VideoDecoders may queue up multiple VideoFrames from a single | 67 // Some VideoDecoders may queue up multiple VideoFrames from a single |
65 // DecoderBuffer, if we have any such queued frames this will return the next | 68 // DecoderBuffer, if we have any such queued frames this will return the next |
66 // one. Otherwise we return a NULL VideoFrame. | 69 // one. Otherwise we return a NULL VideoFrame. |
70 // | |
71 // TODO(xhwang): Revisit this method. | |
67 virtual scoped_refptr<VideoFrame> GetDecodeOutput(); | 72 virtual scoped_refptr<VideoFrame> GetDecodeOutput(); |
68 | 73 |
69 // Resets decoder state, fulfilling all pending DecodeCB and dropping extra | 74 // Resets decoder state, fulfilling all pending DecodeCB and dropping extra |
70 // queued decoded data. After this call, the decoder is back to an initialized | 75 // queued decoded data. After this call, the decoder is back to an initialized |
71 // clean state. | 76 // clean state. |
72 // Note: No VideoDecoder calls should be made before |closure| is executed. | 77 // Note: No VideoDecoder calls should be made before |closure| is executed. |
73 virtual void Reset(const base::Closure& closure) = 0; | 78 virtual void Reset(const base::Closure& closure) = 0; |
74 | 79 |
75 // Stops decoder, fires any pending callbacks and sets the decoder to an | 80 // Stops decoder, fires any pending callbacks and sets the decoder to an |
76 // uninitialized state. A VideoDecoder cannot be re-initialized after it has | 81 // uninitialized state. A VideoDecoder cannot be re-initialized after it has |
77 // been stopped. | 82 // been stopped. |
78 // Note that if Initialize() is pending or has finished successfully, Stop() | 83 // Note that if Initialize() is pending or has finished successfully, Stop() |
79 // must be called before destructing the decoder. | 84 // must be called before destructing the decoder. |
80 virtual void Stop() = 0; | 85 virtual void Stop() = 0; |
81 | 86 |
82 // Returns true if the decoder needs bitstream conversion before decoding. | 87 // Returns true if the decoder needs bitstream conversion before decoding. |
83 virtual bool NeedsBitstreamConversion() const; | 88 virtual bool NeedsBitstreamConversion() const; |
84 | 89 |
85 // Returns true if the decoder currently has the ability to decode and return | 90 // Returns true if the decoder currently has the ability to decode and return |
86 // a VideoFrame. Most implementations can allocate a new VideoFrame and hence | 91 // a VideoFrame. Most implementations can allocate a new VideoFrame and hence |
87 // this will always return true. Override and return false for decoders that | 92 // this will always return true. Override and return false for decoders that |
88 // use a fixed set of VideoFrames for decoding. | 93 // use a fixed set of VideoFrames for decoding. |
89 virtual bool CanReadWithoutStalling() const; | 94 virtual bool CanReadWithoutStalling() const; |
90 | 95 |
96 // Returns maximum number of parallel decode requests. | |
97 virtual int GetMaxDecodeRequests() const; | |
98 | |
91 private: | 99 private: |
92 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); | 100 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); |
93 }; | 101 }; |
94 | 102 |
95 } // namespace media | 103 } // namespace media |
96 | 104 |
97 #endif // MEDIA_BASE_VIDEO_DECODER_H_ | 105 #endif // MEDIA_BASE_VIDEO_DECODER_H_ |
OLD | NEW |