Esempio n. 1
0
void transfer_button_clicked(GtkWidget *button, gpointer call_ref) {
    GtkWidget *menu_item;
    GtkWidget *menu=gtk_menu_new();
    LinphoneCall *call=(LinphoneCall*)call_ref;
    LinphoneCore *lc=linphone_gtk_get_core();
    const MSList *elem=linphone_core_get_calls(lc);

    for(; elem!=NULL; elem=elem->next) {
        LinphoneCall *other_call=(LinphoneCall*)elem->data;
        GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(other_call);
        if (other_call!=call) {
            int call_index=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(call_view),"call_index"));
            char *remote_uri=linphone_call_get_remote_address_as_string (other_call);
            char *text=g_strdup_printf(_("Transfer to call #%i with %s"),call_index,remote_uri);
            menu_item=gtk_image_menu_item_new_with_label(text);
            ms_free(remote_uri);
            g_free(text);
            gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),create_pixmap("status-green.png"));
            gtk_widget_show(menu_item);
            gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
            g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_transfer_call,other_call);
        }
    }
    gtk_menu_popup(GTK_MENU(menu),NULL,NULL,NULL,NULL,0,gtk_get_current_event_time());
    gtk_widget_show(menu);
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
static int remove_from_conference(LinphoneCore *lc, LinphoneCall *call, bool_t active){
	int err=0;

	if (!call->current_params.in_conference){
		if (call->params.in_conference){
			ms_warning("Not (yet) in conference, be patient");
			return -1;
		}else{
			ms_error("Not in a conference.");
			return -1;
		}
	}
	call->params.in_conference=FALSE;

	char *str=linphone_call_get_remote_address_as_string(call);
	ms_message("%s will be removed from conference", str);
	ms_free(str);
	if (active){
		LinphoneCallParams *params=linphone_call_params_copy(linphone_call_get_current_params(call));
		params->in_conference=FALSE;
		// reconnect local audio with this call
		if (linphone_core_is_in_conference(lc)){
			ms_message("Leaving conference for reconnecting with unique call.");
			linphone_core_leave_conference(lc);
		}
		ms_message("Updating call to actually remove from conference");
		err=linphone_core_update_call(lc,call,params);
		linphone_call_params_destroy(params);
	} else{
		ms_message("Pausing call to actually remove from conference");
		err=_linphone_core_pause_call(lc,call);
	}

	return err;
}
Esempio n. 4
0
	/** Callback prototype */
	void theDtmfReceived(struct _LinphoneCore* lc, LinphoneCall *call, int dtmf)
	{
		CVideoConfClientDlg *the_ui = (CVideoConfClientDlg *)linphone_core_get_user_data(lc);
		CString tmp;

		tmp.Format("收到 %s, DTMF 按键 %c",linphone_call_get_remote_address_as_string(call),dtmf);
		if(the_ui)
			the_ui->mStatus.SetWindowText(tmp);
	}
Esempio n. 5
0
/*
 * Linphone core callback
 */
static void
linphonec_transfer_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState new_call_state)
{
	char *remote=linphone_call_get_remote_address_as_string(call);
	if (new_call_state==LinphoneCallConnected){
		linphonec_out("The distant endpoint %s of call %li has been transfered, you can safely close the call.\n",
		              remote,(long)linphone_call_get_user_pointer (call));
	}
	ms_free(remote);
}
Esempio n. 6
0
/**
 * Remove a call from the conference.
 * @param lc the linphone core
 * @param call a call that has been previously merged into the conference.
 * 
 * After removing the remote participant belonging to the supplied call, the call becomes a normal call in paused state.
 * If one single remote participant is left alone together with the local user in the conference after the removal, then the conference is
 * automatically transformed into a simple call in StreamsRunning state.
 * The conference's resources are then automatically destroyed.
 * 
 * In other words, unless linphone_core_leave_conference() is explicitely called, the last remote participant of a conference is automatically
 * put in a simple call in running state.
 * 
 * @returns 0 if successful, -1 otherwise.
 **/
