Add network latency to performance overlay

This commit is contained in:
Cameron Gutman
2021-05-15 16:56:19 -05:00
parent 2ca5182a28
commit e79c12a038
5 changed files with 19 additions and 1 deletions

View File

@@ -656,6 +656,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
}
float decodeTimeMs = (float)lastTwo.decoderTimeMs / lastTwo.totalFramesReceived;
long rttInfo = MoonBridge.getEstimatedRttInfo();
StringBuilder sb = new StringBuilder();
sb.append(context.getString(R.string.perf_overlay_dimensions, initialWidth + "x" + initialHeight)).append('\n');
sb.append(context.getString(R.string.perf_overlay_decoder, decoder)).append('\n');
@@ -664,6 +665,8 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer {
sb.append(context.getString(R.string.perf_overlay_renderingfps, fps.renderedFps)).append('\n');
sb.append(context.getString(R.string.perf_overlay_netdrops,
(float)lastTwo.framesLost / lastTwo.totalFrames * 100)).append('\n');
sb.append(context.getString(R.string.perf_overlay_netlatency,
(rttInfo >> 32) & 0xFFFF, rttInfo & 0xFFFF)).append('\n');
sb.append(context.getString(R.string.perf_overlay_recvtime,
((float)lastTwo.totalTimeMs / lastTwo.totalFramesReceived) - decodeTimeMs)).append('\n');
sb.append(context.getString(R.string.perf_overlay_dectime, decodeTimeMs));

View File

@@ -306,5 +306,8 @@ public class MoonBridge {
public static native String stringifyPortFlags(int portFlags, String separator);
// The RTT is in the top 32 bits, and the RTT variance is in the bottom 32 bits
public static native long getEstimatedRttInfo();
public static native void init();
}

View File

@@ -134,4 +134,15 @@ Java_com_limelight_nvstream_jni_MoonBridge_stringifyPortFlags(JNIEnv *env, jclas
(*env)->ReleaseStringUTFChars(env, separator, separatorStr);
return (*env)->NewStringUTF(env, outputBuffer);
}
JNIEXPORT jlong JNICALL
Java_com_limelight_nvstream_jni_MoonBridge_getEstimatedRttInfo(JNIEnv *env, jclass clazz) {
uint32_t rtt, variance;
if (!LiGetEstimatedRttInfo(&rtt, &variance)) {
return -1;
}
return ((uint64_t)rtt << 32U) | variance;
}

View File

@@ -110,6 +110,7 @@
<string name="perf_overlay_incomingfps">Incoming frame rate from network: %1$.2f FPS</string>
<string name="perf_overlay_renderingfps">Rendering frame rate: %1$.2f FPS</string>
<string name="perf_overlay_netdrops">Frames dropped by your network connection: %1$.2f%%</string>
<string name="perf_overlay_netlatency">Average network latency: %1$d ms (variance: %2$d ms)</string>
<string name="perf_overlay_recvtime">Average receive time: %1$.2f ms</string>
<string name="perf_overlay_dectime">Average decoding time: %1$.2f ms</string>