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