⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testosipexdlg.cpp

📁 eXosip_WinXP_WinCE;可在WinCE下用的sip协议栈
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// TestOsipExDlg.cpp : 实现文件
//

#include "stdafx.h"
#include "TestOsipEx.h"
#include "TestOsipExDlg.h"

//OSIP支持
#include <osip2/osip_mt.h>
#include <eXosip/eXosip.h>
#include <eXosip/eXosip_cfg.h>
#include ".\testosipexdlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

//相关类
class jcall;

class jcall {
public:
	int cid;
	int did;
	
	char reason_phrase[50];
	int  status_code;
	
	char textinfo[256];
	char req_uri[256];
	char local_uri[256];
	char remote_uri[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 enough 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')
		{
			osip_strncpy(ca->reason_phrase, je->reason_phrase, 49);
			ca->status_code = je->status_code;
		}
		
		ca->state = je->type;
		return 0;
	}
	
};

int i;	
osip_message_t *invite;
jcall call;


void __exit( int r )
{
	char line[256];
	gets( line );
	exit( r );
}

void josua_printf(char* buf)
{
	printf( "\n" );
}

CString inf;

int josua_event_get()
{
	int counter =0;
	// use events to print some info 
	eXosip_event_t *je;
	for (;;)
	{
		char buf[100];
		je = eXosip_event_wait(0,50);
		if (je==NULL)
			break;
		counter++;
		
		if (je->type==EXOSIP_CALL_NEW)
		{
			inf.Format("<- (%i %i) INVITE from: %s",
				je->cid, je->did,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
			
			call.build(je);
		}
		else if (je->type==EXOSIP_CALL_ANSWERED)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_CALL_PROCEEDING)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_CALL_RINGING)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_CALL_REDIRECTED)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did,
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_CALL_REQUESTFAILURE)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did,
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_CALL_SERVERFAILURE)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_CALL_GLOBALFAILURE)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did,
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_CALL_CLOSED)
		{
			inf.Format("<- (%i %i) BYE from: %s",
				je->cid, je->did, je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_CALL_HOLD)
		{
			inf.Format("<- (%i %i) INVITE (On Hold) from: %s",
				je->cid, je->did, je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_CALL_OFFHOLD)
		{
			inf.Format("<- (%i %i) INVITE (Off Hold) from: %s",
				je->cid, je->did, je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_REGISTRATION_SUCCESS)
		{
			inf.Format("<- (%i) [%i %s] %s for REGISTER %s",
				je->rid,
				je->status_code,
				je->reason_phrase,
				je->remote_uri,
				je->req_uri);
			josua_printf(buf);AfxMessageBox(inf);
			
		}
		else if (je->type==EXOSIP_REGISTRATION_FAILURE)
		{
			inf.Format("<- (%i) [%i %s] %s for REGISTER %s",
				je->rid,
				je->status_code,
				je->reason_phrase,
				je->remote_uri,
				je->req_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_OPTIONS_NEW)
		{
			inf.Format("<- (%i %i) OPTIONS from: %s",
				je->cid, je->did,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
			
		}
		else if (je->type==EXOSIP_OPTIONS_ANSWERED)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_OPTIONS_PROCEEDING)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
			
		}
		else if (je->type==EXOSIP_OPTIONS_REDIRECTED)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did,
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_OPTIONS_REQUESTFAILURE)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did,
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_OPTIONS_SERVERFAILURE)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_OPTIONS_GLOBALFAILURE)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did,
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_INFO_NEW)
		{
			inf.Format("<- (%i %i) INFO from: %s",
				je->cid, je->did,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_INFO_ANSWERED)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_INFO_PROCEEDING)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_INFO_REDIRECTED)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did,
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_INFO_REQUESTFAILURE)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did,
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_INFO_SERVERFAILURE)
		{
			inf.Format("<- (%i %i) [%i %s] %s",
				je->cid, je->did, 
				je->status_code,
				je->reason_phrase,
				je->remote_uri);
			josua_printf(buf);AfxMessageBox(inf);
		}
		else if (je->type==EXOSIP_INFO_GLOBALFAILURE)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -