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

📄 netfone.h

📁 IP网络语音通讯软件源代码. 不可多得的语音源代码
💻 H
📖 第 1 页 / 共 3 页
字号:
/*

			Master include file
			
*/

//  System include files

#include <windows.h>
#include <shellapi.h>
#define _INC_SHELLAPI

#ifndef RC_INVOKED

#include <windowsx.h>
#include <winsock.h>
#include <mmsystem.h>

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <memory.h>
#include <time.h>
#include <float.h>
#include <io.h>
#include <commdlg.h>
#include <math.h>
#include <wchar.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <share.h>

#define WM_COMMAND_ID(x)	(LOWORD(x))
#define WM_COMMAND_NOTIFY	(HIWORD(wParam))

//	Sugar coating of gratuitous incompatibilities between 16 and 32 bit Windows

#define LPWAVEFORMATxx LPWAVEFORMATEX

//	Application include files

#include "md5.h"
#include "blowfish.h"
#include "des.h"
#include "ndes.h"
#include "idea.h"
#include "ulaw.h"
#include "gsm.h"
#include "adpcm_u.h"
#include "rtp.h"
#include "rtpacket.h"
#include "lpc.h"
#include "vox.h"

#endif

#include "resource.h"

#ifdef NDEBUG
/*	Generate readable compile-time message if we leave debug output in
	a release build.  Genuinely conditional output should be explicitly
	conditioned on NDEBUG.  */
#ifdef OutputDebugString
#undef OutputDebugString
#endif	  
#define OutputDebugString { extern void OutputDebugString_in_release_build(void); \
							OutputDebugString_in_release_build(1); }
#else 
/*	If we're building for debugging, we'll probably eventually
	use the hex dump, so let's compile it in.  */
#define HEXDUMP
#endif
#define Gag(text) OutputDebugString("Gag me with a " #text "!\r\n");

//  Socket used to exchange sound packets

#define NETFONE_COMMAND_PORT           2074

//	If defined, show rant about serial I/O on comm errors

#define RANT_ON_ERROR

//  Maximum length (in characters) of a host name

#define MAX_HOST                        256

//  Get/SetWindowLong offsets

#define GWL_CLIENT                      0               // Client-side data

//  Type fields for client/server window data structures

#define WINDOW_TYPE_CLIENT              1

//  Various timeouts in seconds

#define FRAME_TIMER_ID                  1

#define TIMEOUT_CONNECTION				30				// Remote connection timeout
#define TIMEOUT_AUDIO_OUTPUT			4				// Release audio output timeout
#define TIMEOUT_RESEND_LWL				(119)			// Resend Look Who's Listening listing
#define TIMEOUT_RESEND_SDES				10				// Reset VAT/RTP ID interval
#define BroadcastUnsubscribe			10				// Broadcast mike blip length (seconds) 

//  Maximum printf-like output allowed by MsgBox

#define MAX_PRINTF_OUTPUT               1024

//	LPC encoding frame size

#define LPC_FRAME_SIZE			160

//	Number of recent connections to remember

#define REMEMBER_CONNECTIONS	5

//	Multicast definitions missing from WINSOCK.H

#ifndef IN_MULTICAST
#define IN_MULTICAST(i) ((ntohl((long)(i)) & 0xF0000000) == 0xE0000000)
#endif

//  Messages posted by the asynchronous socket APIs

#define WM_SOCKET_SELECT	(WM_USER + 100)		// Data socket notifications
#define WM_SOCKET_ASYNC		(WM_USER + 101)		// Asynchronous request completions
#define WM_SOCKET_LWL		(WM_USER + 102)		// LWL socket notifications
#define WM_SOCKET_CONTROL	(WM_USER + 103)		// Control socket notifications
#define WM_CLEAN_UP_YOUR_ACT (WM_USER + 104)	// Too depressing to explain--see FRAME.C

// Messages posted to start other sessions

#define WM_NEW_COMMANDLINE	(WM_USER + 200)		// Second instance launched with new site

#define HANDLE_WM_SOCKET_SELECT(hwnd, wParam, lParam, fn) \
    ((fn)((hwnd), (SOCKET)(wParam), (SOCKERR)WSAGETSELECTERROR(lParam), \
    (SOCKEVENT)WSAGETSELECTEVENT(lParam)), 0L)
#define FORWARD_WM_SOCKET_SELECT(hwnd, socket, serr, sevent, fn) \
    (void)(fn)((hwnd), WM_SOCKET_SELECT, (WPARAM)(socket), \
    (LPARAM)WSAMAKESELECTREPLY(sevent, serr))

#define HANDLE_WM_SOCKET_ASYNC(hwnd, wParam, lParam, fn) \
    ((fn)((hwnd), (HANDLE)(wParam), (SOCKERR)WSAGETASYNCERROR(lParam), \
    (WORD)WSAGETASYNCBUFLEN(lParam)), 0L)
#define FORWARD_WM_GETXBYX(hwnd, hAsync, serr, cbBuffer, fn) \
    (void)(fn)((hwnd), WM_SOCKET_ASYNC, (WPARAM)(hAsync), \
    (LPARAM)WSAMAKEASYNCREPLY(cbBuffer, serr))

//  Determine number of elements in an array

#define ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))

//	Macro for retrieving formats from the resource file

#define Format(n)   rstring(IDS_FORMATS + (n))

/*	Force a resource string to be FAR for those (like wsprintf)
	who can't figure out by themselves.  */
	
