From a2699e54294837654ac59de021a70372e6529c81 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 1 Aug 2011 11:48:26 +0200 Subject: [PATCH] Simplified ORTP-ZRTP API. Fix SAS bubbling. Old ARMs --- build/android/Android.mk | 16 ++++++++------ coreapi/linphonecall.c | 42 ++++++++++++++++++++++++++----------- coreapi/linphonecore_jni.cc | 26 +++++++++++------------ mediastreamer2 | 2 +- oRTP | 2 +- 5 files changed, 55 insertions(+), 33 deletions(-) diff --git a/build/android/Android.mk b/build/android/Android.mk index 817ed915..dcc9c9fa 100755 --- a/build/android/Android.mk +++ b/build/android/Android.mk @@ -127,22 +127,26 @@ LOCAL_C_INCLUDES += $(LIBLINPHONE_EXTENDED_C_INCLUDES) endif ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) - LOCAL_SHARED_LIBRARIES += \ - liblinssl liblincrypto + LOCAL_SHARED_LIBRARIES += liblinssl liblincrypto ifeq ($(BUILD_GPLV3_ZRTP),1) - LOCAL_SHARED_LIBRARIES += \ - libzrtpcpp + LOCAL_SHARED_LIBRARIES += libzrtpcpp endif ifeq ($(BUILD_SRTP),1) - LOCAL_SHARED_LIBRARIES += \ - libsrtp + LOCAL_SHARED_LIBRARIES += libsrtp endif else LOCAL_LDLIBS += -lz #LOCAL_STATIC_LIBRARIES += libz libdl LOCAL_STATIC_LIBRARIES += \ libssl-static libcrypto-static + ifeq ($(BUILD_GPLV3_ZRTP),1) + LOCAL_STATIC_LIBRARIES += libzrtpcpp-static + endif + + ifeq ($(BUILD_SRTP),1) + LOCAL_STATIC_LIBRARIES += libsrtp-static + endif endif LOCAL_MODULE := liblinphone diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 7f9c12c2..f405c139 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -79,7 +79,7 @@ bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call) { return TRUE; } -static void propagate_encryption_changed(LinphoneCall *call){ +void propagate_encryption_changed(LinphoneCall *call){ if (call->core->vtable.call_encryption_changed == NULL) return; if (!linphone_call_are_all_streams_encrypted(call)) { @@ -115,10 +115,6 @@ static void linphone_call_audiostream_encryption_changed(void *data, bool_t encr OrtpZrtpParams params; params.zid=get_zrtp_identifier(call->core); params.zid_file=NULL; //unused - OrtpZrtpUiCb cbs={0}; - cbs.data=call; - cbs.encryption_changed=linphone_call_videostream_encryption_changed; - params.ui_cbs=&cbs; video_stream_enable_zrtp(call->videostream,call->audiostream,¶ms); } #endif @@ -1117,11 +1113,6 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut OrtpZrtpParams params; params.zid=get_zrtp_identifier(lc); params.zid_file=lc->zrtp_secrets_cache; - OrtpZrtpUiCb cbs={0}; - cbs.data=call; - cbs.encryption_changed=linphone_call_audiostream_encryption_changed; - cbs.sas_ready=linphone_call_audiostream_auth_token_ready; - params.ui_cbs=&cbs; audio_stream_enable_zrtp(call->audiostream,¶ms); } @@ -1333,11 +1324,38 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse ms_message("Thread processing load: audio=%f\tvideo=%f",audio_load,video_load); } #ifdef VIDEO_ENABLED - if (call->videostream!=NULL) + if (call->videostream!=NULL) { + if (call->videostream->evq){ + OrtpEvent *ev=ortp_ev_queue_get(call->videostream->evq); + if (ev!=NULL){ + OrtpEventType evt=ortp_event_get_type(ev); + if (evt == ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED){ + OrtpEventData *evd=ortp_event_get_data(ev); + linphone_call_videostream_encryption_changed(call, evd->info.zrtp_stream_encrypted); + } + ortp_event_destroy(ev); + } + } video_stream_iterate(call->videostream); + } #endif - if (call->audiostream!=NULL) + if (call->audiostream!=NULL) { + if (call->audiostream->evq){ + OrtpEvent *ev=ortp_ev_queue_get(call->audiostream->evq); + if (ev!=NULL){ + OrtpEventType evt=ortp_event_get_type(ev); + if (evt == ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED){ + OrtpEventData *evd=ortp_event_get_data(ev); + linphone_call_audiostream_encryption_changed(call, evd->info.zrtp_stream_encrypted); + } else if (evt == ORTP_EVENT_ZRTP_SAS_READY) { + OrtpEventData *evd=ortp_event_get_data(ev); + linphone_call_audiostream_auth_token_ready(call, evd->info.zrtp_sas.sas, evd->info.zrtp_sas.verified); + } + ortp_event_destroy(ev); + } + } audio_stream_iterate(call->audiostream); + } if (one_second_elapsed && call->audiostream!=NULL && disconnect_timeout>0 ) disconnected=!audio_stream_alive(call->audiostream,disconnect_timeout); if (disconnected) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 823e5e44..35cade52 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -90,47 +90,47 @@ public: vTable.global_state_changed = globalStateChange; vTable.registration_state_changed = registrationStateChange; vTable.call_state_changed = callStateChange; - //vTable.call_encryption_changed = callEncryptionChange; + vTable.call_encryption_changed = callEncryptionChange; vTable.text_received = text_received; vTable.new_subscription_request = new_subscription_request; vTable.notify_presence_recv = notify_presence_recv; - listernerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener)); + listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener)); /*displayStatus(LinphoneCore lc,String message);*/ - displayStatusId = env->GetMethodID(listernerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V"); + displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V"); /*void generalState(LinphoneCore lc,int state); */ - globalStateId = env->GetMethodID(listernerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V"); + globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V"); globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState")); globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;"); /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/ - registrationStateId = env->GetMethodID(listernerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V"); + registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V"); registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState")); registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;"); /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/ - callStateId = env->GetMethodID(listernerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V"); + callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V"); callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State")); callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;"); /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/ - callEncryptionChangedId=env->GetMethodID(listernerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V"); + callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V"); /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/ - ecCalibrationStatusId = env->GetMethodID(listernerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V"); + ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V"); ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus")); ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;"); /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/ - newSubscriptionRequestId = env->GetMethodID(listernerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V"); + newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V"); /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/ - notifyPresenceReceivedId = env->GetMethodID(listernerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V"); + notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V"); /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/ - textReceivedId = env->GetMethodID(listernerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V"); + textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V"); proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl")); proxyCtrId = env->GetMethodID(proxyClass,"", "(J)V"); @@ -155,7 +155,7 @@ public: env->DeleteGlobalRef(core); env->DeleteGlobalRef(listener); if (userdata) env->DeleteGlobalRef(userdata); - env->DeleteGlobalRef(listernerClass); + env->DeleteGlobalRef(listenerClass); env->DeleteGlobalRef(globalStateClass); env->DeleteGlobalRef(registrationStateClass); env->DeleteGlobalRef(callStateClass); @@ -169,7 +169,7 @@ public: jobject listener; jobject userdata; - jclass listernerClass; + jclass listenerClass; jmethodID displayStatusId; jmethodID newSubscriptionRequestId; jmethodID notifyPresenceReceivedId; diff --git a/mediastreamer2 b/mediastreamer2 index 90912505..97b4a85b 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 9091250591e54e6533cea8ba8c203f6f4f47550d +Subproject commit 97b4a85bba7b0c75040137b6ba1a3543fda9c63c diff --git a/oRTP b/oRTP index 9cdfa6c8..e3e56ecd 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 9cdfa6c826b2a2701122a50ed3c78afa8ef17ec6 +Subproject commit e3e56ecd6179085ffeaf70482da4571415e3e5ff -- 2.39.2