Commit a23c0e4f authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed issue with refs for video surfaces in JNI layer

parent 6b02c99f
......@@ -358,7 +358,11 @@ class JavaTranslator(object):
return methodDict
def translate_jni_method(self, className, _method, static=False):
methodDict = {}
jni_blacklist = ['linphone_call_set_native_video_window_id',\
'linphone_core_set_native_preview_window_id',\
'linphone_core_set_native_video_window_id']
methodDict = {'notEmpty': True}
methodDict['classCName'] = 'Linphone' + className.to_camel_case()
methodDict['className'] = className.to_camel_case()
methodDict['classImplName'] = className.to_camel_case() + 'Impl'
......@@ -378,6 +382,9 @@ class JavaTranslator(object):
methodDict['isRealObjectArray'] = False
methodDict['isStringObjectArray'] = False
methodDict['c_type_return'] = self.translate_as_c_base_type(_method.returnType)
if methodDict['c_name'] in jni_blacklist:
return {'notEmpty': False}
if methodDict['hasListReturn']:
if type(_method.returnType) is AbsApi.BaseType and _method.returnType.name == 'string_array':
......
......@@ -419,6 +419,7 @@ jobject Java_{{jni_package}}FactoryImpl_createCore(JNIEnv *env, jobject thiz, jo
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{{#methods}}
{{#notEmpty}}
{{return}} {{name}}({{params}}) {
{{#notStatic}}{{classCName}} *cptr = ({{classCName}}*)ptr;{{/notStatic}}{{#strings}}
const char* c_{{string}} = GetStringUTFChars(env, {{string}});
......@@ -482,9 +483,67 @@ jobject Java_{{jni_package}}FactoryImpl_createCore(JNIEnv *env, jobject thiz, jo
env->ReleaseByteArrayElements({{bytesargname}}, (jbyte*)c_{{bytesargname}}, JNI_ABORT);
{{/bytes}}{{#hasReturn}}return jni_result;{{/hasReturn}}{{#hasListReturn}}return jni_list_result;{{/hasListReturn}}
}
{{/notEmpty}}
{{/methods}}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Manually wrapped
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Java_org_linphone_core_CallImpl_setNativeVideoWindowId(JNIEnv *env, jobject thiz, jlong ptr, jobject id) {
LinphoneCall *cptr = (LinphoneCall*)ptr;
jobject oldWindow = (jobject) linphone_call_get_native_video_window_id(cptr);
if (oldWindow == id) {
ms_warning("Java_org_linphone_core_CallImpl_setNativeVideoWindowId(): new id (%p) is the same as the current one, skipping...", id);
return;
}
if (id != NULL) {
id = env->NewGlobalRef(id);
ms_message("Java_org_linphone_core_CallImpl_setNativeVideoWindowId(): NewGlobalRef(%p)", id);
} else ms_message("Java_org_linphone_core_CallImpl_setNativeVideoWindowId(): setting to NULL");
linphone_call_set_native_video_window_id(cptr, (void *)id);
if (oldWindow != NULL) {
ms_message("Java_org_linphone_core_CallImpl_setNativeVideoWindowId(): DeleteGlobalRef(%p)", oldWindow);
env->DeleteGlobalRef(oldWindow);
}
}
void Java_org_linphone_core_CoreImpl_setNativePreviewWindowId(JNIEnv *env, jobject thiz, jlong ptr, jobject id) {
LinphoneCore *cptr = (LinphoneCore*)ptr;
jobject oldWindow = (jobject) linphone_core_get_native_video_window_id(cptr);
if (oldWindow == id) {
ms_warning("Java_org_linphone_core_CoreImpl_setNativePreviewWindowId(): new id (%p) is the same as the current one, skipping...", id);
return;
}
if (id != NULL) {
id = env->NewGlobalRef(id);
ms_message("Java_org_linphone_core_CoreImpl_setNativePreviewWindowId(): NewGlobalRef(%p)", id);
} else ms_message("Java_org_linphone_core_CoreImpl_setNativePreviewWindowId(): setting to NULL");
linphone_core_set_native_preview_window_id(cptr, (void *)id);
if (oldWindow != NULL) {
ms_message("Java_org_linphone_core_CoreImpl_setNativePreviewWindowId(): DeleteGlobalRef(%p)", oldWindow);
env->DeleteGlobalRef(oldWindow);
}
}
void Java_org_linphone_core_CoreImpl_setNativeVideoWindowId(JNIEnv *env, jobject thiz, jlong ptr, jobject id) {
LinphoneCore *cptr = (LinphoneCore*)ptr;
jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id(cptr);
if (oldWindow == id) {
ms_warning("Java_org_linphone_core_CoreImpl_setNativeVideoWindowId(): new id (%p) is the same as the current one, skipping...", id);
return;
}
if (id != NULL) {
id = env->NewGlobalRef(id);
ms_message("Java_org_linphone_core_CoreImpl_setNativeVideoWindowId(): NewGlobalRef(%p)", id);
} else ms_message("Java_org_linphone_core_CoreImpl_setNativeVideoWindowId(): setting to NULL");
linphone_core_set_native_video_window_id(cptr, (void *)id);
if (oldWindow != NULL) {
ms_message("Java_org_linphone_core_CoreImpl_setNativeVideoWindowId(): DeleteGlobalRef(%p)", oldWindow);
env->DeleteGlobalRef(oldWindow);
}
}
#ifdef __cplusplus
}
#endif
\ No newline at end of file
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