int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call){
	char * str=linphone_call_get_remote_address_as_string(call);
	ms_message("Removing call %s from the conference", str);
	ms_free(str);
	int err=remove_from_conference(lc,call, FALSE);
	if (err){
		ms_error("Error removing participant from conference.");
		return err;
	}

	if (remote_participants_count(&lc->conf_ctx)==1){
		ms_message("conference size is 1: need to be converted to plain call");
		err=convert_conference_to_call(lc);
	} else {
		ms_message("the conference need not to be converted as size is %i", remote_participants_count(&lc->conf_ctx));
	}
	return err;
}
Esempio n. 7
0
static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
	char temp[256];
	char *from=NULL;
	if(call)
		from = linphone_call_get_remote_address_as_string(call);
	if (from)
	{
		snprintf(temp,sizeof(temp),"Remote end %s seems to have disconnected, the call is going to be closed.",from);
		free(from);
	}		
	else
	{
		snprintf(temp,sizeof(temp),"Remote end seems to have disconnected, the call is going to be closed.");
	}
	if (lc->vtable.display_warning!=NULL)
		lc->vtable.display_warning(lc,temp);
	linphone_core_terminate_call(lc,call);
}
Esempio n. 8
0
/*
 * Call state notification callback
 */
static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){
	LinphoneChatRoom* chat_room = linphone_core_create_chat_room(lc,"sip:[email protected]:9998");
        switch(cstate){
                case LinphoneCallOutgoingRinging:
                        printf("It is now ringing remotely !\n");
                break;
                case LinphoneCallOutgoingEarlyMedia:
                        printf("Receiving some early media\n");
                break;
                case LinphoneCallConnected:
                        printf("We are connected !\n");
                break;
                case LinphoneCallStreamsRunning:
                        printf("Media streams established !\n");
                break;
                case LinphoneCallEnd:
                        printf("Call is terminated.\n");
                break;
                case LinphoneCallError:
                        printf("Call failure !");
                break;
                case LinphoneCallIncomingReceived:
                		printf("Call incoming received !: %s\n",msg);
                		linphone_call_ref(call);
                		printf("Remote address: %s\n",linphone_call_get_remote_address_as_string(call));
                		linphone_chat_room_send_message(chat_room,"Welcome in room!\n");
                		linphone_call_enable_echo_cancellation (call, false);
                		linphone_call_enable_echo_limiter(call,false);
				linphone_core_accept_call(lc,call);


                break;
                case LinphoneCallIncomingEarlyMedia:
                		printf("Call incoming....!");

                break;
                default:
                        printf("Unhandled notification %i\n",cstate);
        }
}
Esempio n. 9
0
static void linphonec_dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf){
	char *from=linphone_call_get_remote_address_as_string(call);
	fprintf(stdout,"Receiving tone %c from %s\n",dtmf,from);
	fflush(stdout);
	ms_free(from);
}
Esempio n. 10
0
/*
 * 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..."));
	}
}
Esempio n. 11
0
/*
 * 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 ;
	}
	
	md=sal_call_get_final_media_description(op);
	
	if (call->state==LinphoneCallOutgoingProgress ||
	    call->state==LinphoneCallOutgoingRinging ||
	    call->state==LinphoneCallOutgoingEarlyMedia){
		linphone_call_set_state(call,LinphoneCallConnected,"Connected");
	}
	if (md && !sal_media_description_empty(md)){
		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");
		}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==LinphoneCallStreamsRunning){
				/*media was running before, the remote as acceted a call modification (that is
					a reinvite made by us. We must notify the application this reinvite was accepted*/
				linphone_call_set_state(call, LinphoneCallUpdated, "Call updated");
			}else{
				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);
			linphone_call_set_state(call, LinphoneCallStreamsRunning, "Streams running");
			lc->current_call=call;
		}
	}else{
		/*send a bye*/
		ms_error("Incompatible SDP offer received in 200Ok, need to abort the call");
		linphone_core_abort_call(lc,call,"No codec intersection");
	}
}
Esempio n. 12
0
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);
}