EXSIP-based soft phone example

xiaoxiao2021-03-06  101

EXSIP-based soft phone example

Reposted from: http://www.coolboysky.com/oblog/more.asp? Name = tucket & id = 72 http://blog.9cbs.net/wffy Since these two places have.

EXOSIP is extended to OSIP, and OSIP does not provide any way to quickly generate request messages and response messages, all request messages and response messages must call a set of SIP Message APIs to manually assemble, so the author is on OSIP Developed EXOSIP, developing soft phones with EXOSIP is very convenient, only a few APIs can be completed. Extrae is included in: JOSUA, but Josua is relatively complex, give a simpler example for your reference, because examples It is too simple to give a comment, see the exosip source code, see the exosip source code, read the example of this example. It is very simple. I use OSIP 2.0.9 exosip 0.77. #Include "Assert .h "#include #include #include #include #include Using Namespace Std; Class JCALL; CLASS JCALL {public: int Cid; int DID; char reason_phrase [50]; int status_code; char textinfo [256]; char copy_uri [256]; char remote_uri [256]; char remote_uri [256]; char SUBJECT [256]; char Subject [256]; char remote_sdp_audio_ip [50]; int remote_sdp_audio_port; int payload; char payload_name [50]; int state; jcall () {} int build (eXosip_event_t * je) {jcall * ca = this; ca-> cid = je-> cid; ca -> DID = JE-> DID; IF (CA-> DID <1 && Ca-> CID <1) {assert (0); RETURN -1; / * NOT INFORMATION for this event ?? * /} osip_strncpy CA-> Textinfo, JE-> Textinfo, 255); OSIP_STRNCPY (CA-> Req_uri, Je-> Req_uri, 255); OSIP_STRNCPY (CA-> local_uri, je-> local_uri, 255); OSIP_STRNCPY (CA-> remote_uri, je-> remote_uri, 255); osip_strncpy (ca-> subject, je-> subject, 255); if (ca-> remote_sdp_audio_ip [0] == '/ 0') {osip_strncpy (ca-> remote_sdp_audio_ip, je-> remote_sdp_audio_ip, 49); ca-> remote_sdp_audio_port = je-> remote_sdp_audio_port; ca-> payload = je-> payload; osip_strncpy (ca-> payload_name, je-> payload_name, 49);} if (je-> reason_phrase [0] = '/ 0! ') {Osite_strncpy (CA->

