OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 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 PPAPI_CPP_VIDEO_DECODER_H_ | 5 #ifndef PPAPI_CPP_VIDEO_DECODER_H_ |
6 #define PPAPI_CPP_VIDEO_DECODER_H_ | 6 #define PPAPI_CPP_VIDEO_DECODER_H_ |
7 | 7 |
8 #include "ppapi/c/pp_codecs.h" | 8 #include "ppapi/c/pp_codecs.h" |
9 #include "ppapi/c/pp_size.h" | 9 #include "ppapi/c/pp_size.h" |
10 #include "ppapi/cpp/completion_callback.h" | 10 #include "ppapi/cpp/completion_callback.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | 74 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
75 /// Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the | 75 /// Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the |
76 /// requested profile is not supported. In this case, the client may call | 76 /// requested profile is not supported. In this case, the client may call |
77 /// Initialize() again with different parameters to find a good configuration. | 77 /// Initialize() again with different parameters to find a good configuration. |
78 int32_t Initialize(const Graphics3D& graphics3d_context, | 78 int32_t Initialize(const Graphics3D& graphics3d_context, |
79 PP_VideoProfile profile, | 79 PP_VideoProfile profile, |
80 bool allow_software_fallback, | 80 bool allow_software_fallback, |
81 const CompletionCallback& callback); | 81 const CompletionCallback& callback); |
82 | 82 |
83 /// Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's | 83 /// Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's |
84 /// |buffer|. The plugin should maintain the buffer and not call Decode() | 84 /// |buffer|. The plugin should wait until the decoder signals completion by |
85 /// again until the decoder signals completion by returning PP_OK or by | 85 /// returning PP_OK or by running |callback| before calling Decode() again. |
86 /// running |callback|. | |
87 /// | 86 /// |
88 /// In general, each bitstream buffer should contain a demuxed bitstream frame | 87 /// In general, each bitstream buffer should contain a demuxed bitstream frame |
89 /// for the selected video codec. For example, H264 decoders expect to receive | 88 /// for the selected video codec. For example, H264 decoders expect to receive |
90 /// one AnnexB NAL unit, including the 4 byte start code prefix, while VP8 | 89 /// one AnnexB NAL unit, including the 4 byte start code prefix, while VP8 |
91 /// decoders expect to receive a bitstream frame without the IVF frame header. | 90 /// decoders expect to receive a bitstream frame without the IVF frame header. |
92 /// | 91 /// |
93 /// If the call to Decode() eventually results in a picture, the |decode_id| | 92 /// If the call to Decode() eventually results in a picture, the |decode_id| |
94 /// parameter is copied into the returned picture. The plugin can use this to | 93 /// parameter is copied into the returned picture. The plugin can use this to |
95 /// associate decoded pictures with Decode() calls (e.g. to assign timestamps | 94 /// associate decoded pictures with Decode() calls (e.g. to assign timestamps |
96 /// or frame numbers to pictures.) This value is opaque to the API so the | 95 /// or frame numbers to pictures.) This value is opaque to the API so the |
97 /// plugin is free to pass any value. | 96 /// plugin is free to pass any value. |
98 /// | 97 /// |
99 /// @param[in] decode_id An optional value, chosen by the plugin, that can be | 98 /// @param[in] decode_id An optional value, chosen by the plugin, that can be |
100 /// used to associate calls to Decode() with decoded pictures returned by | 99 /// used to associate calls to Decode() with decoded pictures returned by |
101 /// GetPicture(). | 100 /// GetPicture(). |
102 /// @param[in] size Buffer size in bytes. | 101 /// @param[in] size Buffer size in bytes. |
103 /// @param[in] buffer Starting address of buffer. | 102 /// @param[in] buffer Starting address of buffer. |
104 /// @param[in] callback A <code>CompletionCallback</code> to be called on | 103 /// @param[in] callback A <code>CompletionCallback</code> to be called on |
105 /// completion. | 104 /// completion. |
106 /// | 105 /// |
107 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | 106 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 107 /// Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Flush() |
| 108 /// or Reset() call is pending. |
| 109 /// Returns PP_ERROR_INPROGRESS if there is another Decode() call pending. |
| 110 /// Returns PP_ERROR_NOMEMORY if a bitstream buffer can't be created. |
| 111 /// Returns PP_ERROR_ABORTED when Reset() is called while Decode() is pending. |
108 int32_t Decode(uint32_t decode_id, | 112 int32_t Decode(uint32_t decode_id, |
109 uint32_t size, | 113 uint32_t size, |
110 const void* buffer, | 114 const void* buffer, |
111 const CompletionCallback& callback); | 115 const CompletionCallback& callback); |
112 | 116 |
113 /// Gets the next picture from the decoder. The picture is valid after the | 117 /// Gets the next picture from the decoder. The picture is valid after the |
114 /// decoder signals completion by returning PP_OK or running |callback|. The | 118 /// decoder signals completion by returning PP_OK or running |callback|. The |
115 /// plugin can call GetPicture() again after the decoder signals completion. | 119 /// plugin can call GetPicture() again after the decoder signals completion. |
116 /// When the plugin is finished using the picture, it should return it to the | 120 /// When the plugin is finished using the picture, it should return it to the |
117 /// system by calling RecyclePicture(). | 121 /// system by calling RecyclePicture(). |
118 /// | 122 /// |
119 /// @param[in] video_decoder A <code>PP_Resource</code> identifying the video | 123 /// @param[in] video_decoder A <code>PP_Resource</code> identifying the video |
120 /// decoder. | 124 /// decoder. |
121 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be | 125 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be |
122 /// called on completion, and on success, to hold the picture descriptor. | 126 /// called on completion, and on success, to hold the picture descriptor. |
123 /// | 127 /// |
124 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | 128 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
125 /// Returns PP_OK if a picture is available. | 129 /// Returns PP_ERROR_FAILED if the decoder isn't initialized or if a Reset() |
| 130 /// call is pending. |
| 131 /// Returns PP_ERROR_INPROGRESS if there is another GetPicture() call pending. |
126 /// Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush() | 132 /// Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush() |
127 /// completes while GetPicture() is pending. | 133 /// completes while GetPicture() is pending. |
128 int32_t GetPicture( | 134 int32_t GetPicture( |
129 const CompletionCallbackWithOutput<PP_VideoPicture>& callback); | 135 const CompletionCallbackWithOutput<PP_VideoPicture>& callback); |
130 | 136 |
131 /// Recycles a picture that the plugin has received from the decoder. | 137 /// Recycles a picture that the plugin has received from the decoder. |
132 /// The plugin should call this as soon as it has finished using the texture | 138 /// The plugin should call this as soon as it has finished using the texture |
133 /// so the decoder can decode more pictures. | 139 /// so the decoder can decode more pictures. |
134 /// | 140 /// |
135 /// @param[in] picture A <code>PP_VideoPicture</code> to return to the | 141 /// @param[in] picture A <code>PP_VideoPicture</code> to return to the |
136 /// decoder. | 142 /// decoder. |
137 void RecyclePicture(const PP_VideoPicture& picture); | 143 void RecyclePicture(const PP_VideoPicture& picture); |
138 | 144 |
139 /// Flushes the decoder. The plugin should call this when it reaches the end | 145 /// Flushes the decoder. The plugin should call Flush() when it reaches the |
140 /// of its video stream in order to stop cleanly. The decoder will run all | 146 /// end of its video stream in order to stop cleanly. The decoder will run any |
141 /// pending calls to completion. The plugin should make no further calls to | 147 /// pending Decode() call to completion. The plugin should make no further |
142 /// the decoder other than GetPicture() and RecyclePicture() until the decoder | 148 /// calls to the decoder other than GetPicture() and RecyclePicture() until |
143 /// signals completion by running the callback. Just before completion, any | 149 /// the decoder signals completion by running |callback|. Just before |
144 /// pending GetPicture() call will complete by running the callback with | 150 /// completion, any pending GetPicture() call will complete by running its |
145 /// result PP_ERROR_ABORTED to signal that no more pictures are available. | 151 /// callback with result PP_ERROR_ABORTED to signal that no more pictures are |
| 152 /// available. The plugin should recycle any pictures it is using before |
| 153 /// resuming decoding. |
146 /// | 154 /// |
147 /// @param[in] callback A <code>CompletionCallback</code> to be called on | 155 /// @param[in] callback A <code>CompletionCallback</code> to be called on |
148 /// completion. | 156 /// completion. |
149 /// | 157 /// |
150 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | 158 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 159 /// Returns PP_ERROR_FAILED if the decoder isn't initialized. |
151 int32_t Flush(const CompletionCallback& callback); | 160 int32_t Flush(const CompletionCallback& callback); |
152 | 161 |
153 /// Resets the decoder as quickly as possible. The plugin can call Reset() to | 162 /// Resets the decoder as quickly as possible. The plugin can call Reset() to |
154 /// skip to another position in the video stream. Pending calls to Decode() | 163 /// skip to another position in the video stream. After Reset() returns, any |
155 /// and GetPicture()) are immediately aborted, causing their callbacks to run | 164 /// pending calls to Decode() and GetPicture()) abort, causing their callbacks |
156 /// with PP_ERROR_ABORTED. The plugin should not make any further calls to the | 165 /// to run with PP_ERROR_ABORTED. The plugin should not make further calls to |
157 /// decoder until the decoder signals completion by running |callback|. | 166 /// the decoder until the decoder signals completion by running |callback|. |
| 167 /// The pictures in use by the plugin remain valid until decoding is resumed, |
| 168 /// but need not be recycled. |
158 /// | 169 /// |
159 /// @param[in] callback A <code>CompletionCallback</code> to be called on | 170 /// @param[in] callback A <code>CompletionCallback</code> to be called on |
160 /// completion. | 171 /// completion. |
161 /// | 172 /// |
162 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | 173 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
163 int32_t Reset(const CompletionCallback& callback); | 174 /// Returns PP_ERROR_FAILED if the decoder isn't initialized. |
| 175 int32_t Reset(const CompletionCallback& callback); |
164 }; | 176 }; |
165 | 177 |
166 } // namespace pp | 178 } // namespace pp |
167 | 179 |
168 #endif // PPAPI_CPP_VIDEO_DECODER_H_ | 180 #endif // PPAPI_CPP_VIDEO_DECODER_H_ |
OLD | NEW |