static void linphonec_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState st, const char *msg){ char *from=linphone_call_get_remote_address_as_string(call); long id=(long)linphone_call_get_user_pointer (call); switch(st){ case LinphoneCallEnd: linphonec_out("Call %i with %s ended (%s).\n", id, from, linphone_reason_to_string(linphone_call_get_reason(call))); break; case LinphoneCallResuming: linphonec_out("Resuming call %i with %s.\n", id, from); break; case LinphoneCallStreamsRunning: linphonec_out("Media streams established with %s for call %i (%s).\n", from,id,( linphone_call_params_video_enabled( linphone_call_get_current_params(call)) ? "video":"audio")); break; case LinphoneCallPausing: linphonec_out("Pausing call %i with %s.\n", id, from); break; case LinphoneCallPaused: linphonec_out("Call %i with %s is now paused.\n", id, from); break; case LinphoneCallPausedByRemote: linphonec_out("Call %i has been paused by %s.\n",id,from); break; case LinphoneCallIncomingReceived: linphonec_call_identify(call); linphone_call_enable_camera (call,linphonec_camera_enabled); id=(long)linphone_call_get_user_pointer (call); linphonec_set_caller(from); if ( auto_answer) { answer_call=TRUE; } linphonec_out("Receiving new incoming call from %s, assigned id %i\n", from,id); break; case LinphoneCallOutgoingInit: linphonec_call_identify(call); id=(long)linphone_call_get_user_pointer (call); linphonec_out("Establishing call id to %s, assigned id %i\n", from,id); break; case LinphoneCallUpdatedByRemote: linphonec_call_updated(call); break; case LinphoneCallOutgoingProgress: linphonec_out("Call %i to %s in progress.\n", id, from); break; case LinphoneCallOutgoingRinging: linphonec_out("Call %i to %s ringing.\n", id, from); break; case LinphoneCallConnected: linphonec_out("Call %i with %s connected.\n", id, from); break; case LinphoneCallOutgoingEarlyMedia: linphonec_out("Call %i with %s early media.\n", id, from); break; case LinphoneCallError: linphonec_out("Call %i with %s error.\n", id, from); break; default: break; } ms_free(from); }
void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md){ SalMediaDescription *oldmd=call->resultdesc; if (lc->ringstream!=NULL){ ring_stop(lc->ringstream); lc->ringstream=NULL; } if (new_md!=NULL){ sal_media_description_ref(new_md); call->media_pending=FALSE; }else{ call->media_pending=TRUE; } call->resultdesc=new_md; if (call->audiostream && call->audiostream->ticker){ /* we already started media: check if we really need to restart it*/ if (oldmd){ if (!media_parameters_changed(call,oldmd,new_md) && !call->playing_ringbacktone){ sal_media_description_unref(oldmd); if (call->all_muted){ ms_message("Early media finished, unmuting inputs..."); /*we were in early media, now we want to enable real media */ linphone_call_enable_camera (call,linphone_call_camera_enabled (call)); if (call->audiostream) linphone_core_mute_mic (lc, linphone_core_is_mic_muted(lc)); #ifdef VIDEO_ENABLED if (call->videostream && call->camera_active) video_stream_change_camera(call->videostream,lc->video_conf.device ); #endif } ms_message("No need to restart streams, SDP is unchanged."); return; }else{ ms_message("Media descriptions are different, need to restart the streams."); } } linphone_call_stop_media_streams (call); linphone_call_init_media_streams (call); } if (oldmd) sal_media_description_unref(oldmd); if (new_md) { bool_t all_muted=FALSE; bool_t send_ringbacktone=FALSE; if (call->audiostream==NULL){ /*this happens after pausing the call locally. The streams is destroyed and then we wait the 200Ok to recreate it*/ linphone_call_init_media_streams (call); } if (call->state==LinphoneCallIncomingEarlyMedia && linphone_core_get_remote_ringback_tone (lc)!=NULL){ send_ringbacktone=TRUE; } if (call->state==LinphoneCallIncomingEarlyMedia || (call->state==LinphoneCallOutgoingEarlyMedia && !call->params.real_early_media)){ all_muted=TRUE; } linphone_call_start_media_streams(call,all_muted,send_ringbacktone); } }
static void enable_disable_camera_after_camera_switches() { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); const char *currentCamId = (char*)linphone_core_get_video_device(marie->lc); const char **cameras=linphone_core_get_video_devices(marie->lc); const char *newCamId=NULL; int i; video_call_base_2(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); for (i=0;cameras[i]!=NULL;++i){ if (strcmp(cameras[i],currentCamId)!=0){ newCamId=cameras[i]; break; } } if (newCamId){ LinphoneCall *call = linphone_core_get_current_call(marie->lc); ms_message("Switching from [%s] to [%s]", currentCamId, newCamId); linphone_core_set_video_device(marie->lc, newCamId); if(call != NULL) { linphone_core_update_call(marie->lc, call, NULL); } BC_ASSERT_STRING_EQUAL(newCamId,ms_web_cam_get_string_id(linphone_call_get_video_device(call))); linphone_call_enable_camera(call,FALSE); linphone_core_iterate(marie->lc); linphone_call_enable_camera(call,TRUE); BC_ASSERT_STRING_EQUAL(newCamId,ms_web_cam_get_string_id(linphone_call_get_video_device(call))); } linphone_core_terminate_all_calls(pauline->lc); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1)); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md){ SalMediaDescription *oldmd=call->resultdesc; bool_t all_muted=FALSE; bool_t send_ringbacktone=FALSE; linphone_core_stop_ringing(lc); if (!new_md) { ms_error("linphone_core_update_streams() called with null media description"); return; } if (call->biggestdesc==NULL || new_md->n_total_streams>call->biggestdesc->n_total_streams){ /*we have been offered and now are ready to proceed, or we added a new stream*/ /*store the media description to remember the mapping of calls*/ if (call->biggestdesc){ sal_media_description_unref(call->biggestdesc); call->biggestdesc=NULL; } if (sal_call_is_offerer(call->op)) call->biggestdesc=sal_media_description_ref(call->localdesc); else call->biggestdesc=sal_media_description_ref(sal_call_get_remote_media_description(call->op)); } sal_media_description_ref(new_md); call->expect_media_in_ack=FALSE; call->resultdesc=new_md; if ((call->audiostream && call->audiostream->ms.ticker) || (call->videostream && call->videostream->ms.ticker)){ /* we already started media: check if we really need to restart it*/ if (oldmd){ int md_changed = media_parameters_changed(call, oldmd, new_md); if ((md_changed & SAL_MEDIA_DESCRIPTION_CODEC_CHANGED) || call->playing_ringbacktone) { ms_message("Media descriptions are different, need to restart the streams."); } else { if (md_changed == SAL_MEDIA_DESCRIPTION_UNCHANGED) { if (call->all_muted){ ms_message("Early media finished, unmuting inputs..."); /*we were in early media, now we want to enable real media */ linphone_call_enable_camera (call,linphone_call_camera_enabled (call)); if (call->audiostream) linphone_core_enable_mic(lc, linphone_core_mic_enabled(lc)); #ifdef VIDEO_ENABLED if (call->videostream && call->camera_enabled) video_stream_change_camera(call->videostream,lc->video_conf.device ); #endif } ms_message("No need to restart streams, SDP is unchanged."); goto end; }else { if (md_changed & SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED) { ms_message("Network parameters have changed, update them."); linphone_core_update_streams_destinations(lc, call, oldmd, new_md); } if (md_changed & SAL_MEDIA_DESCRIPTION_CRYPTO_CHANGED) { ms_message("Crypto parameters have changed, update them."); linphone_call_update_crypto_parameters(call, oldmd, new_md); } goto end; } } } linphone_call_stop_media_streams (call); linphone_call_init_media_streams (call); } if (call->audiostream==NULL){ /*this happens after pausing the call locally. The streams are destroyed and then we wait the 200Ok to recreate them*/ linphone_call_init_media_streams (call); } if (call->state==LinphoneCallIncomingEarlyMedia && linphone_core_get_remote_ringback_tone (lc)!=NULL){ send_ringbacktone=TRUE; } if (call->state==LinphoneCallIncomingEarlyMedia || (call->state==LinphoneCallOutgoingEarlyMedia && !call->params.real_early_media)){ all_muted=TRUE; } linphone_call_start_media_streams(call,all_muted,send_ringbacktone); if (call->state==LinphoneCallPausing && call->paused_by_app && ms_list_size(lc->calls)==1){ linphone_core_play_named_tone(lc,LinphoneToneCallOnHold); } end: if (oldmd) sal_media_description_unref(oldmd); }
static void cb_call_state_changed (LinphoneCore *lc, LinphoneCall *call, LinphoneCallState st, const char *msg){ char *from; from = linphone_call_get_remote_address_as_string (call); switch (st) { case LinphoneCallEnd: ShowStatus ("Call with %s ended (%s).", from, linphone_reason_to_string (linphone_call_get_reason (call))); inCall = FALSE; if (argCallee) running = FALSE; break; case LinphoneCallStreamsRunning: printf ("I: Media streams established with %s (%s).\n", from, (linphone_call_params_video_enabled( linphone_call_get_current_params(call)) ? "video":"audio")); break; case LinphoneCallIncomingReceived: ShowStatus ("Receiving new incoming call from %s", from, NULL); linphone_call_enable_camera (call, TRUE); // necessary? if (inCall) linphone_core_decline_call (lc, call, LinphoneReasonBusy); else linphone_core_accept_call (lc, call); // TBD: must this call be moved outside this handler? break; case LinphoneCallOutgoingInit: ShowStatus ("Establishing call to %s", from, NULL); break; case LinphoneCallOutgoingProgress: ShowStatus ("Call to %s in progress.", from, NULL); break; case LinphoneCallOutgoingRinging: ShowStatus ("Call to %s ringing.", from, NULL); break; case LinphoneCallConnected: ShowStatus ("Connected to %s.", from, NULL); inCall = TRUE; break; case LinphoneCallOutgoingEarlyMedia: printf ("I: Call with %s early media.", from); break; case LinphoneCallError: ShowStatus ("Call error with %s.", from, NULL); if (argCallee) error = TRUE; break; /* case LinphoneCallUpdatedByRemote: printf ("### cb_call_state_changed: Call %i with %s updated.\n", id, from); cp = linphone_call_get_current_params(call); // TBD: auto-start camera? if (!linphone_call_camera_enabled (call) && linphone_call_params_video_enabled (cp)){ printf ("Far end requests to share video.\nType 'camera on' if you agree.\n"); } break; case LinphoneCallPausing: printf ("### cb_call_state_changed: Pausing call %i with %s.\n", id, from); break; case LinphoneCallPaused: printf ("### cb_call_state_changed: Call %i with %s is now paused.\n", id, from); break; case LinphoneCallPausedByRemote: printf ("### cb_call_state_changed: Call %i has been paused by %s.\n",id,from); break; case LinphoneCallResuming: printf ("### cb_call_state_changed: Resuming call %i with %s.\n", id, from); break; */ default: break; } ms_free(from); }