Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / ppapi / api / ppb_video_encoder.idl
blob1796f91b91adadae7a8647dc2b0889edcfbdd708
1 /* Copyright 2015 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 */
6 /**
7 * This file defines the <code>PPB_VideoEncoder</code> interface.
8 */
10 [generate_thunk]
12 label Chrome {
13 [channel=dev] M42 = 0.1
16 /**
17 * Video encoder interface.
19 * Typical usage:
20 * - Call Create() to create a new video encoder resource.
21 * - Call GetSupportedFormats() to determine which codecs and profiles are
22 * available.
23 * - Call Initialize() to initialize the encoder for a supported profile.
24 * - Call GetVideoFrame() to get a blank frame and fill it in, or get a video
25 * frame from another resource, e.g. <code>PPB_MediaStreamVideoTrack</code>.
26 * - Call Encode() to push the video frame to the encoder. If an external frame
27 * is pushed, wait for completion to recycle the frame.
28 * - Call GetBitstreamBuffer() continuously (waiting for each previous call to
29 * complete) to pull encoded pictures from the encoder.
30 * - Call RecycleBitstreamBuffer() after consuming the data in the bitstream
31 * buffer.
32 * - To destroy the encoder, the plugin should release all of its references to
33 * it. Any pending callbacks will abort before the encoder is destroyed.
35 * Available video codecs vary by platform.
36 * All: theora, vorbis, vp8.
37 * Chrome and ChromeOS: h264.
38 * ChromeOS: mpeg4.
40 interface PPB_VideoEncoder {
41 /**
42 * Creates a new video encoder resource.
44 * @param[in] instance A <code>PP_Instance</code> identifying the instance
45 * with the video encoder.
47 * @return A <code>PP_Resource</code> corresponding to a video encoder if
48 * successful or 0 otherwise.
50 PP_Resource Create([in] PP_Instance instance);
52 /**
53 * Determines if the given resource is a video encoder.
55 * @param[in] resource A <code>PP_Resource</code> identifying a resource.
57 * @return <code>PP_TRUE</code> if the resource is a
58 * <code>PPB_VideoEncoder</code>, <code>PP_FALSE</code> if the resource is
59 * invalid or some other type.
61 PP_Bool IsVideoEncoder([in] PP_Resource resource);
63 /**
64 * Gets an array of supported video encoder profiles.
65 * These can be used to choose a profile before calling Initialize().
67 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
68 * encoder.
69 * @param[in] output A <code>PP_ArrayOutput</code> to receive the supported
70 * <code>PP_VideoProfileDescription</code> structs.
71 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
72 * completion.
74 * @return If >= 0, the number of supported profiles returned, otherwise an
75 * error code from <code>pp_errors.h</code>.
77 int32_t GetSupportedProfiles([in] PP_Resource video_encoder,
78 [in] PP_ArrayOutput output,
79 [in] PP_CompletionCallback callback);
81 /**
82 * Initializes a video encoder resource. The plugin should call Initialize()
83 * successfully before calling any of the functions below.
85 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
86 * encoder.
87 * @param[in] input_format The <code>PP_VideoFrame_Format</code> of the
88 * frames which will be encoded.
89 * @param[in] input_visible_size A <code>PP_Size</code> specifying the
90 * dimensions of the visible part of the input frames.
91 * @param[in] output_profile A <code>PP_VideoProfile</code> specifying the
92 * codec profile of the encoded output stream.
93 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
94 * whether to use a hardware accelerated or a software implementation.
95 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
96 * completion.
98 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
99 * Returns PP_ERROR_NOTSUPPORTED if video encoding is not available, or the
100 * requested codec profile is not supported.
102 int32_t Initialize([in] PP_Resource video_encoder,
103 [in] PP_VideoFrame_Format input_format,
104 [in] PP_Size input_visible_size,
105 [in] PP_VideoProfile output_profile,
106 [in] uint32_t initial_bitrate,
107 [in] PP_HardwareAcceleration acceleration,
108 [in] PP_CompletionCallback callback);
111 * Gets the number of input video frames that the encoder may hold while
112 * encoding. If the plugin is providing the video frames, it should have at
113 * least this many available.
115 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
116 * encoder.
117 * @return An int32_t containing the number of frames required, or an error
118 * code from <code>pp_errors.h</code>.
119 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
121 int32_t GetFramesRequired([in] PP_Resource video_encoder);
124 * Gets the coded size of the video frames required by the encoder. Coded
125 * size is the logical size of the input frames, in pixels. The encoder may
126 * have hardware alignment requirements that make this different from
127 * |input_visible_size|, as requested in the call to Initialize().
129 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
130 * encoder.
131 * @param[in] coded_size A <code>PP_Size</code> to hold the coded size.
132 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
133 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
135 int32_t GetFrameCodedSize([in] PP_Resource video_encoder,
136 [out] PP_Size coded_size);
139 * Gets a blank video frame which can be filled with video data and passed
140 * to the encoder.
142 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
143 * encoder.
144 * @param[out] video_frame A blank <code>PPB_VideoFrame</code> resource.
145 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
146 * completion.
148 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
149 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
151 int32_t GetVideoFrame([in] PP_Resource video_encoder,
152 [out] PP_Resource video_frame,
153 [in] PP_CompletionCallback callback);
156 * Encodes a video frame.
158 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
159 * encoder.
160 * @param[in] video_frame The <code>PPB_VideoFrame</code> to be encoded.
161 * @param[in] force_keyframe A <code>PP_Bool> specifying whether the encoder
162 * should emit a key frame for this video frame.
163 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
164 * completion. Plugins that pass <code>PPB_VideoFrame</code> resources owned
165 * by other resources should wait for completion before reusing them.
167 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
168 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
170 int32_t Encode([in] PP_Resource video_encoder,
171 [in] PP_Resource video_frame,
172 [in] PP_Bool force_keyframe,
173 [in] PP_CompletionCallback callback);
176 * Gets the next encoded bitstream buffer from the encoder.
178 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
179 * encoder.
180 * @param[out] bitstream_buffer A <code>PP_BitstreamBuffer</code> containing
181 * encoded video data.
182 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
183 * completion. The plugin can call GetBitstreamBuffer from the callback in
184 * order to continuously "pull" bitstream buffers from the encoder.
186 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
187 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
188 * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has
189 * not completed.
191 int32_t GetBitstreamBuffer([in] PP_Resource video_encoder,
192 [out] PP_BitstreamBuffer bitstream_buffer,
193 [in] PP_CompletionCallback callback);
196 * Recycles a bitstream buffer back to the encoder.
198 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
199 * encoder.
200 * @param[in] bitstream_buffer A <code>PP_BitstreamBuffer</code> that is no
201 * longer needed by the plugin.
203 void RecycleBitstreamBuffer([in] PP_Resource video_encoder,
204 [in] PP_BitstreamBuffer bitstream_buffer);
207 * Requests a change to encoding parameters. This is only a request,
208 * fulfilled on a best-effort basis.
210 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
211 * encoder.
212 * @param[in] bitrate The requested new bitrate, in bits per second.
213 * @param[in] framerate The requested new framerate, in frames per second.
215 void RequestEncodingParametersChange([in] PP_Resource video_encoder,
216 [in] uint32_t bitrate,
217 [in] uint32_t framerate);
220 * Closes the video encoder, and cancels any pending encodes. Any pending
221 * callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> . It is
222 * not valid to call any encoder functions after a call to this method.
223 * <strong>Note:</strong> Destroying the video encoder closes it implicitly,
224 * so you are not required to call Close().
226 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
227 * encoder.
229 void Close([in] PP_Resource video_encoder);