eXosip使用实例

ifeq (1,1)

PWD=$(shell pwd) LIBCODEPATH=/usr/src LIBPATH=/usr/local

all: osip2 eXosip2 myproj

osip2: @echo \ @cd $(LIBCODEPATH)/libosip2-3.6.0;echo -n \$(PWD)

eXosip2: @echo \ @cd $(LIBCODEPATH)/libeXosip2-3.5.0;echo -n \is: \install;cd $(PWD)

ifeq (1,2)

myproj: @echo \ -rm -f sipuac gcc -o sipuac sipuac.c -I$(LIBPATH)/include -L$(LIBPATH)/lib -losip2 -losipparser2 -leXosip2 else

$(warning 1111 $(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 -o sipuac sipuac.o $(LDFLAGS) $(LIBS) rm *.o

endif test:

@echo \ @if [ 1 -eq 2 ];then \\ echo \ echo \ echo \ echo ;\\ cd $(LIBCODEPATH)/libosip2-3.6.0;echo -n \is: \install;cd $(PWD) ;\\ echo \ echo ;\\ echo ;\\ echo \ echo ;\\ cd $(LIBCODEPATH)/libeXosip2-3.5.0;echo -n \is: \install;cd $(PWD) ;\\ echo \ echo ;\\ echo ;\\ echo \ rm -f sipuac ;\\ gcc -o sipuac sipuac.c -I$(LIBPATH)/include -L$(LIBPATH)/lib -losip2 -losipparser2 -leXosip2 ;\\ else \\ echo \ fi

clean: @echo \ @cd $(LIBCODEPATH)/libosip2-3.6.0;echo -n \is: \clean;cd $(PWD) @echo \ @cd $(LIBCODEPATH)/libeXosip2-3.5.0;echo -n \is: \clean;cd $(PWD) @echo \ rm -f sipuac

.PHONY: all osip2 eXosip2 myproj test clean

Endif

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

#include #include #include

#define ENABLE_TRACE //打开osip log用的

#include #include

int reg(); int unreg(); int invite(); int bye(); int hold(); int unhold(); int quit(); int show();

#define COM_REG \#define COM_UNREG \#define COM_INVITE \#define COM_BYE \#define COM_HOLD \#define COM_UNHOLD \#define COM_QUIT \#define COM_SHOW \

typedef enum{ REG = 0, UNREG, INVITE, BYE, HOLD, UNHOLD,

QUIT, SHOW, MAX, }com_type;

typedef int (*COM)();

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

char * localip = \char * serverip = \char * username = \char * passwd = \

char * realm = \这个字段可以不用 int localport = 15061; int serverport = 5061;

char reg_from[50] = {0}; char registrar[50] = {0}; char contact[50] = {0};

int ring_timeout = 20;//20秒是振铃超时

int flag = 0;

int g_r_id = 0;

int g_call_id = 0,g_dialog_id = 0; char * g_body = NULL;

int reg() { int r_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(\

exit(1); } r_id = eXosip_register_build_initial_register(reg_from,registrar,contact,120,®_m); if(r_id < 0) { printf(\ exit(1); } printf(\ 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(\ return 0; }

int unreg() { #if 0 int i = 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(\ exit(1); } i = eXosip_register_build_initial_register(reg_from,registrar,contact,0,®_m); if(i < 0) { printf(\ exit(1); } eXosip_register_send_register(i,reg_m); je = eXosip_event_wait(1,0);

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4