OWPL_RESULT owplCallConnectWithBody(const OWPL_CALL hCall, const char* szAddress, const char* szContentType, const char* szBody, int BodySize) { int i; osip_message_t *invite; char *proxy ; phVLine *vl; char from[512]; OWSIPAccount account ; phcall_t *ca = ph_locate_call_by_cid(hCall); if (ca == NULL) { return OWPL_RESULT_INVALID_ARGS ; } account = owplLineSipAccountGet (ca->vlid) ; if (account <= 0) { return OWPL_RESULT_INVALID_ARGS ; } // TODO verif des arguments if (!szAddress){ return OWPL_RESULT_INVALID_ARGS; } vl = ph_valid_vlid(ca->vlid); if (!vl) { return OWPL_RESULT_INVALID_ARGS; } ph_vline_get_from(from, sizeof(from), vl); proxy = owsip_account_proxy_get (account) ; if((i = eXosip_build_initial_invite(&invite, (char *)szAddress, from, proxy, "")) != 0){ return -1; } eXosip_lock(); i = eXosip_initiate_call_with_body(account, invite, szContentType, szBody, 0); if (i <= 0) { return OWPL_RESULT_FAILURE; } ca->extern_cid = i; ca->vlid = ph_vline2vlid(vl); eXosip_unlock(); owplAssociateCall2PluginByContentType(ca->cid, szContentType); return OWPL_RESULT_SUCCESS; }
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; }
int uas_invite(sipua_uas_t *sipuas, const char *to, sipua_call_t* call_info, char* sdp_body, int sdp_bytes) { eXosipua_t *jua = (eXosipua_t*)sipuas; osip_message_t *invite; char sdp_size[8]; char* proxy = NULL; int ret; char *from = call_info->user_prof->regname; /* OSIP_TRACE (osip_trace(__FILE__, __LINE__, OSIP_INFO2, NULL, "To: |%s|\n", to)); */ if (0!=jua_check_url(from)) { jua_log(("uas_call: illigal sip id!\n")); return UA_FAIL; } if (0!=jua_check_url(to)) { jua_log(("uas_invite: illigal sip destination\n")); return UA_FAIL; } if(jua->sipuas.proxy[0]!='\0') { proxy = uas_check_route(jua->sipuas.proxy); } #if 0 else { proxy = uas_check_route(call_info->user_prof->registrar); } #endif sprintf(sdp_size,"%i", sdp_bytes); printf("uas_invite: [%s] from %s to %s, proxy[%s]\n", call_info->subject, from, to, proxy); printf("\n-------Initiate SDP [%d bytes]--------\n", sdp_bytes); printf("Callid[%s]\n", call_info->setid.id); printf("----------------------------------------\n"); printf("%s", sdp_body); printf("----------------------------------------\n"); if (eXosip_build_initial_invite(&invite, to, from, proxy, call_info->subject) != 0) return UA_FAIL; /* sdp content of the call */ osip_message_set_content_type(invite, "application/sdp"); osip_message_set_content_length(invite, sdp_size); osip_message_set_body(invite, sdp_body, sdp_bytes); eXosip_lock(); ret = eXosip_initiate_call(invite, call_info, NULL/*negotiation_reference*/, NULL/*local_audio_port*/); eXosip_unlock(); if(proxy) osip_free(proxy); /*When to free it ??? osip_message_free(invite); */ return ret; }