{{+bindTo:partials.standard_nacl_api}}
AudioEncoder () | |
AudioEncoder (const InstanceHandle &instance) | |
AudioEncoder (const AudioEncoder &other) | |
int32_t | GetSupportedProfiles (const CompletionCallbackWithOutput< std::vector< PP_AudioProfileDescription > > &cc) |
int32_t | Initialize (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, const CompletionCallback &cc) |
int32_t | GetNumberOfSamples () |
int32_t | GetBuffer (const CompletionCallbackWithOutput< AudioBuffer > &cc) |
int32_t | Encode (const AudioBuffer &buffer, const CompletionCallback &cc) |
int32_t | GetBitstreamBuffer (const CompletionCallbackWithOutput< PP_AudioBitstreamBuffer > &cc) |
void | RecycleBitstreamBuffer (const PP_AudioBitstreamBuffer &bitstream_buffer) |
void | RequestBitrateChange (uint32_t bitrate) |
void | Close () |
Audio encoder interface.
Typical usage:
PPB_MediaStreamAudioTrack
.Available audio codecs vary by platform. All: opus.
Default constructor for creating an is_null() AudioEncoder
object.
pp::AudioEncoder::AudioEncoder | ( | const InstanceHandle & | instance | ) | [explicit] |
A constructor used to create a AudioEncoder
and associate it with the provided Instance
.
[in] | instance | The instance with which this resource will be associated. |
pp::AudioEncoder::AudioEncoder | ( | const AudioEncoder & | other | ) |
The copy constructor for AudioEncoder
.
[in] | other | A reference to a AudioEncoder . |
void pp::AudioEncoder::Close | ( | ) |
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().
int32_t pp::AudioEncoder::Encode | ( | const AudioBuffer & | buffer, |
const CompletionCallback & | cc | ||
) |
Encodes an audio buffer.
[in] | audio_buffer | The AudioBuffer to be encoded. |
[in] | callback | A CompletionCallback to be called upon completion. Plugins that pass AudioBuffer resources owned by other resources should wait for completion before reusing them. |
pp_errors.h
. Returns PP_ERROR_FAILED if Initialize() has not successfully completed. int32_t pp::AudioEncoder::GetBitstreamBuffer | ( | const CompletionCallbackWithOutput< PP_AudioBitstreamBuffer > & | cc | ) |
Gets the next encoded bitstream buffer from the encoder.
[in] | callback | A CompletionCallbackWithOutput to be called upon completion with the next bitstream buffer. The plugin can call GetBitstreamBuffer from the callback in order to continuously "pull" bitstream buffers from the encoder. |
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. int32_t pp::AudioEncoder::GetBuffer | ( | const CompletionCallbackWithOutput< AudioBuffer > & | cc | ) |
Gets a blank audio frame which can be filled with audio data and passed to the encoder.
[in] | callback | A CompletionCallbackWithOutput to be called upon completion with the blank AudioBuffer resource. |
pp_errors.h
. int32_t pp::AudioEncoder::GetNumberOfSamples | ( | ) |
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().
pp_errors.h
. Returns PP_ERROR_FAILED if Initialize() has not successfully completed. int32_t pp::AudioEncoder::GetSupportedProfiles | ( | const CompletionCallbackWithOutput< std::vector< PP_AudioProfileDescription > > & | cc | ) |
Gets an array of supported audio encoder profiles.
These can be used to choose a profile before calling Initialize().
[in] | callback | A CompletionCallbackWithOutput to be called upon completion with the PP_AudioProfileDescription structs. |
pp_errors.h
. int32_t pp::AudioEncoder::Initialize | ( | 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, | ||
const CompletionCallback & | cc | ||
) |
Initializes a audio encoder resource.
This should be called after GetSupportedProfiles() and before any functions below.
[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 CompletionCallback to be called upon completion. |
pp_errors.h
. Returns PP_ERROR_NOTSUPPORTED if audio encoding is not available, or the requested codec profile is not supported. Returns PP_ERROR_NOMEMORY if bitstream buffers can't be created. void pp::AudioEncoder::RecycleBitstreamBuffer | ( | const PP_AudioBitstreamBuffer & | bitstream_buffer | ) |
Recycles a bitstream buffer back to the encoder.
[in] | bitstream_buffer | APP_AudioBitstreamBuffer that is no longer needed by the plugin. |
void pp::AudioEncoder::RequestBitrateChange | ( | uint32_t | bitrate | ) |
Requests a change to the encoding bitrate.
This is only a request, fulfilled on a best-effort basis.
[in] | audio_encoder | A PP_Resource identifying the audio encoder. |