// Georgy Treshchev 2025.

#include "RuntimeMetaHumanLipSync_Standard.h"
#include "Misc/EngineVersionComparison.h"
#include "Modules/ModuleManager.h"
#include "OVRLipSync.h"
#include "Interfaces/IPluginManager.h"
#include "Misc/Paths.h"
#include "Features/IModularFeatures.h"

#define LOCTEXT_NAMESPACE "FRuntimeMetaHumanLipSync_StandardModule"

DEFINE_LOG_CATEGORY(LogRuntimeMetaHumanLipSyncStandard);

void FRuntimeMetaHumanLipSync_StandardModule::StartupModule()
{
	DefaultLipSyncProcessor = MakeShared<FDefaultLipSyncProcessor>();
	static const FName LipSyncFeatureName(TEXT("RuntimeLipSyncProcessor"));
	IModularFeatures::Get().RegisterModularFeature(LipSyncFeatureName, DefaultLipSyncProcessor.Get());
}

void FRuntimeMetaHumanLipSync_StandardModule::ShutdownModule()
{
	static const FName LipSyncFeatureName(TEXT("RuntimeLipSyncProcessor"));
	IModularFeatures::Get().UnregisterModularFeature(LipSyncFeatureName, DefaultLipSyncProcessor.Get());
	DefaultLipSyncProcessor.Reset();
#if PLATFORM_WINDOWS || PLATFORM_ANDROID
	ovrLipSync_Shutdown();
#endif
}

#undef LOCTEXT_NAMESPACE
	
IMPLEMENT_MODULE(FRuntimeMetaHumanLipSync_StandardModule, RuntimeMetaHumanLipSync_Standard)