add TMMBR callback at java level

This commit is contained in:
Simon Morlat 2017-11-09 14:45:55 +01:00
parent 757c396fbf
commit c6a06ea0a7
2 changed files with 34 additions and 4 deletions

View file

@ -7759,19 +7759,45 @@ static void _next_video_frame_decoded_callback(LinphoneCall *call, void *user_da
return; 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); jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onNextVideoFrameDecoded","(Lorg/linphone/core/LinphoneCall;)V"); jmethodID method = env->GetMethodID(clazz, "onNextVideoFrameDecoded","(Lorg/linphone/core/LinphoneCall;)V");
env->DeleteLocalRef(clazz); env->DeleteLocalRef(clazz);
jobject jcall = getCall(env, call); jobject jcall = getCall(env, call);
env->CallVoidMethod(listener, method, jcall); env->CallVoidMethod(listener, method, jcall);
env->DeleteLocalRef(listener);
}
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) { JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallImpl_setListener(JNIEnv* env, jobject thiz, jlong ptr, jobject jlistener) {
jobject listener = env->NewGlobalRef(jlistener);
LinphoneCall *call = (LinphoneCall *)ptr; 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 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setVideoWindowId(JNIEnv* env

View file

@ -31,8 +31,12 @@ public interface LinphoneCall {
/** /**
* LinphoneCall listener * LinphoneCall listener
*/ */
interface LinphoneCallListener { public interface LinphoneCallListener {
void onNextVideoFrameDecoded(LinphoneCall call); void onNextVideoFrameDecoded(LinphoneCall call);
/**
* Invoked when a TMMBR RTCP packet is received.
*/
void tmmbrReceived(LinphoneCall call, int streamIndex, int bitrate);
} }
/** /**