Commit 9fa66fc3 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Some fixes for Java wrapper

parent 12e1ccfe
...@@ -171,10 +171,10 @@ class {{classImplName}} {{#isLinphoneFactory}}extends{{/isLinphoneFactory}}{{#is ...@@ -171,10 +171,10 @@ class {{classImplName}} {{#isLinphoneFactory}}extends{{/isLinphoneFactory}}{{#is
@Override @Override
public native void setDebugMode(boolean enable, String tag); public native void setDebugMode(boolean enable, String tag);
private native Core createCore(long nativePtr, CoreListener listener, String configPath, String factoryConfigPath); private native Core createCore(Factory factory, CoreListener listener, String configPath, String factoryConfigPath);
@Override @Override
public Core createCore(CoreListener listener, String configPath, String factoryConfigPath) { public Core createCore(CoreListener listener, String configPath, String factoryConfigPath) {
return createCore(nativePtr, listener, configPath, factoryConfigPath); return createCore(this, listener, configPath, factoryConfigPath);
} }
{{/isLinphoneFactory}} {{/isLinphoneFactory}}
......
...@@ -70,6 +70,12 @@ static jlong GetObjectNativePtr(JNIEnv *env, jobject object) { ...@@ -70,6 +70,12 @@ static jlong GetObjectNativePtr(JNIEnv *env, jobject object) {
return nativePtr; return nativePtr;
} }
static void SetObjectNativePtr(JNIEnv *env, jobject object, jlong ptr) {
jclass objClass = env->GetObjectClass(object);
jfieldID nativePtrId = env->GetFieldID(objClass, "nativePtr", "J");
env->SetLongField(object, nativePtrId, ptr);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void linphone_android_log_handler(int prio, char *str) { void linphone_android_log_handler(int prio, char *str) {
...@@ -357,8 +363,9 @@ jobject Java_{{jni_package}}CoreImpl_getMediastreamerFactory(JNIEnv *env, jobjec ...@@ -357,8 +363,9 @@ jobject Java_{{jni_package}}CoreImpl_getMediastreamerFactory(JNIEnv *env, jobjec
return env->NewObject(ljb->ms_factory_class, ljb->ms_factory_class_constructor, (jlong)factory); return env->NewObject(ljb->ms_factory_class, ljb->ms_factory_class_constructor, (jlong)factory);
} }
jobject Java_{{jni_package}}FactoryImpl_createCore(JNIEnv *env, jobject thiz, jlong ptr, jobject jlistener, jstring jconfig_path, jstring jfactory_config_path) { jobject Java_{{jni_package}}FactoryImpl_createCore(JNIEnv *env, jobject thiz, jobject jfactory, jobject jlistener, jstring jconfig_path, jstring jfactory_config_path) {
LinphoneFactory *cptr = (LinphoneFactory*)ptr; LinphoneFactory *cptr = linphone_factory_get();
SetObjectNativePtr(env, jfactory, (jlong)cptr); // Set the C factory ptr as Factory.nativePtr for next factory calls
LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(cptr); LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(cptr);
jobject listener = env->NewGlobalRef(jlistener); jobject listener = env->NewGlobalRef(jlistener);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment