eXosip使用实例.docx

上传人:b****2 文档编号:2129583 上传时间:2022-10-27 格式:DOCX 页数:20 大小:18.27KB
下载 相关 举报
eXosip使用实例.docx_第1页
第1页 / 共20页
eXosip使用实例.docx_第2页
第2页 / 共20页
eXosip使用实例.docx_第3页
第3页 / 共20页
eXosip使用实例.docx_第4页
第4页 / 共20页
eXosip使用实例.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

eXosip使用实例.docx

《eXosip使用实例.docx》由会员分享,可在线阅读,更多相关《eXosip使用实例.docx(20页珍藏版)》请在冰豆网上搜索。

eXosip使用实例.docx

eXosip使用实例

ifeq(1,1)

PWD=$(shellpwd)

LIBCODEPATH=/usr/src

LIBPATH=/usr/local

all:

osip2eXosip2myproj

osip2:

@echo"willmakeosip2";echo;echo

@cd$(LIBCODEPATH)/libosip2-3.6.0;echo-n"pwdis:

";pwd;echo;echo;make;makeinstall;cd$(PWD)

eXosip2:

@echo"willmakeeXosip2";echo;echo

@cd$(LIBCODEPATH)/libeXosip2-3.5.0;echo-n"pwdis:

";pwd;echo;echo;make;makeinstall;cd$(PWD)

ifeq(1,2)

myproj:

@echo"willmakemyproj";echo;echo

-rm-fsipuac

gcc-osipuacsipuac.c-I$(LIBPATH)/include-L$(LIBPATH)/lib-losip2-losipparser2-leXosip2

else

$(warning1111$(CC)$(CPPFLAGS)$(CFLAGS)$(LDFLAGS)$(LIBS))

CC:

=gcc

CFLAGS+=-g-O2

CPPFLAGS+=-I$(LIBPATH)/include

LDFLAGS+=-L$(LIBPATH)/lib

LIBS+=-losip2-losipparser2-leXosip2

myproj:

sipuac.o

gcc-osipuacsipuac.o$(LDFLAGS)$(LIBS)

rm*.o

endif

test:

@echo"hereismakeall"

@if[1-eq2];then\

echo"hereismakeallif";\

echo"pwdis$(shellpwd)";\

echo"willmakeosip2";\

echo;\

cd$(LIBCODEPATH)/libosip2-3.6.0;echo-n"pwdis:

";pwd;echo;echo;make;makeinstall;cd$(PWD);\

echo"pwdis$(shellpwd)";\

echo;\

echo;\

echo"willmakeeXosip2";\

echo;\

cd$(LIBCODEPATH)/libeXosip2-3.5.0;echo-n"pwdis:

";pwd;echo;echo;make;makeinstall;cd$(PWD);\

echo"pwdis$(shellpwd)";\

echo;\

echo;\

echo"willmakemyproj";\

rm-fsipuac;\

gcc-osipuacsipuac.c-I$(LIBPATH)/include-L$(LIBPATH)/lib-losip2-losipparser2-leXosip2;\

else\

echo"hereismakeallelse";\

fi

clean:

@echo"willcleanosip2";echo;echo

@cd$(LIBCODEPATH)/libosip2-3.6.0;echo-n"pwdis:

";pwd;echo;echo;makeclean;cd$(PWD)

@echo"willcleaneXosip2";echo;echo

@cd$(LIBCODEPATH)/libeXosip2-3.5.0;echo-n"pwdis:

";pwd;echo;echo;makeclean;cd$(PWD)

@echo"willcleanmyproj";echo;echo

rm-fsipuac

.PHONY:

allosip2eXosip2myprojtestclean

Endif

///////////////////////////////////////代码

#include

#include

#include

#defineENABLE_TRACE//打开osiplog用的

#include

#include

intreg();

intunreg();

intinvite();

intbye();

inthold();

intunhold();

intquit();

intshow();

#defineCOM_REG"reg"

#defineCOM_UNREG"unreg"

#defineCOM_INVITE"invite"

#defineCOM_BYE"bye"

#defineCOM_HOLD"hold"

#defineCOM_UNHOLD"unhold"

#defineCOM_QUIT"quit"

#defineCOM_SHOW"show"

typedefenum{

REG=0,

UNREG,

INVITE,

BYE,

HOLD,

UNHOLD,

QUIT,

SHOW,

MAX,

}com_type;

typedefint(*COM)();

COMcom[MAX]={reg,unreg,invite,bye,hold,unhold,quit,show};

char*localip="192.168.247.130";

char*serverip="192.168.247.130";

char*username="8001";

char*passwd="8001";

char*realm="\"asterisk\"";//这个字段可以不用

intlocalport=15061;

intserverport=5061;

charreg_from[50]={0};

charregistrar[50]={0};

charcontact[50]={0};

intring_timeout=20;//20秒是振铃超时

intflag=0;

intg_r_id=0;

intg_call_id=0,g_dialog_id=0;

char*g_body=NULL;

intreg()

{

intr_id=0;

osip_message_t*reg_m=NULL;

eXosip_event_t*je=NULL;

eXosip_clear_authentication_info();

if(eXosip_add_authentication_info(username,username,passwd,NULL,NULL/*realm*/))

{

printf("######Add_authentication_infofailed\n");

exit

(1);

}

r_id=eXosip_register_build_initial_register(reg_from,registrar,contact,120,®_m);

if(r_id<0)

{

printf("######Registerfailed!

\n");

exit

(1);

}

printf("######r_idis%d\n",r_id);

g_r_id=r_id;

eXosip_register_send_register(r_id,reg_m);

je=eXosip_event_wait(1,0);

eXosip_lock();

eXosip_default_action(je);

eXosip_unlock();

printf("######willreturnfromreg\n");

return0;

}

intunreg()

{

#if0

inti=0;

osip_message_t*reg_m=NULL;

eXosip_event_t*je=NULL;

eXosip_clear_authentication_info();

if(eXosip_add_authentication_info(username,username,passwd,NULL,NULL/*realm*/))

{

printf("######Add_authentication_infofailed\n");

exit

(1);

}

i=eXosip_register_build_initial_register(reg_from,registrar,contact,0,®_m);

if(i<0)

{

printf("######unregisterfailed!

\n");

exit

(1);

}

eXosip_register_send_register(i,reg_m);

je=eXosip_event_wait(1,0);

eXosip_lock();

eXosip_default_action(je);

eXosip_unlock();

#else

osip_message_t*reg_m=NULL;

eXosip_event_t*je=NULL;

if(eXosip_register_build_register(g_r_id,0,®_m)!

=0)

{

printf("######eXosip_register_build_registerfailed!

\n");

exit

(1);

}

eXosip_register_send_register(g_r_id,reg_m);

je=eXosip_event_wait(1,0);

eXosip_lock();

eXosip_default_action(je);

eXosip_unlock();

#endif

return0;

}

intinvite()

{

inti=0,invite_flg=0;

osip_message_t*invite_m=NULL;

osip_message_t*ack_m=NULL;

eXosip_event_t*je=NULL;

staticcharbody[4096]={0};

chardial[20]={0};

charinv_from[50]={0};

charinv_to[50]={0}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 农学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1