static void early_media_video_with_inactive_audio(void) {
	LinphoneCoreManager *marie;
	LinphoneCoreManager *pauline;
	LinphoneCallParams *marie_params;
	LinphoneCallParams *pauline_params;

	marie = linphone_core_manager_new("marie_rc");
	pauline = linphone_core_manager_new("pauline_tcp_rc");
	marie_params = configure_for_early_media_video_receiving_with_inactive_audio(marie);
	pauline_params = configure_for_early_media_video_sending(pauline);

	/* Early media video call from pauline to marie. */
	BC_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);

	/* Check that we are in LinphoneCallOutgoingEarlyMedia state and that the ringstream is present meaning we are playing the ringback tone. */
	BC_ASSERT_EQUAL(linphone_call_get_state(linphone_core_get_current_call(pauline->lc)), LinphoneCallOutgoingEarlyMedia, int, "%d");
	BC_ASSERT_PTR_NOT_NULL(pauline->lc->ringstream);

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

	BC_ASSERT_EQUAL(marie->stat.number_of_video_windows_created, 1, int, "%d");
	BC_ASSERT_EQUAL(pauline->stat.number_of_video_windows_created, 1, int, "%d");

	linphone_call_params_unref(marie_params);
	linphone_call_params_unref(pauline_params);
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
static void quality_reporting_at_call_termination() {
	LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_rtcp_xr");
	LinphoneCall* call_marie = NULL;
	LinphoneCall* call_pauline = NULL;

	if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) {
		linphone_reporting_set_on_report_send(call_marie, on_report_send_with_rtcp_xr_remote);

		linphone_core_terminate_all_calls(marie->lc);

		// now dialog id should be filled
		CU_ASSERT_PTR_NOT_NULL(call_marie->log->reporting.reports[0]->dialog_id);

		CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallReleased,1, 10000));
		CU_ASSERT_TRUE(wait_for_until(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallReleased,1, 10000));

		CU_ASSERT_PTR_NULL(linphone_core_get_current_call(marie->lc));
		CU_ASSERT_PTR_NULL(linphone_core_get_current_call(pauline->lc));

		// PUBLISH submission to the collector should be ok
		CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishProgress,1));
		CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphonePublishOk,1));
	}
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
/*
 * Close linphonec, cleanly terminating
 * any pending call
 */
void
linphonec_finish(int exit_status)
{
	// Do not allow concurrent destroying to prevent glibc errors
	static bool_t terminating=FALSE;
	if (terminating) return; 
	terminating=TRUE;
	linphonec_out("Terminating...\n");

	/* Terminate any pending call */
	linphone_core_terminate_all_calls(linphonec);
#ifdef HAVE_READLINE
	linphonec_finish_readline();
#endif
#if !defined(_WIN32_WCE)
	if (pipe_reader_run)
		stop_pipe_reader();
#endif /*_WIN32_WCE*/

	linphone_core_destroy (linphonec);

	if (mylogfile != NULL && mylogfile != stdout)
	{
		fclose (mylogfile);
	}
	printf("\n");
	exit(exit_status);

}
extern "C" void
Java_com_acsoftware_android_domophone_LibLP_nTerminateCall(JNIEnv* env, jobject thiz) {
    
    if ( lc ) {
        linphone_core_terminate_all_calls(lc);
    };
    
};
static void profile_call_base(bool_t avpf1, LinphoneMediaEncryption srtp1,bool_t avpf2, LinphoneMediaEncryption srtp2, bool_t encryption_mandatory, const char *expected_profile) {
	LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
	LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
	LinphoneProxyConfig *lpc;
	const LinphoneCallParams *params;

	if (avpf1) {
		linphone_core_get_default_proxy(marie->lc, &lpc);
		linphone_proxy_config_enable_avpf(lpc, TRUE);
		linphone_proxy_config_set_avpf_rr_interval(lpc, 3);
	}
	if (avpf2) {
		linphone_core_get_default_proxy(pauline->lc, &lpc);
		linphone_proxy_config_enable_avpf(lpc, TRUE);
		linphone_proxy_config_set_avpf_rr_interval(lpc, 3);
	}

	if (encryption_mandatory) {
		linphone_core_set_media_encryption_mandatory(marie->lc,TRUE);
		linphone_core_set_media_encryption_mandatory(pauline->lc,TRUE);
	}

	if (linphone_core_media_encryption_supported(marie->lc, srtp1)) {
		linphone_core_set_media_encryption(marie->lc, srtp1);
	} else {
		ms_message("Unsupported [%s] encryption type, cannot test",linphone_media_encryption_to_string(srtp1));
		goto end;

	}
	if (linphone_core_media_encryption_supported(pauline->lc, srtp2)) {
		linphone_core_set_media_encryption(pauline->lc, srtp2);
	}else {
		ms_message("Unsupported [%s] encryption type, cannot test",linphone_media_encryption_to_string(srtp2));
		goto end;

	}

	CU_ASSERT_TRUE(call(marie, pauline));
	CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
	CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
	if (linphone_core_get_current_call(marie->lc)) {
		params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc));
		CU_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), expected_profile);
	}
	if (linphone_core_get_current_call(pauline->lc)) {
		params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc));
		CU_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), expected_profile);
	}

	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_EQUAL(marie->stat.number_of_LinphoneCallConnected, 1);
	CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallConnected, 1);
