// Georgy Treshchev 2025.

#pragma once

#include "CoreMinimal.h"
#if PLATFORM_WINDOWS || PLATFORM_ANDROID
#include "OVRLipSync.h"
#endif

#if PLATFORM_WINDOWS || PLATFORM_ANDROID
class RUNTIMEMETAHUMANLIPSYNC_STANDARD_API UOVRLipSyncContextWrapper
{
public:
	UOVRLipSyncContextWrapper(ovrLipSyncContextProvider Provider, int32 SampleRate = 48000, int32 BufferSize = 4096,
							  FString ModelPath = FString(), bool Accelerate = true);
	~UOVRLipSyncContextWrapper();

	void ProcessFrame(const int16_t *Data, int DataSize, TArray<float> &Visemes, float &LaughterScore,
					  int32_t &FrameDelay, bool Stereo = false);

	// Async processing
	using AsyncCallbackType = TFunction<void(const TArray<float> &Visemes, float LaughterScore)>;
	void SetAsyncCallback(const AsyncCallbackType &AsyncCallback);
	void InvokeAsyncCallback(const TArray<float> &Visemes, float LaughterScore);
	void ProcessFrameAsync(const float *Data, int32 DataSize);

private:
	AsyncCallbackType AsyncCallback;
	ovrLipSyncContext LipSyncContext = 0;
};
#endif