Chromium Code Reviews| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 // satisfy the requirements above. | 58 // satisfy the requirements above. |
| 59 // | 59 // |
| 60 // |cdm_context| can be used to handle encrypted buffers. May be null if the | 60 // |cdm_context| can be used to handle encrypted buffers. May be null if the |
| 61 // stream is not encrypted. | 61 // stream is not encrypted. |
| 62 // | 62 // |
| 63 // Note: | 63 // Note: |
| 64 // 1) The VideoDecoder will be reinitialized if it was initialized before. | 64 // 1) The VideoDecoder will be reinitialized if it was initialized before. |
| 65 // Upon reinitialization, all internal buffered frames will be dropped. | 65 // Upon reinitialization, all internal buffered frames will be dropped. |
| 66 // 2) This method should not be called during pending decode or reset. | 66 // 2) This method should not be called during pending decode or reset. |
| 67 // 3) No VideoDecoder calls should be made before |init_cb| is executed. | 67 // 3) No VideoDecoder calls should be made before |init_cb| is executed. |
| 68 // 4) VideoDecoders should take care to run |output_cb| as soon as the frame | |
| 69 // is ready (i.e. w/o thread trampolining) since it can strongly affect frame | |
| 70 // delivery times with high-frame-rate material. See Decode() for additional | |
| 71 // notes. | |
| 68 virtual void Initialize(const VideoDecoderConfig& config, | 72 virtual void Initialize(const VideoDecoderConfig& config, |
| 69 bool low_delay, | 73 bool low_delay, |
| 70 CdmContext* cdm_context, | 74 CdmContext* cdm_context, |
| 71 const InitCB& init_cb, | 75 const InitCB& init_cb, |
| 72 const OutputCB& output_cb) = 0; | 76 const OutputCB& output_cb) = 0; |
| 73 | 77 |
| 74 // Requests a |buffer| to be decoded. The status of the decoder and decoded | 78 // Requests a |buffer| to be decoded. The status of the decoder and decoded |
| 75 // frame are returned via the provided callback. Some decoders may allow | 79 // frame are returned via the provided callback. Some decoders may allow |
| 76 // decoding multiple buffers in parallel. Callers should call | 80 // decoding multiple buffers in parallel. Callers should call |
| 77 // GetMaxDecodeRequests() to get number of buffers that may be decoded in | 81 // GetMaxDecodeRequests() to get number of buffers that may be decoded in |
| 78 // parallel. Decoder must call |decode_cb| in the same order in which Decode() | 82 // parallel. Decoder must call |decode_cb| in the same order in which Decode() |
| 79 // is called. | 83 // is called. |
| 80 // | 84 // |
| 81 // Implementations guarantee that the callback will not be called from within | 85 // Implementations guarantee that the callback will not be called from within |
| 82 // this method and that |decode_cb| will not be blocked on the following | 86 // this method and that |decode_cb| will not be blocked on the following |
| 83 // Decode() calls (i.e. |decode_cb| will be called even if Decode() is never | 87 // Decode() calls (i.e. |decode_cb| will be called even if Decode() is never |
| 84 // called again). | 88 // called again). |
| 85 // | 89 // |
| 86 // After decoding is finished the decoder calls |output_cb| specified in | 90 // After decoding is finished the decoder calls |output_cb| specified in |
| 87 // Initialize() for each decoded frame. In general |output_cb| may be called | 91 // Initialize() for each decoded frame. |output_cb| is always called before |
| 88 // before or after |decode_cb|, but software decoders normally call | 92 // |decode_cb|. However, |output_cb| may be called before Decode() returns, if |
| 89 // |output_cb| before calling |decode_cb|, i.e. while Decode() is pending. | 93 // other behavior is desired callers should ensure that |output_cb| will |
| 94 // trampoline as necessary. | |
|
xhwang
2016/04/25 22:40:28
Note that we requires that the |decode_cb| must NO
DaleCurtis
2016/04/25 22:52:16
Do we need to say anything? If |output_cb| runs wh
DaleCurtis
2016/04/25 23:07:43
Discussed offline, while the existing behavior is
| |
| 90 // | 95 // |
| 91 // If |buffer| is an EOS buffer then the decoder must be flushed, i.e. | 96 // If |buffer| is an EOS buffer then the decoder must be flushed, i.e. |
| 92 // |output_cb| must be called for each frame pending in the queue and | 97 // |output_cb| must be called for each frame pending in the queue and |
| 93 // |decode_cb| must be called after that. Callers will not call Decode() | 98 // |decode_cb| must be called after that. Callers will not call Decode() |
| 94 // again until after the flush completes. | 99 // again until after the flush completes. |
| 95 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 100 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 96 const DecodeCB& decode_cb) = 0; | 101 const DecodeCB& decode_cb) = 0; |
| 97 | 102 |
| 98 // Resets decoder state. All pending Decode() requests will be finished or | 103 // Resets decoder state. All pending Decode() requests will be finished or |
| 99 // aborted before |closure| is called. | 104 // aborted before |closure| is called. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 112 // Returns maximum number of parallel decode requests. | 117 // Returns maximum number of parallel decode requests. |
| 113 virtual int GetMaxDecodeRequests() const; | 118 virtual int GetMaxDecodeRequests() const; |
| 114 | 119 |
| 115 private: | 120 private: |
| 116 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); | 121 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); |
| 117 }; | 122 }; |
| 118 | 123 |
| 119 } // namespace media | 124 } // namespace media |
| 120 | 125 |
| 121 #endif // MEDIA_BASE_VIDEO_DECODER_H_ | 126 #endif // MEDIA_BASE_VIDEO_DECODER_H_ |
| OLD | NEW |