/**
 * Copyright 2022-2025 Theai, Inc. dba Inworld AI
 */

#pragma once

#include "CoreMinimal.h"
#include "Graph/InworldData.h"
#include "InworldRuntimeTypes.h"
#include "Misc/Paths.h"
#include "Misc/TVariant.h"
#include "Primitives/AEC/InworldAECTypes.h"
#include "Tasks/Task.h"

namespace inworld
{
class AECFilterInterface;
}	 // namespace inworld

namespace inworld
{
namespace Tasks
{
namespace AEC
{

/**
 * @brief Creates an asynchronous task for initializing an AEC (Acoustic Echo Cancellation) interface.
 *
 * This function creates a task that initializes the AEC processing system with the provided
 * configuration. The task returns either a valid AEC interface or an error message string.
 *
 * @param AECConfig Configuration parameters for AEC creation
 * @return Task that resolves to either a shared pointer to AECFilterInterface or an error string
 */
UE::Tasks::TTask<TVariant<TSharedPtr<inworld::AECFilterInterface>, FString>> CreateAECTask(
	const FInworldAECCreationConfig& AECConfig);

/**
 * @brief Creates an asynchronous task for filtering audio using AEC processing.
 *
 * This function creates a task that processes microphone audio and reference audio through
 * the AEC filter to remove echo and noise. The task returns the filtered audio data or
 * an error message if processing fails.
 *
 * @param AECInterface The AEC filter interface to use for processing
 * @param Config Runtime configuration settings for the AEC processing
 * @param MicrophoneAudio The microphone audio data to be filtered
 * @param ReferenceAudio The reference audio data (typically speaker output) for echo cancellation
 * @return Task that resolves to either filtered audio data or an error string
 */
UE::Tasks::TTask<TVariant<FInworldData_Audio, FString>> CreateFilterAudioTask(TSharedPtr<inworld::AECFilterInterface> AECInterface,
	const FInworldAECConfig& Config, const FInworldData_Audio& MicrophoneAudio, const FInworldData_Audio& ReferenceAudio);

}	 // namespace AEC
}	 // namespace Tasks
}	 // namespace inworld
