static GtkWidget *create_video_window(LinphoneCall *call, LinphoneCallState cstate) { GtkWidget *video_window; GdkDisplay *display; GdkColor color; MSVideoSize vsize = MS_VIDEO_SIZE_CIF; const char *cstate_str; char *title; stats* counters = get_stats(call->core); cstate_str = linphone_call_state_to_string(cstate); title = g_strdup_printf("%s", cstate_str); video_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(video_window), title); g_free(title); gtk_window_resize(GTK_WINDOW(video_window), vsize.width, vsize.height); gdk_color_parse("black", &color); gtk_widget_modify_bg(video_window, GTK_STATE_NORMAL, &color); gtk_widget_show(video_window); g_object_set_data(G_OBJECT(video_window), "call", call); #if GTK_CHECK_VERSION(2,24,0) display = gdk_window_get_display(gtk_widget_get_window(video_window)); #else // backward compatibility with Debian 6 and Centos 6 display = gdk_drawable_get_display(gtk_widget_get_window(video_window)); #endif gdk_display_flush(display); counters->number_of_video_windows_created++; return video_window; }
/** * Merge a call into a conference. * @param lc the linphone core * @param call an established call, either in LinphoneCallStreamsRunning or LinphoneCallPaused state. * * If this is the first call that enters the conference, the virtual conference will be created automatically. * If the local user was actively part of the call (ie not in paused state), then the local user is automatically entered into the conference. * If the call was in paused state, then it is automatically resumed when entering into the conference. * * @returns 0 if successful, -1 otherwise. **/ int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call){ LinphoneConference *conf=&lc->conf_ctx; if (call->current_params.in_conference){ ms_error("Already in conference"); return -1; } conference_check_init(&lc->conf_ctx, lp_config_get_int(lc->config, "sound","conference_rate",16000)); if (call->state==LinphoneCallPaused){ call->params.in_conference=TRUE; call->params.has_video=FALSE; linphone_core_resume_call(lc,call); }else if (call->state==LinphoneCallStreamsRunning){ LinphoneCallParams *params=linphone_call_params_copy(linphone_call_get_current_params(call)); params->in_conference=TRUE; params->has_video=FALSE; if (call->audiostream || call->videostream){ linphone_call_stop_media_streams (call); /*free the audio & video local resources*/ } if (call==lc->current_call){ lc->current_call=NULL; } /*this will trigger a reINVITE that will later redraw the streams */ linphone_core_update_call(lc,call,params); linphone_call_params_destroy(params); add_local_endpoint(conf,lc); }else{ ms_error("Call is in state %s, it cannot be added to the conference.",linphone_call_state_to_string(call->state)); return -1; } return 0; }
void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const char *message){ LinphoneCore *lc=call->core; if (call->state!=cstate){ if (call->state==LinphoneCallEnd || call->state==LinphoneCallError){ if (cstate!=LinphoneCallReleased){ ms_warning("Spurious call state change from %s to %s, ignored.",linphone_call_state_to_string(call->state), linphone_call_state_to_string(cstate)); return; } } ms_message("Call %p: moving from state %s to %s",call,linphone_call_state_to_string(call->state), linphone_call_state_to_string(cstate)); if (cstate!=LinphoneCallRefered){ /*LinphoneCallRefered is rather an event, not a state. Indeed it does not change the state of the call (still paused or running)*/ call->state=cstate; } if (cstate==LinphoneCallEnd || cstate==LinphoneCallError){ if (call->reason==LinphoneReasonDeclined){ call->log->status=LinphoneCallDeclined; } linphone_call_set_terminated (call); } if (cstate == LinphoneCallConnected) { call->log->status=LinphoneCallSuccess; } if (lc->vtable.call_state_changed) lc->vtable.call_state_changed(lc,call,cstate,message); if (cstate==LinphoneCallReleased){ if (call->op!=NULL) { /* so that we cannot have anymore upcalls for SAL concerning this call*/ sal_op_release(call->op); call->op=NULL; } linphone_call_unref(call); } } }
static bool_t call_player_check_state(LinphonePlayer *player, bool_t check_player){ LinphoneCall *call=(LinphoneCall*)player->impl; if (call->state!=LinphoneCallStreamsRunning){ ms_warning("Call [%p]: in-call player not usable in state [%s]",call,linphone_call_state_to_string(call->state)); return FALSE; } if (call->audiostream==NULL) { ms_error("call_player_check_state(): no audiostream."); return FALSE; } if (check_player && call->audiostream->av_player.player==NULL){ ms_error("call_player_check_state(): no player."); return FALSE; } return TRUE; }
static void call_failure(SalOp *op, SalError error, SalReason sr, const char *details, int code){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); char *msg486=_("User is busy."); char *msg480=_("User is temporarily unavailable."); /*char *retrymsg=_("%s. Retry after %i minute(s).");*/ char *msg600=_("User does not want to be disturbed."); char *msg603=_("Call declined."); const char *msg=details; LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op); LinphoneCall *referer=call->referer; if (call==NULL){ ms_warning("Call faillure reported on already terminated call."); return ; } if (lc->vtable.show) lc->vtable.show(lc); if (error==SalErrorNoResponse){ msg=_("No response."); if (lc->vtable.display_status) lc->vtable.display_status(lc,msg); }else if (error==SalErrorProtocol){ msg=details ? details : _("Protocol error."); if (lc->vtable.display_status) lc->vtable.display_status(lc, msg); }else if (error==SalErrorFailure){ switch(sr){ case SalReasonDeclined: msg=msg603; if (lc->vtable.display_status) lc->vtable.display_status(lc,msg603); break; case SalReasonBusy: msg=msg486; if (lc->vtable.display_status) lc->vtable.display_status(lc,msg486); break; case SalReasonRedirect: { ms_error("case SalReasonRedirect"); linphone_call_stop_media_streams(call); if ( call->state==LinphoneCallOutgoingInit || call->state==LinphoneCallOutgoingProgress || call->state==LinphoneCallOutgoingRinging /*push case*/ || call->state==LinphoneCallOutgoingEarlyMedia){ LinphoneAddress* redirection_to = (LinphoneAddress*)sal_op_get_remote_contact_address(call->op); if( redirection_to ){ char* url = linphone_address_as_string(redirection_to); ms_error("Redirecting call [%p] to %s",call, url); ms_free(url); linphone_call_create_op(call); linphone_core_start_invite(lc, call, redirection_to); return; } } msg=_("Redirected"); if (lc->vtable.display_status) lc->vtable.display_status(lc,msg); } break; case SalReasonTemporarilyUnavailable: msg=msg480; if (lc->vtable.display_status) lc->vtable.display_status(lc,msg480); break; case SalReasonNotFound: if (lc->vtable.display_status) lc->vtable.display_status(lc,msg); break; case SalReasonDoNotDisturb: msg=msg600; if (lc->vtable.display_status) lc->vtable.display_status(lc,msg600); break; case SalReasonUnsupportedContent: /*<this is for compatibility: linphone sent 415 because of SDP offer answer failure*/ case SalReasonNotAcceptable: //media_encryption_mandatory if (call->params.media_encryption == LinphoneMediaEncryptionSRTP && !linphone_core_is_media_encryption_mandatory(lc)) { int i; ms_message("Outgoing call [%p] failed with SRTP (SAVP) enabled",call); linphone_call_stop_media_streams(call); if ( call->state==LinphoneCallOutgoingInit || call->state==LinphoneCallOutgoingProgress || call->state==LinphoneCallOutgoingRinging /*push case*/ || call->state==LinphoneCallOutgoingEarlyMedia){ ms_message("Retrying call [%p] with AVP",call); /* clear SRTP local params */ call->params.media_encryption = LinphoneMediaEncryptionNone; for(i=0; i<call->localdesc->n_active_streams; i++) { call->localdesc->streams[i].proto = SalProtoRtpAvp; memset(call->localdesc->streams[i].crypto, 0, sizeof(call->localdesc->streams[i].crypto)); } linphone_core_restart_invite(lc, call); return; } } msg=_("Incompatible media parameters."); if (lc->vtable.display_status) lc->vtable.display_status(lc,msg); break; case SalReasonRequestPending: /*restore previous state, the application will decide to resubmit the action if relevant*/ call->reason=linphone_reason_from_sal(sr); linphone_call_set_state(call,call->prevstate,msg); return; break; default: if (lc->vtable.display_status) lc->vtable.display_status(lc,_("Call failed.")); } } /*some call error are not fatal*/ switch (call->state) { case LinphoneCallUpdating: case LinphoneCallPausing: case LinphoneCallResuming: ms_message("Call error on state [%s], restoring previous state",linphone_call_state_to_string(call->prevstate)); call->reason=linphone_reason_from_sal(sr); linphone_call_set_state(call, call->prevstate,details); return; default: break; /*nothing to do*/ } linphone_core_stop_ringing(lc); linphone_call_stop_media_streams(call); #ifdef BUILD_UPNP linphone_call_delete_upnp_session(call); #endif //BUILD_UPNP call->reason=linphone_reason_from_sal(sr); if (sr==SalReasonDeclined){ linphone_call_set_state(call,LinphoneCallEnd,"Call declined."); }else{ linphone_call_set_state(call,LinphoneCallError,details); if (sr==SalReasonBusy) linphone_core_play_named_tone(lc,LinphoneToneBusy); } if (referer){ /*notify referer of the failure*/ linphone_core_notify_refer_state(lc,referer,call); /*schedule automatic resume of the call. This must be done only after the notifications are completed due to dialog serialization of requests.*/ linphone_core_queue_task(lc,(belle_sip_source_func_t)resume_call_after_failed_transfer,linphone_call_ref(referer),"Automatic call resuming after failed transfer"); } }