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

📄 defines.h

📁 最近在学习directshow, Directshow实务精选的源代码
💻 H
字号:
//
// defines.h
//

#ifndef __H_defines__
#define __H_defines__

//-----------------------------------------------------------------------------
// 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; } }


// File types we support currently
const long FT_MPEG1		= 0;
const long FT_MPEG2		= 1;
const long FT_AVI		= 2;
const long FT_MP3		= 3;

// Message definitions
const long msg_CommandReceived		= 'vod0' + 1;
const long msg_NewSocketAccepted	= 'vod0' + 2;
const long msg_FilterGraphError		= 'vod0' + 3;

const WORD SERVER_UDP_PORT  = 10080;
const WORD CLIENT_UDP_PORT  = 10081;
const WORD CLIENT_TCP_PORT  = 10086;

const long MAX_COMMAND_SIZE = 200;
const long PACK_SIZE		= 2048;

// UDP commands
typedef enum
{
	Cmd_RequestTCPConnect = 0,
	Cmd_RequestTCPDisconnect,
	Cmd_RequestProgramList,
	Cmd_ProgramList,	
	Cmd_RequestPlay,   // Media playing control
	Cmd_RequestPause,
	Cmd_RequestStop,
} Net_Command;

// Command structs
struct Request_TCP_Connect
{
	long client_ip;   // client ip address
	WORD client_udp;  // client command port
	WORD client_tcp;  // client tcp listening port

	void my_hton(void) 
	{
		client_ip		= htonl(client_ip);
		client_udp		= htons(client_udp);
		client_tcp		= htons(client_tcp);
	};

	void my_ntoh(void) 
	{
		client_ip		= ntohl(client_ip);
		client_udp		= ntohs(client_udp);
		client_tcp		= ntohs(client_tcp);
	};
};

// struct Request_ProgramList

struct Program_List
{
	char file_path[100];
	long pid;
	long file_type;
	long file_size;
	long check_size;
	long check_offset2;

	void my_hton(void) 
	{
		pid				= htonl(pid);
		file_type		= htonl(file_type);
		file_size		= htonl(file_size);
		check_size		= htonl(check_size);
		check_offset2	= htonl(check_offset2);
	};

	void my_ntoh(void) 
	{
		pid				= ntohl(pid);
		file_type		= ntohl(file_type);
		file_size		= ntohl(file_size);
		check_size		= ntohl(check_size);
		check_offset2	= ntohl(check_offset2);
	};
};

// We should specify the program id when control the media playing
struct Media_Control
{
	long program_id;

	void my_hton(void) 
	{
		program_id		= htonl(program_id);
	};

	void my_ntoh(void) 
	{
		program_id		= ntohl(program_id);
	};
};

#endif // __H_defines__

⌨️ 快捷键说明

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