[Osip] Automtic send BYE mesaage

s95321517 s95321517 at ncnu.edu.tw
Sat Dec 8 06:06:27 CET 2007


I=20want=20to=20write=20a=20simple=20program=20based=20on=20exosip2.
It=20can=20call=20others=20and=20receive=20a=20call.
I=20met=20a=20problem=20when=20I=20receive=20a=20call.
A=20softphone=20make=20a=20call=20to=20my=20UA.
The=20signaling=20flow=20is=20correct.
=20=20INVITE=20=20=20=20=20=20--->
=20=20180=20ringing=20<---
=20=20200=20OK=20=20=20=20=20=20<---
=20=20ACK=20=20=20=20=20=20=20=20=20--->
=20=20BYE=20=20=20=20=20=20=20=20=20--->
=20=20200=20OK=20=20=20=20=20=20<---
=20
=20=20But=20I=20dont=20terminate=20the=20call=20on=20the=20softphone=20side.=

=20=20It=20send=20BYE=20message=20automaticly.
=20=20And=20the=20softphone=20side=20has=20the=20error=20message=20of=20"Cal=
l=20failed"=20or=20"the=20client=20is=20not=20available."
=20=20Is=20there=20anything=20wrong=20with=20my=20code?

=09osip_message_t=20*reg=20=3D=20NULL;
=09id=20=3D=20eXosip_register_build_initial_register=20(=20"sip:account at prox=
y=20address",=20"sip:proxy=20address",=20NULL,=203600,=20&reg);=20=20
=09if(id=20<=200)
=09=09cout=20<<=20id;
=09i=20=3D=20eXosip_register_send_register=20(id,=20reg);
for(;;)
=20=20=20=20{
=20=20=20=20=20=20je=20=3D=20eXosip_event_wait=20(0,50);=20
=20=20=20=20=20=20eXosip_lock=20();
=20=20=20=20=20=20eXosip_default_action=20(je);
=20=20=20=20=20=20eXosip_automatic_refresh=20();
=20=20=20=20=20=20eXosip_unlock=20();
=20=20=20=20=20=20if=20(je=20=3D=3D=20NULL)
=20=20=20=20continue;
=20=20=20=20=20=20switch=20(je->type)
=09{
=09case=20EXOSIP_CALL_RINGING:
=09=09cout=20<<=20"ringing";
=09=09PlaySound(L"123.wav",NULL,SND_LOOP|SND_ASYNC);
=09=09=20break;
=20=20=20=20case=20EXOSIP_CALL_INVITE:=20

=20=20=20=20=20=20remote_sdp=20=3D=20eXosip_get_remote_sdp=20(je->did);
=20=20=20=20=20=20call_id=20=3D=20je->cid;
=20=20=20=20=20=20dialog_id=20=3D=20je->did;
=20=20=20=20=20=20
=20=20=20=20=20=20eXosip_lock=20();
=20=20=20=20=20=20eXosip_call_send_answer=20(je->tid,=20180,=20NULL);
=20=20=20=20=20=20i=20=3D=20eXosip_call_build_answer=20(je->tid,=20200,=20&a=
nswer);=20=20
=20=20=20=20=20=20if=20(i=20!=3D=200)
=20=20=20=20=20=20=20=20{
=20=20=20=20=20=20=20=20=20=20printf=20("This=20request=20msg=20is=20invalid=
!Cann't=20response!\n");
=20=20=20=20=20=20=20=20=20=20eXosip_call_send_answer=20(je->tid,=20400,=20N=
ULL);
=20=20=20=20=20=20=20=20}
=20=20=20=20=20=20else
=20=20=20=20=20=20=20=20{
=20=20=20=20=20=20=20=20=20=20_snprintf=20(tmp,=204096,
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20"v=3D0\r\n"
=09"o=3Dbeautidays=206=202=20IN=20IP4=20%s=20\r\n"
=09"c=3DIN=20IP4=20%s\r\n"
=20=20=20=20=20=20=20=20=20"t=3D9=202\r\n"=20=20=20=09=20=20=20=20=20=20=20=20=
=20=20
=20=20=20=20=20=20=20=20=20"m=3Daudio=20%s=20RTP/AVP=20100=20106=20101\r\n"
=09"a=3Drtpmap:100=20SPEEX/16000\r\n"
=09"a=3Drtpmap:106=20SPEEX-FEC/16000\r\n"
=09"a=3Dfmtp:101=200-15\r\n"
=09"a=3Drtpmap:101=20telephone-event/8000\r\n"
=09"a=3Dsendrecv\r\n",localip,localip,port);
=20=20=20=20=20=20=20=20=20=20osip_message_set_body=20(answer,=20tmp,=20strl=
en(tmp));
=20=20=20=20=20=20=20=20=20=20osip_message_set_content_type=20(answer,=20"ap=
plication/sdp");
=20=20=20=20=20=20=20=20=20=20
=20=20=20=20=20=20=20=20=20=20eXosip_call_send_answer=20(je->tid,=20200,=20a=
nswer);=20
=20=20=20=20=20=20=20=20=20=20printf=20("send=20200=20over!\n");
=20=20=20=20=20=20=20=20}
=20=20=20=20=20=20eXosip_unlock=20();
=20=20=20=20=20=20=20=20}
=20=20=20=20=20=20break;
=20=20=20=20=20the=20following=20code=20is=20omitted.
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20Jane

--=3D=3DMailed=20via=20NCNU=20E-Mail=3D=3D--



More information about the Osip mailing list