📄 protocol.h
字号:
/* protocol.h -- Intercom protocol definition Copyright (C) 2001-2003 Shane Wegner This file is part of Intercom. Intercom is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. Intercom is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of version 2 of the GNU General Public License along with Intercom; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA To contact the author, please send email to shane@cm.nu. *//* $Id: protocol.h,v 1.14 2003/02/13 20:22:49 shane Exp $ */#ifndef PROTOCOL_H#define PROTOCOL_H#ifdef HAVE_STDINT_H#include <stdint.h>#else#include <inttypes.h>#endif#define INTERCOM_PROTOCOL_VERSION 1struct pkt_header {uint16_t p_len; /* Length of the packet including this header */uint16_t p_type;};/* Valid packet types *//* Upon connection, both peers must send a hello packet */#define PKT_TYPE_HELLO 0 /* Hello packet */#define PKT_TYPE_CALL 1 /* Incoming call */#define PKT_TYPE_CALLRESPONSE 2 /* Response to incoming call */#define PKT_TYPE_ERROR 3 /* Error condition */#define PKT_TYPE_AUDIOSTART 4 /* Ok to start sending audio data */#define PKT_TYPE_USRTEXT 5 /* User to user text message */struct pkt_hello {uint32_t proto_version;char username[128]; /* username or other identifying string */char clientname[128]; /* Client name and version */};struct audio_params {uint8_t compression;uint8_t bitwidth; /* Currently always 16 */uint32_t rate; /* Sampling rate */};struct cryptinfo {uint8_t type;char challenge[128]; /* Challenge string */char challenge_sha1[20]; /* SHA-1 of decrypted challenge string */};#define CALL_CRYPT_NONE 0#define CALL_CRYPT_DES 1#define CALL_CRYPT_BLOWFISH 2struct pkt_call {struct cryptinfo cryptinfo;struct audio_params aparams; /* audio format caller will be sending */};struct pkt_callresponse {uint8_t responsecode;struct audio_params aparams; /* Format responder will be sending */};#define CALLRESPONSE_ACCEPT 0 /* Call was accepted, ok to send audio data */#define CALLRESPONSE_DENY 1 /* Call was denied */struct pkt_error {uint16_t errorcode;char errormsg[120]; /* Textual error message (null terminated). */};/* If this bit is set, the error is fatal and the call is invalidated. */#define PKT_ERROR_FATAL 0x8000#define PKT_ERROR_PKTUNKNOWN 0 /* Unknown packet type */#define PKT_ERROR_PKTORDER 1 /* Unexpected or out of order packet */#define PKT_ERROR_AUDIOFMT 2 /* Cannot support your audio format */#define PKT_ERROR_PROTO_VERSION 3 /* Cannot support this protocol version */#define PKT_ERROR_NOCRYPT 4 /* Encryption type not supported or encryption not enabled */#define AUDIO_COMPRESSION_NONE 0#define AUDIO_COMPRESSION_GSM 1 #define AUDIO_COMPRESSION_G711U 2#define AUDIO_COMPRESSION_G711A 3#define AUDIO_COMPRESSION_G721 4#define AUDIO_COMPRESSION_G723_24 5#define AUDIO_COMPRESSION_G723_40 6struct pkt_audiostart {uint16_t dport; /* UDP data port to which to send audio data */};/* Packet type USRTEXT has no associated structure. The data is simply *//* the text message which is not null terminated. */struct pkt_udpaudio {uint16_t datalen;uint32_t sequence;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -