Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef PPAPI_CPP_MEDIA_CODEC_VIDEO_DECODER_H_ | |
| 6 #define PPAPI_CPP_MEDIA_CODEC_VIDEO_DECODER_H_ | |
| 7 | |
| 8 #include "ppapi/c/pp_media_codec.h" | |
| 9 #include "ppapi/c/pp_size.h" | |
| 10 #include "ppapi/cpp/completion_callback.h" | |
| 11 #include "ppapi/cpp/graphics_3d.h" | |
| 12 #include "ppapi/cpp/resource.h" | |
| 13 #include "ppapi/cpp/size.h" | |
| 14 | |
| 15 /// @file | |
| 16 /// This file defines the API to create and use a MediaCodecVideoDecoder | |
| 17 /// resource. | |
| 18 | |
| 19 struct PP_FileInfo; | |
| 20 | |
| 21 namespace pp { | |
| 22 | |
| 23 class InstanceHandle; | |
| 24 | |
| 25 /// The <code>MediaCodecVideoDecoder</code> class represents a video decoder | |
| 26 /// resource. | |
| 27 class MediaCodecVideoDecoder : public Resource { | |
| 28 public: | |
| 29 /// Default constructor for creating an is_null() | |
| 30 /// <code>MediaCodecVideoDecoder</code> object. | |
| 31 MediaCodecVideoDecoder(); | |
| 32 | |
| 33 /// A constructor used to create a <code>MediaCodecVideoDecoder</code> and | |
| 34 /// associate it with the provided <code>Instance</code>. | |
| 35 /// @param[in] instance The instance with which this resource will be | |
| 36 /// associated. | |
| 37 explicit MediaCodecVideoDecoder(const InstanceHandle& instance); | |
| 38 | |
| 39 /// The copy constructor for <code>MediaCodecVideoDecoder</code>. | |
| 40 /// @param[in] other A reference to a <code>MediaCodecVideoDecoder</code>. | |
| 41 MediaCodecVideoDecoder(const MediaCodecVideoDecoder& other); | |
| 42 | |
| 43 /// Initializes a video decoder resource. This should only be called once, | |
| 44 /// after construction and before any other methods. | |
| 45 /// | |
| 46 /// @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.
| |
| 47 /// during decoding. | |
| 48 /// @param[in] profile A <code>PP_MediaCodec_VideoProfile</code> specifying | |
| 49 /// the video's codec profile. | |
| 50 /// @param[in] callback A <code>CompletionCallback</code> to be called upon | |
| 51 /// completion. | |
| 52 /// | |
| 53 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 54 /// Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the | |
| 55 /// requested profile is not supported. | |
| 56 int32_t Initialize(const Graphics3D& context, | |
| 57 PP_MediaCodec_VideoProfile profile, | |
| 58 const CompletionCallback& cc); | |
| 59 | |
| 60 /// Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's | |
| 61 /// |buffer|. The plugin should maintain the buffer and not call Decode() | |
| 62 /// again until the decoder signals completion by returning PP_OK or running | |
| 63 /// the |callback|. | |
| 64 /// If the call to Decode() eventually causes GetPicture() to return a | |
| 65 /// picture, the |picture_id| parameter will be copied into the returned | |
| 66 /// picture. The plugin can use this to associate decoded pictures with | |
| 67 /// Decode() calls (e.g. to assign timestamps or frame numbers to pictures.) | |
| 68 /// | |
| 69 /// @param[in] picture_id An identifier that can be used to associate calls to | |
| 70 /// Decode() with decoded pictures returned by GetPicture(). | |
| 71 /// @param[in] size Buffer size in bytes. | |
| 72 /// @param[in] buffer Starting address of buffer. | |
| 73 /// @param[in] callback A <code>CompletionCallback</code> to be called upon | |
| 74 /// completion. | |
| 75 /// | |
| 76 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 77 int32_t Decode(uint32_t picture_id, | |
| 78 uint32_t size, | |
| 79 const void* buffer, | |
| 80 const CompletionCallback& cc); | |
| 81 | |
| 82 /// Gets the next picture from the decoder. The picture is valid after the | |
| 83 /// decoder signals completion by returning PP_OK or running the callback. The | |
| 84 /// plugin can call GetPicture() again after the decoder signals completion. | |
| 85 /// When the plugin is finished using the picture, it should return it to the | |
| 86 /// system by calling RecyclePicture(). | |
| 87 /// | |
| 88 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be | |
| 89 /// called upon completion. On success, the output will contain the picture. | |
| 90 /// | |
| 91 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 92 int32_t GetPicture( | |
| 93 const CompletionCallbackWithOutput<PP_MediaCodec_Picture>& cc); | |
| 94 | |
| 95 /// Recycles a picture that the plugin has received from the decoder. | |
| 96 /// The plugin should call this as soon as it has finished using the texture | |
| 97 /// so the decoder can decode more pictures. | |
| 98 /// | |
| 99 /// @param[in] picture A <code>PP_MediaCodec_Picture</code> to return to | |
| 100 /// the decoder. | |
| 101 void RecyclePicture(const PP_MediaCodec_Picture& picture); | |
| 102 | |
| 103 /// Flushes the decoder. The plugin should call this when it reaches the end | |
| 104 /// of its video stream in order to stop cleanly. The decoder will run all | |
| 105 /// pending calls to completion. The plugin should make no calls to the | |
| 106 /// decoder other than RecyclePicture() until the decoder signals completion | |
| 107 /// by running the callback. | |
| 108 /// | |
| 109 /// @param[in] callback A <code>CompletionCallback</code> to be called when | |
| 110 /// flushing is complete. | |
| 111 /// | |
| 112 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 113 int32_t Flush(const CompletionCallback& cc); | |
| 114 | |
| 115 /// Resets the decoder as quickly as possible. The plugin can call Reset to | |
| 116 /// skip to another position in the video stream. Pending calls to Decode() | |
| 117 /// and GetPicture()) are aborted, causing their callbacks to run with | |
| 118 /// PP_ERROR_ABORTED. The plugin should not make any further calls to the | |
| 119 /// decoder until the decoder signals completion by running the callback. | |
| 120 /// | |
| 121 /// @param[in] callback A <code>CompletionCallback</code> to be called upon | |
| 122 /// completion. | |
| 123 /// | |
| 124 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 125 int32_t Reset(const CompletionCallback& cc); | |
| 126 }; | |
| 127 | |
| 128 } // namespace pp | |
| 129 | |
| 130 #endif // PPAPI_CPP_MEDIA_CODEC_VIDEO_DECODER_H_ | |
| OLD | NEW |