static void quality_reporting_not_sent_if_call_not_started() { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); LinphoneCallLog* out_call_log; LinphoneCall* out_call; linphone_core_set_max_calls(pauline->lc,0); out_call = linphone_core_invite(marie->lc,"pauline"); linphone_call_ref(out_call); CU_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallError,1, 10000)); CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1); if (ms_list_size(linphone_core_get_call_logs(marie->lc))>0) { out_call_log=(LinphoneCallLog*)(linphone_core_get_call_logs(marie->lc)->data); CU_ASSERT_PTR_NOT_NULL(out_call_log); CU_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log),LinphoneCallAborted); } linphone_call_unref(out_call); // wait a few time... wait_for_until(marie->lc,NULL,NULL,0,1000); // since the callee was busy, there should be no publish to do CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishProgress,0); CU_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,0); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
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; }
static void quality_reporting_not_sent_if_call_not_started() { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_quality_reporting_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCallLog* out_call_log; LinphoneCall* out_call; linphone_core_set_max_calls(pauline->lc,0); out_call = linphone_core_invite(marie->lc,"pauline"); linphone_call_ref(out_call); BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallError,1, 10000)); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1, int, "%d"); if (ms_list_size(linphone_core_get_call_logs(marie->lc))>0) { out_call_log=(LinphoneCallLog*)(linphone_core_get_call_logs(marie->lc)->data); BC_ASSERT_PTR_NOT_NULL(out_call_log); BC_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log),LinphoneCallAborted, int, "%d"); }
static void call_invite_200ok_without_contact_header(void) { LinphoneCoreManager *mgr; char *identity_char; char *scen; FILE * sipp_out; LinphoneCall *call = NULL; /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2("empty_rc", FALSE); mgr->identity = linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,"marie"); identity_char = linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); linphone_core_iterate(mgr->lc); scen = bc_tester_res("sipp/call_invite_200ok_without_contact_header.xml"); sipp_out = sip_start_recv(scen); if (sipp_out) { call = linphone_core_invite(mgr->lc, "[email protected]"); BC_ASSERT_PTR_NOT_NULL(call); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallOutgoingInit, 1)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallOutgoingProgress, 1)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallOutgoingRinging, 1)); /*assert that the call never gets connected nor terminated*/ BC_ASSERT_FALSE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallConnected, 1)); BC_ASSERT_EQUAL(mgr->stat.number_of_LinphoneCallEnd, 0, int, "%d"); BC_ASSERT_EQUAL(mgr->stat.number_of_LinphoneCallError, 0, int, "%d"); linphone_core_terminate_call(mgr->lc, call); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallReleased, 1)); pclose(sipp_out); } linphone_core_manager_destroy(mgr); }
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); }