// Copyright Epic Games, Inc. All Rights Reserved.

#include "PixelStreamControllerModule.h"
#include "Misc/CommandLine.h"
#include "PortaSettings.h"

#define LOCTEXT_NAMESPACE "FPixelStreamControllerModule"

void FPixelStreamControllerModule::StartupModule()
{
	// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
	//FEditorModeRegistry::Get().RegisterMode<FPortaInterfaceEdMode>(FPortaInterfaceEdMode::EM_PortaInterfaceEdModeId, LOCTEXT("PortaInterfaceEdModeName", "PortaInterfaceEdMode"), FSlateIcon(), true);
	auto Config = GetMutableDefault<UPortaSettings>();

	if (Config->ShouldStartPixelStream())
	{
		FString Cmd = FString::Printf(TEXT(" -AudioMixer -PixelStreamingIP=%s -PixelStreamingPort=%d"), *Config->PixelStreamHost, Config->PixelStreamPort);
		FCommandLine::Append(*Cmd);
	}
}

void FPixelStreamControllerModule::ShutdownModule()
{
	// This function may be called during shutdown to clean up your module.  For modules that support dynamic reloading,
	// we call this function before unloading the module.
	//FEditorModeRegistry::Get().UnregisterMode(FPortaInterfaceEdMode::EM_PortaInterfaceEdModeId);
}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FPixelStreamControllerModule, PixelStreamController)