diff --git a/src/ControlStream.c b/src/ControlStream.c index ce75c92..33c8540 100644 --- a/src/ControlStream.c +++ b/src/ControlStream.c @@ -570,8 +570,15 @@ static void controlReceiveThreadFunc(void* context) { // SERVER_TERMINATED_INTENDED if (terminationReason == 0x0100) { - // Pass error code 0 to notify the client that this was not an error - terminationErrorCode = ML_ERROR_GRACEFUL_TERMINATION; + if (lastSeenFrame != 0) { + // Pass error code 0 to notify the client that this was not an error + terminationErrorCode = ML_ERROR_GRACEFUL_TERMINATION; + } + else { + // We never saw a frame, so this is probably an error that caused + // NvStreamer to terminate prior to sending any frames. + terminationErrorCode = ML_ERROR_UNEXPECTED_EARLY_TERMINATION; + } } else { // Otherwise pass the reason unmodified diff --git a/src/Limelight.h b/src/Limelight.h index 86803ed..307091b 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -369,6 +369,12 @@ typedef void(*ConnListenerConnectionTerminated)(int errorCode); // an extremely unstable connection or a bitrate that is far too high. #define ML_ERROR_NO_VIDEO_FRAME -101 +// This error is passed to ConnListenerConnectionTerminated() if the stream ends +// very soon after starting due to a graceful termination from the host. Usually +// this seems to happen if DRM protected content is on-screen, or another issue +// that prevents the encoder from being able to capture video successfully. +#define ML_ERROR_UNEXPECTED_EARLY_TERMINATION -102 + // This callback is invoked to log debug message typedef void(*ConnListenerLogMessage)(const char* format, ...);