Commit 6dd6ea84 authored by Simon Morlat's avatar Simon Morlat

add TMMBR callback at java level

parent 84a8e169
......@@ -7755,19 +7755,45 @@ static void _next_video_frame_decoded_callback(LinphoneCall *call, void *user_da
return;
}
jobject listener = (jobject) user_data;
jobject listener = (jobject) env->NewLocalRef((jobject)user_data);
if (listener == NULL){
ms_error("_next_video_frame_decoded_callback: listener has gone.");
return;
}
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onNextVideoFrameDecoded","(Lorg/linphone/core/LinphoneCall;)V");
env->DeleteLocalRef(clazz);
jobject jcall = getCall(env, call);
env->CallVoidMethod(listener, method, jcall);
env->DeleteLocalRef(listener);
}
extern "C" void Java_org_linphone_core_LinphoneCallImpl_setListener(JNIEnv* env, jobject thiz, jlong ptr, jobject jlistener) {
jobject listener = env->NewGlobalRef(jlistener);
static void _on_tmmbr_received(LinphoneCall *call, int index, int bitrate){
LinphoneCallCbs *cbs = linphone_call_get_current_callbacks(call);
JNIEnv *env = ms_get_jni_env();
jobject listener = (jobject) env->NewLocalRef((jobject)linphone_call_cbs_get_user_data(cbs));
if (listener == NULL){
ms_error("_on_tmmbr_received: listener has gone.");
return;
}
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "tmmbrReceived","(Lorg/linphone/core/LinphoneCall;II)V");
env->DeleteLocalRef(clazz);
jobject jcall = getCall(env, call);
env->CallVoidMethod(listener, method, jcall,(jint)index, (jint)bitrate);
env->DeleteLocalRef(listener);
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallImpl_setListener(JNIEnv* env, jobject thiz, jlong ptr, jobject jlistener) {
LinphoneCall *call = (LinphoneCall *)ptr;
linphone_call_set_next_video_frame_decoded_callback(call, _next_video_frame_decoded_callback, listener);
LinphoneCallCbs *cbs = linphone_factory_create_call_cbs(linphone_factory_get());
linphone_call_cbs_set_user_data(cbs, env->NewWeakGlobalRef(jlistener));
linphone_call_cbs_set_tmmbr_received(cbs, _on_tmmbr_received);
linphone_call_add_callbacks(call, cbs);
linphone_call_set_next_video_frame_decoded_callback(call, _next_video_frame_decoded_callback, env->NewWeakGlobalRef(jlistener));
}
extern "C" void Java_org_linphone_core_LinphoneCallImpl_setVideoWindowId(JNIEnv* env
......
......@@ -31,8 +31,12 @@ public interface LinphoneCall {
/**
* LinphoneCall listener
*/
interface LinphoneCallListener {
public interface LinphoneCallListener {
void onNextVideoFrameDecoded(LinphoneCall call);
/**
* Invoked when a TMMBR RTCP packet is received.
*/
void tmmbrReceived(LinphoneCall call, int streamIndex, int bitrate);
}
/**
......
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