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

#pragma once

#include "InworldRuntimeTypes.h"
#include "Logging/LogMacros.h"

namespace inworld
{
class AECFilterInterface;
}

#include "InworldAECTypes.generated.h"

INWORLDRUNTIME_API DECLARE_LOG_CATEGORY_EXTERN(LogInworldAEC, Log, All);

/**
 * @struct FInworldAECCreationConfig
 * @brief Configuration structure for creating AEC (Acoustic Echo Cancellation) instances.
 *
 * This structure defines the parameters required for setting up AEC processing components.
 * Currently serves as a placeholder for future AEC creation configuration options.
 */
USTRUCT(BlueprintType)
struct FInworldAECCreationConfig
{
	GENERATED_BODY()
};

/**
 * @struct FInworldAECConfig
 * @brief Configuration structure for AEC (Acoustic Echo Cancellation) processing settings.
 *
 * This structure defines the runtime parameters for AEC audio processing, including
 * echo suppression levels, noise reduction settings, and adaptive filtering options.
 */
USTRUCT(BlueprintType)
struct FInworldAECConfig
{
	GENERATED_BODY()

	/** AEC processing intensity (0.0-1.0, higher values provide stronger echo cancellation) */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, config, Category = "Inworld|AEC",
		meta = (ClampMin = "0.0", ClampMax = "1.0",
			ToolTip = "AEC processing intensity (0.0-1.0, higher values provide stronger echo cancellation)"))
	float EchoSuppressionLevel = 0.5f;

	/** Noise suppression intensity (0.0-1.0, higher values provide stronger noise reduction) */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, config, Category = "Inworld|AEC",
		meta = (ClampMin = "0.0", ClampMax = "1.0",
			ToolTip = "Noise suppression intensity (0.0-1.0, higher values provide stronger noise reduction)"))
	float NoiseSuppressionLevel = 0.3f;

	/** Enable adaptive filtering for better echo cancellation */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, config, Category = "Inworld|AEC",
		Meta = (ToolTip = "Enable adaptive filtering for better echo cancellation"))
	bool bEnableAdaptiveFilter = true;
};

/** Blueprint delegate called when AEC primitive creation completes */
DECLARE_DYNAMIC_DELEGATE_OneParam(FOnInworldAECPrimitiveCreated, bool, bSuccess);

/** Native delegate called when AEC primitive creation completes with interface access */
DECLARE_DELEGATE_OneParam(FOnInworldAECPrimitiveCreatedNative, TSharedPtr<inworld::AECFilterInterface> /*AECInterface*/);

namespace inworld
{

class LocalAECFilterConfig;
/**
 * @brief Converts Unreal AEC creation configuration to internal AEC filter configuration.
 * @param In The Unreal AEC creation configuration to convert
 * @param Out The internal AEC filter configuration to populate
 */
void Convert(const FInworldAECCreationConfig& In, inworld::LocalAECFilterConfig& Out);

}	 // namespace inworld
