int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; signal(SIGINT,stop); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Fill the LinphoneCoreVTable with application callbacks. All are optional. Here we only use the call_state_changed callbacks in order to get notifications about the progress of the call. */ vtable.call_state_changed=call_state_changed; /*to receive incoming call*/ vtable.message_received=message_received; /*to receive committed messages*/ vtable.is_composing_received=is_composing_received; /*to receive char in real time*/ /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ linphone_core_iterate(lc); ms_usleep(50000); } printf("Shutting down...\n"); linphone_core_destroy(lc); printf("Exited\n"); return 0; }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; LinphoneCall *call=NULL; signal(SIGINT,stop); printf("Version: %s\n",linphone_core_get_version()); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Fill the LinphoneCoreVTable with application callbacks. All are optional. Here we only use the call_state_changed callbacksestablished in order to get notifications about the progress of the call. */ vtable.call_state_changed=call_state_changed; //vtable.text_received=text_received; /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ //linphone_core_disable_logs(); lc=linphone_core_new(&vtable,NULL,NULL,NULL); linphone_core_set_sip_port(lc, 9999); const char** devs = linphone_core_get_sound_devices(lc); printf("DEVICE: %s\n",devs[0]); printf("DEVICE: %s\n",devs[1]); //linphone_core_set_playback_device(lc,devs[1]); //linphone_core_set_capture_device(lc,devs[1]); linphone_core_iterate(lc); //LinphoneChatRoom* chat_room = linphone_core_create_chat_room(lc,"sip:[email protected]:9998"); //linphone_chat_room_send_message(chat_room,"Welcome in room!\n"); /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ linphone_core_iterate(lc); ms_usleep(50000); } if (call && linphone_call_get_state(call)!=LinphoneCallEnd){ /* terminate the call */ printf("Terminating the call...\n"); linphone_core_terminate_call(lc,call); /*at this stage we don't need the call object */ linphone_call_unref(call); } end: printf("Shutting down...\n"); linphone_core_destroy(lc); printf("Exited\n"); return 0; }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; LinphoneCall *call=NULL; const char *dest=NULL; /* take the destination sip uri from the command line arguments */ if (argc>1){ dest=argv[1]; } signal(SIGINT,stop); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Fill the LinphoneCoreVTable with application callbacks. All are optional. Here we only use the call_state_changed callbacks in order to get notifications about the progress of the call. */ vtable.call_state_changed=call_state_changed; /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); if (dest){ /* Place an outgoing call */ call=linphone_core_invite(lc,dest); if (call==NULL){ printf("Could not place call to %s\n",dest); goto end; }else printf("Call to %s is in progress...",dest); linphone_call_ref(call); } /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ linphone_core_iterate(lc); ms_usleep(50000); } if (call && linphone_call_get_state(call)!=LinphoneCallEnd){ /* terminate the call */ printf("Terminating the call...\n"); linphone_core_terminate_call(lc,call); /*at this stage we don't need the call object */ linphone_call_unref(call); } end: printf("Shutting down...\n"); linphone_core_destroy(lc); printf("Exited\n"); return 0; }
int main(int argc, char *argv[]){ LinphoneCore *lc; LinphoneCoreVTable vtable={0}; LinphoneSoundDaemon *lsd; LsdPlayer *p; linphone_core_enable_logs(stdout); lc=linphone_core_new(&vtable,NULL,NULL,NULL); lsd=linphone_sound_daemon_new (NULL,44100,1); linphone_core_use_sound_daemon(lc,lsd); /* start a play */ p=linphone_sound_daemon_get_player(lsd); lsd_player_set_callback (p,play_finished); lsd_player_set_user_pointer (p,"share/hello8000.wav"); lsd_player_play (p,"share/hello8000.wav"); wait_a_bit (lc,2); /*start another one */ p=linphone_sound_daemon_get_player(lsd); lsd_player_set_callback (p,play_finished); lsd_player_set_user_pointer (p,"share/hello16000.wav"); lsd_player_enable_loop (p,TRUE); lsd_player_play (p,"share/hello16000.wav"); /* after a few seconds decrease the volume */ wait_a_bit (lc,3); lsd_player_set_gain (p,0.3); wait_a_bit(lc,5); /*now play some stereo music*/ p=linphone_sound_daemon_get_player(lsd); lsd_player_set_callback (p,play_finished); lsd_player_set_user_pointer (p,"share/rings/rock.wav"); lsd_player_play(p,"share/rings/rock.wav"); wait_a_bit(lc,2); /*now play some stereo music at 22khz in order to test stereo resampling */ p=linphone_sound_daemon_get_player(lsd); lsd_player_set_callback (p,play_finished); lsd_player_set_user_pointer (p,"share/rings/bigben.wav"); lsd_player_play(p,"share/rings/bigben.wav"); wait_a_bit(lc,6); /* now place an outgoing call if sip address argument is given */ if (argc>1){ linphone_core_invite(lc,argv[1]); wait_a_bit(lc,10); linphone_core_terminate_call(lc,NULL); } linphone_core_use_sound_daemon(lc,NULL); linphone_sound_daemon_destroy(lsd); linphone_core_destroy(lc); return 0; }
QLinPhoneCore::QLinPhoneCore(int loopInterval, QObject *parent) : QObject(parent) { m_authInfo = 0; m_rstate = QLinPhoneCore::RegistrationNone; m_loopTimer = new QTimer(this); m_loopTimer->setInterval(loopInterval); connect(m_loopTimer, SIGNAL(timeout()), this, SLOT(update())); #ifdef DEBUG qDebug() << "linphone core version:" << linphone_core_get_version(); /* Enable liblinphone logs. */ linphone_core_enable_logs(NULL); #endif // Fill the LinphoneCoreVTable with application callbacks. All are optional. vtable.registration_state_changed = registration_state_changed; vtable.text_received = text_received; vtable.message_received = message_received; // vtable.call_state_changed // vtable.notify_presence_recv // vtable.new_subscription_request // vtable.auth_info_requested // vtable.call_log_updated // vtable.dtmf_received // vtable.refer_received // vtable.call_encryption_changed // vtable.transfer_state_changed // vtable.buddy_info_updated // vtable.notify_recv // vtable.call_stats_updated // vtable.display_status // vtable.display_message // vtable.display_warning // vtable.display_url // vtable.show // Instantiate a LinphoneCore object given the LinphoneCoreVTable m_lc = linphone_core_new(&vtable, NULL, NULL, NULL); linphone_core_set_user_data(m_lc, static_cast<void *>(this)); m_loopTimer->start(); }
void SipClient::init() { qDebug() << "linphone core version:" << linphone_core_get_version(); m_loopTimer->setInterval(50); connect(m_loopTimer, SIGNAL(timeout()), this, SLOT(update())); LinphoneCoreVTable vtable = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; #ifdef DEBUG /* Enable liblinphone logs. */ linphone_core_enable_logs(NULL); #endif /* Fill the LinphoneCoreVTable with application callbacks. All are optional. */ vtable.registration_state_changed = registration_state_changed; vtable.text_received = text_received; vtable.message_received = message_received; // vtable.call_state_changed // vtable.notify_presence_recv // vtable.new_subscription_request // vtable.auth_info_requested // vtable.call_log_updated // vtable.dtmf_received // vtable.refer_received // vtable.call_encryption_changed // vtable.transfer_state_changed // vtable.buddy_info_updated // vtable.notify_recv // vtable.call_stats_updated // vtable.display_status // vtable.display_message // vtable.display_warning // vtable.display_url // vtable.show /* Instantiate a LinphoneCore object given the LinphoneCoreVTable */ lc = linphone_core_new(&vtable, NULL, NULL, NULL); if (lc) { m_loopTimer->start(); } }
int main (int argc, char *argv[]) { void *p; g_thread_init(NULL); //g_log_set_fatal_mask("GLib",G_LOG_LEVEL_WARNING); //g_mem_set_vtable(glib_mem_profiler_table); //g_mem_set_vtable(&dbgtable); #ifdef ENABLE_NLS p=bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); if (p==NULL) perror("bindtextdomain failed"); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #else printf("NLS disabled.\n"); #endif #ifdef NOWOBSOLETE_NOTYET gnome_program_init ("linphone", LINPHONE_VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR, GNOME_PARAM_POPT_TABLE,&linphone_options,NULL); #endif if (!gtk_init_with_args(&argc,&argv,_("A free SIP video-phone"), linphone_options,NULL,NULL)) return -1; add_pixmap_directory(PACKAGE_DATA_DIR "/pixmaps/linphone"); add_pixmap_directory("pixmaps"); if (verbose) linphone_core_enable_logs(stdout); else linphone_core_disable_logs(); linphone_gnome_init(&ui,&core); linphone_gnome_ui_show(&ui); gtk_main (); gdk_threads_leave(); /* it appears that the gdk lock is hold while exiting from gtk_main() */ linphone_gnome_uninit(&ui); //g_mem_profile(); exit(0); return 0; }
/* * Initialize linphonec */ static int linphonec_init(int argc, char **argv) { //g_mem_set_vtable(&dbgtable); /* * Set initial values for global variables */ mylogfile = NULL; snprintf(configfile_name, PATH_MAX, "%s/.linphonerc", getenv("HOME")); /* 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 */ linphone_core_init (&linphonec, &linphonec_vtable, configfile_name, NULL); linphone_core_enable_video(&linphonec,vcap_enabled,display_enabled); if (!(vcap_enabled || display_enabled)) printf("Warning: video is disabled in linphonec.\n"); /* * Initialize readline */ linphonec_initialize_readline(); /* * Initialize signal handlers */ signal(SIGTERM, linphonec_finish); signal(SIGINT, linphonec_finish); return 1; }
/* * 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; }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; const char* dest_friend=NULL; int i; const char* big_file_content="big file"; LinphoneChatRoom* chat_room; LinphoneContent* content; LinphoneChatMessage* chat_message; LinphoneChatMessageCbs *cbs; /*seting dummy file content to something*/ for (i=0;i<sizeof(big_file);i+=strlen(big_file_content)) memcpy(big_file+i, big_file_content, strlen(big_file_content)); big_file[0]=*"S"; big_file[sizeof(big_file)-1]=*"E"; signal(SIGINT,stop); //#define DEBUG #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif vtable.message_received=message_received; /* Instantiate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); dest_friend = linphone_core_get_primary_contact(lc); printf("Send message to me : %s\n", dest_friend); /** * Globally configure an http file transfer server. */ //linphone_core_set_file_transfer_server(lc,"http://npasc.al/lft.php"); linphone_core_set_file_transfer_server(lc,"https://www.linphone.org:444/lft.php"); /*Next step is to create a chat room*/ chat_room = linphone_core_get_chat_room_from_uri(lc,dest_friend); content = linphone_core_create_content(lc); linphone_content_set_type(content,"text"); linphone_content_set_subtype(content,"plain"); linphone_content_set_size(content,sizeof(big_file)); /*total size to be transfered*/ linphone_content_set_name(content,"bigfile.txt"); /*now create a chat message with custom content*/ chat_message = linphone_chat_room_create_file_transfer_message(chat_room,content); if (chat_message == NULL) { printf("returned message is null\n"); } /** * Fill the application callbacks. The file_transfer_received callback is used in order to get notifications * about incoming file reception, file_transfer_send to feed file to be transfered and * file_transfer_progress_indication to print progress. */ cbs = linphone_chat_message_get_callbacks(chat_message); linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); linphone_chat_message_cbs_set_file_transfer_send(cbs, file_transfer_send); linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); /*initiating file transfer*/ linphone_chat_room_send_chat_message(chat_room, chat_message); /* main loop for receiving incoming messages and doing background linphone core work: */ while(running){ linphone_core_iterate(lc); ms_usleep(50000); } printf("Shutting down...\n"); linphone_content_unref(content); linphone_core_destroy(lc); printf("Exited\n"); return 0; }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; LinphoneCall *call=NULL; LinphoneChatRoom *chat_room; LinphoneChatMessage *chat_message=NULL; const char *dest=NULL; LCSipTransports tp; tp.udp_port=LC_SIP_TRANSPORT_RANDOM; tp.tcp_port=LC_SIP_TRANSPORT_RANDOM; tp.tls_port=LC_SIP_TRANSPORT_RANDOM; /* take the destination sip uri from the command line arguments */ if (argc>1){ dest=argv[1]; } signal(SIGINT,stop); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); linphone_core_set_sip_transports(lc,&tp); /*to avoid port colliding with receiver*/ if (dest){ /* Place an outgoing call with rtt enabled */ LinphoneCallParams *cp = linphone_core_create_call_params(lc, NULL); linphone_call_params_enable_realtime_text(cp,TRUE); /*enable real time text*/ call=linphone_core_invite_with_params(lc,dest,cp); linphone_call_params_destroy(cp); if (call==NULL){ printf("Could not place call to %s\n",dest); goto end; }else printf("Call to %s is in progress...",dest); linphone_call_ref(call); } /*wait for call to be established*/ while (running && (linphone_call_get_state(call) == LinphoneCallOutgoingProgress || linphone_call_get_state(call) == LinphoneCallOutgoingInit)) { linphone_core_iterate(lc); ms_usleep(50000); } /*check if call is established*/ switch (linphone_call_get_state(call)) { case LinphoneCallError: case LinphoneCallReleased: case LinphoneCallEnd: printf("Could not place call to %s\n",dest); goto end; break; default: break; /*continue*/ } chat_room=linphone_call_get_chat_room(call); /*create a chat room associated to this call*/ /* main loop for sending message and doing background linphonecore work: */ while(running){ char character; /*to disable terminal buffering*/ if (system ("/bin/stty raw") == -1){ ms_error("/bin/stty error"); } character = getchar(); if (system("/bin/stty cooked") == -1){ ms_error("/bin/stty error"); } if (character==0x03) {/*CTRL C*/ running=0; break; } if (character != EOF) { /* user has typed something*/ if (chat_message == NULL) { /*create a new message*/ chat_message = linphone_chat_room_create_message(chat_room,""); /*create an empty message*/ } if (character == '\r') { /*new line, committing message*/ linphone_chat_room_send_chat_message(chat_room,chat_message); chat_message = NULL; /*reset message*/ } else { linphone_chat_message_put_char(chat_message,character); /*send char in realtime*/ } } linphone_core_iterate(lc); ms_usleep(50000); } if (call && linphone_call_get_state(call)!=LinphoneCallEnd){ /* terminate the call */ printf("Terminating the call...\n"); linphone_core_terminate_call(lc,call); /*at this stage we don't need the call object */ linphone_call_unref(call); } end: printf("Shutting down...\n"); linphone_core_destroy(lc); printf("Exited\n"); return 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); }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; MyAppData *data=ms_new0(MyAppData,1); char* identity=NULL; char* password=NULL; int i; LinphoneProxyConfig* proxy_cfg; LinphoneAddress *from; LinphoneAuthInfo *info; const char* server_addr; /* takes sip uri identity from the command line arguments */ if (argc>1){ identity=argv[1]; } /* takes password from the command line arguments */ if (argc>2){ password=argv[2]; } signal(SIGINT,stop); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Fill the LinphoneCoreVTable with application callbacks. All are optional. Here we only use the registration_state_changed callbacks in order to get notifications about the progress of the registration. */ vtable.registration_state_changed=registration_state_changed; vtable.subscription_state_changed=subscription_state_changed; /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,data); /*create proxy config*/ proxy_cfg = linphone_proxy_config_new(); /*parse identity*/ from = linphone_address_new(identity); if (from==NULL){ printf("%s not a valid sip uri, must be like sip:[email protected] \n",identity); goto end; } if (password!=NULL){ info=linphone_auth_info_new(linphone_address_get_username(from),NULL,password,NULL,NULL,NULL); /*create authentication structure from identity*/ linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/ } // configure proxy entries linphone_proxy_config_set_identity(proxy_cfg,identity); /*set identity with user name and domain*/ server_addr = linphone_address_get_domain(from); /*extract domain address from identity*/ linphone_proxy_config_set_server_addr(proxy_cfg,server_addr); /* we assume domain = proxy server address*/ linphone_proxy_config_enable_register(proxy_cfg,TRUE); /*activate registration for this proxy config*/ linphone_address_destroy(from); /*release resource*/ linphone_core_add_proxy_config(lc,proxy_cfg); /*add proxy config to linphone core*/ linphone_core_set_default_proxy(lc,proxy_cfg); /*set to default proxy*/ i=0; /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ linphone_core_iterate(lc); /* first iterate initiates registration */ ms_usleep(50000); ++i; if (data->ev && i%100==0){ LinphoneContentPrivate content; content.type="application"; content.subtype="goodxml"; content.data="really cool"; content.size=strlen((const char*)content.data); linphone_event_notify(data->ev,LINPHONE_CONTENT(&content)); } } linphone_core_get_default_proxy(lc,&proxy_cfg); /* get default proxy config*/ linphone_proxy_config_edit(proxy_cfg); /*start editing proxy configuration*/ linphone_proxy_config_enable_register(proxy_cfg,FALSE); /*de-activate registration for this proxy config*/ linphone_proxy_config_done(proxy_cfg); /*initiate REGISTER with expire = 0*/ if (data->ev){ linphone_event_terminate(data->ev); } while(linphone_proxy_config_get_state(proxy_cfg) != LinphoneRegistrationCleared){ linphone_core_iterate(lc); /*to make sure we receive call backs before shutting down*/ ms_usleep(50000); } end: printf("Shutting down...\n"); linphone_core_destroy(lc); ms_free(data); printf("Exited\n"); return 0; }