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

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

Issue 859313002: Pepper: Define PPB_VideoEncoder API + Implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « ppapi/api/pp_codecs.idl ('k') | ppapi/c/pp_codecs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 [channel=dev] M42 = 0.1
14 };
15
16 /**
17 * Video encoder interface.
18 * This interface is still in development (Dev API status) and may change,
19 * so is only supported on Dev channel and Canary currently.
20 *
21 * Typical usage:
22 * - Call Create() to create a new video encoder resource.
23 * - Call GetSupportedFormats() to determine which codecs and profiles are
24 * available.
25 * - Call Initialize() to initialize the encoder for a supported profile.
26 * - Call GetVideoFrame() to get a blank frame and fill it in, or get a video
27 * frame from another resource, e.g. <code>PPB_MediaStreamVideoTrack</code>.
28 * - Call Encode() to push the video frame to the encoder. If an external frame
29 * is pushed, wait for completion to recycle the frame.
30 * - Call GetBitstreamBuffer() continuously (waiting for each previous call to
31 * complete) to pull encoded pictures from the encoder.
32 * - Call RecycleBitstreamBuffer() after consuming the data in the bitstream
33 * buffer.
34 * - To destroy the encoder, the plugin should release all of its references to
35 * it. Any pending callbacks will abort before the encoder is destroyed.
36 *
37 * Available video codecs vary by platform.
38 * All: theora, vorbis, vp8.
39 * Chrome and ChromeOS: h264.
40 * ChromeOS: mpeg4.
41 */
42 interface PPB_VideoEncoder {
43 /**
44 * Creates a new video encoder resource.
45 *
46 * @param[in] instance A <code>PP_Instance</code> identifying the instance
47 * with the video encoder.
48 *
49 * @return A <code>PP_Resource</code> corresponding to a video encoder if
50 * successful or 0 otherwise.
51 */
52 PP_Resource Create(
53 [in] PP_Instance instance);
54
55 /**
56 * Determines if the given resource is a video encoder.
57 *
58 * @param[in] resource A <code>PP_Resource</code> identifying a resource.
59 *
60 * @return <code>PP_TRUE</code> if the resource is a
61 * <code>PPB_VideoEncoder</code>, <code>PP_FALSE</code> if the resource is
62 * invalid or some other type.
63 */
64 PP_Bool IsVideoEncoder(
65 [in] PP_Resource resource);
66
67 /**
68 * Gets an array of supported video encoder profiles.
69 * These can be used to choose a profile before calling Initialize().
70 *
71 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
72 * encoder.
73 * @param[in] output A <code>PP_ArrayOutput</code> to hold the supported
74 * <code>PP_SupportedVideoProfile</code> structs.
75 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
76 * completion.
77 *
78 * @return If >= 0, the number of supported profiles returned, otherwise an
79 * error code from <code>pp_errors.h</code>.
80 */
81 int32_t GetSupportedProfiles(
82 [in] PP_Resource video_encoder,
83 [in] PP_ArrayOutput output,
84 [in] PP_CompletionCallback callback);
85
86 /**
87 * Initializes a video encoder resource. The plugin should call Initialize()
88 * successfully before calling any of the functions below.
89 *
90 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
91 * encoder.
92 * @param[in] input_format The <code>PP_VideoFrame_Format</code> of the
93 * frames which will be encoded.
94 * @param[in] input_visible_size A <code>PP_Size</code> specifying the
95 * dimensions of the visible part of the input frames.
96 * @param[in] output_profile A <code>PP_VideoProfile</code> specifying the
97 * codec profile of the encoded output stream.
98 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
99 * whether to use a hardware accelerated or a software implementation.
100 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
101 * completion.
102 *
103 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
104 * Returns PP_ERROR_NOTSUPPORTED if video encoding is not available, or the
105 * requested codec profile is not supported.
106 */
107 int32_t Initialize(
108 [in] PP_Resource video_encoder,
109 [in] PP_VideoFrame_Format input_format,
110 [in] PP_Size input_visible_size,
111 [in] PP_VideoProfile output_profile,
112 [in] uint32_t initial_bitrate,
113 [in] PP_HardwareAcceleration acceleration,
114 [in] PP_CompletionCallback callback);
115
116 /**
117 * Gets the number of input video frames that the encoder may hold while
118 * encoding. If the plugin is providing the video frames, it should have at
119 * least this many available.
120 *
121 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
122 * encoder.
123 * @return An int32_t containing the number of frames required, or an error
124 * code from <code>pp_errors.h</code>.
125 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
126 */
127 int32_t GetFramesRequired(
128 [in] PP_Resource video_encoder);
129
130 /**
131 * Gets the coded size of the video frames required by the encoder. Coded
132 * size is the logical size of the input frames, in pixels. The encoder may
133 * have hardware alignment requirements that make this different from
134 * |input_visible_size|, as requested in the call to Initialize().
135 *
136 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
137 * encoder.
138 * @param[in] coded_size A <code>PP_Size</code> to hold the coded size.
139 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
140 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
141 */
142 int32_t GetFrameCodedSize(
143 [in] PP_Resource video_encoder,
144 [out] PP_Size coded_size);
145
146 /**
147 * Gets a blank video frame which can be filled with video data and passed
148 * to the encoder.
149 *
150 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
151 * encoder.
152 * @param[out] video_frame A blank <code>PPB_VideoFrame</code> resource.
153 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
154 * completion.
155 *
156 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
157 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
158 */
159 int32_t GetVideoFrame(
160 [in] PP_Resource video_encoder,
161 [out] PP_Resource video_frame,
162 [in] PP_CompletionCallback callback);
163
164 /**
165 * Encodes a video frame.
166 *
167 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
168 * encoder.
169 * @param[in] video_frame The <code>PPB_VideoFrame</code> to be encoded.
170 * @param[in] force_keyframe A <code>PP_Bool> specifying whether the encoder
171 * should emit a key frame for this video frame.
172 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
173 * completion. Plugins that pass <code>PPB_VideoFrame</code> resources owned
174 * by other resources should wait for completion before reusing them.
175 *
176 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
177 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
178 */
179 int32_t Encode(
180 [in] PP_Resource video_encoder,
181 [in] PP_Resource video_frame,
182 [in] PP_Bool force_keyframe,
183 [in] PP_CompletionCallback callback);
184
185 /**
186 * Gets the next encoded bitstream buffer from the encoder.
187 *
188 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
189 * encoder.
190 * @param[out] bitstream_buffer A <code>PP_BitstreamBuffer</code> containing
191 * encoded video data.
192 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
193 * completion. The plugin can call GetBitstreamBuffer from the callback in
194 * order to continuously "pull" bitstream buffers from the encoder.
195 *
196 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
197 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
198 * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has
199 * not completed.
200 */
201 int32_t GetBitstreamBuffer(
202 [in] PP_Resource video_encoder,
203 [out] PP_BitstreamBuffer bitstream_buffer,
204 [in] PP_CompletionCallback callback);
205
206 /**
207 * Recycles a bitstream buffer back to the encoder.
208 *
209 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
210 * encoder.
211 * @param[in] bitstream_buffer A <code>PP_BitstreamBuffer</code> that is no
212 * longer needed by the plugin.
213 */
214 void RecycleBitstreamBuffer(
215 [in] PP_Resource video_encoder,
216 [in] PP_BitstreamBuffer bitstream_buffer);
217
218 /**
219 * Requests a change to encoding parameters. This is only a request,
220 * fulfilled on a best-effort basis.
221 *
222 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
223 * encoder.
224 * @param[in] bitrate The requested new bitrate, in bits per second.
225 * @param[in] framerate The requested new framerate, in frames per second.
226 */
227 void RequestEncodingParametersChange(
228 [in] PP_Resource video_encoder,
229 [in] uint32_t bitrate,
230 [in] uint32_t framerate);
231 };
OLDNEW
« no previous file with comments | « ppapi/api/pp_codecs.idl ('k') | ppapi/c/pp_codecs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698