コード例 #1
0
ファイル: incall_view.c プロジェクト: AirDev/linphone-android
void linphone_gtk_create_in_call_view(LinphoneCall *call){
	GtkWidget *call_view=linphone_gtk_create_widget("main","in_call_frame");
	GtkWidget *main_window=linphone_gtk_get_main_window ();
	GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
	static int call_index=1;
	int idx;

	if (ms_list_size(linphone_core_get_calls(linphone_gtk_get_core()))==1){
		/*this is the only call at this time */
		call_index=1;
	}
	g_object_set_data(G_OBJECT(call_view),"call",call);
	g_object_set_data(G_OBJECT(call_view),"call_index",GINT_TO_POINTER(call_index));

	linphone_call_set_user_pointer (call,call_view);
	linphone_call_ref(call);
	gtk_notebook_append_page (notebook,call_view,make_tab_header(call_index));
	gtk_widget_show(call_view);
	idx = gtk_notebook_page_num(notebook, call_view);
	gtk_notebook_set_current_page(notebook, idx);
	call_index++;
	linphone_gtk_enable_hold_button (call,FALSE,TRUE);
	linphone_gtk_enable_mute_button(
					GTK_BUTTON(linphone_gtk_get_widget(call_view,"incall_mute")),FALSE);
}
コード例 #2
0
ファイル: incall_view.c プロジェクト: mjpak0109/linphone
LinphoneCall *linphone_gtk_get_currently_displayed_call(gboolean *is_conf) {
    LinphoneCore *lc=linphone_gtk_get_core();
    GtkWidget *main_window=linphone_gtk_get_main_window ();
    GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
    const MSList *calls=linphone_core_get_calls(lc);
    if (is_conf) *is_conf=FALSE;
    if (!linphone_gtk_use_in_call_view() || ms_list_size(calls)==1) {
        if (calls) return (LinphoneCall*)calls->data;
    } else {
        int idx=gtk_notebook_get_current_page (notebook);
        GtkWidget *page=gtk_notebook_get_nth_page(notebook,idx);
        if (page!=NULL) {
            LinphoneCall *call=(LinphoneCall*)g_object_get_data(G_OBJECT(page),"call");
            if (call==NULL) {
                GtkWidget *conf_frame=(GtkWidget *)g_object_get_data(G_OBJECT(main_window),"conf_frame");
                if (conf_frame==page) {
                    if (is_conf)
                        *is_conf=TRUE;
                    return NULL;
                }
            }
            return call;
        }
    }
    return NULL;
}
コード例 #3
0
ファイル: incall_view.c プロジェクト: mjpak0109/linphone
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);
}
コード例 #4
0
ファイル: callbacks.c プロジェクト: korobool/liblinphone
static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status, SalReason reason){
	LinphoneChatMessage *chat_msg=(LinphoneChatMessage* )sal_op_get_user_pointer(op);
	const MSList* calls;

	if (chat_msg == NULL) {
		// Do not handle delivery status for isComposing messages.
		return;
	}
	calls = linphone_core_get_calls(chat_msg->chat_room->lc);

	chat_msg->state=chatStatusSal2Linphone(status);
	chat_msg->reason=reason;
	linphone_chat_message_store_state(chat_msg);
	if (chat_msg && chat_msg->cb) {
		ms_message("Notifying text delivery with status %i",chat_msg->state);
		chat_msg->cb(chat_msg
			,chat_msg->state
			,chat_msg->cb_ud);
	}
	if (status != SalTextDeliveryInProgress) { /*don't release op if progress*/
		linphone_chat_message_destroy(chat_msg);

		if (!ms_list_find_custom((MSList*)calls, (MSCompareFunc) op_equals, op)) {
			/*op was only create for messaging purpose, destroying*/
			sal_op_release(op);
		}
	}
}
コード例 #5
0
ファイル: incall_view.c プロジェクト: mjpak0109/linphone
void linphone_gtk_enable_conference_button(LinphoneCore *lc, gboolean value) {
    const MSList *elem=linphone_core_get_calls(lc);
    for(; elem!=NULL; elem=elem->next) {
        LinphoneCall *call=(LinphoneCall*)elem->data;
        GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
        GtkWidget *button=linphone_gtk_get_widget (call_view,"conference_button");
        if (button != NULL) {
            gtk_widget_set_sensitive(button,value);
        }
    }
}
コード例 #6
0
LinphoneCall *linphonec_get_call(long id){
	const MSList *elem=linphone_core_get_calls(linphonec);
	for (;elem!=NULL;elem=elem->next){
		LinphoneCall *call=(LinphoneCall*)elem->data;
		if (linphone_call_get_user_pointer (call)==(void*)id){
			return call;
		}
	}
	linphonec_out("Sorry, no call with id %i exists at this time.\n",id);
	return NULL;
}
コード例 #7
0
ファイル: incall_view.c プロジェクト: Gui13/linphone
void linphone_gtk_create_in_call_view(LinphoneCall *call){
	GtkWidget *call_view=linphone_gtk_create_widget("main","in_call_frame");
	GtkWidget *main_window=linphone_gtk_get_main_window ();
	GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
	static int call_index=1;
	int idx;
	GtkWidget *transfer;
	GtkWidget *conf;
	GtkWidget *button;
	GtkWidget *image;


	if (ms_list_size(linphone_core_get_calls(linphone_gtk_get_core()))==1){
		/*this is the only call at this time */
		call_index=1;
	}
	g_object_set_data(G_OBJECT(call_view),"call",call);
	g_object_set_data(G_OBJECT(call_view),"call_index",GINT_TO_POINTER(call_index));

	linphone_call_set_user_pointer (call,call_view);
	linphone_call_ref(call);
	gtk_notebook_append_page (notebook,call_view,make_tab_header(call_index));
	gtk_widget_show(call_view);
	idx = gtk_notebook_page_num(notebook, call_view);
	gtk_notebook_set_current_page(notebook, idx);
	call_index++;
	linphone_gtk_enable_hold_button (call,FALSE,TRUE);
	linphone_gtk_enable_video_button (call,FALSE,TRUE);
	linphone_gtk_enable_mute_button(
					GTK_BUTTON(linphone_gtk_get_widget(call_view,"incall_mute")),FALSE);

	transfer = linphone_gtk_get_widget(call_view,"transfer_button");
	gtk_button_set_image(GTK_BUTTON(transfer),gtk_image_new_from_stock
							 (GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_BUTTON));
	g_signal_connect(G_OBJECT(transfer),"clicked",(GCallback)transfer_button_clicked,call);
	gtk_widget_hide(transfer);

	conf = linphone_gtk_get_widget(call_view,"conference_button");
	gtk_button_set_image(GTK_BUTTON(conf),gtk_image_new_from_stock (GTK_STOCK_ADD,GTK_ICON_SIZE_BUTTON));
	g_signal_connect(G_OBJECT(conf),"clicked",(GCallback)conference_button_clicked,call);
	gtk_widget_hide(conf);

	button=linphone_gtk_get_widget(call_view,"terminate_call");
	image=create_pixmap (linphone_gtk_get_ui_config("stop_call_icon","stopcall-small.png"));
	gtk_button_set_label(GTK_BUTTON(button),_("Hang up"));
	gtk_button_set_image(GTK_BUTTON(button),image);
	gtk_widget_show(image);
	g_signal_connect_swapped(G_OBJECT(linphone_gtk_get_widget(call_view,"quality_indicator")),"button-press-event",(GCallback)linphone_gtk_show_call_stats,call);
}
コード例 #8
0
ファイル: incall_view.c プロジェクト: ApOgEE/linphone-sdk
void linphone_gtk_enable_transfer_button(LinphoneCore *lc, gboolean value){
	const MSList *elem=linphone_core_get_calls(lc);
	for(;elem!=NULL;elem=elem->next){
		LinphoneCall *call=(LinphoneCall*)elem->data;
		GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call);
		GtkWidget *box=linphone_gtk_get_widget (call_view,"mute_pause_buttons");
		GtkWidget *button=(GtkWidget*)g_object_get_data(G_OBJECT(box),"transfer");
		if (button && value==FALSE){
			gtk_widget_destroy(button);
			button=NULL;
		}else if (!button && value==TRUE){
			button=gtk_button_new_with_label (_("Transfer"));
			gtk_button_set_image(GTK_BUTTON(button),gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD,GTK_ICON_SIZE_BUTTON));
			g_signal_connect(G_OBJECT(button),"clicked",(GCallback)transfer_button_clicked,call);
			gtk_widget_show_all(button);
			gtk_container_add(GTK_CONTAINER(box),button);
		}
		g_object_set_data(G_OBJECT(box),"transfer",button);
	}
}
コード例 #9
0
ファイル: auto_answer.c プロジェクト: 42p/linphone
int main(int argc, char *argv[]){
	LinphoneCoreVTable vtable={0};
	LinphoneCore *lc;
	LinphoneVideoPolicy policy;
	int i;
	LinphoneAddress *addr=NULL;
	LCSipTransports tp;
	char * tmp = NULL;
	LpConfig * lp_config = lp_config_new(NULL);
	int max_call_duration=3600;
	static const char *media_file = NULL;

	policy.automatically_accept=TRUE;
	signal(SIGINT,stop);
#ifndef _WIN32
	signal(SIGUSR1,stats);
	signal(SIGUSR2,dump_call_logs);
#endif
	for(i = 1; i < argc; ++i) {
		if (strcmp(argv[i], "--verbose") == 0) {
			linphone_core_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
		} else if (strcmp(argv[i], "--max-call-duration") == 0){
			max_call_duration = atoi(argv[++i]);
		} else if (strcmp(argv[i], "--listening-uri") == 0){
			addr = linphone_address_new(argv[++i]);
			if (!addr) {
				printf("Error, bad sip uri");
				helper(argv[0]);
			}
/*			switch(linphone_address_get_transport(addr)) {
			case LinphoneTransportUdp:
			case LinphoneTransportTcp:
				break;
			default:
				ms_error("Error, bad sip uri [%s] transport, should be udp | tcp",argv[i]);
				helper();
				break;
			}*/
		} else if (strcmp(argv[i], "--media-file") == 0){
			i++;
			if (i<argc){
				media_file = argv[i];
			}else helper(argv[0]);
		} else {
			helper(argv[0]);
		}
	}

	if (!addr) {
		addr = linphone_address_new("sip:[email protected]:5060");
	}

	lp_config_set_string(lp_config,"sip","bind_address",linphone_address_get_domain(addr));
	lp_config_set_string(lp_config,"rtp","bind_address",linphone_address_get_domain(addr));
	lp_config_set_int(lp_config,"misc","history_max_size",100000);

	vtable.call_state_changed=call_state_changed;

	lc=linphone_core_new_with_config(&vtable,lp_config,NULL);
	linphone_core_enable_video_capture(lc,TRUE);
	linphone_core_enable_video_display(lc,FALSE);
	linphone_core_set_video_policy(lc,&policy);
	linphone_core_enable_keep_alive(lc,FALSE);


	/*instead of using sound capture card, a file is played to the calling party*/
	linphone_core_set_use_files(lc,TRUE);
	linphone_core_enable_echo_cancellation(lc, FALSE); /*no need for local echo cancellation when playing files*/
	if (!media_file){
		linphone_core_set_play_file(lc,PACKAGE_DATA_DIR "/sounds/linphone/hello16000.wav");
		linphone_core_set_preferred_framerate(lc,5);
	}else{
		PayloadType *pt = linphone_core_find_payload_type(lc, "opus", 48000, -1);
		/*if opus is present, give it a bitrate for good quality with music, and stereo enabled*/
		if (pt){
			linphone_core_set_payload_type_bitrate(lc, pt, 150);
			payload_type_set_send_fmtp(pt, "stereo=1");
			payload_type_set_recv_fmtp(pt, "stereo=1");
		}
		linphone_core_set_play_file(lc, media_file);
		linphone_core_set_preferred_video_size_by_name(lc, "720p");
	}

	{
		MSWebCamDesc *desc = ms_mire_webcam_desc_get();
		if (desc){
			ms_web_cam_manager_add_cam(ms_factory_get_web_cam_manager(linphone_core_get_ms_factory(lc)),ms_web_cam_new(desc));
			linphone_core_set_video_device(lc,"Mire: Mire (synthetic moving picture)");
		}
	}



	memset(&tp,0,sizeof(LCSipTransports));

	tp.udp_port = linphone_address_get_port(addr);
	tp.tcp_port = linphone_address_get_port(addr);

	linphone_core_set_sip_transports(lc,&tp);
	linphone_core_set_audio_port_range(lc,1024,65000);
	linphone_core_set_video_port_range(lc,1024,65000);
	linphone_core_set_primary_contact(lc,tmp=linphone_address_as_string(addr));
	ms_free(tmp);

	/* main loop for receiving notifications and doing background linphonecore work: */
	while(running){
		const bctbx_list_t * iterator;
		linphone_core_iterate(lc);
		ms_usleep(50000);
		if (print_stats) {
			ms_message("*********************************");
			ms_message("*Current number of calls   [%10u]  *", (unsigned int)bctbx_list_size(linphone_core_get_calls(lc)));
			ms_message("*Number of calls until now [%10u]  *", (unsigned int)bctbx_list_size(linphone_core_get_call_logs(lc)));
			ms_message("*********************************");
			print_stats=FALSE;
		}
		if (dump_stats) {
			ms_message("*********************************");
			for (iterator=linphone_core_get_call_logs(lc);iterator!=NULL;iterator=iterator->next) {
				LinphoneCallLog *call_log=(LinphoneCallLog *)iterator->data;
				char * tmp_str = linphone_call_log_to_str(call_log);
				ms_message("\n%s",tmp_str);
				ms_free(tmp_str);
			}
			dump_stats=FALSE;
			ms_message("*********************************");
		}
		for (iterator=linphone_core_get_calls(lc);iterator!=NULL;iterator=iterator->next) {
			LinphoneCall *call=(LinphoneCall *)iterator->data;
			if (linphone_call_get_duration(call) > max_call_duration) {
				ms_message("Terminating call [%p] after [%i] s",call,linphone_call_get_duration(call));
				linphone_core_terminate_call(lc,call);
				break;
			}
		}

	}

	ms_message("Shutting down...\n");
	linphone_core_destroy(lc);
	ms_message("Exited\n");
	return 0;
}
コード例 #10
0
ファイル: video_tester.c プロジェクト: xiaolds/VideoCallVoIP
static void two_incoming_early_media_video_calls_test(void) {
	char *ringback_path;
	LinphoneCoreManager *marie;
	LinphoneCoreManager *pauline;
	LinphoneCoreManager *laure;
	LinphoneCallParams *marie_params;
	LinphoneCallParams *pauline_params;
	LinphoneCallParams *laure_params;
	LinphoneCall *call;
	const MSList *calls_list;

	marie = linphone_core_manager_new("marie_rc");
	pauline = linphone_core_manager_new("pauline_rc");
	laure = linphone_core_manager_new("laure_rc");
	marie_params = configure_for_early_media_video_receiving(marie);
	pauline_params = configure_for_early_media_video_sending(pauline);
	laure_params = configure_for_early_media_video_sending(laure);

	/* Configure early media audio to play ring during early-media and send remote ring back tone. */
	linphone_core_set_ring_during_incoming_early_media(marie->lc, TRUE);
	ringback_path = ms_strdup_printf("%s/sounds/ringback.wav", liblinphone_tester_file_prefix);
	linphone_core_set_remote_ringback_tone(marie->lc, ringback_path);
	ms_free(ringback_path);

	/* Early media video call from pauline to marie. */
	CU_ASSERT_TRUE(video_call_with_params(pauline, marie, pauline_params, NULL, FALSE));

	/* Wait for 2s. */
	wait_for_three_cores(marie->lc, pauline->lc, NULL, 2000);

	/* Early media video call from laure to marie. */
	CU_ASSERT_TRUE(video_call_with_params(laure, marie, laure_params, NULL, FALSE));

	/* Wait for 2s. */
	wait_for_three_cores(marie->lc, pauline->lc, laure->lc, 2000);

	CU_ASSERT_EQUAL(linphone_core_get_calls_nb(marie->lc), 2);
	if (linphone_core_get_calls_nb(marie->lc) == 2) {
		calls_list = linphone_core_get_calls(marie->lc);
		call = (LinphoneCall *)ms_list_nth_data(calls_list, 0);
		CU_ASSERT_PTR_NOT_NULL(call);
		if (call != NULL) {
			LinphoneCallParams *params = linphone_call_params_copy(linphone_call_get_current_params(call));
			linphone_call_params_set_audio_direction(params, LinphoneMediaDirectionSendRecv);
			linphone_call_params_set_video_direction(params, LinphoneMediaDirectionSendRecv);
			linphone_core_accept_call_with_params(marie->lc, call, params);

			/* Wait for 5s. */
			wait_for_three_cores(marie->lc, pauline->lc, laure->lc, 5000);
		}
	}

	linphone_core_terminate_all_calls(marie->lc);
	CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallEnd, 1));
	CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
	CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallReleased, 1));
	CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallReleased, 1));
	CU_ASSERT_TRUE(wait_for(marie->lc, laure->lc, &marie->stat.number_of_LinphoneCallEnd, 1));
	CU_ASSERT_TRUE(wait_for(marie->lc, laure->lc, &laure->stat.number_of_LinphoneCallEnd, 1));

	CU_ASSERT_EQUAL(marie->stat.number_of_video_windows_created, 2);
	CU_ASSERT_EQUAL(pauline->stat.number_of_video_windows_created, 1);
	CU_ASSERT_EQUAL(laure->stat.number_of_video_windows_created, 1);

	linphone_call_params_unref(marie_params);
	linphone_call_params_unref(pauline_params);
	linphone_call_params_unref(laure_params);
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
	linphone_core_manager_destroy(laure);
}