#pragma once

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

// Reset the cellular echo canceller at the start of a new Call-TX bridge or
// after a telephony route rebuild. This intentionally preserves no acoustic
// state across calls/routes because the speaker -> microphone path changes.
void secureline_call_aec_reset();

// Feed the cellular far-end (Call-RX) render stream before it is sent to the
// earpiece/speaker. The implementation downmixes to mono and adapts arbitrary
// AudioFlinger buffer sizes to WebRTC AEC3's ~10 ms processing frames.
void secureline_call_aec_render_int16(
        const int16_t* buffer,
        int frames,
        int channels,
        int sampleRate);

void secureline_call_aec_render_float(
        const float* buffer,
        int frames,
        int channels,
        int sampleRate);

// Echo-cancel the cellular near-end (Call-TX) microphone stream in-place.
// This MUST run before the Lemenzo voice transformation. Returns true when
// AEC3 produced output; false means the caller should simply keep the original
// audio (for example, unsupported parameters or allocation/init failure).
bool secureline_call_aec_process_capture_int16(
        int16_t* buffer,
        int frames,
        int channels,
        int sampleRate);

bool secureline_call_aec_process_capture_float(
        float* buffer,
        int frames,
        int channels,
        int sampleRate);

#ifdef __cplusplus
}
#endif
