From 9669da026f9ab6d5c5b7ecc374068d2fc07c2538 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 6 Aug 2020 22:01:45 -0700 Subject: [PATCH] Test network when the connection terminates due to lack of video traffic --- app/src/main/java/com/limelight/Game.java | 30 ++++++++++++++----- .../limelight/nvstream/jni/MoonBridge.java | 2 ++ .../jni/moonlight-core/moonlight-common-c | 2 +- app/src/main/jni/moonlight-core/simplejni.c | 5 ++++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index 4d3a4754..42200663 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -1586,14 +1586,30 @@ public class Game extends Activity implements SurfaceHolder.Callback, if (errorCode != MoonBridge.ML_ERROR_GRACEFUL_TERMINATION) { String message; - switch (errorCode) { - case MoonBridge.ML_ERROR_NO_VIDEO_TRAFFIC: - message = getResources().getString(R.string.no_video_received_error); - break; + // Perform a connection test if the failure could be due to a blocked port + int portFlags = MoonBridge.getPortFlagsFromTerminationErrorCode(errorCode); + int portTestResult; + if (portFlags != 0) { + portTestResult = MoonBridge.testClientConnectivity(ServerHelper.CONNECTION_TEST_SERVER, 443, portFlags); + } + else { + portTestResult = MoonBridge.ML_TEST_RESULT_INCONCLUSIVE; + } - default: - message = getResources().getString(R.string.conn_terminated_msg); - break; + if (portTestResult != MoonBridge.ML_TEST_RESULT_INCONCLUSIVE && portTestResult != 0) { + // If we got a blocked result, that supersedes any other error message + message = getResources().getString(R.string.nettest_text_blocked); + } + else { + switch (errorCode) { + case MoonBridge.ML_ERROR_NO_VIDEO_TRAFFIC: + message = getResources().getString(R.string.no_video_received_error); + break; + + default: + message = getResources().getString(R.string.conn_terminated_msg); + break; + } } Dialog.displayDialog(Game.this, getResources().getString(R.string.conn_terminated_title), diff --git a/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java b/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java index 1ef97133..fa08c87f 100644 --- a/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java +++ b/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java @@ -298,5 +298,7 @@ public class MoonBridge { public static native int getPortFlagsFromStage(int stage); + public static native int getPortFlagsFromTerminationErrorCode(int errorCode); + public static native void init(); } diff --git a/app/src/main/jni/moonlight-core/moonlight-common-c b/app/src/main/jni/moonlight-core/moonlight-common-c index 60103676..2fdcfb94 160000 --- a/app/src/main/jni/moonlight-core/moonlight-common-c +++ b/app/src/main/jni/moonlight-core/moonlight-common-c @@ -1 +1 @@ -Subproject commit 6010367637f79f339fe96b72a446d41c2110ce26 +Subproject commit 2fdcfb9429be64842d2a730801d2b5700d40d7b9 diff --git a/app/src/main/jni/moonlight-core/simplejni.c b/app/src/main/jni/moonlight-core/simplejni.c index e141c273..53d7cfc5 100644 --- a/app/src/main/jni/moonlight-core/simplejni.c +++ b/app/src/main/jni/moonlight-core/simplejni.c @@ -129,4 +129,9 @@ Java_com_limelight_nvstream_jni_MoonBridge_getProtocolFromPortFlagIndex(JNIEnv * JNIEXPORT jint JNICALL Java_com_limelight_nvstream_jni_MoonBridge_getPortFlagsFromStage(JNIEnv *env, jclass clazz, jint stage) { return LiGetPortFlagsFromStage(stage); +} + +JNIEXPORT jint JNICALL +Java_com_limelight_nvstream_jni_MoonBridge_getPortFlagsFromTerminationErrorCode(JNIEnv *env, jclass clazz, jint errorCode) { + return LiGetPortFlagsFromTerminationErrorCode(errorCode); } \ No newline at end of file