final changes

This commit is contained in:
Joshua
2024-01-22 16:05:26 -05:00
parent 3e265f1a64
commit 892343a786
2 changed files with 169 additions and 64 deletions

View File

@@ -32,68 +32,68 @@ public:
//********* Voice Library Functions *************// //********* Voice Library Functions *************//
// Get if a headset is present for the specified local user // Get if a headset is present for the specified local user
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
static void IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum = 0); static void IsHeadsetPresent(UObject* WorldContextObject, bool & bHasHeadset, uint8 LocalPlayerNum = 0);
// Starts networked voice, allows push to talk in coordination with StopNetworkedVoice // Starts networked voice, allows push to talk in coordination with StopNetworkedVoice
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void StartNetworkedVoice(uint8 LocalPlayerNum = 0); static void StartNetworkedVoice(UObject* WorldContextObject, uint8 LocalPlayerNum = 0);
// Stops networked voice, allows push to talk in coordination with StartNetworkedVoice // Stops networked voice, allows push to talk in coordination with StartNetworkedVoice
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void StopNetworkedVoice(uint8 LocalPlayerNum = 0); static void StopNetworkedVoice(UObject* WorldContextObject, uint8 LocalPlayerNum = 0);
// Registers a local player as someone interested in voice data // Registers a local player as someone interested in voice data
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static bool RegisterLocalTalker(uint8 LocalPlayerNum = 0); static bool RegisterLocalTalker(UObject* WorldContextObject, uint8 LocalPlayerNum = 0);
// Registers all signed in players as local talkers // Registers all signed in players as local talkers
// This is already done automatically, only do it manually if you unregistered someone // This is already done automatically, only do it manually if you unregistered someone
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void RegisterAllLocalTalkers(); static void RegisterAllLocalTalkers(UObject* WorldContextObject);
// UnRegisters local player as a local talker // UnRegisters local player as a local talker
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void UnRegisterLocalTalker(uint8 LocalPlayerNum = 0); static void UnRegisterLocalTalker(UObject* WorldContextObject, uint8 LocalPlayerNum = 0);
// UnRegisters all signed in players as local talkers // UnRegisters all signed in players as local talkers
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void UnRegisterAllLocalTalkers(); static void UnRegisterAllLocalTalkers(UObject* WorldContextObject);
// Registers a remote player as a talker // Registers a remote player as a talker
// This is already done automatically, only do it manually if you unregistered someone // This is already done automatically, only do it manually if you unregistered someone
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static bool RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId); static bool RegisterRemoteTalker(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId);
// UnRegisters a remote player as a talker // UnRegisters a remote player as a talker
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static bool UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId); static bool UnRegisterRemoteTalker(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId);
// UnRegisters all remote players as talkers // UnRegisters all remote players as talkers
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void RemoveAllRemoteTalkers(); static void RemoveAllRemoteTalkers(UObject* WorldContextObject);
// Returns whether a local player is currently talking // Returns whether a local player is currently talking
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
static bool IsLocalPlayerTalking(uint8 LocalPlayerNum); static bool IsLocalPlayerTalking(UObject* WorldContextObject, uint8 LocalPlayerNum);
// Returns whether a remote player is currently talking // Returns whether a remote player is currently talking
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
static bool IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId); static bool IsRemotePlayerTalking(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId);
// Returns whether a player is muted for the specified local player // Returns whether a player is muted for the specified local player
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
static bool IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId); static bool IsPlayerMuted(UObject* WorldContextObject, uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId);
// Mutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to mute globally for the player // Mutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to mute globally for the player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static bool MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false); static bool MuteRemoteTalker(UObject* WorldContextObject, uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false);
// UnMutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to unmute globally for the player // UnMutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to unmute globally for the player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static bool UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false); static bool UnMuteRemoteTalker(UObject* WorldContextObject, uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false);
// Gets the number of local talkers for this system // Gets the number of local talkers for this system
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
static void GetNumLocalTalkers(int32 & NumLocalTalkers); static void GetNumLocalTalkers(UObject* WorldContextObject, int32 & NumLocalTalkers);
}; };

View File