end:
	linphone_core_manager_destroy(pauline);
	linphone_core_manager_destroy(marie);
}
Exemple #6
0
void send_dtmf_cleanup() {
	CU_ASSERT_PTR_NULL(marie_call->dtmfs_timer);
	CU_ASSERT_PTR_NULL(marie_call->dtmf_sequence);

	/*just to sleep*/
	linphone_core_terminate_all_calls(pauline->lc);
	CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
	CU_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 Cmeetphonemeet::OnClose()
{
	ShowWindow(SW_HIDE);
	CDialog::OnClose();
	//CDialog::OnDestroy();
	LinphoneCore *lc = theApp.GetCore();
	LinphoneCall *call = call=linphone_core_get_current_call(lc);
	if (call!=NULL)
	{
		linphone_core_terminate_call(lc,call);
	}
	linphone_core_terminate_all_calls(lc);
	//DestroyWindow();
}
static void quality_reporting_session_report_if_video_stopped() {
	LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc_rtcp_xr");
	LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
	LinphoneCall* call_pauline = NULL;
	LinphoneCall* call_marie = NULL;
	LinphoneCallParams* pauline_params;
	LinphoneCallParams* marie_params;

	linphone_core_enable_video_capture(marie->lc, TRUE);
	linphone_core_enable_video_display(marie->lc, FALSE);
	linphone_core_enable_video_capture(pauline->lc, TRUE);
	linphone_core_enable_video_display(pauline->lc, FALSE);
	marie_params=linphone_core_create_default_call_parameters(marie->lc);
	linphone_call_params_enable_video(marie_params,TRUE);
	pauline_params=linphone_core_create_default_call_parameters(pauline->lc);
	linphone_call_params_enable_video(pauline_params,TRUE);

	if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, marie_params, pauline_params)) {
		linphone_reporting_set_on_report_send(call_marie, on_report_send_with_rtcp_xr_local);

		CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0);
		CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);

		CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,NULL,0,3000));
		CU_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline)));

		/*remove video*/
		linphone_call_params_enable_video(pauline_params,FALSE);
		linphone_core_update_call(pauline->lc,call_pauline,pauline_params);

		CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1,5000));
		CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,1,5000));

		CU_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline)));

		linphone_core_terminate_all_calls(marie->lc);

		CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,2,5000));
		CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishOk,2,5000));
	}
	linphone_call_params_destroy(marie_params);
	linphone_call_params_destroy(pauline_params);

	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
