3 Copyright (C) 2010 Simon MORLAT (simon.morlat@free.fr)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "linphonecore.h"
25 #include "mediastreamer2/mediastream.h"
28 static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details);
30 static bool_t media_parameters_changed(LinphoneCall *call, SalMediaDescription *oldmd, SalMediaDescription *newmd){
31 if (call->params.in_conference!=call->current_params.in_conference) return TRUE;
32 return !sal_media_description_equals(oldmd,newmd) || call->up_bw!=linphone_core_get_upload_bandwidth(call->core);
35 void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md){
36 SalMediaDescription *oldmd=call->resultdesc;
38 if (lc->ringstream!=NULL){
39 ring_stop(lc->ringstream);
43 sal_media_description_ref(new_md);
44 call->media_pending=FALSE;
46 call->media_pending=TRUE;
48 call->resultdesc=new_md;
49 if (call->audiostream && call->audiostream->ticker){
50 /* we already started media: check if we really need to restart it*/
52 if (!media_parameters_changed(call,oldmd,new_md) && !call->playing_ringbacktone){
53 /*as nothing has changed, keep the oldmd */
54 call->resultdesc=oldmd;
55 sal_media_description_unref(new_md);
57 ms_message("Early media finished, unmuting inputs...");
58 /*we were in early media, now we want to enable real media */
59 linphone_call_enable_camera (call,linphone_call_camera_enabled (call));
60 if (call->audiostream)
61 linphone_core_mute_mic (lc, linphone_core_is_mic_muted(lc));
63 if (call->videostream && call->camera_active)
64 video_stream_change_camera(call->videostream,lc->video_conf.device );
67 ms_message("No need to restart streams, SDP is unchanged.");
70 ms_message("Media descriptions are different, need to restart the streams.");
73 linphone_call_stop_media_streams (call);
74 linphone_call_init_media_streams (call);
77 sal_media_description_unref(oldmd);
80 bool_t all_muted=FALSE;
81 bool_t send_ringbacktone=FALSE;
83 if (call->audiostream==NULL){
84 /*this happens after pausing the call locally. The streams is destroyed and then we wait the 200Ok to recreate it*/
85 linphone_call_init_media_streams (call);
87 if (call->state==LinphoneCallIncomingEarlyMedia && linphone_core_get_remote_ringback_tone (lc)!=NULL){
88 send_ringbacktone=TRUE;
90 if (call->state==LinphoneCallIncomingEarlyMedia ||
91 (call->state==LinphoneCallOutgoingEarlyMedia && !call->params.real_early_media)){
94 linphone_call_start_media_streams(call,all_muted,send_ringbacktone);
98 static bool_t is_duplicate_call(LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to){
100 for(elem=lc->calls;elem!=NULL;elem=elem->next){
101 LinphoneCall *call=(LinphoneCall*)elem->data;
102 if (linphone_address_weak_equal(call->log->from,from) &&
103 linphone_address_weak_equal(call->log->to, to)){
110 static void call_received(SalOp *h){
111 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
114 const char *from,*to;
116 LinphoneAddress *from_parsed;
117 LinphoneAddress *from_addr, *to_addr;
118 SalMediaDescription *md;
119 bool_t propose_early_media=lp_config_get_int(lc->config,"sip","incoming_calls_early_media",FALSE);
120 const char *ringback_tone=linphone_core_get_remote_ringback_tone (lc);
122 /* first check if we can answer successfully to this invite */
123 if (lc->presence_mode==LinphoneStatusBusy ||
124 lc->presence_mode==LinphoneStatusOffline ||
125 lc->presence_mode==LinphoneStatusDoNotDisturb ||
126 lc->presence_mode==LinphoneStatusMoved){
127 if (lc->presence_mode==LinphoneStatusBusy )
128 sal_call_decline(h,SalReasonBusy,NULL);
129 else if (lc->presence_mode==LinphoneStatusOffline)
130 sal_call_decline(h,SalReasonTemporarilyUnavailable,NULL);
131 else if (lc->presence_mode==LinphoneStatusDoNotDisturb)
132 sal_call_decline(h,SalReasonTemporarilyUnavailable,NULL);
133 else if (lc->alt_contact!=NULL && lc->presence_mode==LinphoneStatusMoved)
134 sal_call_decline(h,SalReasonRedirect,lc->alt_contact);
138 if (!linphone_core_can_we_add_call(lc)){/*busy*/
139 sal_call_decline(h,SalReasonBusy,NULL);
143 from=sal_op_get_from(h);
145 from_addr=linphone_address_new(from);
146 to_addr=linphone_address_new(to);
148 if (is_duplicate_call(lc,from_addr,to_addr)){
149 ms_warning("Receiving duplicated call, refusing this one.");
150 sal_call_decline(h,SalReasonBusy,NULL);
152 linphone_address_destroy(from_addr);
153 linphone_address_destroy(to_addr);
157 call=linphone_call_new_incoming(lc,from_addr,to_addr,h);
158 sal_call_set_local_media_description(h,call->localdesc);
159 md=sal_call_get_final_media_description(h);
161 if (md && sal_media_description_empty(md)){
162 sal_call_decline(h,SalReasonMedia,NULL);
163 linphone_call_unref(call);
167 /* the call is acceptable so we can now add it to our list */
168 linphone_core_add_call(lc,call);
170 from_parsed=linphone_address_new(sal_op_get_from(h));
171 linphone_address_clean(from_parsed);
172 tmp=linphone_address_as_string(from_parsed);
173 linphone_address_destroy(from_parsed);
174 barmesg=ortp_strdup_printf("%s %s%s",tmp,_("is contacting you"),
175 (sal_call_autoanswer_asked(h)) ?_(" and asked autoanswer."):_("."));
176 if (lc->vtable.show) lc->vtable.show(lc);
177 if (lc->vtable.display_status)
178 lc->vtable.display_status(lc,barmesg);
180 /* play the ring if this is the only call*/
181 if (lc->sound_conf.ring_sndcard!=NULL && ms_list_size(lc->calls)==1){
182 lc->current_call=call;
183 if (lc->ringstream && lc->dmfs_playing_start_time!=0){
184 ring_stop(lc->ringstream);
186 lc->dmfs_playing_start_time=0;
188 if(lc->ringstream==NULL && lc->sound_conf.local_ring){
189 MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
190 ms_message("Starting local ring...");
191 lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,ringcard);
195 ms_message("the local ring is already started");
198 /* play a tone within the context of the current call */
199 linphone_core_play_tone(lc);
203 linphone_call_ref(call); /*prevent the call from being destroyed while we are notifying, if the user declines within the state callback */
204 linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
206 if (call->state==LinphoneCallIncomingReceived){
207 sal_call_notify_ringing(h,propose_early_media || ringback_tone!=NULL);
209 if (propose_early_media || ringback_tone!=NULL){
210 linphone_call_set_state(call,LinphoneCallIncomingEarlyMedia,"Incoming call early media");
211 linphone_core_update_streams(lc,call,md);
213 if (sal_call_get_replaces(call->op)!=NULL && lp_config_get_int(lc->config,"sip","auto_answer_replacing_calls",1)){
214 linphone_core_accept_call(lc,call);
217 linphone_call_unref(call);
223 static void call_ringing(SalOp *h){
224 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
225 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(h);
226 SalMediaDescription *md;
228 if (call==NULL) return;
230 if (lc->vtable.display_status)
231 lc->vtable.display_status(lc,_("Remote ringing."));
233 md=sal_call_get_final_media_description(h);
235 if (lc->ringstream && lc->dmfs_playing_start_time!=0){
236 ring_stop(lc->ringstream);
238 lc->dmfs_playing_start_time=0;
240 if (lc->ringstream!=NULL) return; /*already ringing !*/
241 if (lc->sound_conf.play_sndcard!=NULL){
242 MSSndCard *ringcard=lc->sound_conf.lsd_card ? lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
243 lc->ringstream=ring_start(lc->sound_conf.remote_ring,2000,ringcard);
245 ms_message("Remote ringing...");
246 if (lc->vtable.display_status)
247 lc->vtable.display_status(lc,_("Remote ringing..."));
248 linphone_call_set_state(call,LinphoneCallOutgoingRinging,"Remote ringing");
250 /*accept early media */
251 if (call->audiostream && call->audiostream->ticker!=NULL){
252 /*streams already started */
253 ms_message("Early media already started.");
256 if (lc->vtable.show) lc->vtable.show(lc);
257 if (lc->vtable.display_status)
258 lc->vtable.display_status(lc,_("Early media."));
259 linphone_call_set_state(call,LinphoneCallOutgoingEarlyMedia,"Early media");
260 if (lc->ringstream!=NULL){
261 ring_stop(lc->ringstream);
264 ms_message("Doing early media...");
265 linphone_core_update_streams (lc,call,md);
271 * - when the call is accepted
272 * - when a request is accepted (pause, resume)
274 static void call_accepted(SalOp *op){
275 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
276 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
277 SalMediaDescription *md;
280 ms_warning("No call to accept.");
284 md=sal_call_get_final_media_description(op);
286 if (call->state==LinphoneCallOutgoingProgress ||
287 call->state==LinphoneCallOutgoingRinging ||
288 call->state==LinphoneCallOutgoingEarlyMedia){
289 linphone_call_set_state(call,LinphoneCallConnected,"Connected");
291 if (md && !sal_media_description_empty(md)){
292 if (sal_media_description_has_dir(md,SalStreamSendOnly) ||
293 sal_media_description_has_dir(md,SalStreamInactive)){
294 if (lc->vtable.display_status){
295 char *tmp=linphone_call_get_remote_address_as_string (call);
296 char *msg=ms_strdup_printf(_("Call with %s is paused."),tmp);
297 lc->vtable.display_status(lc,msg);
301 linphone_core_update_streams (lc,call,md);
302 linphone_call_set_state(call,LinphoneCallPaused,"Call paused");
303 }else if (sal_media_description_has_dir(md,SalStreamRecvOnly)){
304 /*we are put on hold when the call is initially accepted */
305 if (lc->vtable.display_status){
306 char *tmp=linphone_call_get_remote_address_as_string (call);
307 char *msg=ms_strdup_printf(_("Call answered by %s - on hold."),tmp);
308 lc->vtable.display_status(lc,msg);
312 linphone_core_update_streams (lc,call,md);
313 linphone_call_set_state(call,LinphoneCallPausedByRemote,"Call paused by remote");
315 if (call->state==LinphoneCallStreamsRunning){
316 /*media was running before, the remote as acceted a call modification (that is
317 a reinvite made by us. We must notify the application this reinvite was accepted*/
318 linphone_call_set_state(call, LinphoneCallUpdated, "Call updated");
320 if (call->state==LinphoneCallResuming){
321 if (lc->vtable.display_status){
322 lc->vtable.display_status(lc,_("Call resumed."));
325 if (lc->vtable.display_status){
326 char *tmp=linphone_call_get_remote_address_as_string (call);
327 char *msg=ms_strdup_printf(_("Call answered by %s."),tmp);
328 lc->vtable.display_status(lc,msg);
334 linphone_core_update_streams (lc,call,md);
335 linphone_call_set_state(call, LinphoneCallStreamsRunning, "Streams running");
336 if (!call->current_params.in_conference)
337 lc->current_call=call;
341 ms_error("Incompatible SDP offer received in 200Ok, need to abort the call");
342 linphone_core_abort_call(lc,call,"No codec intersection");
346 static void call_ack(SalOp *op){
347 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
348 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
350 ms_warning("No call to be ACK'd");
353 if (call->media_pending){
354 SalMediaDescription *md=sal_call_get_final_media_description(op);
355 if (md && !sal_media_description_empty(md)){
356 if (call->state==LinphoneCallStreamsRunning){
357 /*media was running before, the remote as acceted a call modification (that is
358 a reinvite made by us. We must notify the application this reinvite was accepted*/
359 linphone_call_set_state(call, LinphoneCallUpdated, "Call updated");
361 linphone_core_update_streams (lc,call,md);
362 linphone_call_set_state (call,LinphoneCallStreamsRunning,"Connected (streams running)");
365 ms_error("Incompatible SDP response received in ACK, need to abort the call");
366 linphone_core_abort_call(lc,call,"No codec intersection");
373 /* this callback is called when an incoming re-INVITE modifies the session*/
374 static void call_updating(SalOp *op){
375 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
376 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
377 LinphoneCallState prevstate=LinphoneCallIdle;
378 SalMediaDescription *md;
380 md=sal_call_get_final_media_description(op);
382 if (md && !sal_media_description_empty(md))
384 if (sal_media_description_has_dir(call->localdesc,SalStreamSendRecv)){
385 ms_message("Our local status is SalStreamSendRecv");
386 if (sal_media_description_has_dir (md,SalStreamRecvOnly) || sal_media_description_has_dir(md,SalStreamInactive)){
387 /* we are being paused */
388 if(lc->vtable.display_status)
389 lc->vtable.display_status(lc,_("We are being paused..."));
390 linphone_call_set_state (call,LinphoneCallPausedByRemote,"Call paused by remote");
391 }else if (!sal_media_description_has_dir(call->resultdesc,SalStreamSendRecv) && sal_media_description_has_dir(md,SalStreamSendRecv)){
392 if(lc->vtable.display_status)
393 lc->vtable.display_status(lc,_("We have been resumed..."));
394 linphone_call_set_state (call,LinphoneCallStreamsRunning,"Connected (streams running)");
395 if (!call->current_params.in_conference)
396 lc->current_call=call;
398 prevstate=call->state;
399 linphone_call_set_state(call, LinphoneCallUpdatedByRemote,"Call updated by remote");
402 /*accept the modification (sends a 200Ok)*/
404 linphone_core_update_streams (lc,call,md);
405 if (prevstate!=LinphoneCallIdle){
406 linphone_call_set_state (call,prevstate,"Connected (streams running)");
411 static void call_terminated(SalOp *op, const char *from){
412 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
413 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
415 if (call==NULL) return;
417 if (linphone_call_get_state(call)==LinphoneCallEnd || linphone_call_get_state(call)==LinphoneCallError){
418 ms_warning("call_terminated: ignoring.");
421 ms_message("Current call terminated...");
422 //we stop the call only if we have this current call or if we are in call
423 if (lc->ringstream!=NULL && ( (ms_list_size(lc->calls) == 1) || linphone_core_in_call(lc) )) {
424 ring_stop(lc->ringstream);
427 linphone_call_stop_media_streams(call);
428 if (lc->vtable.show!=NULL)
430 if (lc->vtable.display_status!=NULL)
431 lc->vtable.display_status(lc,_("Call terminated."));
433 linphone_call_set_state(call, LinphoneCallEnd,"Call ended");
436 static void call_failure(SalOp *op, SalError error, SalReason sr, const char *details, int code){
437 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
438 char *msg486=_("User is busy.");
439 char *msg480=_("User is temporarily unavailable.");
440 /*char *retrymsg=_("%s. Retry after %i minute(s).");*/
441 char *msg600=_("User does not want to be disturbed.");
442 char *msg603=_("Call declined.");
443 const char *msg=details;
444 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
447 ms_warning("Call faillure reported on already cleaned call ?");
451 if (lc->vtable.show) lc->vtable.show(lc);
453 if (error==SalErrorNoResponse){
454 msg=_("No response.");
455 if (lc->vtable.display_status)
456 lc->vtable.display_status(lc,msg);
457 }else if (error==SalErrorProtocol){
458 msg=details ? details : _("Protocol error.");
459 if (lc->vtable.display_status)
460 lc->vtable.display_status(lc, msg);
461 }else if (error==SalErrorFailure){
463 case SalReasonDeclined:
465 if (lc->vtable.display_status)
466 lc->vtable.display_status(lc,msg603);
470 if (lc->vtable.display_status)
471 lc->vtable.display_status(lc,msg486);
473 case SalReasonRedirect:
475 if (lc->vtable.display_status)
476 lc->vtable.display_status(lc,msg);
478 case SalReasonTemporarilyUnavailable:
480 if (lc->vtable.display_status)
481 lc->vtable.display_status(lc,msg480);
483 case SalReasonNotFound:
485 if (lc->vtable.display_status)
486 lc->vtable.display_status(lc,msg);
488 case SalReasonDoNotDisturb:
490 if (lc->vtable.display_status)
491 lc->vtable.display_status(lc,msg600);
494 msg=_("No common codecs");
495 if (lc->vtable.display_status)
496 lc->vtable.display_status(lc,msg);
499 if (lc->vtable.display_status)
500 lc->vtable.display_status(lc,_("Call failed."));
504 if (lc->ringstream!=NULL) {
505 ring_stop(lc->ringstream);
508 linphone_call_stop_media_streams (call);
509 if (sr!=SalReasonDeclined) linphone_call_set_state(call,LinphoneCallError,msg);
511 call->reason=LinphoneReasonDeclined;
512 linphone_call_set_state(call,LinphoneCallEnd,"Call declined.");
516 static void call_released(SalOp *op){
517 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
519 linphone_call_set_state(call,LinphoneCallReleased,"Call released");
520 }else ms_error("call_released() for already destroyed call ?");
523 static void auth_requested(SalOp *h, const char *realm, const char *username){
524 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
525 LinphoneAuthInfo *ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,realm,username);
526 ms_message("auth_requested() for realm=%s, username=%s",realm,username);
528 if (ai && ai->works==FALSE && ai->usecount>=3){
529 /*case we tried 3 times to authenticate, without success */
530 /*Better is to stop (implemeted below in else statement), and retry later*/
531 if (ms_time(NULL)-ai->last_use_time>30){
532 ai->usecount=0; /*so that we can allow to retry */
536 if (ai && (ai->works || ai->usecount<3)){
538 sai.username=ai->username;
539 sai.userid=ai->userid;
541 sai.password=ai->passwd;
542 ms_message("auth_requested(): authenticating realm=%s, username=%s",realm,username);
543 sal_op_authenticate(h,&sai);
545 ai->last_use_time=ms_time(NULL);
547 if (ai && ai->works==FALSE) {
548 sal_op_cancel_authentication(h);
550 if (lc->vtable.auth_info_requested)
551 lc->vtable.auth_info_requested(lc,realm,username);
555 static void auth_success(SalOp *h, const char *realm, const char *username){
556 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
557 LinphoneAuthInfo *ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,realm,username);
559 ms_message("%s/%s authentication works.",realm,username);
564 static void register_success(SalOp *op, bool_t registered){
565 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
566 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)sal_op_get_user_pointer(op);
569 cfg->registered=registered;
570 linphone_proxy_config_set_error(cfg,LinphoneReasonNone);
571 linphone_proxy_config_set_state(cfg, registered ? LinphoneRegistrationOk : LinphoneRegistrationCleared ,
572 registered ? "Registration sucessful" : "Unregistration done");
573 if (lc->vtable.display_status){
574 if (cfg->registered) msg=ms_strdup_printf(_("Registration on %s successful."),sal_op_get_proxy(op));
575 else msg=ms_strdup_printf(_("Unregistration on %s done."),sal_op_get_proxy(op));
576 lc->vtable.display_status(lc,msg);
582 static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details){
583 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
584 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)sal_op_get_user_pointer(op);
587 ms_warning("Registration failed for unknown proxy config.");
591 details=_("no response timeout");
593 if (lc->vtable.display_status) {
594 char *msg=ortp_strdup_printf(_("Registration on %s failed: %s"),sal_op_get_proxy(op),details );
595 lc->vtable.display_status(lc,msg);
598 if (error== SalErrorFailure && reason == SalReasonForbidden) {
599 linphone_proxy_config_set_error(cfg, LinphoneReasonBadCredentials);
600 } else if (error == SalErrorNoResponse) {
601 linphone_proxy_config_set_error(cfg, LinphoneReasonNoResponse);
603 linphone_proxy_config_set_state(cfg,LinphoneRegistrationFailed,details);
604 if (error== SalErrorFailure && reason == SalReasonForbidden) {
605 const char *realm=NULL,*username=NULL;
606 if (sal_op_get_auth_requested(op,&realm,&username)==0){
607 if (lc->vtable.auth_info_requested)
608 lc->vtable.auth_info_requested(lc,realm,username);
613 static void vfu_request(SalOp *op){
615 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer (op);
617 ms_warning("VFU request but no call !");
620 if (call->videostream)
621 video_stream_send_vfu(call->videostream);
625 static void dtmf_received(SalOp *op, char dtmf){
626 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
627 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
628 if (lc->vtable.dtmf_received != NULL)
629 lc->vtable.dtmf_received(lc, call, dtmf);
632 static void refer_received(Sal *sal, SalOp *op, const char *referto){
633 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
634 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
636 if (call->refer_to!=NULL){
637 ms_free(call->refer_to);
639 call->refer_to=ms_strdup(referto);
640 call->refer_pending=TRUE;
641 linphone_call_set_state(call,LinphoneCallRefered,"Refered");
642 if (lc->vtable.display_status){
643 char *msg=ms_strdup_printf(_("We are transferred to %s"),referto);
644 lc->vtable.display_status(lc,msg);
647 if (call->state!=LinphoneCallPaused){
648 ms_message("Automatically pausing current call to accept transfer.");
649 linphone_core_pause_call(lc,call);
651 linphone_core_start_refered_call(lc,call);
652 sal_call_accept_refer(op);
653 }else if (lc->vtable.refer_received){
654 lc->vtable.refer_received(lc,referto);
655 sal_call_accept_refer(op);
659 static void text_received(Sal *sal, const char *from, const char *msg){
660 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
661 linphone_core_text_received(lc,from,msg);
664 static void notify(SalOp *op, const char *from, const char *msg){
665 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
666 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer (op);
667 ms_message("get a %s notify from %s",msg,from);
668 if(lc->vtable.notify_recv)
669 lc->vtable.notify_recv(lc,call,from,msg);
672 static void notify_presence(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg){
673 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
674 linphone_notify_recv(lc,op,ss,status);
677 static void subscribe_received(SalOp *op, const char *from){
678 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
679 linphone_subscription_new(lc,op,from);
682 static void subscribe_closed(SalOp *op, const char *from){
683 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
684 linphone_subscription_closed(lc,op);
687 static void ping_reply(SalOp *op){
688 LinphoneCall *call=(LinphoneCall*) sal_op_get_user_pointer(op);
689 ms_message("ping reply !");
691 if (call->state==LinphoneCallOutgoingInit){
692 linphone_core_start_invite(call->core,call,NULL);
697 ms_warning("ping reply without call attached...");
701 SalCallbacks linphone_sal_callbacks={