diff --git a/Source/CoreUtility/CoreUtility.Build.cs b/Source/CoreUtility/CoreUtility.Build.cs index b813a63..2cb27e7 100644 --- a/Source/CoreUtility/CoreUtility.Build.cs +++ b/Source/CoreUtility/CoreUtility.Build.cs @@ -46,6 +46,17 @@ public CoreUtility(ReadOnlyTargetRules Target) : base(Target) ); + if (Target.Version.MajorVersion == 5 && Target.Version.MinorVersion >= 4) + { + PrivateDependencyModuleNames.AddRange( + new string[] + { + "OpusAudioDecoder", + } + ); + } + + DynamicallyLoadedModuleNames.AddRange( new string[] { diff --git a/Source/CoreUtility/Private/CUBlueprintLibrary.cpp b/Source/CoreUtility/Private/CUBlueprintLibrary.cpp index ecb29cc..d3de1d1 100644 --- a/Source/CoreUtility/Private/CUBlueprintLibrary.cpp +++ b/Source/CoreUtility/Private/CUBlueprintLibrary.cpp @@ -10,7 +10,11 @@ #include "HAL/ThreadSafeBool.h" #include "RHI.h" #include "Misc/FileHelper.h" +#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 4 +#include "Decoders/OpusAudioInfo.h" +#else #include "OpusAudioInfo.h" +#endif #include "Runtime/Launch/Resources/Version.h" #include "Developer/TargetPlatform/Public/Interfaces/IAudioFormat.h" #include "CoreMinimal.h" diff --git a/Source/CoreUtility/Private/CUOpusCoder.cpp b/Source/CoreUtility/Private/CUOpusCoder.cpp index 89d3ade..d7083f5 100644 --- a/Source/CoreUtility/Private/CUOpusCoder.cpp +++ b/Source/CoreUtility/Private/CUOpusCoder.cpp @@ -109,7 +109,7 @@ bool FCUOpusCoder::EncodeStream(const TArray& InPCMBytes, FCUOpusMinimalS if (EncodedBytes < 0) { - UE_LOG(LogTemp, Warning, TEXT("opus_encode err: %s"), opus_strerror(EncodedBytes)); + UE_LOG(LogTemp, Warning, TEXT("opus_encode err: %hs"), opus_strerror(EncodedBytes)); return false; } OutStream.CompressedBytes.Append(TempBuffer.GetData(), EncodedBytes); @@ -164,7 +164,7 @@ bool FCUOpusCoder::DecodeStream(const FCUOpusMinimalStream& InStream, TArray& InPCMFrame, TArray& { #if WITH_OPUS return opus_encode(Encoder, (const opus_int16*)InPCMFrame.GetData(), FrameSize, OutCompressed.GetData(), MaxPacketSize); -#endif +#else return 0; +#endif } int32 FCUOpusCoder::DecodeFrame(const TArray& InCompressedFrame, TArray& OutPCMFrame) { #if WITH_OPUS return opus_decode(Decoder, InCompressedFrame.GetData(), InCompressedFrame.Num(), (opus_int16*)OutPCMFrame.GetData(), FrameSize, 0); -#endif +#else return 0; +#endif }