Skip to content

Commit

Permalink
RemotePlayPlugin: Improved LibStreaming error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrin committed Feb 26, 2018
1 parent 9f9c54c commit 596d1f0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,44 @@ class FCaptureContext

void __declspec(noinline) Initialize_GameThread()
{
StreamingIO.Reset(Streaming::createNetworkIO(Streaming::NetworkAPI::ENET));
StreamingIO->listen((int)StreamParams.ConnectionPort);
try
{
StreamingIO.Reset(Streaming::createNetworkIO(Streaming::NetworkAPI::ENET));
StreamingIO->listen((int)StreamParams.ConnectionPort);
}
catch(const std::exception& e)
{
UE_LOG(LogRemotePlayPlugin, Fatal, TEXT("%s"), UTF8_TO_TCHAR(e.what()));
}
}

void __declspec(noinline) Initialize_RenderThread(FRHICommandListImmediate& RHICmdList)
{
RHI.Reset(new FRemotePlayRHI(RHICmdList, StreamParams.FrameWidth, StreamParams.FrameHeight));

StreamingEncoder.Reset(Streaming::createEncoder(Streaming::Platform::NV));
StreamingEncoder->initialize(RHI.Get(), StreamParams.FrameWidth, StreamParams.FrameHeight, StreamParams.IDRFrequency);
try
{
StreamingEncoder.Reset(Streaming::createEncoder(Streaming::Platform::NV));
StreamingEncoder->initialize(RHI.Get(), StreamParams.FrameWidth, StreamParams.FrameHeight, StreamParams.IDRFrequency);
}
catch(const std::exception& e)
{
UE_LOG(LogRemotePlayPlugin, Fatal, TEXT("%s"), UTF8_TO_TCHAR(e.what()));
}

FrameIndex = 0;
}

void __declspec(noinline) Release_RenderThread(FRHICommandListImmediate& RHICmdList)
{
StreamingEncoder->shutdown();
try
{
StreamingEncoder->shutdown();
}
catch(const std::exception& e)
{
UE_LOG(LogRemotePlayPlugin, Fatal, TEXT("%s"), UTF8_TO_TCHAR(e.what()));
}
}

void ProjectCapturedEnvironment(
Expand All @@ -128,12 +149,19 @@ class FCaptureContext

void ProcessCapturedEnvironment()
{
StreamingEncoder->encode(FrameIndex++);
StreamingIO->processServer();
try
{
StreamingEncoder->encode(FrameIndex++);
StreamingIO->processServer();

const Streaming::Bitstream Bitstream = StreamingEncoder->lock();
StreamingIO->write(Bitstream);
StreamingEncoder->unlock();
const Streaming::Bitstream Bitstream = StreamingEncoder->lock();
StreamingIO->write(Bitstream);
StreamingEncoder->unlock();
}
catch(const std::exception& e)
{
UE_LOG(LogRemotePlayPlugin, Fatal, TEXT("%s"), UTF8_TO_TCHAR(e.what()));
}
}

TUniquePtr<FRemotePlayRHI> RHI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ class FViewContext
{
if(!bConnected)
{
try {
try
{
StreamingIO->connect(TCHAR_TO_UTF8(*RemoteAddr), (int)StreamParams.ConnectionPort);
bConnected = true;
}
catch(const std::exception&) {
UE_LOG(LogRemotePlayPlugin, Warning, TEXT("Failed to connect to RemotePlay server. Retrying..."));
return false;
}
}
Expand All @@ -170,27 +172,47 @@ class FViewContext
RHI.Reset(new FRemotePlayRHI(RHICmdList, StreamParams.FrameWidth, StreamParams.FrameHeight));
RHI->createSurface(Streaming::SurfaceFormat::ARGB);

StreamingDecoder.Reset(Streaming::createDecoder(Streaming::Platform::NV));

StreamingDecoder->initialize(RHI.Get(), StreamParams.FrameWidth, StreamParams.FrameHeight);
try
{
StreamingDecoder.Reset(Streaming::createDecoder(Streaming::Platform::NV));
StreamingDecoder->initialize(RHI.Get(), StreamParams.FrameWidth, StreamParams.FrameHeight);
}
catch(const std::exception& e)
{
UE_LOG(LogRemotePlayPlugin, Fatal, TEXT("%s"), UTF8_TO_TCHAR(e.what()));
}
}

void __declspec(noinline) Release_RenderThread(FRHICommandListImmediate& RHICmdList)
{
StreamingDecoder->shutdown();
try
{
StreamingDecoder->shutdown();
}
catch(const std::exception& e)
{
UE_LOG(LogRemotePlayPlugin, Fatal, TEXT("%s"), UTF8_TO_TCHAR(e.what()));
}
}

bool DecodeFrame()
{
if(StreamingIO->processClient())
try
{
Streaming::Bitstream Bitstream = StreamingIO->read();
if(Bitstream)
if(StreamingIO->processClient())
{
StreamingDecoder->decode(Bitstream);
return true;
Streaming::Bitstream Bitstream = StreamingIO->read();
if(Bitstream)
{
StreamingDecoder->decode(Bitstream);
return true;
}
}
}
catch(const std::exception& e)
{
UE_LOG(LogRemotePlayPlugin, Fatal, TEXT("%s"), UTF8_TO_TCHAR(e.what()));
}
return false;
}

Expand Down

0 comments on commit 596d1f0

Please sign in to comment.