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

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

Issue 1151973003: ppapi: implement PPB_AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Windows fixes in proxy code Created 5 years, 6 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 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_AudioEncoder</code> interface.
8 */
9
10 [generate_thunk]
11
12 label Chrome {
13 [channel=dev] M44 = 0.1
14 };
15
16 /**
17 * Audio encoder interface.
18 *
19 * Typical usage:
20 * - Call Create() to create a new audio 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 GetBuffer() to get a blank frame and fill it in, or get an audio
25 * frame from another resource, e.g. <code>PPB_MediaStreamAudioTrack</code>.
26 * - Call Encode() to push the audio buffer to the encoder. If an external
27 * buffer is pushed, wait for completion to recycle the frame.
28 * - Call GetBitstreamBuffer() continuously (waiting for each previous call to
29 * complete) to pull encoded buffers 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 audio codecs vary by platform.
36 * All: opus.
37 */
38 interface PPB_AudioEncoder {
39 /**
40 * Creates a new audio encoder resource.
41 *
42 * @param[in] instance A <code>PP_Instance</code> identifying the instance
43 * with the audio encoder.
44 *
45 * @return A <code>PP_Resource</code> corresponding to an audio encoder if
46 * successful or 0 otherwise.
47 */
48 PP_Resource Create([in] PP_Instance instance);
49
50 /**
51 * Determines if the given resource is an audio encoder.
52 *
53 * @param[in] resource A <code>PP_Resource</code> identifying a resource.
54 *
55 * @return <code>PP_TRUE</code> if the resource is a
56 * <code>PPB_AudioEncoder</code>, <code>PP_FALSE</code> if the resource is
57 * invalid or some other type.
58 */
59 PP_Bool IsAudioEncoder([in] PP_Resource resource);
60
61 /**
62 * Gets an array of supported audio encoder profiles.
63 * These can be used to choose a profile before calling Initialize().
64 *
65 * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
66 * encoder.
67 * @param[in] output A <code>PP_ArrayOutput</code> to receive the supported
68 * <code>PP_AudioProfileDescription</code> structs.
69 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
70 * completion.
71 *
72 * @return If >= 0, the number of supported profiles returned, otherwise an
73 * error code from <code>pp_errors.h</code>.
74 */
75 int32_t GetSupportedProfiles([in] PP_Resource audio_encoder,
76 [in] PP_ArrayOutput output,
77 [in] PP_CompletionCallback callback);
78
79 /**
80 * Initializes an audio encoder resource. The plugin should call Initialize()
81 * successfully before calling any of the functions below.
82 *
83 * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
84 * encoder.
85 * @param[in] channels The number of audio channels to encode.
86 * @param[in] input_sampling_rate The sampling rate of the input audio buffer.
87 * @param[in] input_sample_size The sample size of the input audio buffer.
88 * @param[in] output_profile A <code>PP_AudioProfile</code> specifying the
89 * codec profile of the encoded output stream.
90 * @param[in] initial_bitrate The initial bitrate for the encoder.
91 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
92 * whether to use a hardware accelerated or a software implementation.
93 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
94 * completion.
95 *
96 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
97 * Returns PP_ERROR_NOTSUPPORTED if audio encoding is not available, or the
98 * requested codec profile is not supported.
99 */
100 int32_t Initialize([in] PP_Resource audio_encoder,
101 [in] uint32_t channels,
102 [in] PP_AudioBuffer_SampleRate input_sample_rate,
103 [in] PP_AudioBuffer_SampleSize input_sample_size,
104 [in] PP_AudioProfile output_profile,
105 [in] uint32_t initial_bitrate,
106 [in] PP_HardwareAcceleration acceleration,
107 [in] PP_CompletionCallback callback);
108
109 /**
110 * Gets the number of audio samples per channel that audio buffers
111 * must contain in order to be processed by the encoder. This will
112 * be the number of samples per channels contained in buffers
113 * returned by GetBuffer().
114 *
115 * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
116 * encoder.
117 * @return An int32_t containing the number of samples required, or an error
118 * code from <code>pp_errors.h</code>.
119 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
120 */
121 int32_t GetNumberOfSamples([in] PP_Resource audio_encoder);
122
123 /**
124 * Gets a blank audio buffer (with metadata given by the Initialize()
125 * call) which can be filled with audio data and passed to the
126 * encoder.
127 *
128 * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
129 * encoder.
130 * @param[out] audio_buffer A blank <code>PPB_AudioBuffer</code> resource.
131 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
132 * completion.
133 *
134 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
135 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
136 */
137 int32_t GetBuffer([in] PP_Resource audio_encoder,
138 [out] PP_Resource audio_buffer,
139 [in] PP_CompletionCallback callback);
140
141 /**
142 * Encodes an audio buffer.
143 *
144 * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
145 * encoder.
146 * @param[in] audio_buffer The <code>PPB_AudioBuffer</code> to be encoded.
147 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
148 * completion. Plugins that pass <code>PPB_AudioBuffer</code> resources owned
149 * by other resources should wait for completion before reusing them.
150 *
151 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
152 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
153 */
154 int32_t Encode([in] PP_Resource audio_encoder,
155 [in] PP_Resource audio_buffer,
156 [in] PP_CompletionCallback callback);
157
158 /**
159 * Gets the next encoded bitstream buffer from the encoder.
160 *
161 * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
162 * encoder.
163 * @param[out] bitstream_buffer A <code>PP_BitstreamBuffer</code> containing
164 * encoded audio data.
165 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
166 * completion. The plugin can call GetBitstreamBuffer from the callback in
167 * order to continuously "pull" bitstream buffers from the encoder.
168 *
169 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
170 * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
171 * Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has
172 * not completed.
173 */
174 int32_t GetBitstreamBuffer([in] PP_Resource audio_encoder,
175 [out] PP_AudioBitstreamBuffer bitstream_buffer,
176 [in] PP_CompletionCallback callback);
177
178 /**
179 * Recycles a bitstream buffer back to the encoder.
180 *
181 * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
182 * encoder.
183 * @param[in] bitstream_buffer A <code>PP_BitstreamBuffer</code> that is no
184 * longer needed by the plugin.
185 */
186 void RecycleBitstreamBuffer([in] PP_Resource audio_encoder,
187 [in] PP_AudioBitstreamBuffer bitstream_buffer);
188
189 /**
190 * Requests a change to the encoding bitrate. This is only a request,
191 * fulfilled on a best-effort basis.
192 *
193 * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
194 * encoder.
195 * @param[in] bitrate The requested new bitrate, in bits per second.
196 */
197 void RequestBitrateChange([in] PP_Resource audio_encoder,
198 [in] uint32_t bitrate);
199
200 /**
201 * Closes the audio encoder, and cancels any pending encodes. Any pending
202 * callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> . It is
203 * not valid to call any encoder functions after a call to this method.
204 * <strong>Note:</strong> Destroying the audio encoder closes it implicitly,
205 * so you are not required to call Close().
206 *
207 * @param[in] audio_encoder A <code>PP_Resource</code> identifying the audio
208 * encoder.
209 */
210 void Close([in] PP_Resource audio_encoder);
211 };
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