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

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: Update and add comments. 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 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);
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
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(
llandwerlin-old 2015/01/15 11:19:15 Do we need to prevent concurrent calls to this met
bbudge 2015/01/15 12:31:50 It's simpler, so yes. We can return INPROGRESS if
80 [in] PP_Resource video_encoder,
81 [in] PP_ArrayOutput output,
82 [in] PP_CompletionCallback callback);
83
84 /**
85 * Initializes a video encoder resource. This should be called after Create()
86 * and GetSupportedProfiles() and before any 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 * Returns PP_ERROR_NOMEMORY if frame and bitstream buffers can't be created.
105 */
106 int32_t Initialize(
107 [in] PP_Resource video_encoder,
108 [in] PP_VideoFrame_Format input_format,
109 [in] PP_Size input_visible_size,
llandwerlin-old 2015/01/15 11:32:53 I forgot, but I think we might also need to add a
bbudge 2015/01/15 12:31:50 This brings up some interesting questions: 1) Can
llandwerlin-old 2015/01/15 14:04:43 1) Only at initialization. 2) My understanding i
110 [in] PP_VideoProfile output_profile,
111 [in] uint32_t initial_bitrate,
112 [in] PP_HardwareAcceleration acceleration,
113 [in] PP_CompletionCallback callback);
114
115 /**
116 * Gets the number of input video frames that the encoder may hold while
117 * encoding. If the plugin is providing the video frames, it should have at
118 * least this many available. This must be called after Initialize().
119 *
120 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
121 * encoder.
122 * @return An int32_t containing the number of frames required, or an error
123 * code from <code>pp_errors.h</code>.
124 */
125 int32_t GetInputFramesRequired(
llandwerlin-old 2015/01/15 11:22:27 We should also add here that it's going to fail un
bbudge 2015/01/15 21:51:08 Done.
126 [in] PP_Resource video_encoder);
127
128 /**
129 * Gets a blank video frame which can be filled with video data and passed
130 * to the encoder.
131 *
132 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
133 * encoder.
134 * @param[out] video_frame A blank <code>PPB_VideoFrame</code> resource.
135 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
136 * completion.
137 *
138 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
139 */
140 int32_t GetVideoFrame(
llandwerlin-old 2015/01/15 11:22:28 We should also add here that it's going to fail un
bbudge 2015/01/15 21:51:09 Done.
141 [in] PP_Resource video_encoder,
142 [out] PP_Resource video_frame,
143 [in] PP_CompletionCallback callback);
144
145 /**
146 * Encodes a video frame.
147 *
148 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
149 * encoder.
150 * @param[in] video_frame The <code>PPB_VideoFrame</code> to be encoded.
151 * @param[in] force_keyframe A <code>PP_Bool> specifying whether the encoder
152 * should emit a key frame for this video frame.
153 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
154 * completion. Plugins that pass <code>PPB_VideoFrame</code> resources owned
155 * by other resources should wait for completion before reusing them.
156 *
157 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
158 */
159 int32_t Encode(
llandwerlin-old 2015/01/15 11:22:28 Will fail unless Initialize succeeds.
bbudge 2015/01/15 21:51:09 Done.
160 [in] PP_Resource video_encoder,
161 [in] PP_Resource video_frame,
162 [in] PP_Bool force_keyframe,
163 [in] PP_CompletionCallback callback);
164
165 /**
166 * Gets the next encoded bitstream buffer from the encoder.
167 *
168 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
169 * encoder.
170 * @param[out] bitstream_buffer A <code>PP_BitstreamBuffer</code> containing
171 * encoded video data.
172 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
173 * completion. The plugin can call GetBitstreamBuffer from the callback in
174 * order to continuously "pull" bitstream buffers from the encoder.
175 *
176 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
177 */
llandwerlin-old 2015/01/15 11:19:15 We should add that multiple calls without waiting
bbudge 2015/01/15 21:51:09 Done.
178 int32_t GetBitstreamBuffer(
179 [in] PP_Resource video_encoder,
180 [out] PP_BitstreamBuffer bitstream_buffer,
181 [in] PP_CompletionCallback callback);
182
183 /**
184 * Recycles a bitstream buffer back to the encoder.
185 *
186 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
187 * encoder.
188 * @param[in] bitstream_buffer A <code>PP_BitstreamBuffer</code> that is no
189 * longer needed by the plugin.
190 */
191 void RecycleBitstreamBuffer(
192 [in] PP_Resource video_encoder,
193 [in] PP_BitstreamBuffer bitstream_buffer);
194
195 /**
196 * Requests a change to encoding parameters. This is only a request,
197 * fulfilled on a best-effort basis.
198 *
199 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
200 * encoder.
201 * @param[in] bitrate The requested new bitrate, in bits per second.
202 * @param[in] framerate The requested new framerate, in frames per second.
203 */
204 void RequestEncodingParametersChange(
205 [in] PP_Resource video_encoder,
206 [in] uint32_t bitrate,
207 [in] uint32_t framerate);
208 };
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