# Transcoder

**Detailed Description**

This section contains APIs related to Audio Transcoder operation.

- *group* Telematics\_audio\_transcoder

    - Typedefs

- using TranscoderReadResponseCb = std::function&lt;void(std::shared\_ptr&lt;IAudioBuffer&gt; buffer, uint32\_t isLastBuffer, [telux](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv45telux)::[common](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6commonE)::[ErrorCode](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6common9ErrorCodeE) error)&gt;

    - Called to pass the transcoded audio data. Used with [ITranscoder::read()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00277_1a4e6bac8efd24d537221be0559fa08109).

- Param buffer:

    - **[in]** Contains the transcoded data with [IAudioBuffer::getDataSize()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00263_1a7d1a1fc87fad286621e891d81a903fa4) giving the actual number of data bytes in this buffer. Should be cleared using [IAudioBuffer::reset()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00263_1ac1bd2c56bfa545d246232b5bcee7bb06) before reusing it for sending the next compressed data for transcoding.

- Param isLastBuffer:

    - **[in]** Indicates that this is the last chunk of the transcoded data

- Param error:

    - **[in]** telux::common::ErrorCode::SUCCESS if the transcoding was successful, an appropriate error code otherwise

- using TranscoderWriteResponseCb = std::function&lt;void(std::shared\_ptr&lt;IAudioBuffer&gt; buffer, uint32\_t bytesWritten, [telux](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv45telux)::[common](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6commonE)::[ErrorCode](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6common9ErrorCodeE) error)&gt;

    - Called when the compressed data has been sent for transcoding. Used with [ITranscoder::write()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00277_1ae499fc3bf7df6274b6bf7159122bb638).

- Param buffer:

    - **[in]** Buffer that is passed to [ITranscoder::write()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00277_1ae499fc3bf7df6274b6bf7159122bb638). To reuse it for sending the next compressed data for transcoding, clear it using [IAudioBuffer::reset()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00263_1ac1bd2c56bfa545d246232b5bcee7bb06).

- Param bytesWritten:

    - **[in]** Number of data bytes sent for transcoding

- Param error:

    - **[in]** telux::common::ErrorCode::SUCCESS if the data was sent successfully, an appropriate error code otherwise

