mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 03:58:08 +00:00
52 lines
No EOL
1.8 KiB
Text
52 lines
No EOL
1.8 KiB
Text
/*
|
|
linphone_jni.cc
|
|
Copyright (C) 2017 Belledonne Communications SARL
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include <jni.h>
|
|
#include <cpu-features.h>
|
|
|
|
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) {
|
|
#ifdef __ANDROID__
|
|
ms_set_jvm(ajvm);
|
|
#endif /* __ANDROID__ */
|
|
jvm=ajvm;
|
|
return JNI_VERSION_1_2;
|
|
}
|
|
|
|
static const char* GetStringUTFChars(JNIEnv* env, jstring string) {
|
|
const char *cstring = string ? env->GetStringUTFChars(string, NULL) : NULL;
|
|
return cstring;
|
|
}
|
|
|
|
static void ReleaseStringUTFChars(JNIEnv* env, jstring string, const char *cstring) {
|
|
if (string) env->ReleaseStringUTFChars(string, cstring);
|
|
}
|
|
|
|
static jlong GetObjectNativePtr(JNIEnv *env, jobject object) {
|
|
jclass objClass = env->GetObjectClass(object);
|
|
jfieldID nativePtrId = env->GetFieldID(objClass, "nativePtr", "J");
|
|
jlong nativePtr = env->GetLongField(object, nativePtrId);
|
|
return nativePtr;
|
|
}
|
|
|
|
static jlong SetObjectNativePtr(JNIEnv *env, jobject object, jlong ptr) {
|
|
jclass objClass = env->GetObjectClass(object);
|
|
jfieldID nativePtrId = env->GetFieldID(objClass, "nativePtr", "J");
|
|
env->SetLongField(object, nativePtrId, ptr);
|
|
return ptr;
|
|
} |