Exemple #9
0
static void early_media_video_during_video_call_test(void) {
	LinphoneCoreManager *marie;
	LinphoneCoreManager *pauline;
	LinphoneCoreManager *laure;
	LinphoneCallParams *marie_params;
	LinphoneCallParams *pauline_params;
	LinphoneCallParams *laure_params;

	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_video(pauline);
	laure_params = configure_for_early_media_video_sending(laure);

	/* Normal automatically accepted video call from marie to pauline. */
	CU_ASSERT_TRUE(video_call_with_params(marie, pauline, marie_params, pauline_params, TRUE));

	/* 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);

	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);
}
static void quality_reporting_invalid_report() {
	LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
	LinphoneCall* call_marie = NULL;
	LinphoneCall* call_pauline = NULL;

	if (create_call_for_quality_reporting_tests(marie, pauline, &call_marie, &call_pauline, NULL, NULL)) {
		linphone_reporting_set_on_report_send(call_marie, on_report_send_remove_fields);

		linphone_core_terminate_all_calls(marie->lc);

		CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishProgress,1));
		CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePublishError,1,3000));
		CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);
	}
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
static void quality_reporting_not_sent_if_low_bandwidth() {
	LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
	LinphoneCallParams* marie_params;

	marie_params=linphone_core_create_default_call_parameters(marie->lc);
	linphone_call_params_enable_low_bandwidth(marie_params,TRUE);

	if (create_call_for_quality_reporting_tests(marie, pauline, NULL, NULL, marie_params, NULL)) {
		linphone_core_terminate_all_calls(marie->lc);

		CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0);
		CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0);
	}
	linphone_call_params_destroy(marie_params);
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
Exemple #12
0
/* the core no longer changes the presence status when a call is ongoing, this is left to the application*/
static void call_with_presence(void) {
	LinphoneCoreManager* marie = presence_linphone_core_manager_new("marie");
	LinphoneCoreManager* pauline = presence_linphone_core_manager_new("pauline");
	LinphoneVideoPolicy pol={0};
	linphone_core_set_video_policy(marie->lc,&pol);
	CU_ASSERT_TRUE(subscribe_to_callee_presence(marie,pauline));
	CU_ASSERT_TRUE(subscribe_to_callee_presence(pauline,marie));

	CU_ASSERT_TRUE(call(marie,pauline));
	CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityOnThePhone,1));
	CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphonePresenceActivityOnThePhone,1));

	reset_counters(&marie->stat);
	reset_counters(&pauline->stat);
	linphone_core_terminate_all_calls(marie->lc);
	CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphonePresenceActivityOnline,1));
	CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphonePresenceActivityOnline,1));
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
}
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);
}
static void early_media_call_forking(void) {
	LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
	LinphoneCoreManager* marie1 = linphone_core_manager_new("marie_early_rc");
	LinphoneCoreManager* marie2 = linphone_core_manager_new("marie_early_rc");
	MSList *lcs=NULL;
	LinphoneCallParams *params=linphone_core_create_default_call_parameters(pauline->lc);
	LinphoneVideoPolicy pol;
	LinphoneCall *marie1_call;
	LinphoneCall *marie2_call;
	LinphoneCall *pauline_call;
	int dummy=0;

	pol.automatically_accept=1;
	pol.automatically_initiate=1;
	
	linphone_core_set_user_agent(marie1->lc,"Natted Linphone",NULL);
	linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL);
	linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL);
	
	linphone_core_enable_video(pauline->lc,TRUE,TRUE);
	
	linphone_core_enable_video(marie1->lc,TRUE,TRUE);
	linphone_core_set_video_policy(marie1->lc,&pol);
	
	linphone_core_enable_video(marie2->lc,TRUE,TRUE);
	linphone_core_set_video_policy(marie2->lc,&pol);
	linphone_core_set_audio_port_range(marie2->lc,40200,40300);
	linphone_core_set_video_port_range(marie2->lc,40400,40500);
	
	lcs=ms_list_append(lcs,marie1->lc);
	lcs=ms_list_append(lcs,marie2->lc);
	lcs=ms_list_append(lcs,pauline->lc);

	linphone_call_params_enable_early_media_sending(params,TRUE);
	linphone_call_params_enable_video(params,TRUE);
	
	linphone_core_invite_address_with_params(pauline->lc,marie1->identity,params);
	linphone_call_params_destroy(params);

	CU_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000));
	CU_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000));
	CU_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,3000));
	CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia,1);
	
	pauline_call=linphone_core_get_current_call(pauline->lc);
	marie1_call=linphone_core_get_current_call(marie1->lc);
	marie2_call=linphone_core_get_current_call(marie2->lc);
	
	/*wait a bit that streams are established*/
	wait_for_list(lcs,&dummy,1,3000);
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth>70
					&& linphone_call_get_audio_stats(pauline_call)->download_bandwidth<90);
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth>70
					&& linphone_call_get_audio_stats(marie1_call)->download_bandwidth<90);
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(marie2_call)->download_bandwidth>70
					&& linphone_call_get_audio_stats(marie2_call)->download_bandwidth<90);
	
	linphone_core_accept_call(marie1->lc,linphone_core_get_current_call(marie1->lc));
	CU_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallStreamsRunning,1,3000));
	CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,3000));
	
	/*marie2 should get her call terminated*/
	CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000));
	
	/*wait a bit that streams are established*/
	wait_for_list(lcs,&dummy,1,3000);
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth>71
					&& linphone_call_get_audio_stats(pauline_call)->download_bandwidth<91 );
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth>71
					&& linphone_call_get_audio_stats(marie1_call)->download_bandwidth<91 );
	
	linphone_core_terminate_all_calls(pauline->lc);
	CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000));
	CU_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallEnd,1,1000));

	ms_list_free(lcs);
	linphone_core_manager_destroy(marie1);
	linphone_core_manager_destroy(marie2);
	linphone_core_manager_destroy(pauline);
}
Exemple #15
0
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);
}
static void forked_outgoing_early_media_video_call_with_inactive_audio_test(void) {
	LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc");
	LinphoneCoreManager *marie1 = linphone_core_manager_new("marie_early_rc");
	LinphoneCoreManager *marie2 = linphone_core_manager_new("marie_early_rc");
	MSList *lcs = NULL;
	LinphoneCallParams *pauline_params;
	LinphoneCallParams *marie1_params;
	LinphoneCallParams *marie2_params;
	LinphoneVideoPolicy pol;
	LinphoneCall *marie1_call;
	LinphoneCall *marie2_call;
	LinphoneCall *pauline_call;
	LinphoneInfoMessage *info;
	int dummy = 0;
	pol.automatically_accept = 1;
	pol.automatically_initiate = 1;

	linphone_core_enable_video(pauline->lc, TRUE, TRUE);
	linphone_core_enable_video(marie1->lc, TRUE, TRUE);
	linphone_core_set_video_policy(marie1->lc, &pol);
	linphone_core_enable_video(marie2->lc, TRUE, TRUE);
	linphone_core_set_video_policy(marie2->lc, &pol);
	linphone_core_set_audio_port_range(marie2->lc, 40200, 40300);
	linphone_core_set_video_port_range(marie2->lc, 40400, 40500);

	lcs = ms_list_append(lcs,marie1->lc);
	lcs = ms_list_append(lcs,marie2->lc);
	lcs = ms_list_append(lcs,pauline->lc);

	pauline_params = linphone_core_create_default_call_parameters(pauline->lc);
	linphone_call_params_enable_early_media_sending(pauline_params, TRUE);
	linphone_call_params_enable_video(pauline_params, TRUE);
	marie1_params = configure_for_early_media_video_receiving_with_inactive_audio(marie1);
	marie2_params = configure_for_early_media_video_receiving_with_inactive_audio(marie2);

	linphone_core_invite_address_with_params(pauline->lc, marie1->identity, pauline_params);
	linphone_call_params_destroy(pauline_params);

	BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingEarlyMedia, 1, 3000));
	BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingEarlyMedia, 1, 3000));
	BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia, 1, 3000));

	pauline_call = linphone_core_get_current_call(pauline->lc);
	marie1_call = linphone_core_get_current_call(marie1->lc);
	marie2_call = linphone_core_get_current_call(marie2->lc);

	BC_ASSERT_PTR_NOT_NULL(pauline_call);
	BC_ASSERT_PTR_NOT_NULL(marie1_call);
	BC_ASSERT_PTR_NOT_NULL(marie2_call);

	if (pauline_call && marie1_call && marie2_call) {
		/* wait a bit that streams are established */
		wait_for_list(lcs, &dummy, 1, 6000);
		BC_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth == 0);
		BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth == 0);
		BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie2_call)->download_bandwidth == 0);
		BC_ASSERT_TRUE(linphone_call_get_video_stats(pauline_call)->download_bandwidth == 0);
		BC_ASSERT_TRUE(linphone_call_get_video_stats(marie1_call)->download_bandwidth > 0);
		BC_ASSERT_TRUE(linphone_call_get_video_stats(marie2_call)->download_bandwidth > 0);

		linphone_call_params_set_audio_direction(marie1_params, LinphoneMediaDirectionSendRecv);
		linphone_core_accept_call_with_params(marie1->lc, linphone_core_get_current_call(marie1->lc), marie1_params);
		BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallStreamsRunning, 1, 3000));
		BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1, 3000));

		/* marie2 should get her call terminated */
		BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallEnd, 1, 1000));

		/*wait a bit that streams are established*/
		wait_for_list(lcs, &dummy, 1, 3000);
		BC_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth > 71);
		BC_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth > 71);
		BC_ASSERT_TRUE(linphone_call_get_video_stats(pauline_call)->download_bandwidth > 0);
		BC_ASSERT_TRUE(linphone_call_get_video_stats(marie1_call)->download_bandwidth > 0);

		/* send an INFO in reverse side to check that dialogs are properly established */
		info = linphone_core_create_info_message(marie1->lc);
		linphone_call_send_info_message(marie1_call, info);
		BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_inforeceived, 1, 3000));
	}

	linphone_core_terminate_all_calls(pauline->lc);
	BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallEnd, 1, 3000));
	BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallEnd, 1, 3000));

	linphone_call_params_destroy(marie1_params);
	linphone_call_params_destroy(marie2_params);
	ms_list_free(lcs);
	linphone_core_manager_destroy(marie1);
	linphone_core_manager_destroy(marie2);
	linphone_core_manager_destroy(pauline);
}
Exemple #17
0
int main (int argc, char *argv[]) {
  char *arg;
  int n;

  printf ("I: Phone2l " VERSION " by Gundolf Kiefer <*****@*****.**>, University of Applied Sciences Augsburg, 2015\n");

  // Interpret command line...
  error = FALSE;
  for (n = 1; n < argc; n++) {
    arg = argv[n];
    if (arg[0] != '-') {
      if (!argCallee) argCallee = arg;
      else error = TRUE;
    }
    else switch (arg[1]) {
      case 'h':
        argHelp = TRUE;
        break;
      case 'v':
        argVerbose = TRUE;
        break;
      case 'c':
        if (arg[2] == '=') argConfig = arg + 3;
        else error = TRUE;
        break;
      case 'f':
        if (arg[2] == '=') argFontFileName = arg + 3;
        else error = TRUE;
        break;
      case 's':
        if (arg[2] != '=') error = TRUE;
        else {
          argFontSize = atoi (arg + 3);
          if (argFontSize < 8) error = TRUE;
            // we assume that smaller fonts do not make sense and are unreadable
        }
        break;
      case 'a':
        argSoftwareRenderer = TRUE;
        break;
      case 'i':
        argInterpolation = arg[2] - '0';
        if (argInterpolation < 0 || argInterpolation > 2) error = TRUE;
        break;
      default:
        error = TRUE;
    }
  }
  if (error || argHelp) {
    printf ("Usage: phone2l [<options>]           - run phone2l in listening mode\n"
            "       phone2l [<options>] <URL>     - call <URL> and terminate with call\n"
            "\n"
            "Options:\n"
            "  -h : show this help\n"
            "  -v : be verbose\n"
            "  -c=<config> : specify linphone configuration file (default: ~/.linphonerc)\n"
            "  -f=<font>: specify ttf font file (default: %s)\n"
            "  -s=<size>: specify font size (default: %i)\n"
            "  -a: disable hardware acceleration, force software rendering\n"
            "  -i[0|1|2]: set interpolation method - 0=auto, 1=nearest, 2=bilinear (default: 0)\n"
            "\n"
            "By default, debug messages from the underlying libraries (liblinphone,\n"
            "mediastreamer, ...) are sent to 'stderr' and can safely be redirected\n"
            "to /dev/null. Messages to 'stdout' can be automatically processed\n"
            "according to the following prefixes:\n"
            "  S:   Status messages, also shown on the screen\n"
            "  I:   Information messages\n"
            "  W:   Warnings\n"
            "  E:   Errors (typically causing the tool to exit)\n",
            argFontFileName, argFontSize
            );
    exit (error ? 3 : 0);
  }

  // Set signal handlers...
  signal (SIGTERM, signal_handler);   // for kill command / requested by project team
  signal (SIGINT, signal_handler);    // for keyboard interrupt

  // Init liblinphone_core...
  printf ("I: Initializing 'liblinphone'...\n");
  lpcVtable.display_status = cb_display_status;
  //lpcVtable.display_message = cb_display_message;
  lpcVtable.display_warning = cb_display_warning;
  //lpcVtable.display_url = cb_display_url;
  lpcVtable.call_state_changed = cb_call_state_changed;

  if (argVerbose) linphone_core_enable_logs (stderr);
  if (argConfig) strncpy (configFileName, argConfig, MAX_PATH);
  else snprintf (configFileName, MAX_PATH, "%s/.linphonerc", getenv ("HOME"));
  lpc = linphone_core_new (&lpcVtable, configFileName, NULL, NULL);
  linphone_core_set_user_agent (lpc, "Phone2l", VERSION);
  linphone_core_enable_video_capture (lpc, TRUE);
  linphone_core_enable_video_display (lpc, TRUE);
  linphone_core_enable_video_preview (lpc, TRUE);

  // Init 'beam-render' ...
  if (!BRInit (argFontFileName, argFontSize)) exit (3);
  if (!BRWindowOpen ("Phone2l", argSoftwareRenderer, argInterpolation)) exit (3);
  BRInitMediastreamer ();

  // The following calls only work for 3.8.1 (not 3.6.x)...
  //printf ("### linphone_core_set_video_display_filter (linphonec, 'BRDisplay')...\n");
  linphone_core_set_video_display_filter (lpc, "BRDisplay");
    // "MSVideoOut": A SDL-based video display
    // "MSX11Video": A video display using X11+Xv
    // "MSGLXVideo": A video display using GL (glx)
  //printf ("### linphone_core_get_video_display_filter (): %s\n", linphone_core_get_video_display_filter (lpc));
  //printf ("### video_stream_get_default_video_renderer (): %s\n", video_stream_get_default_video_renderer ());

  // Testing ...
  //BRDisplayMessage ("Hello World!");

  // Initiate call if set...
  if (argCallee) {
    printf ("I: Calling '%s'...\n", argCallee);
    if (!linphone_core_invite (lpc, argCallee)) {
      printf ("E: Call initiation failed!\n");
      error = TRUE;
    }
  }

  // Main loop ...
  while (running && !error) {
    linphone_core_iterate (lpc);
    BRIterate ();
    usleep (20000);   // 20 ms / 50 Hz
  }

  // Finish ...
  printf ("I: Terminating all calls...\n");
  linphone_core_terminate_all_calls (lpc);
  printf ("I: Exiting...\n");
  linphone_core_destroy (lpc);
  BRDone ();

  exit (error ? 1 : 0);
}
static void early_media_call_forking(void) {
	LinphoneCoreManager* marie1 = linphone_core_manager_new("marie_early_rc");
	LinphoneCoreManager* marie2 = linphone_core_manager_new("marie_early_rc");
	LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_rc_tcp");
	MSList *lcs=NULL;
	LinphoneCallParams *params=linphone_core_create_default_call_parameters(pauline->lc);
	LinphoneVideoPolicy pol;
	LinphoneCall *marie1_call;
	LinphoneCall *marie2_call;
	LinphoneCall *pauline_call;
	int dummy=0;
	char ringbackpath[256];
	snprintf(ringbackpath,sizeof(ringbackpath), "%s/sounds/hello8000.wav" /*use hello because rinback is too short*/, liblinphone_tester_file_prefix);
	
	pol.automatically_accept=1;
	pol.automatically_initiate=1;
	
	linphone_core_set_user_agent(marie1->lc,"Natted Linphone",NULL);
	linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL);
	linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL);
	
	linphone_core_enable_video(pauline->lc,TRUE,TRUE);
	
	linphone_core_enable_video(marie1->lc,TRUE,TRUE);
	linphone_core_set_video_policy(marie1->lc,&pol);
	/*use playfile for marie1 to avoid locking on capture card*/
	linphone_core_use_files (marie1->lc,TRUE);
	linphone_core_set_play_file(marie1->lc,ringbackpath);

	linphone_core_enable_video(marie2->lc,TRUE,TRUE);
	linphone_core_set_video_policy(marie2->lc,&pol);
	linphone_core_set_audio_port_range(marie2->lc,40200,40300);
	linphone_core_set_video_port_range(marie2->lc,40400,40500);
	/*use playfile for marie2 to avoid locking on capture card*/
	linphone_core_use_files (marie2->lc,TRUE);
	linphone_core_set_play_file(marie2->lc,ringbackpath);
	
	
	lcs=ms_list_append(lcs,marie1->lc);
	lcs=ms_list_append(lcs,marie2->lc);
	lcs=ms_list_append(lcs,pauline->lc);

	linphone_call_params_enable_early_media_sending(params,TRUE);
	linphone_call_params_enable_video(params,TRUE);
	
	linphone_core_invite_address_with_params(pauline->lc,marie1->identity,params);
	linphone_call_params_destroy(params);

	CU_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingEarlyMedia,1,1000));
	CU_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingEarlyMedia,1,1000));
	CU_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,1000));
	
	pauline_call=linphone_core_get_current_call(pauline->lc);
	marie1_call=linphone_core_get_current_call(marie1->lc);
	marie2_call=linphone_core_get_current_call(marie2->lc);
	
	/*wait a bit that streams are established*/
	wait_for_list(lcs,&dummy,1,3000);
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth>70);
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth>70);
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(marie2_call)->download_bandwidth>70);
	
	linphone_core_accept_call(marie1->lc,linphone_core_get_current_call(marie1->lc));
	CU_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallStreamsRunning,1,1000));
	CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000));
	
	/*marie2 should get her call terminated*/
	CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000));
	
	/*wait a bit that streams are established*/
	wait_for_list(lcs,&dummy,1,1000);
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(pauline_call)->download_bandwidth>71);
	CU_ASSERT_TRUE(linphone_call_get_audio_stats(marie1_call)->download_bandwidth>71);
	
	linphone_core_terminate_all_calls(pauline->lc);
	CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000));
	CU_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallEnd,1,1000));

	ms_list_free(lcs);
	linphone_core_manager_destroy(marie1);
	linphone_core_manager_destroy(marie2);
	linphone_core_manager_destroy(pauline);
}