- class ITranscodeListener : public [telux](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv45telux)::[common](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6commonE)::[ISDKListener](https://docs.qualcomm.com/doc/80-PF458-2/topic/class_a00046.html#_CPPv4N5telux6common12ISDKListenerE)

    - Listener for events during transcoding.

Public Functions

- inline virtual void onReadyForWrite()

    - Called when the audio pipeline is ready to accept the next buffer containing data to transcode.

- inline virtual ~ITranscodeListener()

    - Destructor of [ITranscodeListener](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00261).

- class ITranscoder

    - Provides the methods for transcoding the compressed audio data.

Public Functions

- virtual std::shared\_ptr&lt;[IAudioBuffer](https://docs.qualcomm.com/doc/80-PF458-2/topic/class_a00263.html#_CPPv4N5telux5audio12IAudioBufferE)&gt; getWriteBuffer() = 0

    - Gets a buffer for sending the data for transcoding.

- Returns:

    - [IAudioBuffer](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00263) instance representing the buffer or nullptr if allocation failed

- virtual std::shared\_ptr&lt;[IAudioBuffer](https://docs.qualcomm.com/doc/80-PF458-2/topic/class_a00263.html#_CPPv4N5telux5audio12IAudioBufferE)&gt; getReadBuffer() = 0

    - Gets a buffer that will contain the transcoded data.

- Returns:

    - [IAudioBuffer](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00263) instance representing the buffer or nullptr if allocation failed

- virtual [telux](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv45telux)::[common](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6commonE)::[Status](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6common6StatusE) write(std::shared\_ptr&lt;[IAudioBuffer](https://docs.qualcomm.com/doc/80-PF458-2/topic/class_a00263.html#_CPPv4N5telux5audio12IAudioBufferE)&gt; buffer, uint32\_t isLastBuffer, [TranscoderWriteResponseCb](https://docs.qualcomm.com/doc/80-PF458-2/topic/typedef_a00056_1ga6f5eaa860b4db2536320d822f26da66f.html#_CPPv4N5telux5audio25TranscoderWriteResponseCbE) callback = nullptr) = 0

    - Sends the compressed data for transcoding. First write starts the transcoding operation.

Internally, a pipeline is maintained for the data to transcode. The application should send the next data for transcoding only when the pipeline can accomodate more data. This readiness is indicated by calling the [ITranscodeListener::onReadyForWrite()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00261_1a42271acbf7ce60c8292214141632789e) method.

- Parameters:

    - - **buffer** – **[in]** Contains the data to transcode
- **isLastBuffer** – **[in]** Marks that this is the last chunk of the data to transcode
- **callback** – **[in]** Optional, invoked to pass the status of pushing the data in the pipeline

- Returns:

    - telux::common::Status::SUCCESS if the data is sent, otherwise, an appropriate error code

- virtual [telux](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv45telux)::[common](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6commonE)::[Status](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6common6StatusE) tearDown([telux](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv45telux)::[common](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6commonE)::[ResponseCallback](https://docs.qualcomm.com/doc/80-PF458-2/topic/typedef_a00236_1a8f614f0a0eeca90c94dad1967ca93bcd.html#_CPPv4N5telux6common16ResponseCallbackE) callback = nullptr) = 0

    - Destroys the [ITranscoder](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00277) instance created with [IAudioManager::createTranscoder()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00265_1a4c34d6d274f4ca26f22a70ba84e65c83). This must be called after the transcoding is finished.

- Parameters:

    - **callback** – **[in]** Optional, invoked to pass the result of the destruction

- Returns:

    - telux::common::Status::SUCCESS if the teardown was initiated, otherwise, an appropriate error code

- virtual [telux](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv45telux)::[common](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6commonE)::[Status](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6common6StatusE) read(std::shared\_ptr&lt;[IAudioBuffer](https://docs.qualcomm.com/doc/80-PF458-2/topic/class_a00263.html#_CPPv4N5telux5audio12IAudioBufferE)&gt; buffer, uint32\_t bytesToRead, [TranscoderReadResponseCb](https://docs.qualcomm.com/doc/80-PF458-2/topic/typedef_a00056_1ga87305ec768fa482fef15f098aa1dd8b8.html#_CPPv4N5telux5audio24TranscoderReadResponseCbE) callback = nullptr) = 0

    - Initiates a read request to fetch the transcoded data. Transcoded data will be by the [TranscoderReadResponseCb](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00056_1ga87305ec768fa482fef15f098aa1dd8b8) callback.

- Parameters:

    - - **buffer** – **[in]** Buffer that will contain the transcoded data
- **bytesToRead** – **[in]** Length of the data to fetch
- **callback** – **[in]** Optional, invoked to pass the transcoded data

- Returns:

    - telux::common::Status::SUCCESS if the request is sent, otherwise, an appropriate error code

- virtual [telux](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv45telux)::[common](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6commonE)::[Status](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6common6StatusE) registerListener(std::weak\_ptr&lt;[ITranscodeListener](https://docs.qualcomm.com/doc/80-PF458-2/topic/class_a00261.html#_CPPv4N5telux5audio18ITranscodeListenerE)&gt; listener) = 0

    - Registers the given listener to know ‘when the pipeline is ready to accept the next buffer’ for transcoding. Event is received by the [ITranscodeListener::onReadyForWrite()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00261_1a42271acbf7ce60c8292214141632789e) method.

- Parameters:

    - **listener** – **[in]** Receives the events during transcoding

- Returns:

    - telux::common::Status::SUCCESS if the listener is registered, otherwise, an appropriate error code

- virtual [telux](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv45telux)::[common](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6commonE)::[Status](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#_CPPv4N5telux6common6StatusE) deRegisterListener(std::weak\_ptr&lt;[ITranscodeListener](https://docs.qualcomm.com/doc/80-PF458-2/topic/class_a00261.html#_CPPv4N5telux5audio18ITranscodeListenerE)&gt; listener) = 0

    - Unregisters the given listener registered with [ITranscoder::registerListener()](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00277_1a778444ee0b9ab7e6f39840c4b908bc2f).

- Parameters:

    - **listener** – **[in]** Listener to unregister

- Returns:

    - telux::common::Status::SUCCESS if the listener is unregistered, otherwise, an appropriate error code

- inline virtual ~ITranscoder()

    - Destructor of the [ITranscoder](https://docs.qualcomm.com/doc/80-PF458-2/topic/common.html#a00277).

Last Published: Apr 14, 2026

[Previous Topic
telux::audio::IAudioToneGeneratorStream](https://docs.qualcomm.com/bundle/publicresource/80-PF458-2/topics/audio_stream.md) [Next Topic
Audio player](https://docs.qualcomm.com/bundle/publicresource/80-PF458-2/topics/audio_player.md)