/* Speak Freely Engine API * * Copyright (C) 2000 Brian C. Wiles * * Version 8.0 * * $Id: sfengine.h,v 1.3 2000/01/12 19:29:50 Administrator Exp $ */ #ifndef SFENGINE_H #define SFENGINE_H #ifdef __cplusplus extern "C" { #endif #ifdef WIN32 #include #endif #include "gsm/inc/gsm.h" // Defines // SFAPI type #ifdef WIN32 #ifdef _DLL // We're making engine a DLL. #define SFAPI _declspec( dllexport ) #elif defined(SFDLL) // We're using engine DLL #define SFAPI _declspec( dllimport ) #else #define SFAPI #endif #else // !WIN32 #define SFAPI #endif #define MAX_HOST 256 #define BUFL 3600 // Sound buffer maximum length (actually less) // Error values #define SFERR_ENGINE_TOO_OLD 1 #define SFERR_ENGINE_TOO_NEW 2 #define SFERR_BAD_PARAMETER 3 #define SFERR_OUT_OF_MEMORY 4 #define SFERR_HOST_NOT_FOUND 5 #define SFERR_NETWORK_INIT_FAILED 6 #define SFERR_CREATESOCK_FAILURE 7 #define SFERR_CONNECT_FAILURE 8 // Integer types typedef signed char Int8; typedef unsigned char UInt8; #ifdef WIN32 typedef short signed Int16; typedef short unsigned UInt16; typedef int signed Int32; typedef unsigned int UInt32; #endif #ifdef __MAC__ #define Int16 short signed #define Uint16 short unsigned #define Int32 int signed #define Uint32 int unsigned #define BIG_ENDIAN #endif #ifdef GNUC #define Int16 short signed #define Uint16 short unsigned #define Int32 int signed #define Uint32 int unsigned #endif // Potential states for connection windows typedef enum _CLIENT_STATE { Embryonic, // Newly creates connection Idle, // Idle SendingLiveAudio, // Sending live audio Transferring, // Sending audio file PlayingReceivedAudio // Playing audio received from remote host } CLIENT_STATE; // Structures typedef struct _SFENGINE { UInt16 iVersionMajor; // The major API version (e.g. the '8' in version 8.0) UInt16 iVersionMinor; // The minor API version (e.g. the '0' in version 8.0) char szVendor[100]; // The name of the author/vendor of this engine (e.g. "Speak Freely Developers") char szName[100]; // The name of the engine (e.g. "Speak Freely") char szEngineVersion[100]; // This engine implementation's version number (vendor-specific string, may be different than API version) UInt32 pfnAcceptConnection; // This function is called when a connection arrives. This can be NULL if every connection should be accepted. UInt32 pEngineData; // Pointer to engine internal data (implementation-specific). } SFENGINE, *PSFENGINE; typedef struct _SFCALL { UInt32 dwType; // Type of window (WINDOW_TYPE_CLIENT) CLIENT_STATE state; // Current state. SOCKET sAudio; // Socket for audio traffic SOCKET sControl; // Socket for RTP/VAT control messages Int16 timeout; // Timeout counter SOCKADDR_IN inetSock; // Client's socket address UInt16 port; // Destination data port number struct auxSocket *auxSock; // Auxiliary socket, if any CHAR szHost[MAX_HOST]; // Target server's host name HFILE hFile; // Handle to open file UInt32 cbSent; // Count of bytes sent so far. UInt32 cbReceived; // Count of bytes received so far CHAR szFile[MAX_PATH]; // Name of file being sent HANDLE getNameTask; // Get full site name task handle BYTE hostBuffer[MAXGETHOSTSTRUCT]; // Host name reply buffer Int16 modemConnection; // Connection is via the modem HMMIO mmioHandle; // WAVE file MMIO handle LPWAVEFORMAT mmioFormat; // WAVE file format descriptor UInt32 mmioDataLeft; // WAVE file data left to send Int16 quitSoundFile; // Abort current sound file ? Int16 wantsInput; // Is wave input wanted ? Int16 outputSocketBusy; // Output socket is busy with a sendto() UInt32 broadcastBeginTime; // Time (ticks) when subscribed to broadcast Int16 broadcastEnd; // Terminate broadcast connection ? struct sockaddr_in name; // Target system address struct sockaddr_in ctrl; // Target system control port address char desKeyString[256]; // DES key string char deskey[9]; // Destination DES key, if any char rtpdeskey[9]; // Destination RTP DES key, if any char vatdeskey[9]; // Destination VAT DES key, if any char ideaKeyString[256]; // IDEA key string char ideakey[17]; // Destination IDEA key, if any char blowfishKeyString[256]; // Blowfish key string char blowfish_spec; // Is Blowfish key specified? UInt32 blowfishkey[1042]; // Generated Blowfish key char pgpkeymd5[16]; // Inbound MD5 signature of PGP session key char pgpkey[17]; // Inbound PGP-transmitted session key char pgpFileName[MAX_PATH]; // Inbound PGP decoded file name, if strlen > 0 char opgpUserList[256]; // Outbound PGP user ID list char opgpkey[17]; // Outbound PGP-transmitted session key char opgpFileName[MAX_PATH]; // Outbound PGP decoded file name, if strlen > 0 char otpFileName[MAX_PATH]; // One-time pad file name char otp[BUFL]; // One-time pad Int16 multicast_scope; // Multicast scope (time-to-live) Int16 squelch; // Squelch Int16 ring; // Ring Int16 debugging; // Debug mode Int16 debugReq; // Debug output requested by remote ? Int16 loopback; // Loopback mode Int16 saveKeys; // Save keys in connection file char connectionFileName[MAX_PATH]; // Connection file name for save gsm gsmh; // GSM handle Int16 rseq; // Robust mode packet sequence number short protocol; // Transmission protocol short localLoopback; // Local loopback enabled ? struct localLoop *llhead, // Local loopback packet chain *lltail; char session_id[4]; // VAT/RTP session identifier Int16 sendSDEStimer; // Sent RTP/VAT ID timer Int16 buttonUpTimer; // Button up timer running LPSTR uname; // User name, if known char email[256]; // User E-mail address, if known Int16 face_stat; // Face retrieval status UInt32 face_address; // Address of current block request Int16 face_retry; // Timeout retry count Int16 face_timeout; // Timeout interval LPSTR face_bmp; // In memory copy of face .bmp file Int16 face_is_gif; // Face being received as .gif file UInt32 face_file_length; // Length of face file being received Int16 face_shown; // Face bitmap currently displayed ? Int16 bSentOutgoingMessage; // Sent outgoing message already. void FAR* pfnCallback; // The function to call when a packet of data arrives. } SFCALL, *PSFCALL; typedef struct _SFUSER { void FAR* next; // Next connection UInt32 ltime; // Time of last update UInt32 ssrc; // Session source descriptor UInt32 naddr; // Internet address UInt16 port; // Port address LPSTR cname; // Canonical name LPSTR name; // User name LPSTR email; // Electronic mail address LPSTR phone; // Telephone number LPSTR loc; // Geographic location LPSTR tool; // Application name } SFUSER, *PSFUSER; typedef struct _SFPACKET { UInt32 compression; // Compression and encryption flags for this packet. char sendinghost[16]; // Host data used internally by engine. struct { UInt32 buffer_len; // The length of the encoded buffer char buffer_val[BUFL]; // The actual compressed and/or encrypted bytes. } buffer; UInt32 dwSequence; // Packet sequence number for this call, used to detect lost or duplicate packets. } SFPACKET, *PSFPACKET; // Functions UInt16 SFAPI SFInitEngine (UInt16 MinVersion, UInt16 MaxVersion, PSFENGINE sfEngine); UInt16 SFAPI SFCallConnect (char* szAddress, PSFCALL* sfCall); UInt16 SFAPI SFCallConnectIP (IN_ADDR inAddress, PSFCALL* sfCall); UInt16 SFAPI SFCallGetOptions (PSFCALL sfCall); UInt16 SFAPI SFCallSetOptions (PSFCALL sfCall); UInt16 SFAPI SFCallTerminate (PSFCALL sfCall); UInt16 SFAPI SFDirectoryLookup (PSFUSER sfUser); UInt16 SFAPI SFDirectoryPublish (PSFUSER sfUser, UInt8 bPublish); UInt16 SFAPI SFCloseEngine (PSFENGINE sfEngine); UInt16 SFAPI SFEncodePacket (PSFCALL sfCall, PSFPACKET sfPacket, char* pSamples); UInt16 SFAPI SFDecodePacket (PSFCALL sfCall, PSFPACKET sfPacket, char* pSamples); UInt16 SFAPI SFShipPacket (PSFCALL sfCall, PSFPACKET sfPacket); #ifdef __cplusplus } #endif #endif // SFENGINE_H