Skip to main content

odin_encoder_push

enum OdinError odin_encoder_push(struct OdinEncoder *encoder,
const float *samples,
uint32_t samples_count);

Overview

Pushes raw audio samples to the encoder for processing. The provided audio samples, which must be interleaved floating-point values in the range [-1, 1], are processed through the encoder's pipeline.

Parameters

NameTypeDescription
encoderstruct OdinEncoder *The encoder handle.
samplesconst float *Buffer of interleaved float samples.
samples_countuint32_tNumber of samples in the buffer.

Return Value

TypeDescription
OdinErrorODIN_ERROR_SUCCESS on success.

Example

// Inside an audio capture callback
// input buffer contains 'input_count' samples
odin_encoder_push(encoder, input_buffer, input_count);

uint8_t datagram[2048];
uint32_t len = sizeof(datagram);
uint16_t media_id = 123; // ID of the local media stream

// After pushing, pop processed packets
while (odin_encoder_pop(encoder, &media_id, 1, datagram, &len) == ODIN_ERROR_SUCCESS) {
odin_room_send_datagram(room, datagram, len);
len = sizeof(datagram); // Reset length for next packet
}