REASON_PHRASE, JE-> Reason_phrase, 49); CA-> status_code = je-> status_code;} ca-> state = je-> type; return 0;}}; jcall call; void __exit (int R) {char line [ 256]; Gets (line); exit (r);} void josua_printf (char * buf) {printf ("/ n");} int JOSUA_EVENT_GET () {int counter = 0; / * Use Events to print some info * / EXoSIP_EVENT_T * JE; for (;;) {charf [char 50]; je = exosip_event_wait (0, 50); if (JE == NULL) Break; counter ; if (je-> type == exosip_call_new) {Printf ( "<- (% I% i) Invite from:% s", JE-> CID, JE-> DID, JE-> Remote_uri); JOSUA_PRINTF (BUF); Call.Build (je);} else if (JE- > type == exosip_call_answered) {Printf ("<- (% i) [% I% s]% s", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE- > transote_uri; josua_printf (buf);} else if (je-> type == exosip_call_proceeding) {Printf ("<- (% i) [% I% s]% s", JE-> CID, JE- > DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; JOSUA_PRINTF (BUF);} else if (je-> type == exosip_ca LL_RINGING) {Printf ("<- (% I) [% I% s]% s", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; JOSUA_PRINTF (BUF);} else if (je-> type == exosip_call_redirected) {printf ("<- (% i) [% i% s]% s", je-> CID, JE-> DID, JE -> status_code, je-> Reason_phrase, je-> transote_uri; josua_printf (buf);} else if (je-> type == exosip_call_requestfail) {printf ("<- (% i) [% I% s] % s ", Je-> CID, JE-> DID, JE-> status_code, je->

REASON_PHRASE, JE-> Remote_uri; josua_printf (buf);} else if (je-> type == exosip_call_serverfail) {printf ("<- (% i) [% i% s]% s", je-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; Josua_Printf (BUF);} else if (je-> type == exosip_call_globalfail) {Printf ("<- (% i) I) [% i% s]% s ", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, Josua_Printf (BUF);} else if (JE-> TYPE == exosip_call_closed) {printf ("<- (% I) BYE from:% s", JE-> CID, JE-> DID, JE-> Remote_uri); JOSUA_PRINTF (BUF);} Else IF -> type == exosip_call_hold) {Printf ("<- (% I) INVITE (ON HOLD) from:% S", JE-> CID, JE-> DID, JE-> Remote_uri; Josua_Printf (BUF) } Else if (je-> type == exosip_call_offhold) {printf ("<- (% I) INVITE (OFF HOLD) from:% s", JE-> CID, JE-> DID, JE-> Remote_uri JOSUA_PRINTF (BUF);} else if (je-> type == exosip_registration_success) {Printf ("<- (% i) [% I% s]% s forreg register% s", J E-> RID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri, JE-> Req_uri; JOSUA_PRINTF (BUF);} else if (je-> type == exosip_registration_failure) {printf ("<- % i) [% i% s]% s for register% s ", je-> rid, je-> status_code, je-> reason_phrase, je-> remote_uri, je-> req_uri; josua_printf (buf);} else IF (je-> type == exosip_options_new) {Printf ("<- (% I) Options from:% s", JE-> CID, JE-> DID, JE-> Remote_uri; JOSUA_PRINTF (BUF);

} Else if (je-> type == exosip_options_answered) {printf ("<- (% i) [% I% s]% s", je-> CID, JE-> DID, JE-> status_code, JE -> Reason_phrase, JE-> Remote_uri; josua_printf (buf);} else if (je-> type == exosip_options_proceeding) {Printf ("<- (% i) [% i% s]% s", JE -> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; Josua_Printf (BUF);} else if (je-> type == exosip_options_redirected) {printf ("<- (%) I% i) [% i% s]% s ", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, je-> transote_uri; josua_printf (buf);} else if -> Type == exosip_options_requestfail) {Printf ("<- (% i) [% I% s]% s", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE -> transote_uri; josua_printf (buf);} else if (je-> type == exosip_options_serverfail) {printf ("<- (% i) [% I% s]% s", JE-> CID, JE -> DID, JE-> Status_code, JE-> Reason_phrase, je-> remote_uri; josua_printf (buf);} else if (je-> type == EXOSIP_ Options_globalfail) {Printf ("<- (% I) [% I% S]% S", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; JOSUA_PRINTF (BUF);} else if (je-> type == exosip_info_new) {printf ("<- (% i) info from:% s", JE-> CID, JE-> DID, JE-> Remote_uri JOSUA_PRINTF (BUF);} else if (je-> type == exosip_info_ambwered) {printf ("<- (% i) [% I% s]% s", je-> CID, JE-> DID , Je-> status_code, je->

REASON_PHRASE, JE-> Remote_uri; josua_printf (buf);} else if (je-> type == exosip_info_proceeding) {printf ("<- (% i) [% i% s]% s", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, Je-> Remote_uri; josua_printf (buf);} else if (je-> type == exosip_info_redirected) {printf ("<- (% i) I) [% i% s]% s ", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, Josua_Printf (BUF);} else if (JE-> Type == exosip_info_requestfail) {Printf ("<- (% i) [% I% s]% s", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; josua_printf (buf);} else if (je-> type == exosip_info_serverfail) {printf ("<- (% i) [% I% s]% s", je-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; josua_printf (buf);} else if (je-> type == exosip_info_globalfail) {printf ("<- (% i) [% i % s]% s ", JE-> CID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; JOSUA_ Printf (buf);} else if (je-> type == exosip_subscription_answered) {printf ("<- (% i) [% I% s]% s for subscribe", JE-> SID, JE-> DID , JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; JOSUA_PRINTF (BUF); Printf ("<- (% I) Online =% i [status:% I Reason:% i]", JE -> SID, JE-> DID, JE-> online_status, je-> ss_status, jE-> ss_reason); josua_printf (buf);} else if (je-> type == exosip_subscription_proceeding) {printf ("<

- (% I) [% I) [% I% s]% s for subscribe ", JE-> SID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JO-> Remote_uri; JOSUA_PRINTF (BUF); } Else if (je-> type == exosip_subscription_redirected) {printf ("<- (% i) [% I% s]% s for subscribe", je-> sid, je-> did, je-> status_code , JE-> Reason_phrase, je-> transote_uri; josua_printf (buf);} else if (je-> type == exosip_subscription_requestfail) {printf ("<- (% i) [% I% S]% s for Subscribe ", Je-> SID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; josua_printf (buf);} else if (je-> type == exosip_subscription_serverfail) {printf (" <- (% I) [% I% s]% s for subscribe ", JE-> SID, JE-> DID, JE-> Status_code, JE-> Reason_phrase, JE-> Remote_uri; JOSUA_PRINTF (BUF) } Else if (je-> type == exosip_subscription_globalfail) {Printf ("<- (% i) [% I% s]% s for subscribe", JE-> SID, JE-> DID, JE-> Status_code, je-> Reason_phrase, je-> transote_uri; josua_printf (buf); } Else if (je-> type == exosip_subscription_notify) {printf ("<- (% I) Notify from:% s", JE-> SID, JE-> DID, JE-> Remote_uri); JOSUA_PRINTF (BUF ); Printf ("<- (% I) online =% i [status:% i real-> sid, je-> did, je-> online_status, je-> ss_status, je -> ss_reason); josua_printf (buf);} else if (je-> type == exosip_in_subscription_new) {printf ("<- (% i) subscribe from:% s", je-> nid, je-> DID , JE-> Remote_uri; JOSUA_PRINTF (BUF);

! / * Search for the user to see if he has been previously accepted or not * / eXosip_notify (je-> did, EXOSIP_SUBCRSTATE_PENDING, EXOSIP_NOTIFY_AWAY);} else if (je-> textinfo [0] = '/ 0'!) { Printf ("(% I% I% i)% s", JE-> CID, JE-> SID, JE-> NID, JE-> DID, JE-> TEXTINFO); JOSUA_PRINTF (BUF);} exosip_event_free (je); = f (counter> 0) RETURN 0; RETURN-1;} int main (int Argc, char * argv []) {INT i; MEMSET (& Call, 0, sizeof (call); cout << "USAGE: << Endl; cout <<" a - answering call "<< endl; cout <<" h - hangup << endl; cout << "r - ringing" << endl; cout << "c - Call "<< endl; cout <<" q - quit "<< Endl; file * logfile = fopen (" logfile.txt "," w "); // 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子 帖子OSIP_TRACE_INITIALIZE ((_trace_level) 8, stdout); i = exosip_init (stdin, stdout, 5060); if (i! = 0) {fprintf (stderr, "test: could not initialize exosip / n"); __exit (0); } EXOSIP_SDP_NEGOTIN_REMOVE_AUDIO_PAYLOADS (); 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_NEGOTION_ADD_CODEC (OSIP_STRDUP ("8"), NULL, OSIP_STRDUP ("RTP / AVP "), NULL, NULL, NULL, NULL, NULL, osip_strdup (" 8 PCMA / 8000 ")); / * register callbacks * / eXosip_set_mode (EVENT_MODE); osip_message_t * invite; i = eXosip_build_initial_invite (& invite,?" sip: 192.168.197.5:5060 ", // is called IP" SIP: 192.168.197.254: 5060 ", // ourselves IP NULL,"

转载请注明原文地址:https://www.9cbs.com/read-97376.html

New Post(0)