static void call_multicast_base(bool_t video) {
	LinphoneCoreManager *marie, *pauline;
	int begin;
	int leaked_objects;
	LinphoneVideoPolicy marie_policy, pauline_policy;

	belle_sip_object_enable_leak_detector(TRUE);
	begin=belle_sip_object_get_object_count();
	marie = linphone_core_manager_new( "marie_rc");
	pauline = linphone_core_manager_new( "pauline_rc");

	if (video) {
		linphone_core_enable_video_capture(marie->lc, TRUE);
		linphone_core_enable_video_display(marie->lc, TRUE);
		linphone_core_enable_video_capture(pauline->lc, TRUE);
		linphone_core_enable_video_display(pauline->lc, FALSE);

		marie_policy.automatically_initiate=TRUE;
		marie_policy.automatically_accept=TRUE;
		pauline_policy.automatically_initiate=TRUE;
		pauline_policy.automatically_accept=TRUE;

		linphone_core_set_video_policy(marie->lc,&marie_policy);
		linphone_core_set_video_policy(pauline->lc,&pauline_policy);
		linphone_core_set_video_multicast_addr(pauline->lc,"224.1.2.3");
		linphone_core_enable_video_multicast(pauline->lc,TRUE);
	}
	linphone_core_set_audio_multicast_addr(pauline->lc,"224.1.2.3");
	linphone_core_enable_audio_multicast(pauline->lc,TRUE);

	CU_ASSERT_TRUE(call(pauline,marie));
	wait_for_until(marie->lc, pauline->lc, NULL, 1, 3000);
	if (linphone_core_get_current_call(marie->lc)) {
		CU_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(marie->lc))->download_bandwidth>70);
		if (video) {
			/*check video path*/
			linphone_call_set_next_video_frame_decoded_callback(linphone_core_get_current_call(marie->lc),linphone_call_cb,marie->lc);
			linphone_call_send_vfu_request(linphone_core_get_current_call(marie->lc));
			CU_ASSERT_TRUE( wait_for(marie->lc,pauline->lc,&marie->stat.number_of_IframeDecoded,1));
		}

		end_call(marie,pauline);
	}
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);

	leaked_objects=belle_sip_object_get_object_count()-begin;
	CU_ASSERT_TRUE(leaked_objects==0);
	if (leaked_objects>0){
		belle_sip_object_dump_active_objects();
	}
	belle_sip_object_enable_leak_detector(FALSE);

}
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);
}
static void call_multicast_base(bool_t video) {
	LinphoneCoreManager *marie, *pauline;
	int begin;
	int leaked_objects;
	LinphoneVideoPolicy marie_policy, pauline_policy;

	belle_sip_object_enable_leak_detector(TRUE);
	begin=belle_sip_object_get_object_count();
	marie = linphone_core_manager_new( "marie_rc");
	pauline = linphone_core_manager_new( "pauline_tcp_rc");

	if (video) {
		linphone_core_enable_video_capture(marie->lc, TRUE);
		linphone_core_enable_video_display(marie->lc, TRUE);
		linphone_core_enable_video_capture(pauline->lc, TRUE);
		linphone_core_enable_video_display(pauline->lc, FALSE);

		marie_policy.automatically_initiate=TRUE;
		marie_policy.automatically_accept=TRUE;
		pauline_policy.automatically_initiate=TRUE;
		pauline_policy.automatically_accept=TRUE;

		linphone_core_set_video_policy(marie->lc,&marie_policy);
		linphone_core_set_video_policy(pauline->lc,&pauline_policy);
		linphone_core_set_video_multicast_addr(pauline->lc,"224.1.2.3");
		linphone_core_enable_video_multicast(pauline->lc,TRUE);
	}
	linphone_core_set_audio_multicast_addr(pauline->lc,"224.1.2.3");
	linphone_core_enable_audio_multicast(pauline->lc,TRUE);

	BC_ASSERT_TRUE(call(pauline,marie));
	wait_for_until(marie->lc, pauline->lc, NULL, 1, 6000);
	if (linphone_core_get_current_call(marie->lc)) {
		BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(marie),70,int,"%d");
		if (video) {
			/*check video path*/
			linphone_call_set_next_video_frame_decoded_callback(linphone_core_get_current_call(marie->lc),linphone_call_iframe_decoded_cb,marie->lc);
			linphone_call_send_vfu_request(linphone_core_get_current_call(marie->lc));
			BC_ASSERT_TRUE( wait_for(marie->lc,pauline->lc,&marie->stat.number_of_IframeDecoded,1));
		}

		end_call(marie,pauline);
	}
