Chromium Code Reviews| Index: ppapi/cpp/media_codec_video_decoder.h |
| diff --git a/ppapi/cpp/media_codec_video_decoder.h b/ppapi/cpp/media_codec_video_decoder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..becad5c0bc757cd99a89ba2b5dfe73e607532659 |
| --- /dev/null |
| +++ b/ppapi/cpp/media_codec_video_decoder.h |
| @@ -0,0 +1,130 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef PPAPI_CPP_MEDIA_CODEC_VIDEO_DECODER_H_ |
| +#define PPAPI_CPP_MEDIA_CODEC_VIDEO_DECODER_H_ |
| + |
| +#include "ppapi/c/pp_media_codec.h" |
| +#include "ppapi/c/pp_size.h" |
| +#include "ppapi/cpp/completion_callback.h" |
| +#include "ppapi/cpp/graphics_3d.h" |
| +#include "ppapi/cpp/resource.h" |
| +#include "ppapi/cpp/size.h" |
| + |
| +/// @file |
| +/// This file defines the API to create and use a MediaCodecVideoDecoder |
| +/// resource. |
| + |
| +struct PP_FileInfo; |
| + |
| +namespace pp { |
| + |
| +class InstanceHandle; |
| + |
| +/// The <code>MediaCodecVideoDecoder</code> class represents a video decoder |
| +/// resource. |
| +class MediaCodecVideoDecoder : public Resource { |
| + public: |
| + /// Default constructor for creating an is_null() |
| + /// <code>MediaCodecVideoDecoder</code> object. |
| + MediaCodecVideoDecoder(); |
| + |
| + /// A constructor used to create a <code>MediaCodecVideoDecoder</code> and |
| + /// associate it with the provided <code>Instance</code>. |
| + /// @param[in] instance The instance with which this resource will be |
| + /// associated. |
| + explicit MediaCodecVideoDecoder(const InstanceHandle& instance); |
| + |
| + /// The copy constructor for <code>MediaCodecVideoDecoder</code>. |
| + /// @param[in] other A reference to a <code>MediaCodecVideoDecoder</code>. |
| + MediaCodecVideoDecoder(const MediaCodecVideoDecoder& other); |
| + |
| + /// Initializes a video decoder resource. This should only be called once, |
| + /// after construction and before any other methods. |
| + /// |
| + /// @param[in] graphics3d_context A <code>Graphics3D</code> resource to use |
|
dmichael (off chromium)
2014/04/21 17:25:34
nit: comment doesn't match param name
bbudge
2014/04/21 18:14:58
Done.
|
| + /// during decoding. |
| + /// @param[in] profile A <code>PP_MediaCodec_VideoProfile</code> specifying |
| + /// the video's codec profile. |
| + /// @param[in] callback A <code>CompletionCallback</code> to be called upon |
| + /// completion. |
| + /// |
| + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| + /// Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the |
| + /// requested profile is not supported. |
| + int32_t Initialize(const Graphics3D& context, |
| + PP_MediaCodec_VideoProfile profile, |
| + const CompletionCallback& cc); |
| + |
| + /// Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's |
| + /// |buffer|. The plugin should maintain the buffer and not call Decode() |
| + /// again until the decoder signals completion by returning PP_OK or running |
| + /// the |callback|. |
| + /// If the call to Decode() eventually causes GetPicture() to return a |
| + /// picture, the |picture_id| parameter will be copied into the returned |
| + /// picture. The plugin can use this to associate decoded pictures with |
| + /// Decode() calls (e.g. to assign timestamps or frame numbers to pictures.) |
| + /// |
| + /// @param[in] picture_id An identifier that can be used to associate calls to |
| + /// Decode() with decoded pictures returned by GetPicture(). |
| + /// @param[in] size Buffer size in bytes. |
| + /// @param[in] buffer Starting address of buffer. |
| + /// @param[in] callback A <code>CompletionCallback</code> to be called upon |
| + /// completion. |
| + /// |
| + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| + int32_t Decode(uint32_t picture_id, |
| + uint32_t size, |
| + const void* buffer, |
| + const CompletionCallback& cc); |
| + |
| + /// Gets the next picture from the decoder. The picture is valid after the |
| + /// decoder signals completion by returning PP_OK or running the callback. The |
| + /// plugin can call GetPicture() again after the decoder signals completion. |
| + /// When the plugin is finished using the picture, it should return it to the |
| + /// system by calling RecyclePicture(). |
| + /// |
| + /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be |
| + /// called upon completion. On success, the output will contain the picture. |
| + /// |
| + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| + int32_t GetPicture( |
| + const CompletionCallbackWithOutput<PP_MediaCodec_Picture>& cc); |
| + |
| + /// Recycles a picture that the plugin has received from the decoder. |
| + /// The plugin should call this as soon as it has finished using the texture |
| + /// so the decoder can decode more pictures. |
| + /// |
| + /// @param[in] picture A <code>PP_MediaCodec_Picture</code> to return to |
| + /// the decoder. |
| + void RecyclePicture(const PP_MediaCodec_Picture& picture); |
| + |
| + /// Flushes the decoder. The plugin should call this when it reaches the end |
| + /// of its video stream in order to stop cleanly. The decoder will run all |
| + /// pending calls to completion. The plugin should make no calls to the |
| + /// decoder other than RecyclePicture() until the decoder signals completion |
| + /// by running the callback. |
| + /// |
| + /// @param[in] callback A <code>CompletionCallback</code> to be called when |
| + /// flushing is complete. |
| + /// |
| + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| + int32_t Flush(const CompletionCallback& cc); |
| + |
| + /// Resets the decoder as quickly as possible. The plugin can call Reset to |
| + /// skip to another position in the video stream. Pending calls to Decode() |
| + /// and GetPicture()) are aborted, causing their callbacks to run with |
| + /// PP_ERROR_ABORTED. The plugin should not make any further calls to the |
| + /// decoder until the decoder signals completion by running the callback. |
| + /// |
| + /// @param[in] callback A <code>CompletionCallback</code> to be called upon |
| + /// completion. |
| + /// |
| + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| + int32_t Reset(const CompletionCallback& cc); |
| +}; |
| + |
| +} // namespace pp |
| + |
| +#endif // PPAPI_CPP_MEDIA_CODEC_VIDEO_DECODER_H_ |