#include <ppb_audio_encoder.h>
|
PP_Resource(* | Create )(PP_Instance instance) |
|
PP_Bool(* | IsAudioEncoder )(PP_Resource resource) |
|
int32_t(* | GetSupportedProfiles )(PP_Resource audio_encoder, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) |
|
int32_t(* | Initialize )(PP_Resource audio_encoder, uint32_t channels, PP_AudioBuffer_SampleRate input_sample_rate, PP_AudioBuffer_SampleSize input_sample_size, PP_AudioProfile output_profile, uint32_t initial_bitrate, PP_HardwareAcceleration acceleration, struct PP_CompletionCallback callback) |
|
int32_t(* | GetNumberOfSamples )(PP_Resource audio_encoder) |
|
int32_t(* | GetBuffer )(PP_Resource audio_encoder, PP_Resource *audio_buffer, struct PP_CompletionCallback callback) |
|
int32_t(* | Encode )(PP_Resource audio_encoder, PP_Resource audio_buffer, struct PP_CompletionCallback callback) |
|
int32_t(* | GetBitstreamBuffer )(PP_Resource audio_encoder, struct PP_AudioBitstreamBuffer *bitstream_buffer, struct PP_CompletionCallback callback) |
|
void(* | RecycleBitstreamBuffer )(PP_Resource audio_encoder, const struct PP_AudioBitstreamBuffer *bitstream_buffer) |
|
void(* | RequestBitrateChange )(PP_Resource audio_encoder, uint32_t bitrate) |
|
void(* | Close )(PP_Resource audio_encoder) |
|
Audio encoder interface.
Typical usage:
- Call Create() to create a new audio encoder resource.
- Call GetSupportedProfiles() to determine which codecs and profiles are available.
- Call Initialize() to initialize the encoder for a supported profile.
- Call GetBuffer() to get an empty buffer and fill it in, or get an audio buffer from another resource, e.g.
PPB_MediaStreamAudioTrack
.
- Call Encode() to push the audio buffer to the encoder. If an external buffer is pushed, wait for completion to recycle the buffer.
- Call GetBitstreamBuffer() continuously (waiting for each previous call to complete) to pull encoded buffers from the encoder.
- Call RecycleBitstreamBuffer() after consuming the data in the bitstream buffer.
- To destroy the encoder, the plugin should release all of its references to it. Any pending callbacks will abort before the encoder is destroyed.
Available audio codecs vary by platform. All: opus.
void(* PPB_AudioEncoder_0_1::Close)(PP_Resource audio_encoder) |
Closes the audio encoder, and cancels any pending encodes. Any pending callbacks will still run, reporting PP_ERROR_ABORTED
. It is not valid to call any encoder functions after a call to this method. Note: Destroying the audio encoder closes it implicitly, so you are not required to call Close().
- Parameters
-
[in] | audio_encoder | A PP_Resource identifying the audio encoder. |
Creates a new audio encoder resource.
- Parameters
-
[in] | instance | A PP_Instance identifying the instance with the audio encoder. |
- Returns
- A
PP_Resource
corresponding to an audio encoder if successful or 0 otherwise.
Encodes an audio buffer.
- Parameters
-
[in] | audio_encoder | A PP_Resource identifying the audio encoder. |
[in] | audio_buffer | The PPB_AudioBuffer to be encoded. |
[in] | callback | A PP_CompletionCallback to be called upon completion. Plugins that pass PPB_AudioBuffer resources owned by other resources should wait for completion before reusing them. |
- Returns
- An int32_t containing an error code from
pp_errors.h
. Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
Gets the next encoded bitstream buffer from the encoder.
- Parameters
-
[in] | audio_encoder | A PP_Resource identifying the audio encoder. |
[out] | bitstream_buffer | A PP_BitstreamBuffer containing encoded audio data. |
[in] | callback | A PP_CompletionCallback to be called upon completion. The plugin can call GetBitstreamBuffer from the callback in order to continuously "pull" bitstream buffers from the encoder. |
- Returns
- An int32_t containing an error code from
pp_errors.h
. Returns PP_ERROR_FAILED if Initialize() has not successfully completed. Returns PP_ERROR_INPROGRESS if a prior call to GetBitstreamBuffer() has not completed.
Gets a blank audio buffer (with metadata given by the Initialize() call) which can be filled with audio data and passed to the encoder.
- Parameters
-
[in] | audio_encoder | A PP_Resource identifying the audio encoder. |
[out] | audio_buffer | A blank PPB_AudioBuffer resource. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
- Returns
- An int32_t containing an error code from
pp_errors.h
. Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
int32_t(* PPB_AudioEncoder_0_1::GetNumberOfSamples)(PP_Resource audio_encoder) |
Gets the number of audio samples per channel that audio buffers must contain in order to be processed by the encoder. This will be the number of samples per channels contained in buffers returned by GetBuffer().
- Parameters
-
[in] | audio_encoder | A PP_Resource identifying the audio encoder. |
- Returns
- An int32_t containing the number of samples required, or an error code from
pp_errors.h
. Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
Gets an array of supported audio encoder profiles. These can be used to choose a profile before calling Initialize().
- Parameters
-
- Returns
- If >= 0, the number of supported profiles returned, otherwise an error code from
pp_errors.h
.
Initializes an audio encoder resource. The plugin should call Initialize() successfully before calling any of the functions below.
- Parameters
-
[in] | audio_encoder | A PP_Resource identifying the audio encoder. |
[in] | channels | The number of audio channels to encode. |
[in] | input_sampling_rate | The sampling rate of the input audio buffer. |
[in] | input_sample_size | The sample size of the input audio buffer. |
[in] | output_profile | A PP_AudioProfile specifying the codec profile of the encoded output stream. |
[in] | initial_bitrate | The initial bitrate for the encoder. |
[in] | acceleration | A PP_HardwareAcceleration specifying whether to use a hardware accelerated or a software implementation. |
[in] | callback | A PP_CompletionCallback to be called upon completion. |
- Returns
- An int32_t containing an error code from
pp_errors.h
. Returns PP_ERROR_NOTSUPPORTED if audio encoding is not available, or the requested codec profile is not supported.
Determines if the given resource is an audio encoder.
- Parameters
-
[in] | resource | A PP_Resource identifying a resource. |
- Returns
PP_TRUE
if the resource is a PPB_AudioEncoder
, PP_FALSE
if the resource is invalid or some other type.
Recycles a bitstream buffer back to the encoder.
- Parameters
-
[in] | audio_encoder | A PP_Resource identifying the audio encoder. |
[in] | bitstream_buffer | A PP_BitstreamBuffer that is no longer needed by the plugin. |
void(* PPB_AudioEncoder_0_1::RequestBitrateChange)(PP_Resource audio_encoder, uint32_t bitrate) |
Requests a change to the encoding bitrate. This is only a request, fulfilled on a best-effort basis.
- Parameters
-
[in] | audio_encoder | A PP_Resource identifying the audio encoder. |
[in] | bitrate | The requested new bitrate, in bits per second. |
The documentation for this struct was generated from the following file: