Skip to content

Commit

Permalink
Merge pull request #12 from 4Players/ue-networking-5.4
Browse files Browse the repository at this point in the history
add binaries in SteamAudio/Source, update odin to 1.8.11
  • Loading branch information
SFuhrmann authored Aug 19, 2024
2 parents cd32f1c + 56083ac commit 8f41125
Show file tree
Hide file tree
Showing 31 changed files with 629 additions and 482 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ DerivedDataCache/*

!Plugins/Odin/ThirdParty/OdinLibrary/x64/Win/odin.dll
!Plugins/Odin/ThirdParty/OdinLibrary/x64/Win/odin.lib
!Plugins/Odin/Source/**
!Plugins/Odin/Source/**
!Plugins/SteamAudio/Source/**
Binary file modified Content/Blueprints/Game/GameInstance_TD.uasset
Binary file not shown.
Binary file modified Content/Blueprints/Game/SettingsSaveGame.uasset
Binary file not shown.
Binary file modified Content/Blueprints/Widgets/OptionsMenu/WBP_Options.uasset
Binary file not shown.
4 changes: 2 additions & 2 deletions Plugins/Odin/Odin.uplugin
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"FileVersion": 2,
"EngineVersion": "5.4.0",
"Version": 415,
"Version": 447,
"WhitelistPlatforms": [ "Win64", "Mac", "IOS", "Linux", "LinuxArm64", "Android" ],
"VersionName": "1.8.9",
"VersionName": "1.8.11",
"FriendlyName": "4Players ODIN",
"Description": "Unreal integration plugin to integrate real-time chat technology into your game",
"Category": "Other",
Expand Down
9 changes: 7 additions & 2 deletions Plugins/Odin/Source/Odin/Private/Odin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
#include "IOSAppDelegate.h"
#endif

#include "AudioDevice.h"
#include "odin_sdk.h"
#include "OdinFunctionLibrary.h"

#define LOCTEXT_NAMESPACE "FOdinModule"

Expand Down Expand Up @@ -74,6 +73,12 @@ void FOdinModule::ShutdownModule()
#endif
}

void FOdinModule::LogErrorCode(FString Prefix, uint32_t ErrorCode)
{
FString ErrorMessage = UOdinFunctionLibrary::FormatError(ErrorCode, false);
UE_LOG(Odin, Error, TEXT("%s, Error: %s"), *Prefix, *ErrorMessage);
}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FOdinModule, Odin)
2 changes: 2 additions & 0 deletions Plugins/Odin/Source/Odin/Private/OdinAudioCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ void UOdinAudioCapture::SetIsPaused(bool newValue)

bool UOdinAudioCapture::RestartCapturing(bool bAutomaticallyStartCapture)
{
TRACE_CPUPROFILER_EVENT_SCOPE(UOdinAudioCapture::RestartCapturing)

if (AudioCapture.IsStreamOpen()) {
AudioCapture.CloseStream();
}
Expand Down
19 changes: 13 additions & 6 deletions Plugins/Odin/Source/Odin/Private/OdinCaptureMedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ void UOdinCaptureMedia::RemoveRoom()

void UOdinCaptureMedia::SetAudioCapture(UAudioCapture* audio_capture)
{
TRACE_CPUPROFILER_EVENT_SCOPE(UOdinCaptureMedia::SetAudioCapture)

if (!audio_capture) {
UE_LOG(Odin, Error,
TEXT("UOdinCaptureMedia::SetAudioCapture - audio capture is null, microphone will "
Expand All @@ -32,6 +34,7 @@ void UOdinCaptureMedia::SetAudioCapture(UAudioCapture* audio_capture)
this->audio_capture_ = audio_capture;

if (this->stream_handle_) {
TRACE_CPUPROFILER_EVENT_SCOPE(UOdinCaptureMedia::SetAudioCapture Odin Create Audio Stream)
odin_media_stream_destroy(this->stream_handle_);
this->SetMediaHandle(0);
}
Expand All @@ -40,12 +43,16 @@ void UOdinCaptureMedia::SetAudioCapture(UAudioCapture* audio_capture)
stream_sample_rate_ = audio_capture->GetSampleRate();
stream_num_channels_ = audio_capture->GetNumChannels();
}

UE_LOG(Odin, Log,
TEXT("Initializing Audio Capture stream with Sample Rate: %d and Channels: %d"),
stream_sample_rate_, stream_num_channels_);
this->stream_handle_ = odin_audio_stream_create(OdinAudioStreamConfig{
static_cast<uint32_t>(stream_sample_rate_), static_cast<uint8_t>(stream_num_channels_)});
{
TRACE_CPUPROFILER_EVENT_SCOPE(UOdinCaptureMedia::SetAudioCapture Odin Create Audio Stream)

UE_LOG(Odin, Log,
TEXT("Initializing Audio Capture stream with Sample Rate: %d and Channels: %d"),
stream_sample_rate_, stream_num_channels_);
this->stream_handle_ = odin_audio_stream_create(
OdinAudioStreamConfig{static_cast<uint32_t>(stream_sample_rate_),
static_cast<uint8_t>(stream_num_channels_)});
}

TWeakObjectPtr<UOdinCaptureMedia> WeakThisPtr = this;
if (audio_capture && audio_capture->IsValidLowLevel()) {
Expand Down
23 changes: 20 additions & 3 deletions Plugins/Odin/Source/Odin/Private/OdinFunctionLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ FString UOdinFunctionLibrary::GenerateAccessKey()
{
char buf[128] = {0};
odin_access_key_generate(buf, sizeof(buf));
#if ENGINE_MAJOR_VERSION >= 5
return FString(128, buf);
#else
return ANSI_TO_TCHAR(buf);
#endif
}

FString UOdinFunctionLibrary::FormatOdinError(int64 code, bool ueTrace)
Expand All @@ -60,20 +64,33 @@ FString UOdinFunctionLibrary::FormatError(int32 code, bool ueTrace)

FString UOdinFunctionLibrary::BytesToString(const TArray<uint8>& data)
{
#if ENGINE_MAJOR_VERSION >= 5
const UTF8CHAR* UTF8Char = reinterpret_cast<const UTF8CHAR*>(data.GetData());
return FString(data.Num(), UTF8Char);
#else
// ensure null terminated string is being returned
if (data.Num() > 0 && data[data.Num() - 1] != TEXT('\0')) {
TArray<uint8> NullTerminatedArray = data;
NullTerminatedArray.Add(TEXT('\0'));
return UTF8_TO_TCHAR(NullTerminatedArray.GetData());
}
return FString(data.Num(), UTF8_TO_TCHAR(data.GetData()));
#endif
}

UOdinAudioCapture* UOdinFunctionLibrary::CreateOdinAudioCapture(UObject* WorldContextObject)
{
UWorld* World = nullptr;
TRACE_CPUPROFILER_EVENT_SCOPE(UOdinFunctionLibrary::CreateOdinAudioCapture)

UOdinAudioCapture* OdinAudioCapture;
if (IsValid(WorldContextObject)) {
World = WorldContextObject->GetWorld();
OdinAudioCapture = NewObject<UOdinAudioCapture>(WorldContextObject);
} else {
OdinAudioCapture = NewObject<UOdinAudioCapture>();
UE_LOG(Odin, Warning,
TEXT("No World Context provided when creating Odin Audio Capture. Audio Capture "
"will not be able to react to capture devices being removed."));
}
UOdinAudioCapture* OdinAudioCapture = NewObject<UOdinAudioCapture>(WorldContextObject);
if (OdinAudioCapture->RestartCapturing(false)) {
return OdinAudioCapture;
}
Expand Down
15 changes: 10 additions & 5 deletions Plugins/Odin/Source/Odin/Private/OdinJsonObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,18 @@ TArray<uint8> UOdinJsonObject::EncodeJsonBytes() const
return data;
}

FString OutputString = EncodeJson();
uint32 size = OutputString.Len();
const FString OutputString = EncodeJson();

data.AddUninitialized(size);
FTCHARToUTF8_Convert::Convert((UTF8CHAR *)data.GetData(), data.Num(), *OutputString,
OutputString.Len());
#if ENGINE_MAJOR_VERSION >= 5
const auto Utf8String = StringCast<UTF8CHAR>(*OutputString);
#else
const auto Utf8String = FTCHARToUTF8(*OutputString);
#endif

const uint32 size = Utf8String.Length();

data.AddUninitialized(size);
FMemory::Memcpy(data.GetData(), Utf8String.Get(), size);
return data;
}

Expand Down
Loading

0 comments on commit 8f41125

Please sign in to comment.