From 9855ea2a97adaebb02833c862188b44887b95c2a Mon Sep 17 00:00:00 2001 From: smorlat Date: Mon, 21 Sep 2009 19:18:55 +0000 Subject: [PATCH] add sip session timers support git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@673 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/coreapi/exevents.c | 18 +++++++++-- linphone/coreapi/linphonecore.c | 17 ++++++++--- linphone/coreapi/linphonecore.h | 54 +++------------------------------ linphone/coreapi/private.h | 53 ++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 58 deletions(-) diff --git a/linphone/coreapi/exevents.c b/linphone/coreapi/exevents.c index 58513e558..eb14a58ad 100644 --- a/linphone/coreapi/exevents.c +++ b/linphone/coreapi/exevents.c @@ -316,7 +316,8 @@ int linphone_inc_new_call(LinphoneCore *lc, eXosip_event_t *ev) eXosip_unlock(); goto end; } - lc->call=linphone_call_new_incoming(lc,from,to,ev->cid,ev->did,ev->tid); + lc->call=linphone_call_new_incoming(lc,from,to,ev); + sdp=eXosip_get_sdp_info(ev->request); if (sdp==NULL){ ms_message("No sdp body in invite, 200-ack scheme"); @@ -1003,6 +1004,16 @@ static bool_t comes_from_local_if(osip_message_t *msg){ return FALSE; } +static void linphone_inc_update(LinphoneCore *lc, eXosip_event_t *ev){ + osip_message_t *msg=NULL; + ms_message("Processing incoming UPDATE"); + eXosip_lock(); + eXosip_message_build_answer(ev->tid,200,&msg); + if (msg!=NULL) + eXosip_message_send_answer(ev->tid,200,msg); + eXosip_unlock(); +} + static void linphone_other_request(LinphoneCore *lc, eXosip_event_t *ev){ ms_message("in linphone_other_request"); if (ev->request==NULL) return; @@ -1033,8 +1044,9 @@ static void linphone_other_request(LinphoneCore *lc, eXosip_event_t *ev){ } }else ms_warning("Ignored REFER not coming from this local loopback interface."); - } - else { + }else if (strncmp(ev->request->sip_method, "UPDATE", 6) == 0){ + linphone_inc_update(lc,ev); + }else { char *tmp=NULL; size_t msglen=0; osip_message_to_str(ev->request,&tmp,&msglen); diff --git a/linphone/coreapi/linphonecore.c b/linphone/coreapi/linphonecore.c index b0f4a16f5..caf8a6100 100644 --- a/linphone/coreapi/linphonecore.c +++ b/linphone/coreapi/linphonecore.c @@ -127,14 +127,16 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const osip_f } -LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, const char *from, const char *to, int cid, int did, int tid){ +LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, const char *from, const char *to, eXosip_event_t *ev){ LinphoneCall *call=ms_new0(LinphoneCall,1); osip_from_t *me= linphone_core_get_primary_contact_parsed(lc); osip_from_t *from_url=NULL; + osip_header_t *h=NULL; + call->dir=LinphoneCallIncoming; - call->cid=cid; - call->did=did; - call->tid=tid; + call->cid=ev->cid; + call->did=ev->did; + call->tid=ev->tid; call->core=lc; osip_from_init(&from_url); osip_from_parse(from_url, from); @@ -147,6 +149,8 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, const char *from, co discover_mtu(lc,from_url->url->host); osip_from_free(me); osip_from_free(from_url); + osip_message_header_get_byname(ev->request,"Session-expires",0,&h); + if (h) call->supports_session_timers=TRUE; return call; } @@ -1356,7 +1360,8 @@ int linphone_core_invite(LinphoneCore *lc, const char *url) ms_warning("Could not build initial invite"); goto end; } - + osip_message_set_header(invite, "Session-expires", "200"); + osip_message_set_supported(invite, "timer"); /* make sdp message */ osip_from_init(&parsed_url2); @@ -1742,6 +1747,8 @@ int linphone_core_accept_call(LinphoneCore *lc, const char *url) ms_error("Fail to build answer for call: err=%i",err); return -1; } + + if (call->supports_session_timers) osip_message_set_supported(msg, "timer"); /*try to be best-effort in giving real local or routable contact address, except when the user choosed to override the ipaddress */ if (linphone_core_get_firewall_policy(lc)!=LINPHONE_POLICY_USE_NAT_ADDRESS) diff --git a/linphone/coreapi/linphonecore.h b/linphone/coreapi/linphonecore.h index 05a0bd98b..cd81fc2cc 100644 --- a/linphone/coreapi/linphonecore.h +++ b/linphone/coreapi/linphonecore.h @@ -150,55 +150,12 @@ typedef struct autoreplier_config struct _LinphoneCore; struct _sdp_context; struct _SipSetupContext; - -typedef struct _StreamParams -{ - int initialized; - int line; - int localport; - int remoteport; - int remotertcpport; - int pt; - char *relay_session_id; - int natd_port; - char remoteaddr[LINPHONE_HOSTNAME_SIZE]; - char natd_addr[LINPHONE_HOSTNAME_SIZE]; -} StreamParams; +struct _LinphoneCall; -typedef enum _LCState{ - LCStateInit, - LCStateRinging, - LCStateAVRunning -}LCState; typedef enum _LinphoneCallDir {LinphoneCallOutgoing, LinphoneCallIncoming} LinphoneCallDir; -typedef struct _LinphoneCall -{ - struct _LinphoneCore *core; - StreamParams audio_params; - StreamParams video_params; - LinphoneCallDir dir; - struct _RtpProfile *profile; /*points to the local_profile or to the remote "guessed" profile*/ - struct _LinphoneCallLog *log; - int cid; /*call id */ - int did; /*dialog id */ - int tid; /*last transaction id*/ - char localip[LINPHONE_IPADDR_SIZE]; /* our best guess for local ipaddress for this call */ - struct _sdp_context *sdpctx; - time_t start_time; /*time at which the call was initiated*/ - time_t media_start_time; /*time at which it was accepted, media streams established*/ - LCState state; - bool_t auth_pending; -} LinphoneCall; - -LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const osip_from_t *from, const osip_to_t *to); -LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, const char *from, const char *to, int cid, int did , int tid); -#define linphone_call_set_state(lcall,st) (lcall)->state=(st) -void linphone_call_destroy(struct _LinphoneCall *obj); - - typedef enum _LinphoneCallStatus { LinphoneCallSuccess, LinphoneCallAborted, @@ -215,10 +172,7 @@ typedef struct _LinphoneCallLog{ } LinphoneCallLog; -/* private: */ -LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *local, char * remote); -void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call); -void linphone_call_log_destroy(LinphoneCallLog *cl); + /*public: */ char * linphone_call_log_to_str(LinphoneCallLog *cl); @@ -512,7 +466,7 @@ typedef struct _LinphoneCore struct _RingStream *ringstream; LCCallbackObj preview_finished_cb; bool_t preview_finished; - LinphoneCall *call; /* the current call, in the future it will be a list of calls (conferencing)*/ + struct _LinphoneCall *call; /* the current call, in the future it will be a list of calls (conferencing)*/ int rid; /*registration id*/ MSList *queued_calls; /* used by the autoreplier */ MSList *call_logs; @@ -817,7 +771,7 @@ void linphone_core_destroy(LinphoneCore *lc); /*internal use only */ #define linphone_core_lock(lc) ms_mutex_lock(&(lc)->lock) #define linphone_core_unlock(lc) ms_mutex_unlock((&lc)->lock) -void linphone_core_start_media_streams(LinphoneCore *lc, LinphoneCall *call); +void linphone_core_start_media_streams(LinphoneCore *lc, struct _LinphoneCall *call); void linphone_core_stop_media_streams(LinphoneCore *lc); const char * linphone_core_get_identity(LinphoneCore *lc); const char * linphone_core_get_route(LinphoneCore *lc); diff --git a/linphone/coreapi/private.h b/linphone/coreapi/private.h index 7e1b76c74..84fbbbbfa 100644 --- a/linphone/coreapi/private.h +++ b/linphone/coreapi/private.h @@ -58,6 +58,59 @@ #endif #endif + +typedef struct _StreamParams +{ + int initialized; + int line; + int localport; + int remoteport; + int remotertcpport; + int pt; + char *relay_session_id; + int natd_port; + char remoteaddr[LINPHONE_HOSTNAME_SIZE]; + char natd_addr[LINPHONE_HOSTNAME_SIZE]; +} StreamParams; + +typedef enum _LCState{ + LCStateInit, + LCStateRinging, + LCStateAVRunning +}LCState; + + +typedef struct _LinphoneCall +{ + struct _LinphoneCore *core; + StreamParams audio_params; + StreamParams video_params; + LinphoneCallDir dir; + struct _RtpProfile *profile; /*points to the local_profile or to the remote "guessed" profile*/ + struct _LinphoneCallLog *log; + int cid; /*call id */ + int did; /*dialog id */ + int tid; /*last transaction id*/ + char localip[LINPHONE_IPADDR_SIZE]; /* our best guess for local ipaddress for this call */ + struct _sdp_context *sdpctx; + time_t start_time; /*time at which the call was initiated*/ + time_t media_start_time; /*time at which it was accepted, media streams established*/ + LCState state; + bool_t auth_pending; + bool_t supports_session_timers; +} LinphoneCall; + +LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const osip_from_t *from, const osip_to_t *to); +LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, const char *from, const char *to, eXosip_event_t *ev); +#define linphone_call_set_state(lcall,st) (lcall)->state=(st) +void linphone_call_destroy(struct _LinphoneCall *obj); + +/* private: */ +LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *local, char * remote); +void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call); +void linphone_call_log_destroy(LinphoneCallLog *cl); + + void linphone_core_init_media_streams(LinphoneCore *lc); void linphone_auth_info_write_config(struct _LpConfig *config, LinphoneAuthInfo *obj, int pos);