bool FOnlineVoiceImpl::Init()
{
	bool bSuccess = false;

	if (!GConfig->GetInt(TEXT("OnlineSubsystem"),TEXT("MaxLocalTalkers"), MaxLocalTalkers, GEngineIni))
	{
		MaxLocalTalkers = MAX_SPLITSCREEN_TALKERS;
		UE_LOG(LogVoice, Warning, TEXT("Missing MaxLocalTalkers key in OnlineSubsystem of DefaultEngine.ini"));
	}
	if (!GConfig->GetInt(TEXT("OnlineSubsystem"),TEXT("MaxRemoteTalkers"), MaxRemoteTalkers, GEngineIni))
	{
		MaxRemoteTalkers = MAX_REMOTE_TALKERS;
		UE_LOG(LogVoice, Warning, TEXT("Missing MaxRemoteTalkers key in OnlineSubsystem of DefaultEngine.ini"));
	}
	if (!GConfig->GetFloat(TEXT("OnlineSubsystem"),TEXT("VoiceNotificationDelta"), VoiceNotificationDelta, GEngineIni))
	{
		VoiceNotificationDelta = 0.2;
		UE_LOG(LogVoice, Warning, TEXT("Missing VoiceNotificationDelta key in OnlineSubsystem of DefaultEngine.ini"));
	}

	if (OnlineSubsystem)
	{
		SessionInt = OnlineSubsystem->GetSessionInterface().Get();
		IdentityInt = OnlineSubsystem->GetIdentityInterface().Get();

		bSuccess = SessionInt && IdentityInt;
	}

	if (bSuccess && !IsRunningDedicatedServer())
	{
		VoiceEngine = new FVoiceEngineImpl(OnlineSubsystem);
		bSuccess = VoiceEngine->Init(MaxLocalTalkers, MaxRemoteTalkers);
		LocalTalkers.Init(FLocalTalker(), MaxLocalTalkers);
	}

	RemoteTalkers.Empty(MaxRemoteTalkers);

	if (!bSuccess)
	{
		LocalTalkers.Empty();
		RemoteTalkers.Empty();

		delete VoiceEngine;
		VoiceEngine = NULL;

		UE_LOG(LogVoice, Warning, TEXT("Failed to initialize voice interface"));
	}

	return bSuccess;
}
Exemplo n.º 2
0
bool FOnlineVoiceSteam::Init()
{
	bool bSuccess = false;

	if (!GConfig->GetInt(TEXT("OnlineSubsystem"),TEXT("MaxLocalTalkers"), MaxLocalTalkers, GEngineIni))
	{
		MaxLocalTalkers = MAX_SPLITSCREEN_TALKERS;
		UE_LOG(LogVoice, Warning, TEXT("Missing MaxLocalTalkers key in OnlineSubsystem of DefaultEngine.ini"));
	}
	if (!GConfig->GetInt(TEXT("OnlineSubsystem"),TEXT("MaxRemoteTalkers"), MaxRemoteTalkers, GEngineIni))
	{
		MaxRemoteTalkers = MAX_REMOTE_TALKERS;
		UE_LOG(LogVoice, Warning, TEXT("Missing MaxRemoteTalkers key in OnlineSubsystem of DefaultEngine.ini"));
	}
	if (!GConfig->GetFloat(TEXT("OnlineSubsystem"),TEXT("VoiceNotificationDelta"), VoiceNotificationDelta, GEngineIni))
	{
		VoiceNotificationDelta = 0.2;
		UE_LOG(LogVoice, Warning, TEXT("Missing VoiceNotificationDelta key in OnlineSubsystem of DefaultEngine.ini"));
	}

	if (SteamSubsystem)
	{
		SessionInt = (FOnlineSessionSteam*)SteamSubsystem->GetSessionInterface().Get();
		IdentityInt = (FOnlineIdentitySteam*)SteamSubsystem->GetIdentityInterface().Get();

		bSuccess = SessionInt && IdentityInt;
	}

	const bool bIntentionallyDisabled = SteamSubsystem->IsDedicated() || GIsBuildMachine;
	if (bSuccess && !bIntentionallyDisabled)
	{
		VoiceEngine = MakeShareable(new FVoiceEngineSteam(SteamSubsystem));
		bSuccess = VoiceEngine->Init(MaxLocalTalkers, MaxRemoteTalkers);
	}

	LocalTalkers.Init(FLocalTalker(), MaxLocalTalkers);
	RemoteTalkers.Empty(MaxRemoteTalkers);

	if (!bSuccess)
	{
		UE_LOG(LogVoice, Warning, TEXT("Failed to initialize Steam voice interface"));

		LocalTalkers.Empty();
		RemoteTalkers.Empty();
		VoiceEngine = NULL;
	}

	return bSuccess;
}