Inheritance diagram for pp::AudioEncoder:

List of all members.

Public Member Functions

 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 ()

Detailed Description

Audio encoder interface.

Typical usage:

  • Call Create() to create a new audio encoder resource.
  • Call GetSupportedFormats() to determine which codecs and profiles are available.
  • Call Initialize() to initialize the encoder for a supported profile.
  • Call GetBuffer() to get a blank frame and fill it in, or get an audio frame 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 frame.
  • 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.


Constructor & Destructor Documentation

Default constructor for creating an is_null() AudioEncoder object.

pp::AudioEncoder::AudioEncoder(const InstanceHandleinstance) [explicit]

A constructor used to create a AudioEncoder and associate it with the provided Instance.

Parameters:
[in]instanceThe instance with which this resource will be associated.

The copy constructor for AudioEncoder.

Parameters:
[in]otherA reference to a AudioEncoder.

Member Function Documentation

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 AudioBufferbuffer,
const CompletionCallbackcc 
)

Encodes an audio buffer.

Parameters:
[in]audio_bufferThe AudioBuffer to be encoded.
[in]callbackA CompletionCallback to be called upon completion. Plugins that pass 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.
int32_t pp::AudioEncoder::GetBitstreamBuffer(const CompletionCallbackWithOutput< PP_AudioBitstreamBuffer > & cc)

Gets the next encoded bitstream buffer from the encoder.

Parameters:
[in]callbackA 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.
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 frame which can be filled with audio data and passed to the encoder.

Parameters:
[in]callbackA CompletionCallbackWithOutput to be called upon completion with the blank AudioBuffer resource.
Returns:
An int32_t containing an error code from pp_errors.h.

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().

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.
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().

Parameters:
[in]callbackA CompletionCallbackWithOutput to be called upon completion with the PP_AudioProfileDescription structs.
Returns:
If >= 0, the number of supported profiles returned, otherwise an error code from 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 CompletionCallbackcc 
)

Initializes a audio encoder resource.

This should be called after GetSupportedProfiles() and before any functions below.

Parameters:
[in]channelsThe number of audio channels to encode.
[in]input_sampling_rateThe sampling rate of the input audio buffer.
[in]input_sample_sizeThe sample size of the input audio buffer.
[in]output_profileA PP_AudioProfile specifying the codec profile of the encoded output stream.
[in]initial_bitrateThe initial bitrate for the encoder.
[in]accelerationA PP_HardwareAcceleration specifying whether to use a hardware accelerated or a software implementation.
[in]callbackA 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. 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.

Parameters:
[in]bitstream_bufferAPP_AudioBitstreamBuffer that is no longer needed by the plugin.

Requests a change to the encoding bitrate.

This is only a request, fulfilled on a best-effort basis.

Parameters:
[in]audio_encoderA PP_Resource identifying the audio encoder.

The documentation for this class was generated from the following file:
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.