Esempio n. 4
0
static LinphoneCallParams * _configure_for_video(LinphoneCoreManager *manager, LinphoneCoreCallStateChangedCb cb) {
	LinphoneCallParams *params;
	LinphoneCoreVTable *vtable = linphone_core_v_table_new();
	vtable->call_state_changed = cb;
	linphone_core_add_listener(manager->lc, vtable);
	linphone_core_set_video_device(manager->lc, "StaticImage: Static picture");
	linphone_core_enable_video_capture(manager->lc, TRUE);
	linphone_core_enable_video_display(manager->lc, TRUE);
	params = linphone_core_create_default_call_parameters(manager->lc);
	linphone_call_params_enable_video(params, TRUE);
	if (linphone_core_find_payload_type(manager->lc,"VP8", 90000, -1)!=NULL){
		disable_all_video_codecs_except_one(manager->lc, "VP8");
	}else{
		ms_warning("VP8 codec not available, will use MP4V-ES instead");
		disable_all_video_codecs_except_one(manager->lc, "MP4V-ES");
	}
	return params;
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
/*
 * Initialize linphonec
 */
static int
linphonec_init(int argc, char **argv)
{

	//g_mem_set_vtable(&dbgtable);

	/*
	 * Set initial values for global variables
	 */
	mylogfile = NULL;


#ifndef _WIN32
	snprintf(configfile_name, PATH_MAX, "%s/.linphonerc",
			getenv("HOME"));
	snprintf(zrtpsecrets, PATH_MAX, "%s/.linphone-zidcache",
			getenv("HOME"));
	snprintf(usr_certificates_path, PATH_MAX, "%s/.linphone-usr-crt",
			getenv("HOME"));
#elif defined(_WIN32_WCE)
	strncpy(configfile_name,PACKAGE_DIR "\\linphonerc",PATH_MAX);
	mylogfile=fopen(PACKAGE_DIR "\\" "linphonec.log","w");
	printf("Logs are redirected in" PACKAGE_DIR "\\linphonec.log");
#else
	snprintf(configfile_name, PATH_MAX, "%s/Linphone/linphonerc",
			getenv("APPDATA"));
	snprintf(zrtpsecrets, PATH_MAX, "%s/Linphone/linphone-zidcache",
			getenv("APPDATA"));
	snprintf(usr_certificates_path, PATH_MAX, "%s/Linphone/linphone-usr-crt",
			getenv("APPDATA"));
#endif
	/* Handle configuration filename changes */
	switch (handle_configfile_migration())
	{
		case -1: /* error during file copies */
			fprintf(stderr,
				"Error in configuration file migration\n");
			break;

		case 0: /* nothing done */
		case 1: /* migrated */
		default:
			break;
	}

	linphonec_parse_cmdline(argc, argv);

	if (trace_level > 0)
	{
		if (logfile_name != NULL)
			mylogfile = fopen (logfile_name, "w+");

		if (mylogfile == NULL)
		{
			mylogfile = stdout;
			fprintf (stderr,
				 "INFO: no logfile, logging to stdout\n");
		}
		linphone_core_enable_logs(mylogfile);
	}
	else
	{
		linphone_core_disable_logs();
	}
	/*
	 * Initialize auth stack
	 */
	auth_stack.nitems=0;

	/*
	 * Initialize linphone core
	 */
	linphonec=linphone_core_new (&linphonec_vtable, configfile_name, factory_configfile_name, NULL);

	linphone_core_set_user_agent(linphonec,"Linphonec", LINPHONE_VERSION);
	linphone_core_set_zrtp_secrets_file(linphonec,zrtpsecrets);
	linphone_core_set_user_certificates_path(linphonec,usr_certificates_path);
	linphone_core_enable_video_capture(linphonec, vcap_enabled);
	linphone_core_enable_video_display(linphonec, display_enabled);
	if (display_enabled && (window_id != NULL))
	{
		printf("Setting window_id: 0x%p\n", window_id);
		linphone_core_set_native_video_window_id(linphonec,window_id);
	}

	linphone_core_enable_video_preview(linphonec,preview_enabled);
	if (!(vcap_enabled || display_enabled)) printf("Warning: video is disabled in linphonec, use -V or -C or -D to enable.\n");
#ifdef HAVE_READLINE
	/*
	 * Initialize readline
	 */
	linphonec_initialize_readline();
#endif
#if !defined(_WIN32_WCE)
	/*
	 * Initialize signal handlers
	 */
	signal(SIGTERM, linphonec_finish);
	signal(SIGINT, linphonec_finish);
#endif /*_WIN32_WCE*/
	return 1;
}
static void early_media_with_multicast_base(bool_t video) {
	LinphoneCoreManager *marie, *pauline, *pauline2;
	MSList* lcs = NULL;
	int dummy=0;
	int leaked_objects;
	int begin;
	LinphoneVideoPolicy marie_policy, pauline_policy;
	LpConfig *marie_lp;

	belle_sip_object_enable_leak_detector(TRUE);
	begin=belle_sip_object_get_object_count();
	marie   = linphone_core_manager_new("marie_rc");
	pauline = linphone_core_manager_new("pauline_rc");
	pauline2 = linphone_core_manager_new("pauline_rc");

	marie_lp=linphone_core_get_config(marie->lc);
	lp_config_set_int(marie_lp,"misc","real_early_media",1);

	if (video) {
		linphone_core_enable_video_capture(pauline->lc, FALSE);
		linphone_core_enable_video_display(pauline->lc, TRUE);
		linphone_core_enable_video_capture(pauline2->lc, FALSE);
		linphone_core_enable_video_display(pauline2->lc, TRUE);
		linphone_core_enable_video_capture(marie->lc, TRUE);
		linphone_core_enable_video_display(marie->lc, FALSE);

		marie_policy.automatically_initiate=TRUE;
		marie_policy.automatically_accept=TRUE;
		pauline_policy.automatically_initiate=TRUE;
		pauline_policy.automatically_accept=TRUE;

		linphone_core_set_video_policy(marie->lc,&marie_policy);
		linphone_core_set_video_policy(pauline->lc,&pauline_policy);
		linphone_core_set_video_policy(pauline2->lc,&pauline_policy);
		linphone_core_set_video_multicast_addr(marie->lc,"224.1.2.3");
		linphone_core_enable_video_multicast(marie->lc,TRUE);
	}
	linphone_core_set_audio_multicast_addr(marie->lc,"224.1.2.3");
	linphone_core_enable_audio_multicast(marie->lc,TRUE);


	lcs = ms_list_append(lcs,marie->lc);
	lcs = ms_list_append(lcs,pauline->lc);
	lcs = ms_list_append(lcs,pauline2->lc);
	/*
		Marie calls Pauline, and after the call has rung, transitions to an early_media session
	*/

	linphone_core_invite_address(marie->lc, pauline->identity);

	CU_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingReceived,1,3000));
	CU_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingRinging,1,1000));


	if (linphone_core_inc_invite_pending(pauline->lc)) {
		/* send a 183 to initiate the early media */
		if (video) {
			/*check video path*/
			linphone_call_set_next_video_frame_decoded_callback(linphone_core_get_current_call(pauline->lc),linphone_call_cb,pauline->lc);
		}
		linphone_core_accept_early_media(pauline->lc, linphone_core_get_current_call(pauline->lc));

		CU_ASSERT_TRUE( wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia,1,2000) );
		CU_ASSERT_TRUE( wait_for_list(lcs, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,2000) );

		if (linphone_core_inc_invite_pending(pauline2->lc)) {
				/* send a 183 to initiate the early media */
				if (video) {
					/*check video path*/
					linphone_call_set_next_video_frame_decoded_callback(linphone_core_get_current_call(pauline2->lc),linphone_call_cb,pauline2->lc);
				}
				linphone_core_accept_early_media(pauline2->lc, linphone_core_get_current_call(pauline2->lc));

				CU_ASSERT_TRUE( wait_for_list(lcs, &pauline2->stat.number_of_LinphoneCallIncomingEarlyMedia,1,2000) );
		}

		wait_for_list(lcs, &dummy, 1, 3000);

		CU_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->download_bandwidth>70);
		CU_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->download_bandwidth<90);

		CU_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline2->lc))->download_bandwidth>70);
		CU_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline2->lc))->download_bandwidth<90);


		if (video) {
			CU_ASSERT_TRUE( wait_for_list(lcs,&pauline->stat.number_of_IframeDecoded,1,2000));
			CU_ASSERT_TRUE( wait_for_list(lcs,&pauline2->stat.number_of_IframeDecoded,1,2000));
		}

		linphone_core_accept_call(pauline->lc, linphone_core_get_current_call(pauline->lc));

		CU_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallConnected, 1,1000));
		CU_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 1,1000));

		linphone_core_update_call(	pauline->lc
									, linphone_core_get_current_call(pauline->lc)
									, linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)));

		CU_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 2,1000));

		end_call(marie,pauline);
	}
	ms_free(lcs);
	linphone_core_manager_destroy(marie);
	linphone_core_manager_destroy(pauline);
	linphone_core_manager_destroy(pauline2);

	leaked_objects=belle_sip_object_get_object_count()-begin;
	CU_ASSERT_EQUAL(leaked_objects,0);
	if (leaked_objects>0){
		belle_sip_object_dump_active_objects();
	}
	belle_sip_object_enable_leak_detector(FALSE);
}
Esempio n. 8
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);
}
Esempio n. 9
0
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");
	bctbx_list_t *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_capture(pauline->lc, TRUE);
	linphone_core_enable_video_display(pauline->lc, TRUE);
	linphone_core_enable_video_capture(marie1->lc, TRUE);
	linphone_core_enable_video_display(marie1->lc, TRUE);
	linphone_core_set_video_policy(marie1->lc, &pol);
	linphone_core_enable_video_capture(marie2->lc, TRUE);
	linphone_core_enable_video_display(marie2->lc, 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 = bctbx_list_append(lcs,marie1->lc);
	lcs = bctbx_list_append(lcs,marie2->lc);
	lcs = bctbx_list_append(lcs,pauline->lc);

	pauline_params = linphone_core_create_call_params(pauline->lc, NULL);
	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_LinphoneCallIncomingReceived, 1, 3000));
	BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingReceived, 1, 3000));

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

	if (marie1_call){
		linphone_call_set_next_video_frame_decoded_callback(marie1_call, linphone_call_iframe_decoded_cb, marie1->lc);
	}
	if (marie2_call){
		linphone_call_set_next_video_frame_decoded_callback(marie2_call, linphone_call_iframe_decoded_cb, marie2->lc);
	}

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

	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) {
		linphone_call_set_next_video_frame_decoded_callback(pauline_call, linphone_call_iframe_decoded_cb, pauline->lc);

		/* wait a bit that streams are established */
		wait_for_list(lcs, &dummy, 1, 3000);
		BC_ASSERT_EQUAL(linphone_call_get_audio_stats(pauline_call)->download_bandwidth, 0, float, "%f");
		BC_ASSERT_EQUAL(linphone_call_get_audio_stats(marie1_call)->download_bandwidth, 0, float, "%f");
		BC_ASSERT_EQUAL(linphone_call_get_audio_stats(marie2_call)->download_bandwidth, 0, float, "%f");
		BC_ASSERT_LOWER(linphone_call_get_video_stats(pauline_call)->download_bandwidth, 11, float, "%f"); /* because of stun packets*/
		BC_ASSERT_GREATER(linphone_call_get_video_stats(marie1_call)->download_bandwidth, 0, float, "%f");
		BC_ASSERT_GREATER(linphone_call_get_video_stats(marie2_call)->download_bandwidth, 0, float, "%f");
		BC_ASSERT_GREATER(marie1->stat.number_of_IframeDecoded, 1, int, "%i");
		BC_ASSERT_GREATER(marie2->stat.number_of_IframeDecoded, 1, int, "%i");

		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_GREATER(linphone_call_get_audio_stats(pauline_call)->download_bandwidth, 71, float, "%f");
		BC_ASSERT_GREATER(linphone_call_get_audio_stats(marie1_call)->download_bandwidth, 71, float, "%f");
		BC_ASSERT_GREATER(linphone_call_get_video_stats(pauline_call)->download_bandwidth, 0, float, "%f");
		BC_ASSERT_GREATER(linphone_call_get_video_stats(marie1_call)->download_bandwidth, 0, float, "%f");
		BC_ASSERT_GREATER(pauline->stat.number_of_IframeDecoded, 1, int, "%i");

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