mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 11:03:01 +00:00
Add Java bindings to STUN code in moonlight-common-c
This commit is contained in:
parent
16c4b2532d
commit
c9cf485025
@ -347,4 +347,8 @@ public class NvConnection {
|
||||
MoonBridge.sendMouseScroll(scrollClicks);
|
||||
}
|
||||
}
|
||||
|
||||
public static String findExternalAddressForMdns() {
|
||||
return MoonBridge.findExternalAddressIP4("stun.stunprotocol.org", 3478);
|
||||
}
|
||||
}
|
||||
|
@ -203,5 +203,7 @@ public class MoonBridge {
|
||||
|
||||
public static native String getStageName(int stage);
|
||||
|
||||
public static native String findExternalAddressIP4(String stunHostName, int stunPort);
|
||||
|
||||
public static native void init();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ LOCAL_SRC_FILES := moonlight-common-c/src/AudioStream.c \
|
||||
moonlight-common-c/src/RtspConnection.c \
|
||||
moonlight-common-c/src/RtspParser.c \
|
||||
moonlight-common-c/src/SdpGenerator.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 \
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 558ba488e8eb7a614b6d9a93968c7c69683f942d
|
||||
Subproject commit 0eed722635f411ebfef662501e35733f6fb24e0c
|
@ -1,6 +1,9 @@
|
||||
#include <Limelight.h>
|
||||
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_limelight_nvstream_jni_MoonBridge_sendMouseMove(JNIEnv *env, jclass clazz, jshort deltaX, jshort deltaY) {
|
||||
@ -54,3 +57,27 @@ JNIEXPORT jstring JNICALL
|
||||
Java_com_limelight_nvstream_jni_MoonBridge_getStageName(JNIEnv *env, jclass clazz, jint stage) {
|
||||
return (*env)->NewStringUTF(env, LiGetStageName(stage));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_limelight_nvstream_jni_MoonBridge_findExternalAddressIP4(JNIEnv *env, jclass clazz, jstring stunHostName, jint stunPort) {
|
||||
int err;
|
||||
struct in_addr wanAddr;
|
||||
const char* stunHostNameStr = (*env)->GetStringUTFChars(env, stunHostName, NULL);
|
||||
|
||||
err = LiFindExternalAddressIP4(stunHostNameStr, stunPort, &wanAddr.s_addr);
|
||||
(*env)->ReleaseStringUTFChars(env, stunHostName, stunHostNameStr);
|
||||
|
||||
if (err == 0) {
|
||||
char addrStr[INET_ADDRSTRLEN];
|
||||
|
||||
inet_ntop(AF_INET, &wanAddr, addrStr, sizeof(addrStr));
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "moonlight-common-c", "Resolved WAN address to %s", addrStr);
|
||||
|
||||
return (*env)->NewStringUTF(env, addrStr);
|
||||
}
|
||||
else {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "moonlight-common-c", "STUN failed to get WAN address: %d", err);
|
||||
return NULL;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user