Exemplo n.º 1
0
/**
 * Processes the in bound bunch to extract the voice data
 *
 * @param Bunch the voice data to process
 */
void UVoiceChannel::ReceivedBunch(FInBunch& Bunch)
{
	IOnlineVoicePtr VoiceInt = Online::GetVoiceInterface();
	if (VoiceInt.IsValid())
	{
		while (!Bunch.AtEnd())
		{
			// Give the data to the local voice processing
			TSharedPtr<FVoicePacket> VoicePacket = VoiceInt->SerializeRemotePacket(Bunch);
			if (VoicePacket.IsValid())
			{
				if (Connection->Driver->ServerConnection == NULL)
				{
					// Possibly replicate the data to other clients
					Connection->Driver->ReplicateVoicePacket(VoicePacket, Connection);
				}
#if STATS
				// Increment the number of voice packets we've received
				Connection->Driver->VoicePacketsRecv++;
				Connection->Driver->VoiceBytesRecv += VoicePacket->GetBufferSize();
#endif
			}
		}
	}
}
void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers()
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister All Local Talkers couldn't get the voice interface!"));
		return;
	}

	VoiceInterface->UnregisterLocalTalkers();
}
bool UAdvancedVoiceLibrary::RegisterLocalTalker(uint8 LocalPlayerNum)
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talker couldn't get the voice interface!"));
		return false;
	}

	return VoiceInterface->RegisterLocalTalker(LocalPlayerNum);
}
void UAdvancedVoiceLibrary::StopNetworkedVoice(uint8 LocalPlayerNum)
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!"));
		return;
	}

	VoiceInterface->StopNetworkedVoice(LocalPlayerNum);
}
bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide)
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!"));
		return false;
	}

	return VoiceInterface->UnmuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide);
}
bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId)
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted couldn't get the voice interface!"));
		return false;
	}

	return VoiceInterface->IsMuted(LocalUserNumChecking, *UniqueNetId.GetUniqueNetId());
}
bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId)
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking couldn't get the voice interface!"));
		return false;
	}

	return VoiceInterface->IsRemotePlayerTalking(*UniqueNetId.GetUniqueNetId());
}
void UAdvancedVoiceLibrary::RemoveAllRemoteTalkers()
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("Remove All Remote Talkers couldn't get the voice interface!"));
		return;
	}

	VoiceInterface->RemoveAllRemoteTalkers();
}
bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId)
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker couldn't get the voice interface!"));
		return false;
	}

	return VoiceInterface->UnregisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
}
void UAdvancedVoiceLibrary::IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum)
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		bHasHeadset = false;
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("Check For Headset couldn't get the voice interface!"));
		return;
	}

	bHasHeadset = VoiceInterface->IsHeadsetPresent(LocalPlayerNum);
}
void UAdvancedVoiceLibrary::GetNumLocalTalkers(int32 & NumLocalTalkers)
{
	IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();

	if (!VoiceInterface.IsValid())
	{
		NumLocalTalkers = 0;
		UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!"));
		return;
	}

	NumLocalTalkers = VoiceInterface->GetNumLocalTalkers();
}
void FOnlineSessionNull::UnregisterVoice(const FUniqueNetId& PlayerId)
{
	IOnlineVoicePtr VoiceInt = NullSubsystem->GetVoiceInterface();
	if (VoiceInt.IsValid())
	{
		if (!NullSubsystem->IsLocalPlayer(PlayerId))
		{
			if (VoiceInt.IsValid())
			{
				VoiceInt->UnregisterRemoteTalker(PlayerId);
			}
		}
	}
}
void FOnlineSessionNull::RegisterLocalPlayers(FNamedOnlineSession* Session)
{
	if (!NullSubsystem->IsDedicated())
	{
		IOnlineVoicePtr VoiceInt = NullSubsystem->GetVoiceInterface();
		if (VoiceInt.IsValid())
		{
			for (int32 Index = 0; Index < MAX_LOCAL_PLAYERS; Index++)
			{
				// Register the local player as a local talker
				VoiceInt->RegisterLocalTalker(Index);
			}
		}
	}
}
void FOnlineSessionNull::RegisterVoice(const FUniqueNetId& PlayerId)
{
	IOnlineVoicePtr VoiceInt = NullSubsystem->GetVoiceInterface();
	if (VoiceInt.IsValid())
	{
		if (!NullSubsystem->IsLocalPlayer(PlayerId))
		{
			VoiceInt->RegisterRemoteTalker(PlayerId);
		}
		else
		{
			// This is a local player. In case their PlayerState came last during replication, reprocess muting
			VoiceInt->ProcessMuteChangeNotification();
		}
	}
}
Exemplo n.º 15
0
void UCheatManager::DumpVoiceMutingState()
{
	TSharedPtr<FUniqueNetId> NetId;
	
	UE_LOG(LogCheatManager, Display, TEXT(""));
	UE_LOG(LogCheatManager, Display, TEXT("-------------------------------------------------------------"));
	UE_LOG(LogCheatManager, Display, TEXT(""));

	// Log the online view of the voice state
	IOnlineVoicePtr VoiceInt = Online::GetVoiceInterface(GetWorld());
	if (VoiceInt.IsValid())
	{
		UE_LOG(LogCheatManager, Display, TEXT("\n%s"), *VoiceInt->GetVoiceDebugState());
	}

	// For each player list their gameplay mutes and system wide mutes
	UE_LOG(LogCheatManager, Display, TEXT("\n%s"), *DumpMutelistState(GetWorld()));
}
Exemplo n.º 16
0
void FPlayerMuteList::ClientMutePlayer(APlayerController* OwningPC, const FUniqueNetIdRepl& MuteId)
{
	const TSharedPtr<const FUniqueNetId>& PlayerIdToMute = MuteId.GetUniqueNetId();

	// Add to the filter list on clients (used for peer to peer voice)
	AddIdToMuteList(VoicePacketFilter, PlayerIdToMute);

	// Use the local player to determine the controller id
	ULocalPlayer* LP = Cast<ULocalPlayer>(OwningPC->Player);
	if (LP != NULL)
	{
		UWorld* World = OwningPC->GetWorld();
		IOnlineVoicePtr VoiceInt = Online::GetVoiceInterface(World);
		if (VoiceInt.IsValid())
		{
			// Have the voice subsystem mute this player
			VoiceInt->MuteRemoteTalker(LP->GetControllerId(), *PlayerIdToMute, false);
		}
	}
}