diff --git a/Source/VAPlugin/Private/VAReceiverActor.cpp b/Source/VAPlugin/Private/VAReceiverActor.cpp index 07b9a86b0d861d82337629e0c13ed65a1b097bf3..b0615041399fe92d05dc4f87143279c7b081fe35 100644 --- a/Source/VAPlugin/Private/VAReceiverActor.cpp +++ b/Source/VAPlugin/Private/VAReceiverActor.cpp @@ -57,7 +57,7 @@ void AVAReceiverActor::BeginPlay() if (bAutomaticRemoteVAStart) { FVAPlugin::VAServerLauncher.StartVAServerLauncher(); //if possible - bStartedVAServer = FVAPlugin::VAServerLauncher.RemoteStartVAServer(GetIPAddress(), RemoteVAStarterPort, WhichVAServerVersionToStart, VARendererIniFile); + bStartedVAServer = FVAPlugin::VAServerLauncher.RemoteStartVAServer(GetIPAddress(), RemoteVAStarterPort, WhichVAServerVersionToStart, VARendererIniFile, ReproductionInputType); if(bStartedVAServer){ FVAPlugin::SetUseVA(true); } diff --git a/Source/VAPlugin/Private/VAServerLauncher.cpp b/Source/VAPlugin/Private/VAServerLauncher.cpp index 37b1ebd8e78bfcd65eb4ccd3d7f66ed717255ad5..b57dd25b369e8f91e2a051bd69f4bf1f30718aed 100644 --- a/Source/VAPlugin/Private/VAServerLauncher.cpp +++ b/Source/VAPlugin/Private/VAServerLauncher.cpp @@ -13,7 +13,7 @@ #include "VAPlugin.h" -bool FVAServerLauncher::RemoteStartVAServer(const FString& Host, const int Port, const FString& VersionName, const FString& VARendererIniFile) +bool FVAServerLauncher::RemoteStartVAServer(const FString& Host, const int Port, const FString& VersionName, const FString& VARendererIniFile, const EReproductionInput ReproductionInputType) { if (!UVirtualRealityUtilities::IsMaster()) { @@ -59,7 +59,16 @@ bool FVAServerLauncher::RemoteStartVAServer(const FString& Host, const int Port, if (!SendFileToVAServer(VARendererIniFile)) { FVAUtils::OpenMessageBox("[FVAServerLauncher::RemoteStartVAServer()]: VARenderer.ini file '" + VARendererIniFile + - "' could not be copied to VAServer. Does the file exist? See error log for additional info. VAServer will be launched with default settings.", true); + "' could not be copied to VAServerLauncher. Does the file exist? See error log for additional info. VAServerLauncher will run with default settings.", true); + } + } + + if (ReproductionInputType != EReproductionInput::Default) + { + if (!SendReproductionInputSignalType(ReproductionInputType)) + { + FVAUtils::OpenMessageBox("[FVAServerLauncher::RemoteStartVAServer()]: ReproductionInputType '" + EnumToString(ReproductionInputType) + + "' could not be sent to VAServerLauncher. See error log for additional info. VAServerLauncher will run with default settings.", true); } } @@ -282,6 +291,33 @@ bool FVAServerLauncher::IsVAServerLauncherConnected() return VAServerLauncherSocket!=nullptr; } +bool FVAServerLauncher::SendReproductionInputSignalType(const EReproductionInput ReproductionInputType) +{ + const FString ProjectName = GetDefault<UGeneralProjectSettings>()->ProjectName; + FString CommandMsg = "reproduction_input_type:" + EnumToString(ReproductionInputType); + TArray<uint8> CommandMsgBinary = ConvertString(CommandMsg); + + int32 BytesSend; + VAServerLauncherSocket->Send(CommandMsgBinary.GetData(), CommandMsgBinary.Num(), BytesSend); + + const int32 BufferSize = 16; + int32 BytesRead = 0; + uint8 Response[16]; + if (VAServerLauncherSocket->Recv(Response, BufferSize, BytesRead)) + { + FString ResponseString = ByteArrayToString(Response, BytesRead); + if (ResponseString == "ack") + { + FVAUtils::LogStuff("[FVAServerLauncher::SendReproductionInputSignalType()]: ReproductionInputType was successfully received by VAServerLauncher!", false); + return true; + } + FVAUtils::LogStuff("[FVAServerLauncher::SendReproductionInputSignalType()]: ReproductionInputType not accepted by VAServerLauncher! Answer: " + ResponseString, false); + return false; + } + FVAUtils::LogStuff("[FVAServerLauncher::SendReproductionInputSignalType()]: VAServerLauncher did not answer!", true); + return false; +} + TArray<uint8> FVAServerLauncher::ConvertString(const FString& String) { TArray<uint8> RequestData; @@ -313,3 +349,21 @@ FString FVAServerLauncher::ByteArrayToString(const uint8* In, int32 Count) } return Result; } + +FString FVAServerLauncher::EnumToString(EReproductionInput Enum) +{ + switch (Enum) + { + case EReproductionInput::Default: + return TEXT("default"); + case EReproductionInput::Binaural: + return TEXT("binaural"); + case EReproductionInput::Ambisonics: + return TEXT("ambisonics"); + case EReproductionInput::Custom: + return TEXT("custom"); + default: + return TEXT("invalid"); + } + +} diff --git a/Source/VAPlugin/Private/VAServerLauncher.h b/Source/VAPlugin/Private/VAServerLauncher.h index acc4b1f2a991a591b90f641036cfb0b9840c578e..b9dffc0fd1287dbe4d3d856f67e93d6f4451821b 100644 --- a/Source/VAPlugin/Private/VAServerLauncher.h +++ b/Source/VAPlugin/Private/VAServerLauncher.h @@ -2,12 +2,14 @@ #include "Sockets.h" +#include "VAEnums.h" + class FVAServerLauncher { public: // Remote Start VAServer bool RemoteStartVAServer(const FString& Host, int Port, - const FString& VersionName, const FString& VARendererIni = ""); + const FString& VersionName, const FString& VARendererIni = "", const EReproductionInput ReproductionInputType = EReproductionInput::Default); bool StartVAServerLauncher(); @@ -22,9 +24,13 @@ public: private: + bool SendReproductionInputSignalType(const EReproductionInput ReproductionInputType); + TArray<uint8> ConvertString(const FString& String); FString ByteArrayToString(const uint8* In, int32 Count); + static FString EnumToString(EReproductionInput Enum); + //Socket connection to the VAServer Launcher, has to be held open until the program ends FSocket* VAServerLauncherSocket=nullptr; diff --git a/Source/VAPlugin/Public/VAEnums.h b/Source/VAPlugin/Public/VAEnums.h index 56f69caf060264c2d655adf729d7bc476b15a8b6..8866e0ef8277ba1a8c0fa4d4a7548e5ef72bda45 100644 --- a/Source/VAPlugin/Public/VAEnums.h +++ b/Source/VAPlugin/Public/VAEnums.h @@ -34,6 +34,19 @@ namespace EConnectionSetting }; } +UENUM() +enum class EReproductionInput : uint8 +{ + // [NOT RECOMMENDED] Use default reproduction modules + Default = 0, + // Use reproduction modules for binaural signals + Binaural = 1, + // Use reproduction modules for ambisonics signals + Ambisonics = 2, + // Use reproduction modules for custom purposes (e.g. mixed signal types) + Custom = 3 +}; + UENUM(BlueprintType) namespace EDirectivitySetting diff --git a/Source/VAPlugin/Public/VAReceiverActor.h b/Source/VAPlugin/Public/VAReceiverActor.h index 9a475a2ff553d60a96276e1dfcc0ad5a577c5d92..2e0f387d21c657751093338029b9048f0f8f0987 100644 --- a/Source/VAPlugin/Public/VAReceiverActor.h +++ b/Source/VAPlugin/Public/VAReceiverActor.h @@ -89,6 +89,10 @@ protected: UPROPERTY(EditAnywhere, meta = (DisplayName = "VARenderer.ini file", Category = "VAServer Launcher")) FString VARendererIniFile = TEXT(""); + //Used to select the group of reproduction modules specified in VAServer Launcher config. + UPROPERTY(EditAnywhere, meta = (DisplayName = "Reproduction input signal type", Category = "VAServer Launcher")) + EReproductionInput ReproductionInputType = EReproductionInput::Binaural; + // Read an initial mapping file for directivities? UPROPERTY(EditAnywhere, meta = (DisplayName = "Read an initial mapping file?", Category = "Directivity Manager"))