Compare commits

..
10 Commits
6 changed files with 38 additions and 13 deletions

No files matched your search

+2 -2
View File
@@ -11,8 +11,8 @@ android {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 23 targetSdkVersion 23
versionName "4.5.4" versionName "4.5.6"
versionCode = 91 versionCode = 94
} }
productFlavors { productFlavors {
Binary file not shown.
+1 -1
View File
@@ -327,7 +327,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
Dialog.displayDialog(PcView.this, getResources().getString(R.string.pair_pairing_title), Dialog.displayDialog(PcView.this, getResources().getString(R.string.pair_pairing_title),
getResources().getString(R.string.pair_pairing_msg)+" "+pinStr, false); getResources().getString(R.string.pair_pairing_msg)+" "+pinStr, false);
PairingManager.PairState pairState = httpConn.pair(pinStr); PairingManager.PairState pairState = httpConn.pair(httpConn.getServerInfo(), pinStr);
if (pairState == PairingManager.PairState.PIN_WRONG) { if (pairState == PairingManager.PairState.PIN_WRONG) {
message = getResources().getString(R.string.pair_incorrect_pin); message = getResources().getString(R.string.pair_incorrect_pin);
} }
+33 -8
View File
@@ -1,6 +1,8 @@
#include "enet/enet.h" #include "enet/enet.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <jni.h> #include <jni.h>
#define CLIENT_TO_LONG(x) ((intptr_t)(x)) #define CLIENT_TO_LONG(x) ((intptr_t)(x))
@@ -15,9 +17,21 @@ Java_com_limelight_nvstream_enet_EnetConnection_initializeEnet(JNIEnv *env, jobj
} }
JNIEXPORT jlong JNICALL JNIEXPORT jlong JNICALL
Java_com_limelight_nvstream_enet_EnetConnection_createClient(JNIEnv *env, jobject class) { Java_com_limelight_nvstream_enet_EnetConnection_createClient(JNIEnv *env, jobject class, jstring address) {
ENetAddress enetAddress;
const char *addrStr;
int err;
// Perform a lookup on the address to determine the address family
addrStr = (*env)->GetStringUTFChars(env, address, 0);
err = enet_address_set_host(&enetAddress, addrStr);
(*env)->ReleaseStringUTFChars(env, address, addrStr);
if (err < 0) {
return CLIENT_TO_LONG(NULL);
}
// Create a client that can use 1 outgoing connection and 1 channel // Create a client that can use 1 outgoing connection and 1 channel
return CLIENT_TO_LONG(enet_host_create(NULL, 1, 1, 0, 0)); return CLIENT_TO_LONG(enet_host_create(enetAddress.address.ss_family, NULL, 1, 1, 0, 0));
} }
JNIEXPORT jlong JNICALL JNIEXPORT jlong JNICALL
@@ -26,12 +40,16 @@ Java_com_limelight_nvstream_enet_EnetConnection_connectToPeer(JNIEnv *env, jobje
ENetAddress enetAddress; ENetAddress enetAddress;
ENetEvent event; ENetEvent event;
const char *addrStr; const char *addrStr;
int err;
// Initialize the ENet address // Initialize the ENet address
addrStr = (*env)->GetStringUTFChars(env, address, 0); addrStr = (*env)->GetStringUTFChars(env, address, 0);
enet_address_set_host(&enetAddress, addrStr); err = enet_address_set_host(&enetAddress, addrStr);
enet_address_set_port(&enetAddress, port); enet_address_set_port(&enetAddress, port);
(*env)->ReleaseStringUTFChars(env, address, addrStr); (*env)->ReleaseStringUTFChars(env, address, addrStr);
if (err < 0) {
return PEER_TO_LONG(NULL);
}
// Start the connection // Start the connection
peer = enet_host_connect(LONG_TO_CLIENT(client), &enetAddress, 1, 0); peer = enet_host_connect(LONG_TO_CLIENT(client), &enetAddress, 1, 0);
@@ -99,9 +117,16 @@ Java_com_limelight_nvstream_enet_EnetConnection_writePacket(JNIEnv *env, jobject
packet = enet_packet_create(dataPtr, length, packetFlags); packet = enet_packet_create(dataPtr, length, packetFlags);
if (packet != NULL) { if (packet != NULL) {
// Send the message to the peer // Send the message to the peer
enet_peer_send(LONG_TO_PEER(peer), 0, packet); if (enet_peer_send(LONG_TO_PEER(peer), 0, packet) < 0) {
enet_host_flush(LONG_TO_CLIENT(client)); // This can fail if the peer has been disconnected
ret = JNI_TRUE; enet_packet_destroy(packet);
ret = JNI_FALSE;
}
else {
// Force the client to send the packet now
enet_host_flush(LONG_TO_CLIENT(client));
ret = JNI_TRUE;
}
} }
else { else {
ret = JNI_FALSE; ret = JNI_FALSE;
@@ -112,12 +137,12 @@ Java_com_limelight_nvstream_enet_EnetConnection_writePacket(JNIEnv *env, jobject
return ret; return ret;
} }
JNIEXPORT jint JNICALL JNIEXPORT void JNICALL
Java_com_limelight_nvstream_enet_EnetConnection_destroyClient(JNIEnv *env, jobject class, jlong client) { Java_com_limelight_nvstream_enet_EnetConnection_destroyClient(JNIEnv *env, jobject class, jlong client) {
enet_host_destroy(LONG_TO_CLIENT(client)); enet_host_destroy(LONG_TO_CLIENT(client));
} }
JNIEXPORT jint JNICALL JNIEXPORT void JNICALL
Java_com_limelight_nvstream_enet_EnetConnection_disconnectPeer(JNIEnv *env, jobject class, jlong peer) { Java_com_limelight_nvstream_enet_EnetConnection_disconnectPeer(JNIEnv *env, jobject class, jlong peer) {
enet_peer_disconnect_now(LONG_TO_PEER(peer), 0); enet_peer_disconnect_now(LONG_TO_PEER(peer), 0);
} }
+1 -1
View File
@@ -4,7 +4,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta6' classpath 'com.android.tools.build:gradle:2.1.0-alpha4'
} }
} }