Example #1
0
void linphone_gtk_show_camera_preview_clicked(GtkButton *button){
	GtkWidget *mw=linphone_gtk_get_main_window();
	GtkWidget *video_preview=(GtkWidget *)g_object_get_data(G_OBJECT(mw),"video_preview");

	if (!video_preview){
		gchar *title;
		LinphoneCore *lc=linphone_gtk_get_core();
		GdkColor color;
		guint tid;

		video_preview=gtk_window_new(GTK_WINDOW_TOPLEVEL);
		title=g_strdup_printf("%s - Video preview",linphone_gtk_get_ui_config("title","Linphone"));
		gtk_window_set_title(GTK_WINDOW(video_preview),title);
		gdk_color_parse("black",&color);
		gtk_widget_modify_bg(video_preview,GTK_STATE_NORMAL,&color);
		g_free(title);
		g_object_set_data(G_OBJECT(mw),"video_preview",video_preview);
		g_signal_connect(video_preview,"destroy",(GCallback)on_video_preview_destroyed,mw);
		gtk_widget_show(video_preview);
		linphone_core_set_native_preview_window_id(lc,get_native_handle(gtk_widget_get_window(video_preview)));
		linphone_core_enable_video_preview(lc,TRUE);
		tid=g_timeout_add(100,(GSourceFunc)check_preview_size,video_preview);
		g_object_set_data(G_OBJECT(video_preview),"timeout-id",GINT_TO_POINTER(tid));
	}
}
Example #2
0
static void on_video_preview_destroyed(GtkWidget *video_preview, GtkWidget *mw){
	LinphoneCore *lc=linphone_gtk_get_core();
	guint timeout_id=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(video_preview),"timeout-id"));
	g_object_set_data(G_OBJECT(mw),"video_preview",NULL);
	linphone_core_enable_video_preview(lc,FALSE);
	linphone_core_set_native_preview_window_id(lc,(void *)(unsigned long)-1);
	g_source_remove(timeout_id);
}
Example #3
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"));
#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"));
#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;
	}

#ifdef ENABLE_NLS
	if (NULL == bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR))
		perror ("bindtextdomain failed");
#ifndef __ARM__
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
	textdomain (GETTEXT_PACKAGE);
#else
	printf ("NLS disabled.\n");
#endif

	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_zrtp_secrets_file(linphonec,zrtpsecrets);
	linphone_core_enable_video(linphonec,vcap_enabled,display_enabled);
	if (display_enabled && window_id != 0) 
	{
		printf ("Setting window_id: 0x%x\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;
}
Example #4
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);
}