mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-22 05:38:14 +00:00
Move ZRTP flags to application level.
This commit is contained in:
parent
bfb27bb7cf
commit
d8adfcf296
4 changed files with 56 additions and 22 deletions
|
|
@ -326,9 +326,10 @@ static void linphonec_call_updated(LinphoneCall *call){
|
|||
static void linphonec_call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t encrypted, const char *auth_token) {
|
||||
long id=(long)linphone_call_get_user_pointer (call);
|
||||
if (!encrypted) {
|
||||
linphonec_out("Call %i is not encrypted.\n", id);
|
||||
linphonec_out("Call %i is not fully encrypted and auth token is %s.\n", id,
|
||||
(auth_token != NULL) ? auth_token : "absent");
|
||||
} else {
|
||||
linphonec_out("Call %i is encrypted and auth token is %s.\n", id,
|
||||
linphonec_out("Call %i is fully encrypted and auth token is %s.\n", id,
|
||||
(auth_token != NULL) ? auth_token : "absent");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "sipsetup.h"
|
||||
#include "lpconfig.h"
|
||||
#include "private.h"
|
||||
#include <ortp/event.h>
|
||||
|
||||
|
||||
#include "mediastreamer2/mediastream.h"
|
||||
|
|
@ -56,22 +57,22 @@ static const char* get_zrtp_identifier(LinphoneCore *lc){
|
|||
}
|
||||
|
||||
const char* linphone_call_get_authentication_token(LinphoneCall *call){
|
||||
return call->audiostream->auth_token;
|
||||
return call->auth_token;
|
||||
}
|
||||
|
||||
bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call){
|
||||
return call->audiostream->auth_token_verified;
|
||||
return call->auth_token_verified;
|
||||
}
|
||||
bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call) {
|
||||
// Check ZRTP encryption in audiostream
|
||||
if (!call->audiostream->encrypted) {
|
||||
if (!call->audiostream_encrypted) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef VIDEO_ENABLED
|
||||
// If video enabled, check ZRTP encryption in videostream
|
||||
const LinphoneCallParams *params=linphone_call_get_current_params(call);
|
||||
if (params->has_video && !call->videostream->encrypted) {
|
||||
if (params->has_video && !call->videostream_encrypted) {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -83,9 +84,11 @@ void propagate_encryption_changed(LinphoneCall *call){
|
|||
if (call->core->vtable.call_encryption_changed == NULL) return;
|
||||
|
||||
if (!linphone_call_are_all_streams_encrypted(call)) {
|
||||
call->core->vtable.call_encryption_changed(call->core, call, FALSE, NULL);
|
||||
ms_message("Some streams are not encrypted");
|
||||
call->core->vtable.call_encryption_changed(call->core, call, FALSE, call->auth_token);
|
||||
} else {
|
||||
call->core->vtable.call_encryption_changed(call->core, call, TRUE, call->audiostream->auth_token);
|
||||
ms_message("All streams are encrypted");
|
||||
call->core->vtable.call_encryption_changed(call->core, call, TRUE, call->auth_token);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +97,7 @@ static void linphone_call_videostream_encryption_changed(void *data, bool_t encr
|
|||
ms_message("Video stream is %s", encrypted ? "encrypted" : "not encrypted");
|
||||
|
||||
LinphoneCall *call = (LinphoneCall *)data;
|
||||
call->videostream->encrypted=encrypted;
|
||||
call->videostream_encrypted=encrypted;
|
||||
propagate_encryption_changed(call);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -103,7 +106,7 @@ static void linphone_call_audiostream_encryption_changed(void *data, bool_t encr
|
|||
ms_message("Audio stream is %s ", encrypted ? "encrypted" : "not encrypted");
|
||||
|
||||
LinphoneCall *call = (LinphoneCall *)data;
|
||||
call->audiostream->encrypted=encrypted;
|
||||
call->audiostream_encrypted=encrypted;
|
||||
propagate_encryption_changed(call);
|
||||
|
||||
|
||||
|
|
@ -123,11 +126,11 @@ static void linphone_call_audiostream_encryption_changed(void *data, bool_t encr
|
|||
|
||||
static void linphone_call_audiostream_auth_token_ready(void *data, const char* auth_token, bool_t verified) {
|
||||
LinphoneCall *call=(LinphoneCall *)data;
|
||||
if (call->audiostream->auth_token != NULL)
|
||||
ms_free(call->audiostream->auth_token);
|
||||
if (call->auth_token != NULL)
|
||||
ms_free(call->auth_token);
|
||||
|
||||
call->audiostream->auth_token=ms_strdup(auth_token);
|
||||
call->audiostream->auth_token_verified=verified;
|
||||
call->auth_token=ms_strdup(auth_token);
|
||||
call->auth_token_verified=verified;
|
||||
|
||||
ms_message("Authentication token is %s (%s)", auth_token, verified?"verified":"unverified");
|
||||
}
|
||||
|
|
@ -449,6 +452,10 @@ static void linphone_call_destroy(LinphoneCall *obj)
|
|||
}
|
||||
if (obj->owns_call_log)
|
||||
linphone_call_log_destroy(obj->log);
|
||||
if (obj->auth_token) {
|
||||
ms_free(obj->auth_token);
|
||||
}
|
||||
|
||||
ms_free(obj);
|
||||
}
|
||||
|
||||
|
|
@ -765,6 +772,9 @@ void linphone_call_init_media_streams(LinphoneCall *call){
|
|||
if (lc->a_rtp)
|
||||
rtp_session_set_transports(audiostream->session,lc->a_rtp,lc->a_rtcp);
|
||||
|
||||
call->audiostream_app_evq = ortp_ev_queue_new();
|
||||
rtp_session_register_event_queue(audiostream->session,call->audiostream_app_evq);
|
||||
|
||||
#ifdef VIDEO_ENABLED
|
||||
|
||||
if ((lc->video_conf.display || lc->video_conf.capture) && md->streams[1].port>0){
|
||||
|
|
@ -774,6 +784,8 @@ void linphone_call_init_media_streams(LinphoneCall *call){
|
|||
video_stream_set_event_callback(call->videostream,video_stream_event_cb, call);
|
||||
if (lc->v_rtp)
|
||||
rtp_session_set_transports(call->videostream->session,lc->v_rtp,lc->v_rtcp);
|
||||
call->videostream_app_evq = ortp_ev_queue_new();
|
||||
rtp_session_register_event_queue(call->videostream->session,call->videostream_app_evq);
|
||||
#ifdef TEST_EXT_RENDERER
|
||||
video_stream_set_render_callback(call->videostream,rendercb,NULL);
|
||||
#endif
|
||||
|
|
@ -1129,6 +1141,10 @@ static void linphone_call_log_fill_stats(LinphoneCallLog *log, AudioStream *st){
|
|||
|
||||
void linphone_call_stop_media_streams(LinphoneCall *call){
|
||||
if (call->audiostream!=NULL) {
|
||||
rtp_session_unregister_event_queue(call->audiostream->session,call->audiostream_app_evq);
|
||||
ortp_ev_queue_flush(call->audiostream_app_evq);
|
||||
ortp_ev_queue_destroy(call->audiostream_app_evq);
|
||||
|
||||
if (call->audiostream->ec){
|
||||
const char *state_str=NULL;
|
||||
ms_filter_call_method(call->audiostream->ec,MS_ECHO_CANCELLER_GET_STATE_STRING,&state_str);
|
||||
|
|
@ -1141,8 +1157,13 @@ void linphone_call_stop_media_streams(LinphoneCall *call){
|
|||
audio_stream_stop(call->audiostream);
|
||||
call->audiostream=NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef VIDEO_ENABLED
|
||||
if (call->videostream!=NULL){
|
||||
rtp_session_unregister_event_queue(call->videostream->session,call->videostream_app_evq);
|
||||
ortp_ev_queue_flush(call->videostream_app_evq);
|
||||
ortp_ev_queue_destroy(call->videostream_app_evq);
|
||||
video_stream_stop(call->videostream);
|
||||
call->videostream=NULL;
|
||||
}
|
||||
|
|
@ -1325,9 +1346,13 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
|
|||
}
|
||||
#ifdef VIDEO_ENABLED
|
||||
if (call->videostream!=NULL) {
|
||||
if (call->videostream->evq){
|
||||
OrtpEvent *ev=ortp_ev_queue_get(call->videostream->evq);
|
||||
if (ev!=NULL){
|
||||
// Beware that the application queue should not depend on treatments fron the
|
||||
// mediastreamer queue.
|
||||
video_stream_iterate(call->videostream);
|
||||
|
||||
if (call->videostream_app_evq){
|
||||
OrtpEvent *ev;
|
||||
while (NULL != (ev=ortp_ev_queue_get(call->videostream_app_evq))){
|
||||
OrtpEventType evt=ortp_event_get_type(ev);
|
||||
if (evt == ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED){
|
||||
OrtpEventData *evd=ortp_event_get_data(ev);
|
||||
|
|
@ -1336,13 +1361,16 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
|
|||
ortp_event_destroy(ev);
|
||||
}
|
||||
}
|
||||
video_stream_iterate(call->videostream);
|
||||
}
|
||||
#endif
|
||||
if (call->audiostream!=NULL) {
|
||||
// Beware that the application queue should not depend on treatments fron the
|
||||
// mediastreamer queue.
|
||||
audio_stream_iterate(call->audiostream);
|
||||
|
||||
if (call->audiostream->evq){
|
||||
OrtpEvent *ev=ortp_ev_queue_get(call->audiostream->evq);
|
||||
if (ev!=NULL){
|
||||
OrtpEvent *ev;
|
||||
while (NULL != (ev=ortp_ev_queue_get(call->audiostream_app_evq))){
|
||||
OrtpEventType evt=ortp_event_get_type(ev);
|
||||
if (evt == ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED){
|
||||
OrtpEventData *evd=ortp_event_get_data(ev);
|
||||
|
|
@ -1354,7 +1382,6 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -99,6 +99,12 @@ struct _LinphoneCall
|
|||
bool_t all_muted; /*this flag is set during early medias*/
|
||||
bool_t playing_ringbacktone;
|
||||
bool_t owns_call_log;
|
||||
OrtpEvQueue *audiostream_app_evq;
|
||||
bool_t audiostream_encrypted;
|
||||
char *auth_token;
|
||||
bool_t auth_token_verified;
|
||||
OrtpEvQueue *videostream_app_evq;
|
||||
bool_t videostream_encrypted;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 97b4a85bba7b0c75040137b6ba1a3543fda9c63c
|
||||
Subproject commit 737846b3719dd5be9786f2a9be1aacf29595ad9f
|
||||
Loading…
Add table
Reference in a new issue