Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: ppapi/api/ppb_video_encoder.idl

Issue 842293003: Pepper: Define PPB_VideoEncoder API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add |acceleration| field to PP_SupportedVideoProfile. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /* Copyright (c) 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 */
5
6 /**
7 * This file defines the <code>PPB_VideoEncoder</code> interface.
8 */
9
10 [generate_thunk]
11
12 label Chrome {
13 M42 = 0.1
14 };
15
16 /**
17 * Video encoder interface.
18 *
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.
34 *
35 * Available video codecs vary by platform.
36 * All: theora, vorbis, vp8.
37 * Chrome and ChromeOS: h264.
38 * ChromeOS: mpeg4.
39 */
40 interface PPB_VideoEncoder {
41 /**
42 * Creates a new video encoder resource.
43 *
44 * @param[in] instance A <code>PP_Instance</code> identifying the instance
45 * with the video encoder.
46 *
47 * @return A <code>PP_Resource</code> corresponding to a video encoder if
48 * successful or 0 otherwise.
49 */
50 PP_Resource Create(
51 [in] PP_Instance instance);
dmichael (off chromium) 2015/02/03 23:26:08 tiny nit: I don't know why we do this style in so
bbudge 2015/02/04 13:56:40 Done.
52
53 /**
54 * Determines if the given resource is a video encoder.
55 *
56 * @param[in] resource A <code>PP_Resource</code> identifying a resource.
57 *
58 * @return <code>PP_TRUE</code> if the resource is a
59 * <code>PPB_VideoEncoder</code>, <code>PP_FALSE</code> if the resource is
60 * invalid or some other type.
61 */
62 PP_Bool IsVideoEncoder(
63 [in] PP_Resource resource);
64
65 /**
66 * Gets an array of supported video encoder profiles.
67 * These can be used to choose a profile before calling Initialize().
68 *
69 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
70 * encoder.
71 * @param[in] output A <code>PP_ArrayOutput</code> to hold the supported
dmichael (off chromium) 2015/02/03 23:26:08 nit: s/hold/receive? The ArrayOutput doesn't reall
bbudge 2015/02/04 13:56:40 Done.
72 * <code>PP_SupportedVideoProfile</code> structs.
73 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
74 * completion.
75 *
76 * @return If >= 0, the number of supported profiles returned, otherwise an
77 * error code from <code>pp_errors.h</code>.
78 */
79 int32_t GetSupportedProfiles(
80 [in] PP_Resource video_encoder,
81 [in] PP_ArrayOutput output,
82 [in] PP_CompletionCallback callback);
83
84 /**
85 * Initializes a video encoder resource. The plugin should call Initialize()
86 * successfully before calling any of the functions below.
87 *
88 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
89 * encoder.
90 * @param[in] input_format The <code>PP_VideoFrame_Format</code> of the
91 * frames which will be encoded.
92 * @param[in] input_visible_size A <code>PP_Size</code> specifying the
93 * dimensions of the visible part of the input frames.
94 * @param[in] output_profile A <code>PP_VideoProfile</code> specifying the
95 * codec profile of the encoded output stream.
96 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
97 * whether to use a hardware accelerated or a software implementation.
98 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
99 * completion.
100 *
101 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
102 * Returns PP_ERROR_NOTSUPPORTED if video encoding is not available, or the
103 * requested codec profile is not supported.
104 */
105 int32_t Initialize(
106 [in] PP_Resource video_encoder,
107 [in] PP_VideoFrame_Format input_format,
108 [in] PP_Size input_visible_size,
109 [in] PP_VideoProfile output_profile,
110 [in] uint32_t initial_bitrate,
111 [in] PP_HardwareAcceleration acceleration,
112 [in] PP_CompletionCallback callback);
113
114 /**
115 * Gets the number of input video frames that the encoder may hold while
116 * encoding. If the plugin is providing the video frames, it should have at
117 * least this many available.
118 *
119 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
120 * encoder.
121 * @return An int32_t containing the number of frames required, or an error
122 * code from <code>pp_errors.h</code>.
123 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
124 */
125 int32_t GetFramesRequired(
126 [in] PP_Resource video_encoder);
127
128 /**
129 * Gets the coded size of the video frames required by the encoder. Coded
130 * size is the logical size of the input frames, in pixels. The encoder may
131 * have hardware alignment requirements that make this different from
132 * |input_visible_size|, as requested in the call to Initialize().
dmichael (off chromium) 2015/02/03 23:26:08 Does that mean that the plugin is responsible for
llandwerlin-old 2015/02/04 01:01:52 That means that frames returned through GetVideoFr
133 *
134 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
135 * encoder.
136 * @param[in] coded_size A <code>PP_Size</code> to hold the coded size.
137 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
138 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
139 */
140 int32_t GetFrameCodedSize(
141 [in] PP_Resource video_encoder,
142 [out] PP_Size coded_size);
143
144 /**
145 * Gets a blank video frame which can be filled with video data and passed
146 * to the encoder.
147 *
148 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
149 * encoder.
150 * @param[out] video_frame A blank <code>PPB_VideoFrame</code> resource.
151 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
152 * completion.
153 *
154 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
155 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
156 */
157 int32_t GetVideoFrame(
158 [in] PP_Resource video_encoder,
159 [out] PP_Resource video_frame,
160 [in] PP_CompletionCallback callback);
161
162 /**
163 * Encodes a video frame.
164 *
165 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
166 * encoder.
167 * @param[in] video_frame The <code>PPB_VideoFrame</code> to be encoded.
dmichael (off chromium) 2015/02/03 23:26:08 Do we "neuter" the frame resource so that the plug
llandwerlin-old 2015/02/04 01:01:52 That's currently what the implementation does, the
dmichael (off chromium) 2015/02/04 17:31:16 Makes sense. I'm glad there's at least some protec
168 * @param[in] force_keyframe A <code>PP_Bool> specifying whether the encoder
169 * should emit a key frame for this video frame.
170 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
171 * completion. Plugins that pass <code>PPB_VideoFrame</code> resources owned
172 * by other resources should wait for completion before reusing them.
173 *
174 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
175 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
176 */
177 int32_t Encode(
178 [in] PP_Resource video_encoder,
179 [in] PP_Resource video_frame,
180 [in] PP_Bool force_keyframe,
181 [in] PP_CompletionCallback callback);
182
183 /**
184 * Gets the next encoded bitstream buffer from the encoder.
185 *
186 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
187 * encoder.
188 * @param[out] bitstream_buffer A <code>PP_BitstreamBuffer</code> containing
189 * encoded video data.
190 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
191 * completion. The plugin can call GetBitstreamBuffer from the callback in
192 * order to continuously "pull" bitstream buffers from the encoder.
193 *
194 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
195 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
196 * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has
197 * not completed.
198 */
199 int32_t GetBitstreamBuffer(
200 [in] PP_Resource video_encoder,
201 [out] PP_BitstreamBuffer bitstream_buffer,
202 [in] PP_CompletionCallback callback);
203
204 /**
205 * Recycles a bitstream buffer back to the encoder.
206 *
207 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
208 * encoder.
209 * @param[in] bitstream_buffer A <code>PP_BitstreamBuffer</code> that is no
210 * longer needed by the plugin.
211 */
212 void RecycleBitstreamBuffer(
213 [in] PP_Resource video_encoder,
214 [in] PP_BitstreamBuffer bitstream_buffer);
215
216 /**
217 * Requests a change to encoding parameters. This is only a request,
218 * fulfilled on a best-effort basis.
219 *
220 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
221 * encoder.
222 * @param[in] bitrate The requested new bitrate, in bits per second.
223 * @param[in] framerate The requested new framerate, in frames per second.
224 */
225 void RequestEncodingParametersChange(
226 [in] PP_Resource video_encoder,
227 [in] uint32_t bitrate,
228 [in] uint32_t framerate);
229 };
dmichael (off chromium) 2015/02/03 23:26:08 We may want a Close() (or Reset) to make it easy t
llandwerlin-old 2015/02/04 01:01:52 I've argued for that, but it's up to bbudge@.
bbudge 2015/02/04 13:56:40 We've talked about a Destroy() method, but that is
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698