| 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" |
| 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 enum Status { | 23 enum Status { |
| 24 kOk, // Everything went as planned. | 24 kOk, // Everything went as planned. |
| 25 kAborted, // Decode was aborted as a result of Reset() being called. |
| 25 kNotEnoughData, // Not enough data to produce a video frame. | 26 kNotEnoughData, // Not enough data to produce a video frame. |
| 26 kDecodeError, // Decoding error happened. | 27 kDecodeError, // Decoding error happened. |
| 27 kDecryptError // Decrypting error happened. | 28 kDecryptError // Decrypting error happened. |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 VideoDecoder(); | 31 VideoDecoder(); |
| 31 virtual ~VideoDecoder(); | 32 virtual ~VideoDecoder(); |
| 32 | 33 |
| 33 // Initializes a VideoDecoder with the given |config|, executing the | 34 // Initializes a VideoDecoder with the given |config|, executing the |
| 34 // |status_cb| upon completion. | 35 // |status_cb| upon completion. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 // Requests a |buffer| to be decoded. The status of the decoder and decoded | 46 // Requests a |buffer| to be decoded. The status of the decoder and decoded |
| 46 // frame are returned via the provided callback. Only one decode may be in | 47 // frame are returned via the provided callback. Only one decode may be in |
| 47 // flight at any given time. | 48 // flight at any given time. |
| 48 // | 49 // |
| 49 // Implementations guarantee that the callback will not be called from within | 50 // Implementations guarantee that the callback will not be called from within |
| 50 // this method. | 51 // this method. |
| 51 // | 52 // |
| 52 // If the returned status is kOk: | 53 // If the returned status is kOk: |
| 53 // - Non-EOS (end of stream) frame contains decoded video data. | 54 // - Non-EOS (end of stream) frame contains decoded video data. |
| 54 // - EOS frame indicates the end of the stream. | 55 // - EOS frame indicates the end of the stream. |
| 55 // - NULL frame indicates an aborted decode. This can happen if Reset() or | |
| 56 // Stop() is called during the decoding process. | |
| 57 // Otherwise the returned frame must be NULL. | 56 // Otherwise the returned frame must be NULL. |
| 58 typedef base::Callback<void(Status, | 57 typedef base::Callback<void(Status, |
| 59 const scoped_refptr<VideoFrame>&)> DecodeCB; | 58 const scoped_refptr<VideoFrame>&)> DecodeCB; |
| 60 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 59 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 61 const DecodeCB& decode_cb) = 0; | 60 const DecodeCB& decode_cb) = 0; |
| 62 | 61 |
| 63 // Resets decoder state, fulfilling all pending DecodeCB and dropping extra | 62 // Resets decoder state, fulfilling all pending DecodeCB and dropping extra |
| 64 // queued decoded data. After this call, the decoder is back to an initialized | 63 // queued decoded data. After this call, the decoder is back to an initialized |
| 65 // clean state. | 64 // clean state. |
| 66 // Note: No VideoDecoder calls should be made before |closure| is executed. | 65 // Note: No VideoDecoder calls should be made before |closure| is executed. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 87 // use a fixed set of VideoFrames for decoding. | 86 // use a fixed set of VideoFrames for decoding. |
| 88 virtual bool CanReadWithoutStalling() const; | 87 virtual bool CanReadWithoutStalling() const; |
| 89 | 88 |
| 90 private: | 89 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); | 90 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); |
| 92 }; | 91 }; |
| 93 | 92 |
| 94 } // namespace media | 93 } // namespace media |
| 95 | 94 |
| 96 #endif // MEDIA_BASE_VIDEO_DECODER_H_ | 95 #endif // MEDIA_BASE_VIDEO_DECODER_H_ |
| OLD | NEW |