#define Lrstring(n)	((LPSTR) rstring(n))

//  Make life with RC a little easier

#ifdef RC_INVOKED
#define ID(x)           x
#else
#define ID(x)           MAKEINTRESOURCE(x)
#endif

///	Resource IDs

#define IDI_BASE                        1000
#define IDM_BASE                        2000
#define IDD_BASE                        3000
#define IDA_BASE                        4000

//  Icon resource IDs

#define IDI_FRAME                       ID(1000)        // IDI_BASE + 0
#define IDI_CLIENT                      ID(1001)        // IDI_BASE + 1
#define IDI_SERVER                      ID(1002)        // IDI_BASE + 2

//  Menu resource IDs

#define IDM_FRAME_BASE                  2000            // IDM_BASE + 0
#define IDM_FRAME                       ID(IDM_FRAME_BASE)
#define IDM_CONNECTION_BASE             (IDM_FRAME_BASE + 0)
#define IDM_CONNECTION_EXIT             (IDM_CONNECTION_BASE + 3)

#define IDM_WINDOW_BASE                 (IDM_FRAME_BASE + 100)
#define IDM_WINDOW_CASCADE              (IDM_WINDOW_BASE + 0)
#define IDM_WINDOW_TILE_VERTICALLY      (IDM_WINDOW_BASE + 1)
#define IDM_WINDOW_TILE_HORIZONTALLY    (IDM_WINDOW_BASE + 2)
#define IDM_WINDOW_ARRANGE_ICONS        (IDM_WINDOW_BASE + 3)
#define IDM_WINDOW_FIRST_CHILD          (IDM_WINDOW_BASE + 4)

#define IDM_HELP_BASE                   (IDM_FRAME_BASE + 200)
#define IDM_HELP_ABOUT                  (IDM_HELP_BASE + 0)

#define IDM_CUSTOM						9000			// Custom (remembered file) menu items

//  Dialog resource IDs

#define IDD_ABOUT                       ID(3000)        // IDD_BASE + 0

#define IDD_NEW                         ID(3100)        // IDD_BASE + 100
#define IDD_NEW_HOST                    3101
#define IDD_NEW_HOST_LABEL              3102

//  Accelerator table resource IDs

#define IDA_FRAME	ID(4000)			// IDA_BASE + 0

#define BUFL	3600					// Sound buffer maximum length (actually less)

#define LONG	long

#define SPEAK_FREE_FRAME_CLASS "SpeakFreeFrameClass"

struct soundbuf {
	LONG compression;
	char sendinghost[16];
	struct {
		LONG buffer_len;
		char buffer_val[BUFL];
	} buffer;
};
typedef struct soundbuf soundbuf;

// Packet mode flags

#define fComp2X     1		      // Simple 2 to 1 compression
#define fDebug	    2		      // Debug mode
#define fSetDest    4		      // Set sound output destination
#define fDestSpkr   0		      // Destination: speaker
#define fDestJack   8		      // Destination: audio output jack
#define fLoopBack   16		      // Loopback packets for testing
#define fCompGSM    32		      // GSM compression
#define fEncDES     64		      // DES encrypted
#define fEncOTP     128 	      // One-time pad encrypted
#define fEncIDEA    256 	      // IDEA encrypted
#define fCompADPCM	512 		  // ADPCM compressed
#define fEncPGP		1024		  // PGP-protected session key encrypted
#define fKeyPGP		2048		  // Packet contains PGP-encrypted session key
#define fCompLPC	4096		  // LPC compressed
#define fFaceData   8192          // Request/reply for face data
#define fFaceOffer  16384         // Offer face image to remote host
#define fCompVOX	0x10000		  // VOX compressed
#define fCompLPC10	0x20000 	  // LPC-10 compressed
#define fCompRobust	0x40000		  // Robust duplicate packet mode
#define fEncBF		0x80000		  // Blowfish encrypted
#define fProtocol   0x40000000    // Speak Freely protocol flag

// Special definitions for face data packets (which have fFaceData set)

#define faceRequest 1             // Face data request
#define faceReply   2             // Face data reply
#define faceLess    4             // No face available

// Mask to extract compression modes

#define fCompressionModes   (fComp2X | fCompGSM | fCompADPCM | fCompLPC | fCompVOX)

/*	The following flags appear in the compression field of sound
	buffers but never figure in buffers actually transmitted on
	the network; they're used purely for internal housekeeping.
	In some cases flags used in network buffers are reused.  */

#define fFromModem	0x8000		  // From the modem
#define fPlayback	0x02000000	  // Answering machine playback packet
#define fAnsNewMsg	0x01000000	  // Start of new message on answering machine

// Test if a packet actually contains sound

#define isSoundPacket(c)    (((c) & (fFaceData | fKeyPGP)) == 0)

// Protocol types

#define PROTOCOL_SPEAKFREE  0		// Speak Freely protocol
#define PROTOCOL_VAT        1		// VAT protocol
#define PROTOCOL_RTP        2		// RTP protocol
#define PROTOCOL_VATRTP_CRYPT 3		// Probably encrypted VAT or RTP message
#define PROTOCOL_UNKNOWN    4		// No evidence as to protocol yet

//	Answering machine file format

struct respHeader {
	struct in_addr hostIPnumber;	// IP number of sending host
	time_t itemTime;				// Time and date buffer received
	short hostNameLength;			// Length of hostName including zero terminator

⌨️ 快捷键说明

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