static void refer_received(Sal *sal, SalOp *op, const char *referto){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal); LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op); if (call){ if (call->refer_to!=NULL){ ms_free(call->refer_to); } call->refer_to=ms_strdup(referto); call->refer_pending=TRUE; linphone_call_set_state(call,LinphoneCallRefered,"Refered"); if (lc->vtable.display_status){ char *msg=ms_strdup_printf(_("We are transferred to %s"),referto); lc->vtable.display_status(lc,msg); ms_free(msg); } if (call->state!=LinphoneCallPaused){ ms_message("Automatically pausing current call to accept transfer."); linphone_core_pause_call(lc,call); } linphone_core_start_refered_call(lc,call); sal_call_accept_refer(op); }else if (lc->vtable.refer_received){ lc->vtable.refer_received(lc,referto); sal_call_accept_refer(op); } }
static void call_terminated(SalOp *op, const char *from){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op); if (call==NULL) return; switch(linphone_call_get_state(call)){ case LinphoneCallEnd: case LinphoneCallError: ms_warning("call_terminated: ignoring."); return; break; case LinphoneCallIncomingReceived: case LinphoneCallIncomingEarlyMedia: call->reason=LinphoneReasonNotAnswered; break; default: break; } ms_message("Current call terminated..."); if (call->refer_pending){ linphone_core_start_refered_call(lc,call,NULL); } //we stop the call only if we have this current call or if we are in call if (lc->ringstream!=NULL && ( (ms_list_size(lc->calls) == 1) || linphone_core_in_call(lc) )) { linphone_core_stop_ringing(lc); } linphone_call_stop_media_streams(call); if (lc->vtable.show!=NULL) lc->vtable.show(lc); if (lc->vtable.display_status!=NULL) lc->vtable.display_status(lc,_("Call terminated.")); #ifdef BUILD_UPNP linphone_call_delete_upnp_session(call); #endif //BUILD_UPNP linphone_call_set_state(call, LinphoneCallEnd,"Call ended"); }
/* * could be reach : * - when the call is accepted * - when a request is accepted (pause, resume) */ static void call_accepted(SalOp *op){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op); SalMediaDescription *md; if (call==NULL){ ms_warning("No call to accept."); return ; } /*set privacy*/ call->current_params.privacy=(LinphonePrivacyMask)sal_op_get_privacy(call->op); /* Handle remote ICE attributes if any. */ if (call->ice_session != NULL) { linphone_core_update_ice_from_remote_media_description(call, sal_call_get_remote_media_description(op)); } #ifdef BUILD_UPNP if (call->upnp_session != NULL) { linphone_core_update_upnp_from_remote_media_description(call, sal_call_get_remote_media_description(op)); } #endif //BUILD_UPNP md=sal_call_get_final_media_description(op); if (md) /*make sure re-invite will not propose video again*/ call->params.has_video &= linphone_core_media_description_contains_video_stream(md); if (call->state==LinphoneCallOutgoingProgress || call->state==LinphoneCallOutgoingRinging || call->state==LinphoneCallOutgoingEarlyMedia){ linphone_call_set_state(call,LinphoneCallConnected,"Connected"); if (call->referer) linphone_core_notify_refer_state(lc,call->referer,call); } if (md && !sal_media_description_empty(md) && !linphone_core_incompatible_security(lc,md)){ linphone_call_update_remote_session_id_and_ver(call); if (sal_media_description_has_dir(md,SalStreamSendOnly) || sal_media_description_has_dir(md,SalStreamInactive)){ if (lc->vtable.display_status){ char *tmp=linphone_call_get_remote_address_as_string (call); char *msg=ms_strdup_printf(_("Call with %s is paused."),tmp); lc->vtable.display_status(lc,msg); ms_free(tmp); ms_free(msg); } linphone_core_update_streams (lc,call,md); linphone_call_set_state(call,LinphoneCallPaused,"Call paused"); if (call->refer_pending) linphone_core_start_refered_call(lc,call,NULL); }else if (sal_media_description_has_dir(md,SalStreamRecvOnly)){ /*we are put on hold when the call is initially accepted */ if (lc->vtable.display_status){ char *tmp=linphone_call_get_remote_address_as_string (call); char *msg=ms_strdup_printf(_("Call answered by %s - on hold."),tmp); lc->vtable.display_status(lc,msg); ms_free(tmp); ms_free(msg); } linphone_core_update_streams (lc,call,md); linphone_call_set_state(call,LinphoneCallPausedByRemote,"Call paused by remote"); }else{ if (call->state!=LinphoneCallUpdating){ if (call->state==LinphoneCallResuming){ if (lc->vtable.display_status){ lc->vtable.display_status(lc,_("Call resumed.")); } }else{ if (lc->vtable.display_status){ char *tmp=linphone_call_get_remote_address_as_string (call); char *msg=ms_strdup_printf(_("Call answered by %s."),tmp); lc->vtable.display_status(lc,msg); ms_free(tmp); ms_free(msg); } } } linphone_core_update_streams(lc,call,md); /*also reflect the change if the "wished" params, in order to avoid to propose SAVP or video again * further in the call, for example during pause,resume, conferencing reINVITEs*/ linphone_call_fix_call_parameters(call); if (!call->current_params.in_conference) lc->current_call=call; linphone_call_set_state(call, LinphoneCallStreamsRunning, "Streams running"); } }else{ /*send a bye*/ ms_error("Incompatible SDP offer received in 200Ok, need to abort the call"); linphone_core_abort_call(lc,call,_("Incompatible, check codecs or security settings...")); } }