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

Side by Side Diff: ppapi/c/ppb_audio_encoder.h

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

Powered by Google App Engine
This is Rietveld 408576698