int csenn_eXosip_init(void) { g_register_id = 0;/*注册ID/用来更新注册或取消注册*/ g_call_id = 0;/*INVITE连接ID/用来分辨不同的INVITE连接,每个时刻只允许有一个INVITE连接*/ g_did_realPlay = 0;/*会话ID/用来分辨不同的会话:实时视音频点播*/ g_did_backPlay = 0;/*会话ID/用来分辨不同的会话:历史视音频回放*/ g_did_fileDown = 0;/*会话ID/用来分辨不同的会话:视音频文件下载*/ int ret = 0; ret = eXosip_init();/*初始化osip和eXosip协议栈*/ if (0 != ret) { printf("Couldn't initialize eXosip!\r\n"); return -1; } printf("eXosip_init success!\r\n"); ret = eXosip_listen_addr(IPPROTO_UDP, NULL, atoi(device_info.ipc_port), AF_INET, 0); if (0 != ret)/*传输层初始化失败*/ { eXosip_quit(); printf("eXosip_listen_addr error!\r\n"); return -1; } printf("eXosip_listen_addr success!\r\n"); return 0; }
int main ( int argc, char *argv[] ) { int i, port = 5060; osip_trace_initialize_func(END_TRACE_LEVEL, &android_trace_func); i=eXosip_init(); if (i!=0) return -1; i = eXosip_listen_addr (IPPROTO_UDP, NULL, port, AF_INET, 0); if (i!=0) { eXosip_quit(); __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "%s", "could not initialize transport layer\n"); return -1; } eXosip_event_t *je; for (;;) { je = eXosip_event_wait (0, 24*60*60*1000); eXosip_lock(); eXosip_automatic_action (); eXosip_unlock(); if (je == NULL) break; if (je->type == EXOSIP_CALL_INVITE) { __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, "%s", "incoming call\n"); std::cout << "incoming call" << std::endl; } } return 0; } // ---------- end of function main ----------
void sipomatic_uninit(Sipomatic *obj) { ms_mutex_destroy(&obj->lock); eXosip_quit(); }
int main( int argc, char *argv[] ) { /* Set default preferences and retrieve existing preferences */ preferences_set_default_preferences(); preferences_get_preferences_from_xml_file("preferences.xml"); state = IDLE; /* Initialize libraries */ gtk_init (&argc, &argv); gst_init(NULL, NULL); if(msrp_init(events_msrp) < 0) { printf("Error initializing the MSRP library...\n"); } /* Display the main GUI */ imsUA = create_imsUA (); gtk_widget_show (imsUA); /* Setup our IPTV window */ videoWin = create_videoWin(); gtk_window_set_decorated(GTK_WINDOW(videoWin),FALSE); /* Prepare a GST pipeline for the background video */ backgroundVideoPipeline = NULL; if (initialise_eXosip() < 0) { fprintf(stderr, "Could not initialise - Is port 5060 in use?\n"); } else { eXosip_set_user_agent("UCT IMS Client"); presence_get_buddy_list_from_file("buddylist"); /* Check for incoming eXosip events every 200 ms */ g_timeout_add (200, get_exosip_events, imsUA); /* run the main GUI */ gtk_main (); /* if registered to a proxy deregister on exit*/ if(registered == REGISTERED)//if client is registered { ims_send_deregister_message (); sleep(1); eXosip_event_t *je; while((je = eXosip_event_wait(0,50)) != NULL) { if((je->type == EXOSIP_REGISTRATION_FAILURE) && ((je->response)->status_code == 401)) ims_process_401(je); } } presence_write_buddy_list_to_file("buddylist"); preferences_write_preferences_to_xml_file("preferences.xml"); msrp_quit(); eXosip_quit(); return 0; } }
int main (int argc, char *argv[]) { eXosip_event_t *je; osip_message_t *reg = NULL; osip_message_t *invite = NULL; osip_message_t *ack = NULL; osip_message_t *info = NULL; osip_message_t *message = NULL; int call_id, dialog_id; int i,flag; int flag1 = 1; int id; char *identity = "sip:[email protected]"; char *registerer = "sip:192.168.44.100:5060"; char *source_call = "sip:[email protected]"; char *dest_call = "sip:[email protected]:5060"; char command; char tmp[4096]; char localip[128]; printf("r 向服务器注册\n\n"); printf("c 取消注册\n\n"); printf("i 发起呼叫请求\n\n"); printf("h 挂断\n\n"); printf("q 退出程序\n\n"); printf("s 执行方法INFO\n\n"); printf("m 执行方法MESSAGE\n\n"); //初始化 i = eXosip_init (); if (i != 0) { printf ("Couldn't initialize eXosip!\n"); return -1; } else { printf ("eXosip_init successfully!\n"); } i = eXosip_listen_addr (IPPROTO_UDP, NULL, 5060, AF_INET, 0); if (i != 0) { eXosip_quit (); fprintf (stderr, "Couldn't initialize transport layer!\n"); return -1; } flag = 1; while (flag) { printf ("please input the comand:\n"); scanf ("%c", &command); getchar (); switch (command) { case 'r': printf ("This modal isn't commpleted!\n"); break; case 'i':/* INVITE */ i = eXosip_call_build_initial_invite (&invite, dest_call, source_call, NULL, "This si a call for a conversation"); if (i != 0) { printf ("Intial INVITE failed!\n"); break; } //符合SDP格式,其中属性a是自定义格式,也就是说可以存放自己的信息,但是只能是两列,比如帐户信息 //但是经测试,格式:v o t必不可少,原因未知,估计是协议栈在传输时需要检查的 snprintf (tmp, 4096, "v=0\r\n" "o=anonymous 0 0 IN IP4 0.0.0.0\r\n" "t=1 10\r\n" "a=username:rainfish\r\n" "a=password:123\r\n"); osip_message_set_body (invite, tmp, strlen(tmp)); osip_message_set_content_type (invite, "application/sdp"); eXosip_lock (); i = eXosip_call_send_initial_invite (invite); eXosip_unlock (); flag1 = 1; while (flag1) { je = eXosip_event_wait (0, 200); if (je == NULL) { printf ("No response or the time is over!\n"); break; } switch (je->type) { case EXOSIP_CALL_INVITE: printf ("a new invite reveived!\n"); break; case EXOSIP_CALL_PROCEEDING: printf ("proceeding!\n"); break; case EXOSIP_CALL_RINGING: printf ("ringing!\n"); // call_id = je->cid; // dialog_id = je->did; printf ("call_id is %d, dialog_id is %d \n", je->cid, je->did); break; case EXOSIP_CALL_ANSWERED: printf ("ok! connected!\n"); call_id = je->cid; dialog_id = je->did; printf ("call_id is %d, dialog_id is %d \n", je->cid, je->did); eXosip_call_build_ack (je->did, &ack); eXosip_call_send_ack (je->did, ack); flag1 = 0; break; case EXOSIP_CALL_CLOSED: printf ("the other sid closed!\n"); break; case EXOSIP_CALL_ACK: printf ("ACK received!\n"); break; default: printf ("other response!\n"); break; } eXosip_event_free (je); } break; case 'h': printf ("Holded !\n"); eXosip_lock (); eXosip_call_terminate (call_id, dialog_id); eXosip_unlock (); break; case 'c': printf ("This modal isn't commpleted!\n"); break; case 's': //传输INFO方法 eXosip_call_build_info (dialog_id, &info); snprintf (tmp , 4096, "hello,rainfish"); osip_message_set_body (info, tmp, strlen(tmp)); //格式可以任意设定,text/plain代表文本信息 osip_message_set_content_type (info, "text/plain"); eXosip_call_send_request (dialog_id, info); break; case 'm': //传输MESSAGE方法,也就是即时消息,和INFO方法相比,我认为主要区别,是MESSAGE不用建立连接,直接传输信息,而INFO必须 //在建立INVITE的基础上传输。 printf ("the mothed :MESSAGE\n"); eXosip_message_build_request (&message, "MESSAGE", dest_call, source_call, NULL); snprintf (tmp, 4096, "hellor rainfish"); osip_message_set_body (message, tmp, strlen(tmp)); //假设格式是xml osip_message_set_content_type (message, "text/xml"); eXosip_message_send_request (message); break; case 'q': eXosip_quit (); printf ("Exit the setup!\n"); flag = 0; break; } } return (0); }
int main(int argc, char* argv[]) { int i; expires = 3600; memset( &call, 0, sizeof(call) ); cout<<"Please Enter Your Username:"******"Please Enter Your Password:"******"Usage:"<< endl; cout << "a - answering call"<< endl; cout << "h - hangup"<< endl; cout << "z - zhuxiao"<< endl; cout << "c - call"<< endl; cout << "q - quit"<< endl; FILE* logfile = fopen( "logfile.txt", "w"); i = eXosip_init(NULL, NULL, 6060); if (i!=0) { fprintf (stderr, "test: could not initialize eXosip\n"); __exit(0); } eXosip_sdp_negotiation_remove_audio_payloads(); reg_id = eXosip_register_init(identity, registrar, contact); j = eXosip_register(reg_id, 3600); cout<<"init"<<endl; // eXosip_sdp_negotiation_add_codec(osip_strdup("0"), // NULL, // osip_strdup("RTP/AVP"), // NULL, NULL, NULL, // NULL,NULL, // osip_strdup("0 PCMU/8000")); eXosip_sdp_negotiation_add_codec(osip_strdup("8"), NULL, osip_strdup("RTP/AVP"), NULL, NULL, NULL, NULL,NULL, osip_strdup("8 PCMA/8000")); // eXosip_sdp_negotiation_add_codec(osip_strdup("18"), // NULL, // osip_strdup("RTP/AVP"), // NULL, NULL, NULL, // NULL,NULL, // osip_strdup("18 G729a/8000")); // eXosip_set_mode(EVENT_MODE); eXosip_set_mode(EVENT_MODE); osip_message_t *invite; cout << "oSIP>"<<endl; while( run ) { josua_event_get(); if ( _kbhit() ) { switch ( _getch() ) { case 'a': cout << "answer"<< endl; eXosip_lock(); eXosip_answer_call(call.did, 200, 0); eXosip_unlock(); break; case 'h': cout << "hangup"<< endl; eXosip_lock(); eXosip_terminate_call( call.cid, call.did ); eXosip_unlock(); break; case 'z': cout << "zhuxiao"<< endl; expires = 0; reg_id = eXosip_register_init(identity, registrar, contact); j = eXosip_register(reg_id, 0); break; case 'c': cout << "call"<< endl; i = eXosip_build_initial_invite(&invite, destip, //掩請 identity, //翋請 NULL, "oSIP phone"); if (i!=0) { fprintf (stderr, "eXosip_build_initial_invite failed\n"); __exit(0); } eXosip_lock(); eXosip_initiate_call(invite, NULL, NULL, "10500"); eXosip_unlock(); break; case 'q': eXosip_quit(); cout << "quit"<< endl; run = false; break; } } } return 0; }