From 0dc4c4fe67548b0383d8dbff2d0ba7833e156e14 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 1 Sep 2026 00:03:22 -0500 Subject: [PATCH] Update moonlight-common-c --- .../binding/video/MediaCodecDecoderRenderer.java | 12 +++++++++--- .../nvstream/av/video/VideoDecoderRenderer.java | 2 +- .../java/com/limelight/nvstream/jni/MoonBridge.java | 6 ++++-- app/src/main/jni/moonlight-core/Android.mk | 7 +++++-- app/src/main/jni/moonlight-core/callbacks.c | 4 ++-- app/src/main/jni/moonlight-core/moonlight-common-c | 2 +- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java index d24ec0dc7..cca41a468 100644 --- a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java +++ b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java @@ -113,6 +113,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C private long lastTimestampUs; private int lastFrameNumber; + private long baseTimestampUs; private int refreshRate; private PreferenceConfiguration prefs; @@ -1396,7 +1397,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C @Override public int submitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int decodeUnitType, int frameNumber, int frameType, char frameHostProcessingLatency, - long receiveTimeMs, long enqueueTimeMs) { + long receiveTimeUs, long enqueueTimeUs) { if (stopping) { // Don't bother if we're stopping return MoonBridge.DR_OK; @@ -1695,7 +1696,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C // Count time from first packet received to enqueue time as receive time // We will count DU queue time as part of decoding, because it is directly // caused by a slow decoder. - activeWindowVideoStats.totalTimeMs += enqueueTimeMs - receiveTimeMs; + activeWindowVideoStats.totalTimeMs += (enqueueTimeUs - receiveTimeUs) / 1000; } if (!fetchNextInputBuffer()) { @@ -1721,7 +1722,12 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C } } - long timestampUs = enqueueTimeMs * 1000; + // The frame timestamps use an undefined epoch, so normalize them to uptime microseconds. + if (baseTimestampUs == 0) { + baseTimestampUs = (SystemClock.uptimeMillis() * 1000) - enqueueTimeUs; + } + + long timestampUs = baseTimestampUs + enqueueTimeUs; if (timestampUs <= lastTimestampUs) { // We can't submit multiple buffers with the same timestamp // so bump it up by one before queuing diff --git a/app/src/main/java/com/limelight/nvstream/av/video/VideoDecoderRenderer.java b/app/src/main/java/com/limelight/nvstream/av/video/VideoDecoderRenderer.java index 8c222eeee..a0f53f276 100644 --- a/app/src/main/java/com/limelight/nvstream/av/video/VideoDecoderRenderer.java +++ b/app/src/main/java/com/limelight/nvstream/av/video/VideoDecoderRenderer.java @@ -11,7 +11,7 @@ public abstract class VideoDecoderRenderer { // for an IDR frame which contains several parameter sets and the I-frame data. public abstract int submitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int decodeUnitType, int frameNumber, int frameType, char frameHostProcessingLatency, - long receiveTimeMs, long enqueueTimeMs); + long receiveTimeUs, long enqueueTimeUs); public abstract void cleanup(); 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 0a92ac916..0dcafff55 100644 --- a/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java +++ b/app/src/main/java/com/limelight/nvstream/jni/MoonBridge.java @@ -102,6 +102,7 @@ public class MoonBridge { public static final byte LI_CTYPE_XBOX = 0x01; public static final byte LI_CTYPE_PS = 0x02; public static final byte LI_CTYPE_NINTENDO = 0x03; + public static final byte LI_CTYPE_STEAM = 0x04; public static final short LI_CCAP_ANALOG_TRIGGERS = 0x01; public static final short LI_CCAP_RUMBLE = 0x02; @@ -111,6 +112,7 @@ public class MoonBridge { public static final short LI_CCAP_GYRO = 0x20; public static final short LI_CCAP_BATTERY_STATE = 0x40; public static final short LI_CCAP_RGB_LED = 0x80; + public static final short LI_CCAP_DUAL_TOUCHPAD = 0x100; public static final byte LI_MOTION_TYPE_ACCEL = 0x01; public static final byte LI_MOTION_TYPE_GYRO = 0x02; @@ -217,10 +219,10 @@ public class MoonBridge { public static int bridgeDrSubmitDecodeUnit(byte[] decodeUnitData, int decodeUnitLength, int decodeUnitType, int frameNumber, int frameType, char frameHostProcessingLatency, - long receiveTimeMs, long enqueueTimeMs) { + long receiveTimeUs, long enqueueTimeUs) { if (videoRenderer != null) { return videoRenderer.submitDecodeUnit(decodeUnitData, decodeUnitLength, - decodeUnitType, frameNumber, frameType, frameHostProcessingLatency, receiveTimeMs, enqueueTimeMs); + decodeUnitType, frameNumber, frameType, frameHostProcessingLatency, receiveTimeUs, enqueueTimeUs); } else { return DR_OK; diff --git a/app/src/main/jni/moonlight-core/Android.mk b/app/src/main/jni/moonlight-core/Android.mk index f74231a33..55027c0f8 100644 --- a/app/src/main/jni/moonlight-core/Android.mk +++ b/app/src/main/jni/moonlight-core/Android.mk @@ -28,7 +28,9 @@ LOCAL_SRC_FILES := moonlight-common-c/src/AudioStream.c \ moonlight-common-c/src/SimpleStun.c \ moonlight-common-c/src/VideoDepacketizer.c \ moonlight-common-c/src/VideoStream.c \ - moonlight-common-c/reedsolomon/rs.c \ + moonlight-common-c/nanors/deps/obl/oblas_common.c \ + moonlight-common-c/nanors/deps/obl/oblas_lite.c \ + moonlight-common-c/nanors/rs.c \ moonlight-common-c/enet/callbacks.c \ moonlight-common-c/enet/compress.c \ moonlight-common-c/enet/host.c \ @@ -44,7 +46,8 @@ LOCAL_SRC_FILES := moonlight-common-c/src/AudioStream.c \ LOCAL_C_INCLUDES := $(LOCAL_PATH)/moonlight-common-c/enet/include \ - $(LOCAL_PATH)/moonlight-common-c/reedsolomon \ + $(LOCAL_PATH)/moonlight-common-c/nanors/deps/obl \ + $(LOCAL_PATH)/moonlight-common-c/nanors \ $(LOCAL_PATH)/moonlight-common-c/src \ LOCAL_CFLAGS := -DHAS_SOCKLEN_T=1 -DLC_ANDROID -DHAVE_CLOCK_GETTIME=1 diff --git a/app/src/main/jni/moonlight-core/callbacks.c b/app/src/main/jni/moonlight-core/callbacks.c index 6b6e13ac5..b9be69177 100644 --- a/app/src/main/jni/moonlight-core/callbacks.c +++ b/app/src/main/jni/moonlight-core/callbacks.c @@ -168,7 +168,7 @@ int BridgeDrSubmitDecodeUnit(PDECODE_UNIT decodeUnit) { ret = (*env)->CallStaticIntMethod(env, GlobalBridgeClass, BridgeDrSubmitDecodeUnitMethod, DecodedFrameBuffer, currentEntry->length, currentEntry->bufferType, decodeUnit->frameNumber, decodeUnit->frameType, (jchar)decodeUnit->frameHostProcessingLatency, - (jlong)decodeUnit->receiveTimeMs, (jlong)decodeUnit->enqueueTimeMs); + (jlong)decodeUnit->receiveTimeUs, (jlong)decodeUnit->enqueueTimeUs); if ((*env)->ExceptionCheck(env)) { // We will crash here (*JVM)->DetachCurrentThread(JVM); @@ -189,7 +189,7 @@ int BridgeDrSubmitDecodeUnit(PDECODE_UNIT decodeUnit) { ret = (*env)->CallStaticIntMethod(env, GlobalBridgeClass, BridgeDrSubmitDecodeUnitMethod, DecodedFrameBuffer, offset, BUFFER_TYPE_PICDATA, decodeUnit->frameNumber, decodeUnit->frameType, (jchar)decodeUnit->frameHostProcessingLatency, - (jlong)decodeUnit->receiveTimeMs, (jlong)decodeUnit->enqueueTimeMs); + (jlong)decodeUnit->receiveTimeUs, (jlong)decodeUnit->enqueueTimeUs); if ((*env)->ExceptionCheck(env)) { // We will crash here (*JVM)->DetachCurrentThread(JVM); diff --git a/app/src/main/jni/moonlight-core/moonlight-common-c b/app/src/main/jni/moonlight-core/moonlight-common-c index 8af4562af..874ac9548 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 8af4562af672dd6b9ed28553ead172984fd9a683 +Subproject commit 874ac9548f1bd6f095ef2b435c42cdde460e7821