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

📄 globaldefs.h

📁 陆其明的实务精选中附带光盘中的视频聊天源代码
💻 H
字号:
//
// GlobalDefs.h
//

#ifndef __H_GlobalDefs__
#define __H_GlobalDefs__

//-----------------------------------------------------------------------------
// Miscellaneous helper functions
//-----------------------------------------------------------------------------
#define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
#define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }

// Attention: we place TCP listening on the client
#define SERVER_UDP_PORT		10096
#define CLIENT_UDP_PORT		10098
#define CLIENT_TCP_PORT		10099 

// Role definitions
typedef enum 
{
	SERVER = 0, 
	CLIENT
} ROLE;

// Device types
typedef enum
{
	DT_DV = 0,
	DT_USB_Camera,
	DT_Audio_Capture,
	DT_Unknown
} Device_Type;

// How devices config to the peer PCs
typedef enum 
{
	Local_Has_Video  = 1, 
	Local_Has_Audio  = 2,
	Remote_Has_Video = 4,
	Remote_Has_Audio = 8
} Device_Config;

const long Local_Device_Mask	= 0x03;
const long Remote_Device_Mask	= 0x0c;

// Preferred capture size
const long Preferred_Width		= 320;
const long Preferred_Height		= 240;

// TCP stream header
struct Pack_Header
{
	long pack_type;
	long pack_size;

	void my_hton(void) 
	{
		pack_type		= htonl(pack_type);
		pack_size		= htonl(pack_size);
	};

	void my_ntoh(void) 
	{
		pack_type		= ntohl(pack_type);
		pack_size		= ntohl(pack_size);
	};
};

// TCP pack types
const long PT_AudioMediaType	= 10001;
const long PT_VideoMediaType	= 10002;
const long PT_Payload			= 10003;
 
// Messages
const long msg_FilterGraphError		= 'avct' + 1;
const long msg_MediaTypeReceived	= 'avct' + 2;
const long msg_TCPSocketAccepted	= 'avct' + 3;
const long msg_UDPCommandReceived	= 'avct' + 4;
const long msg_ModifyFilterGraph	= 'avct' + 5;

// Let the main thread modify filter graph
#define WM_ModifyFilterGraph		(WM_USER+123)

// UDP command defines
const long MAX_COMMAND_SIZE			= 100;
const long cmd_ClientCalling		= 'avct' + 100;
const long cmd_DeviceConfig			= 'avct' + 101;
const long cmd_BuildFilterGraph		= 'avct' + 102;
const long cmd_DisconnectRequest	= 'avct' + 103;

// UDP command pack
struct UDP_Pack
{
	long command;
	long param1;
	long param2;
	long reserved;

	void my_hton(void) 
	{
		command		= htonl(command);
		param1		= htonl(param1);
		param2		= htonl(param2);
		reserved	= htonl(reserved);
	};

	void my_ntoh(void) 
	{
		command		= ntohl(command);
		param1		= ntohl(param1);
		param2		= ntohl(param2);
		reserved	= ntohl(reserved);
	};
};

#endif // __H_GlobalDefs__

⌨️ 快捷键说明

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