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 return !sal_media_description_equals(oldmd,newmd) || call->up_bw!=linphone_core_get_upload_bandwidth(call->core);
34 void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md){
35 SalMediaDescription *oldmd=call->resultdesc;
37 if (lc->ringstream!=NULL){
38 ring_stop(lc->ringstream);
42 sal_media_description_ref(new_md);
43 call->media_pending=FALSE;
45 call->media_pending=TRUE;
47 call->resultdesc=new_md;
48 if (call->audiostream && call->audiostream->ticker){
49 /* we already started media: check if we really need to restart it*/
51 if (!media_parameters_changed(call,oldmd,new_md) && !call->playing_ringbacktone){
52 /*as nothing has changed, keep the oldmd */
53 call->resultdesc=oldmd;
54 sal_media_description_unref(new_md);
56 ms_message("Early media finished, unmuting inputs...");
57 /*we were in early media, now we want to enable real media */
58 linphone_call_enable_camera (call,linphone_call_camera_enabled (call));
59 if (call->audiostream)
60 linphone_core_mute_mic (lc, linphone_core_is_mic_muted(lc));
62 if (call->videostream && call->camera_active)
63 video_stream_change_camera(call->videostream,lc->video_conf.device );
66 ms_message("No need to restart streams, SDP is unchanged.");
69 ms_message("Media descriptions are different, need to restart the streams.");
72 linphone_call_stop_media_streams (call);
73 linphone_call_init_media_streams (call);
76 sal_media_description_unref(oldmd);
79 bool_t all_muted=FALSE;
80 bool_t send_ringbacktone=FALSE;
82 if (call->audiostream==NULL){
83 /*this happens after pausing the call locally. The streams is destroyed and then we wait the 200Ok to recreate it*/
84 linphone_call_init_media_streams (call);
86 if (call->state==LinphoneCallIncomingEarlyMedia && linphone_core_get_remote_ringback_tone (lc)!=NULL){
87 send_ringbacktone=TRUE;
89 if (call->state==LinphoneCallIncomingEarlyMedia ||
90 (call->state==LinphoneCallOutgoingEarlyMedia && !call->params.real_early_media)){
93 linphone_call_start_media_streams(call,all_muted,send_ringbacktone);
97 static bool_t is_duplicate_call(LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to){
99 for(elem=lc->calls;elem!=NULL;elem=elem->next){
100 LinphoneCall *call=(LinphoneCall*)elem->data;
101 if (linphone_address_weak_equal(call->log->from,from) &&
102 linphone_address_weak_equal(call->log->to, to)){
109 static void call_received(SalOp *h){
110 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
113 const char *from,*to;
115 LinphoneAddress *from_parsed;
116 LinphoneAddress *from_addr, *to_addr;
117 SalMediaDescription *md;
118 bool_t propose_early_media=lp_config_get_int(lc->config,"sip","incoming_calls_early_media",FALSE);
119 const char *ringback_tone=linphone_core_get_remote_ringback_tone (lc);
121 /* first check if we can answer successfully to this invite */
122 if (lc->presence_mode==LinphoneStatusBusy ||
123 lc->presence_mode==LinphoneStatusOffline ||
124 lc->presence_mode==LinphoneStatusDoNotDisturb ||
125 lc->presence_mode==LinphoneStatusMoved){
126 if (lc->presence_mode==LinphoneStatusBusy )
127 sal_call_decline(h,SalReasonBusy,NULL);
128 else if (lc->presence_mode==LinphoneStatusOffline)
129 sal_call_decline(h,SalReasonTemporarilyUnavailable,NULL);
130 else if (lc->presence_mode==LinphoneStatusDoNotDisturb)
131 sal_call_decline(h,SalReasonTemporarilyUnavailable,NULL);
132 else if (lc->alt_contact!=NULL && lc->presence_mode==LinphoneStatusMoved)
133 sal_call_decline(h,SalReasonRedirect,lc->alt_contact);
137 if (!linphone_core_can_we_add_call(lc)){/*busy*/
138 sal_call_decline(h,SalReasonBusy,NULL);
142 from=sal_op_get_from(h);
144 from_addr=linphone_address_new(from);
145 to_addr=linphone_address_new(to);
147 if (is_duplicate_call(lc,from_addr,to_addr)){
148 ms_warning("Receiving duplicated call, refusing this one.");
149 sal_call_decline(h,SalReasonBusy,NULL);
151 linphone_address_destroy(from_addr);
152 linphone_address_destroy(to_addr);
156 call=linphone_call_new_incoming(lc,from_addr,to_addr,h);
157 sal_call_set_local_media_description(h,call->localdesc);
158 md=sal_call_get_final_media_description(h);
160 if (md && sal_media_description_empty(md)){
161 sal_call_decline(h,SalReasonMedia,NULL);
162 linphone_call_unref(call);
166 /* the call is acceptable so we can now add it to our list */
167 linphone_core_add_call(lc,call);
169 from_parsed=linphone_address_new(sal_op_get_from(h));
170 linphone_address_clean(from_parsed);
171 tmp=linphone_address_as_string(from_parsed);
172 linphone_address_destroy(from_parsed);
173 barmesg=ortp_strdup_printf("%s %s%s",tmp,_("is contacting you"),
174 (sal_call_autoanswer_asked(h)) ?_(" and asked autoanswer."):_("."));
175 if (lc->vtable.show) lc->vtable.show(lc);
176 if (lc->vtable.display_status)
177 lc->vtable.display_status(lc,barmesg);
179 /* play the ring if this is the only call*/
180 if (lc->sound_conf.ring_sndcard!=NULL && ms_list_size(lc->calls)==1){
181 lc->current_call=call;
182 if (lc->ringstream && lc->dmfs_playing_start_time!=0){
183 ring_stop(lc->ringstream);
185 lc->dmfs_playing_start_time=0;
187 if(lc->ringstream==NULL && lc->sound_conf.local_ring){
188 MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
189 ms_message("Starting local ring...");
190 lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,ringcard);
194 ms_message("the local ring is already started");
197 /*TODO : play a tone within the context of the current call */
201 linphone_call_ref(call); /*prevent the call from being destroyed while we are notifying, if the user declines within the state callback */
202 linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
204 if (call->state==LinphoneCallIncomingReceived){
205 sal_call_notify_ringing(h,propose_early_media || ringback_tone!=NULL);
207 if (propose_early_media || ringback_tone!=NULL){
208 linphone_call_set_state(call,LinphoneCallIncomingEarlyMedia,"Incoming call early media");
209 linphone_core_update_streams(lc,call,md);
211 if (sal_call_get_replaces(call->op)!=NULL && lp_config_get_int(lc->config,"sip","auto_answer_replacing_calls",1)){
212 linphone_core_accept_call(lc,call);
215 linphone_call_unref(call);
221 static void call_ringing(SalOp *h){
222 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
223 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(h);
224 SalMediaDescription *md;
226 if (call==NULL) return;
228 if (lc->vtable.display_status)
229 lc->vtable.display_status(lc,_("Remote ringing."));
231 md=sal_call_get_final_media_description(h);
233 if (lc->ringstream && lc->dmfs_playing_start_time!=0){
234 ring_stop(lc->ringstream);
236 lc->dmfs_playing_start_time=0;
238 if (lc->ringstream!=NULL) return; /*already ringing !*/
239 if (lc->sound_conf.play_sndcard!=NULL){
240 MSSndCard *ringcard=lc->sound_conf.lsd_card ? lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
241 lc->ringstream=ring_start(lc->sound_conf.remote_ring,2000,ringcard);
243 ms_message("Remote ringing...");
244 if (lc->vtable.display_status)
245 lc->vtable.display_status(lc,_("Remote ringing..."));
246 linphone_call_set_state(call,LinphoneCallOutgoingRinging,"Remote ringing");
248 /*accept early media */
249 if (call->audiostream && call->audiostream->ticker!=NULL){
250 /*streams already started */
251 ms_message("Early media already started.");
254 if (lc->vtable.show) lc->vtable.show(lc);
255 if (lc->vtable.display_status)
256 lc->vtable.display_status(lc,_("Early media."));
257 linphone_call_set_state(call,LinphoneCallOutgoingEarlyMedia,"Early media");
258 if (lc->ringstream!=NULL){
259 ring_stop(lc->ringstream);
262 ms_message("Doing early media...");
263 linphone_core_update_streams (lc,call,md);
269 * - when the call is accepted
270 * - when a request is accepted (pause, resume)
272 static void call_accepted(SalOp *op){
273 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
274 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
275 SalMediaDescription *md;
278 ms_warning("No call to accept.");
282 md=sal_call_get_final_media_description(op);
284 if (call->state==LinphoneCallOutgoingProgress ||
285 call->state==LinphoneCallOutgoingRinging ||
286 call->state==LinphoneCallOutgoingEarlyMedia){
287 linphone_call_set_state(call,LinphoneCallConnected,"Connected");
289 if (md && !sal_media_description_empty(md)){
290 if (sal_media_description_has_dir(md,SalStreamSendOnly) ||
291 sal_media_description_has_dir(md,SalStreamInactive)){
292 if (lc->vtable.display_status){
293 char *tmp=linphone_call_get_remote_address_as_string (call);
294 char *msg=ms_strdup_printf(_("Call with %s is paused."),tmp);
295 lc->vtable.display_status(lc,msg);
299 linphone_core_update_streams (lc,call,md);
300 linphone_call_set_state(call,LinphoneCallPaused,"Call paused");
301 }else if (sal_media_description_has_dir(md,SalStreamRecvOnly)){
302 /*we are put on hold when the call is initially accepted */
303 if (lc->vtable.display_status){
304 char *tmp=linphone_call_get_remote_address_as_string (call);
305 char *msg=ms_strdup_printf(_("Call answered by %s - on hold."),tmp);
306 lc->vtable.display_status(lc,msg);
310 linphone_core_update_streams (lc,call,md);
311 linphone_call_set_state(call,LinphoneCallPausedByRemote,"Call paused by remote");
313 if (call->state==LinphoneCallStreamsRunning){
314 /*media was running before, the remote as acceted a call modification (that is
315 a reinvite made by us. We must notify the application this reinvite was accepted*/
316 linphone_call_set_state(call, LinphoneCallUpdated, "Call updated");
318 if (call->state==LinphoneCallResuming){
319 if (lc->vtable.display_status){
320 lc->vtable.display_status(lc,_("Call resumed."));
323 if (lc->vtable.display_status){
324 char *tmp=linphone_call_get_remote_address_as_string (call);
325 char *msg=ms_strdup_printf(_("Call answered by %s."),tmp);
326 lc->vtable.display_status(lc,msg);
332 linphone_core_update_streams (lc,call,md);
333 linphone_call_set_state(call, LinphoneCallStreamsRunning, "Streams running");
334 lc->current_call=call;
338 ms_error("Incompatible SDP offer received in 200Ok, need to abort the call");
339 linphone_core_abort_call(lc,call,"No codec intersection");
343 static void call_ack(SalOp *op){
344 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
345 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
347 ms_warning("No call to be ACK'd");
350 if (call->media_pending){
351 SalMediaDescription *md=sal_call_get_final_media_description(op);
352 if (md && !sal_media_description_empty(md)){
353 if (call->state==LinphoneCallStreamsRunning){
354 /*media was running before, the remote as acceted a call modification (that is
355 a reinvite made by us. We must notify the application this reinvite was accepted*/
356 linphone_call_set_state(call, LinphoneCallUpdated, "Call updated");
358 linphone_core_update_streams (lc,call,md);
359 linphone_call_set_state (call,LinphoneCallStreamsRunning,"Connected (streams running)");
362 ms_error("Incompatible SDP response received in ACK, need to abort the call");
363 linphone_core_abort_call(lc,call,"No codec intersection");
370 /* this callback is called when an incoming re-INVITE modifies the session*/
371 static void call_updating(SalOp *op){
372 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
373 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
374 LinphoneCallState prevstate=LinphoneCallIdle;
375 SalMediaDescription *md;
377 md=sal_call_get_final_media_description(op);
379 if (md && !sal_media_description_empty(md))
381 if (sal_media_description_has_dir(call->localdesc,SalStreamSendRecv)){
382 ms_message("Our local status is SalStreamSendRecv");
383 if (sal_media_description_has_dir (md,SalStreamRecvOnly) || sal_media_description_has_dir(md,SalStreamInactive)){
384 /* we are being paused */
385 if(lc->vtable.display_status)
386 lc->vtable.display_status(lc,_("We are being paused..."));
387 linphone_call_set_state (call,LinphoneCallPausedByRemote,"Call paused by remote");
388 }else if (!sal_media_description_has_dir(call->resultdesc,SalStreamSendRecv) && sal_media_description_has_dir(md,SalStreamSendRecv)){
389 if(lc->vtable.display_status)
390 lc->vtable.display_status(lc,_("We have been resumed..."));
391 linphone_call_set_state (call,LinphoneCallStreamsRunning,"Connected (streams running)");
392 lc->current_call=call;
394 prevstate=call->state;
395 linphone_call_set_state(call, LinphoneCallUpdatedByRemote,"Call updated by remote");
398 /*accept the modification (sends a 200Ok)*/
400 linphone_core_update_streams (lc,call,md);
401 if (prevstate!=LinphoneCallIdle){
402 linphone_call_set_state (call,prevstate,"Connected (streams running)");
407 static void call_terminated(SalOp *op, const char *from){
408 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
409 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
411 if (call==NULL) return;
413 if (linphone_call_get_state(call)==LinphoneCallEnd || linphone_call_get_state(call)==LinphoneCallError){
414 ms_warning("call_terminated: ignoring.");
417 ms_message("Current call terminated...");
418 //we stop the call only if we have this current call or if we are in call
419 if (lc->ringstream!=NULL && ( (ms_list_size(lc->calls) == 1) || linphone_core_in_call(lc) )) {
420 ring_stop(lc->ringstream);
423 linphone_call_stop_media_streams(call);
424 if (lc->vtable.show!=NULL)
426 if (lc->vtable.display_status!=NULL)
427 lc->vtable.display_status(lc,_("Call terminated."));
429 linphone_call_set_state(call, LinphoneCallEnd,"Call ended");
432 static void call_failure(SalOp *op, SalError error, SalReason sr, const char *details, int code){
433 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
434 char *msg486=_("User is busy.");
435 char *msg480=_("User is temporarily unavailable.");
436 /*char *retrymsg=_("%s. Retry after %i minute(s).");*/
437 char *msg600=_("User does not want to be disturbed.");
438 char *msg603=_("Call declined.");
439 const char *msg=details;
440 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
443 ms_warning("Call faillure reported on already cleaned call ?");
447 if (lc->vtable.show) lc->vtable.show(lc);
449 if (error==SalErrorNoResponse){
450 msg=_("No response.");
451 if (lc->vtable.display_status)
452 lc->vtable.display_status(lc,msg);
453 }else if (error==SalErrorProtocol){
454 msg=details ? details : _("Protocol error.");
455 if (lc->vtable.display_status)
456 lc->vtable.display_status(lc, msg);
457 }else if (error==SalErrorFailure){
459 case SalReasonDeclined:
461 if (lc->vtable.display_status)
462 lc->vtable.display_status(lc,msg603);
466 if (lc->vtable.display_status)
467 lc->vtable.display_status(lc,msg486);
469 case SalReasonRedirect:
471 if (lc->vtable.display_status)
472 lc->vtable.display_status(lc,msg);
474 case SalReasonTemporarilyUnavailable:
476 if (lc->vtable.display_status)
477 lc->vtable.display_status(lc,msg480);
479 case SalReasonNotFound:
481 if (lc->vtable.display_status)
482 lc->vtable.display_status(lc,msg);
484 case SalReasonDoNotDisturb:
486 if (lc->vtable.display_status)
487 lc->vtable.display_status(lc,msg600);
490 msg=_("No common codecs");
491 if (lc->vtable.display_status)
492 lc->vtable.display_status(lc,msg);
495 if (lc->vtable.display_status)
496 lc->vtable.display_status(lc,_("Call failed."));
500 if (lc->ringstream!=NULL) {
501 ring_stop(lc->ringstream);
504 linphone_call_stop_media_streams (call);
505 if (sr!=SalReasonDeclined) linphone_call_set_state(call,LinphoneCallError,msg);
507 call->reason=LinphoneReasonDeclined;
508 linphone_call_set_state(call,LinphoneCallEnd,"Call declined.");
512 static void call_released(SalOp *op){
513 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
515 linphone_call_set_state(call,LinphoneCallReleased,"Call released");
516 }else ms_error("call_released() for already destroyed call ?");
519 static void auth_requested(SalOp *h, const char *realm, const char *username){
520 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
521 LinphoneAuthInfo *ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,realm,username);
522 ms_message("auth_requested() for realm=%s, username=%s",realm,username);
524 if (ai && ai->works==FALSE && ai->usecount>=3){
525 /*case we tried 3 times to authenticate, without success */
526 /*Better is to stop (implemeted below in else statement), and retry later*/
527 if (ms_time(NULL)-ai->last_use_time>30){
528 ai->usecount=0; /*so that we can allow to retry */
532 if (ai && (ai->works || ai->usecount<3)){
534 sai.username=ai->username;
535 sai.userid=ai->userid;
537 sai.password=ai->passwd;
538 ms_message("auth_requested(): authenticating realm=%s, username=%s",realm,username);
539 sal_op_authenticate(h,&sai);
541 ai->last_use_time=ms_time(NULL);
543 if (ai && ai->works==FALSE) {
544 sal_op_cancel_authentication(h);
546 if (lc->vtable.auth_info_requested)
547 lc->vtable.auth_info_requested(lc,realm,username);
551 static void auth_success(SalOp *h, const char *realm, const char *username){
552 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
553 LinphoneAuthInfo *ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,realm,username);
555 ms_message("%s/%s authentication works.",realm,username);
560 static void register_success(SalOp *op, bool_t registered){
561 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
562 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)sal_op_get_user_pointer(op);
565 cfg->registered=registered;
566 linphone_proxy_config_set_error(cfg,LinphoneReasonNone);
567 linphone_proxy_config_set_state(cfg, registered ? LinphoneRegistrationOk : LinphoneRegistrationCleared ,
568 registered ? "Registration sucessful" : "Unregistration done");
569 if (lc->vtable.display_status){
570 if (cfg->registered) msg=ms_strdup_printf(_("Registration on %s successful."),sal_op_get_proxy(op));
571 else msg=ms_strdup_printf(_("Unregistration on %s done."),sal_op_get_proxy(op));
572 lc->vtable.display_status(lc,msg);
578 static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details){
579 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
580 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)sal_op_get_user_pointer(op);
583 ms_warning("Registration failed for unknown proxy config.");
587 details=_("no response timeout");
589 if (lc->vtable.display_status) {
590 char *msg=ortp_strdup_printf(_("Registration on %s failed: %s"),sal_op_get_proxy(op),details );
591 lc->vtable.display_status(lc,msg);
594 if (error== SalErrorFailure && reason == SalReasonForbidden) {
595 linphone_proxy_config_set_error(cfg, LinphoneReasonBadCredentials);
596 } else if (error == SalErrorNoResponse) {
597 linphone_proxy_config_set_error(cfg, LinphoneReasonNoResponse);
599 linphone_proxy_config_set_state(cfg,LinphoneRegistrationFailed,details);
600 if (error== SalErrorFailure && reason == SalReasonForbidden) {
601 const char *realm=NULL,*username=NULL;
602 if (sal_op_get_auth_requested(op,&realm,&username)==0){
603 if (lc->vtable.auth_info_requested)
604 lc->vtable.auth_info_requested(lc,realm,username);
609 static void vfu_request(SalOp *op){
611 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer (op);
613 ms_warning("VFU request but no call !");
616 if (call->videostream)
617 video_stream_send_vfu(call->videostream);
621 static void dtmf_received(SalOp *op, char dtmf){
622 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
623 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
624 if (lc->vtable.dtmf_received != NULL)
625 lc->vtable.dtmf_received(lc, call, dtmf);
628 static void refer_received(Sal *sal, SalOp *op, const char *referto){
629 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
630 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
632 if (call->refer_to!=NULL){
633 ms_free(call->refer_to);
635 call->refer_to=ms_strdup(referto);
636 call->refer_pending=TRUE;
637 linphone_call_set_state(call,LinphoneCallRefered,"Refered");
638 if (lc->vtable.display_status){
639 char *msg=ms_strdup_printf(_("We are transferred to %s"),referto);
640 lc->vtable.display_status(lc,msg);
643 if (call->state!=LinphoneCallPaused){
644 ms_message("Automatically pausing current call to accept transfer.");
645 linphone_core_pause_call(lc,call);
647 linphone_core_start_refered_call(lc,call);
648 sal_call_accept_refer(op);
649 }else if (lc->vtable.refer_received){
650 lc->vtable.refer_received(lc,referto);
651 sal_call_accept_refer(op);
655 static void text_received(Sal *sal, const char *from, const char *msg){
656 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
657 linphone_core_text_received(lc,from,msg);
660 static void notify(SalOp *op, const char *from, const char *msg){
661 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
662 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer (op);
663 ms_message("get a %s notify from %s",msg,from);
664 if(lc->vtable.notify_recv)
665 lc->vtable.notify_recv(lc,call,from,msg);
668 static void notify_presence(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg){
669 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
670 linphone_notify_recv(lc,op,ss,status);
673 static void subscribe_received(SalOp *op, const char *from){
674 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
675 linphone_subscription_new(lc,op,from);
678 static void subscribe_closed(SalOp *op, const char *from){
679 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
680 linphone_subscription_closed(lc,op);
683 static void internal_message(Sal *sal, const char *msg){
684 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
689 static void ping_reply(SalOp *op){
690 LinphoneCall *call=(LinphoneCall*) sal_op_get_user_pointer(op);
691 ms_message("ping reply !");
693 if (call->state==LinphoneCallOutgoingInit){
694 linphone_core_start_invite(call->core,call,NULL);
699 ms_warning("ping reply without call attached...");
703 SalCallbacks linphone_sal_callbacks={