@@ -5,9 +5,16 @@
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedVoiceLog); DEFINE_LOG_CATEGORY(AdvancedVoiceLog);
void UAdvancedVoiceLibrary::IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum) void UAdvancedVoiceLibrary::IsHeadsetPresent(UObject* WorldContextObject, bool & bHasHeadset, uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -19,9 +26,16 @@ void UAdvancedVoiceLibrary::IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlay
bHasHeadset = VoiceInterface->IsHeadsetPresent(LocalPlayerNum); bHasHeadset = VoiceInterface->IsHeadsetPresent(LocalPlayerNum);
} }
void UAdvancedVoiceLibrary::StartNetworkedVoice(uint8 LocalPlayerNum) void UAdvancedVoiceLibrary::StartNetworkedVoice(UObject* WorldContextObject, uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -32,9 +46,16 @@ void UAdvancedVoiceLibrary::StartNetworkedVoice(uint8 LocalPlayerNum)
VoiceInterface->StartNetworkedVoice(LocalPlayerNum); VoiceInterface->StartNetworkedVoice(LocalPlayerNum);
} }
void UAdvancedVoiceLibrary::StopNetworkedVoice(uint8 LocalPlayerNum) void UAdvancedVoiceLibrary::StopNetworkedVoice(UObject* WorldContextObject, uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -45,9 +66,15 @@ void UAdvancedVoiceLibrary::StopNetworkedVoice(uint8 LocalPlayerNum)
VoiceInterface->StopNetworkedVoice(LocalPlayerNum); VoiceInterface->StopNetworkedVoice(LocalPlayerNum);
} }
bool UAdvancedVoiceLibrary::RegisterLocalTalker(uint8 LocalPlayerNum) bool UAdvancedVoiceLibrary::RegisterLocalTalker(UObject* WorldContextObject, uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -58,9 +85,16 @@ bool UAdvancedVoiceLibrary::RegisterLocalTalker(uint8 LocalPlayerNum)
return VoiceInterface->RegisterLocalTalker(LocalPlayerNum); return VoiceInterface->RegisterLocalTalker(LocalPlayerNum);
} }
void UAdvancedVoiceLibrary::RegisterAllLocalTalkers() void UAdvancedVoiceLibrary::RegisterAllLocalTalkers(UObject* WorldContextObject)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -72,9 +106,16 @@ void UAdvancedVoiceLibrary::RegisterAllLocalTalkers()
} }
void UAdvancedVoiceLibrary::UnRegisterLocalTalker(uint8 LocalPlayerNum) void UAdvancedVoiceLibrary::UnRegisterLocalTalker(UObject* WorldContextObject, uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -85,9 +126,16 @@ void UAdvancedVoiceLibrary::UnRegisterLocalTalker(uint8 LocalPlayerNum)
VoiceInterface->UnregisterLocalTalker(LocalPlayerNum); VoiceInterface->UnregisterLocalTalker(LocalPlayerNum);
} }
void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers() void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers(UObject* WorldContextObject)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -98,7 +146,7 @@ void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers()
VoiceInterface->UnregisterLocalTalkers(); VoiceInterface->UnregisterLocalTalkers();
} }
bool UAdvancedVoiceLibrary::RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId) bool UAdvancedVoiceLibrary::RegisterRemoteTalker(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
@@ -106,7 +154,13 @@ bool UAdvancedVoiceLibrary::RegisterRemoteTalker(const FBPUniqueNetId& UniqueNet
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -117,7 +171,7 @@ bool UAdvancedVoiceLibrary::RegisterRemoteTalker(const FBPUniqueNetId& UniqueNet
return VoiceInterface->RegisterRemoteTalker(*UniqueNetId.GetUniqueNetId()); return VoiceInterface->RegisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
} }
bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId) bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
@@ -125,7 +179,13 @@ bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueN
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -136,9 +196,16 @@ bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueN
return VoiceInterface->UnregisterRemoteTalker(*UniqueNetId.GetUniqueNetId()); return VoiceInterface->UnregisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
} }
void UAdvancedVoiceLibrary::RemoveAllRemoteTalkers() void UAdvancedVoiceLibrary::RemoveAllRemoteTalkers(UObject* WorldContextObject)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -149,9 +216,16 @@ void UAdvancedVoiceLibrary::RemoveAllRemoteTalkers()
VoiceInterface->RemoveAllRemoteTalkers(); VoiceInterface->RemoveAllRemoteTalkers();
} }
bool UAdvancedVoiceLibrary::IsLocalPlayerTalking(uint8 LocalPlayerNum) bool UAdvancedVoiceLibrary::IsLocalPlayerTalking(UObject* WorldContextObject, uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -162,7 +236,7 @@ bool UAdvancedVoiceLibrary::IsLocalPlayerTalking(uint8 LocalPlayerNum)
return VoiceInterface->IsLocalPlayerTalking(LocalPlayerNum); return VoiceInterface->IsLocalPlayerTalking(LocalPlayerNum);
} }
bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId) bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
@@ -170,7 +244,13 @@ bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNe
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -181,7 +261,7 @@ bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNe
return VoiceInterface->IsRemotePlayerTalking(*UniqueNetId.GetUniqueNetId()); return VoiceInterface->IsRemotePlayerTalking(*UniqueNetId.GetUniqueNetId());
} }
bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId) bool UAdvancedVoiceLibrary::IsPlayerMuted(UObject* WorldContextObject, uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
@@ -189,7 +269,13 @@ bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPU
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -200,7 +286,7 @@ bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPU
return VoiceInterface->IsMuted(LocalUserNumChecking, *UniqueNetId.GetUniqueNetId()); return VoiceInterface->IsMuted(LocalUserNumChecking, *UniqueNetId.GetUniqueNetId());
} }
bool UAdvancedVoiceLibrary::MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide) bool UAdvancedVoiceLibrary::MuteRemoteTalker(UObject* WorldContextObject, uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
@@ -208,7 +294,13 @@ bool UAdvancedVoiceLibrary::MuteRemoteTalker(uint8 LocalUserNum, const FBPUnique
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -219,7 +311,7 @@ bool UAdvancedVoiceLibrary::MuteRemoteTalker(uint8 LocalUserNum, const FBPUnique
return VoiceInterface->MuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide); return VoiceInterface->MuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide);
} }
bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide) bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(UObject* WorldContextObject, uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide)
{ {
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
@@ -227,7 +319,13 @@ bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniq
return false; return false;
} }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
@@ -239,9 +337,16 @@ bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniq
} }
void UAdvancedVoiceLibrary::GetNumLocalTalkers(int32 & NumLocalTalkers) void UAdvancedVoiceLibrary::GetNumLocalTalkers(UObject* WorldContextObject, int32 & NumLocalTalkers)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {