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

📄 typedef.h

📁 m80320 VoIP DSP驱动源码
💻 H
字号:
#ifndef TYPEDEF_H
#define TYPEDEF_H
#include "Vxworks.h"
#include "install.h"
#include "ros_ex.h"

#define LITTLE_ENDIAN_MODE      1

/***********************************************************************

    Constants Definitions :

************************************************************************/
#define FAX_V21_DATA_PAYLOAD_SIZE 4
#define DIGIT_BUF_SIZE          32
#define EVENT_BUF_SIZE          10
#define SAMPLES_PER_MSEC        8

#define MAX_VOIP_SIZE           1600      /*bytes*/
#define PACKET_CMD_HDR_SIZE     16   /*bytes*/
#define MAX_PAYLOAD_SIZE        160  /*bytes*/
#define MAX_M                   12
#define MAX_M_BUF_SIZE          (MAX_PAYLOAD_SIZE*MAX_M) /*bytes*/
#define DTMF_BUF_SIZE           6         /*bytes*/
#define DTMF_FRAME_LEN          12
#define DTMF_PAYLOAD_LEN        8
#define MOD_PRI_SEQ_NUM         16
#define DTMF_PERIOD             20
#define MAX_DTMF_EDGE_LOCATION  19
#define MOD_DTMF_SEQ_NUM        256
#define MAX_DTMF_HANGOVER       3
#define DTMF_GENERATOR_HANGOVER 1000       /*milisec*/
#define MAX_REDUNDANCY_DEPTH                      1
#define RTP_REDUNDANCY_ADDITIONAL_HDR_LENGTH_LOG2 2  /*extra redundancy header is 4 bytes*/
#define MAX_REDUNDANCY_HDR_SIZE ((MAX_REDUNDANCY_DEPTH<<RTP_REDUNDANCY_ADDITIONAL_HDR_LENGTH_LOG2)+1)

#define G723_HIGH_RATE_PAYLOAD_SIZE  24
#define G723_LOW_RATE_PAYLOAD_SIZE   20
#define G723_SID_PAYLOAD_SIZE        4
#define G723_RTP_PAYLOAD_TYPE        4


#define RTP_DTMF_PAYLOAD_TYPE             100
#define RTP_FAX_PAYLOAD_TYPE              101
#define RTP_FAX_BYPASS_PAYLOAD_TYPE       102
#define RTP_MODEM_BYPASS_PAYLOAD_TYPE     103
#define RTP_REDUNDANCY_PAYLOAD_TYPE       104
#define RTP_MODEM_RELAY_PAYLOAD_TYPE      105


/*Big Endian <-> Little Endian conversions*/
#define ULONG_BE2LE(x)((((x) & 0x000000FF) << 24) |\
                       (((x) & 0x0000FF00) <<  8) |\
                       (((x) & 0x00FF0000) >>  8) |\
                       (((x) & 0xFF000000) >> 24))
#define ULONG_LE2BE(x) ULONG_BE2LE(x)
#define ULONG_SWAP(x) ULONG_BE2LE(x)
#define UL_SWAP(x) ULONG_BE2LE(x)

#define USHORT_BE2LE(x) ((((x) & 0x00FF) << 8) | (((x) & 0xFF00) >> 8))
#define USHORT_LE2BE(x) USHORT_BE2LE(x)
#define US_SWAP(x) USHORT_BE2LE(x)

#define BE2LE_24_BIT(x) ((((x) & 0x0000FF) << 16) | (((x) & 0xFF0000) >> 16) | ((x)&0x00FF00))
#define LE2BE_24_BIT(x) BE2LE_24_BIT(x)
#define U24BIT_SWAP(x) BE2LE_24_BIT(x)


/***********************************************************************

    Error Codes Constants Definitions:

************************************************************************/
/*error codes - RTCP*/
#define INVALID_RTCP_SDES_PACKET_ERROR  0x7001
#define INVALID_RTCP_PACKET_TYPE_ERROR  0x7002
#define INVALID_RTCP_PACKET_ERROR       0x7003
#define INVALID_RTCP_EXT_LEN_ERROR      0x7004
#define INVALID_SET_RTCP_EXT_LEN_ERROR  0x7005

/*fractional representation of 1mSec (0.001 Sec)*/
#define FracmSecTime            ((unsigned int)0x00418937)
#define FracmSecTimeShort       ((unsigned int)0x0041)
#define ROUND_TRIP_WRAP_AROUND  (65536*1000) 

#define RTCP_TIME(CHID)     (RecordRTPTimeStamp[CHID]/SAMPLES_PER_MSEC/1000)
#define RTCP_NTP_SEC(CHID)  (RecordRTPTimeStamp[CHID]/SAMPLES_PER_MSEC/1000)
#define RTCP_NTP_FRAC(CHID) (unsigned int)(((RecordRTPTimeStamp[CHID]/SAMPLES_PER_MSEC)%1000)*FracmSecTime)
#define RTCP_TIMESTAMP_TO_65536  (65536/(SAMPLES_PER_MSEC*1000))

enum TECLength
{
    ECLength10MSec=0,
    ECLength15MSec=1,
    ECLength20MSec=2,
    ECLength25MSec=3,
    ECLength30MSec=4,
    ECLength35MSec=5,
    ECLength40MSec=6
};

enum TVFDCode
{
    AnswerTone  = 0,
    Data        = 1,
    Voice       = 2, 
    Fax         = 3  /*T.38FAX*/
    /*注: 是走T.38 FAX或者是T.30透传,由上层通告到驱动*/
}M803XX_STREAM_TYPE;


/***********************************************************************

    VoIP Types declerations:

     Enumerations:
       TPayloadCode
       TDigitType
       TFaxRate
       TFaxMode
       TRTCPType
       TRTCPSdesType


     Structures
       TRTCPHeader
       TRTCPRR
       TDTMFElement
       TRxDTMFElement
       TRxCASElement
       TDigit
       TRxStatistics
       TTxChannelInfo
       TRxChannelInfo
       TChannelInfo
       TTrunkPackCfg

************************************************************************/

enum TFaxRate
{
        Rate2400bps=0,
        Rate4800bps=1,
        Rate7200bps=2,
        Rate9600bps=3,
        Rate12000bps=4,
        Rate14400bps=5
};


/*RTCP packet type*/
enum TRTCPType
{
    RTCP_SR   = 200,
    RTCP_RR   = 201,
    RTCP_SDES = 202,
    RTCP_BYE  = 203,
    RTCP_APP  = 204
};


/*RTCP event type*/
enum TRTCPEventType
{
    RTCP_RR_Rx = 0,
    RTCP_SR_Rx = 1,
    RTCP_RR_Tx = 2,
    RTCP_SR_Tx = 3
};

#if INSTALL_ON_LITTLE_ENDIAN
typedef struct
{
  UINT8   RTPCSRCCnt:4; /*RTP CSRC count (0)*/
  UINT8   RTPExt    :1; /*RTP extension (0)*/
  UINT8   RTPPadding:1; /*RTP padding (0)*/
  UINT8   RTPVer    :2; /*RTP version (2)*/
  UINT8   RTPPT     :7; /*RTP payload type*/
  UINT8   RTPMarker :1; /*RTP marker (0)*/
  UINT16         RTPSeqNum;    /*RTP sequence number*/
  UINT32         RTPTimeStamp; /*RTP Time stamp*/
  UINT32         RTPSSRC;      /*RTP synchronization source identifier*/
}STRUCTURE_ATTR TRTPHeader;

/*RTCP common header word*/
typedef struct
{
    unsigned int   RTCPCount:5;   /* varies by packet type (RR's or SDES's) */
    unsigned int   RTCPPadding:1; /* padding flag */
    unsigned int   RTCPVer:2;     /* protocol version */
    unsigned int   RTCPPT:8;      /* RTCP packet type */
    unsigned short RTCPLength;    /* pkt len in words, w/o this word */
    unsigned int   RTCPSsrc;      /* data source reporting */
} TRTCPHeader;
#else
typedef struct
{
  UINT8   RTPVer    :2; /*RTP version (2)*/
  UINT8   RTPPadding:1; /*RTP padding (0)*/
  UINT8   RTPExt    :1; /*RTP extension (0)*/
  UINT8   RTPCSRCCnt:4; /*RTP CSRC count (0)*/
  UINT8   RTPMarker :1; /*RTP marker (0)*/
  UINT8   RTPPT     :7; /*RTP payload type*/
  UINT16  RTPSeqNum;    /*RTP sequence number*/
  UINT32  RTPTimeStamp; /*RPT Time stamp*/
  UINT32  RTPSSRC;      /*RTP synchronization source identifier*/
}STRUCTURE_ATTR TRTPHeader;

/*RTCP common header word*/
typedef struct
{
    unsigned int   RTCPVer:2;     /* protocol version */
    unsigned int   RTCPPadding:1; /* padding flag */
    unsigned int   RTCPCount:5;   /* varies by packet type (RR's or SDES's) */
    unsigned int   RTCPPT:8;      /* RTCP packet type */
    unsigned short RTCPLength;    /* pkt len in words, w/o this word */
    unsigned int   RTCPSsrc;      /* data source reporting */
} TRTCPHeader;
#endif

/*Reception report block (RR)*/
typedef struct
{
    unsigned int RTCPSsrc;        /* data source being reported */
    unsigned int RTCPFraction:8;  /* fraction lost since last SR/RR */
    int          RTCPCumLost:24;  /* cumul. no. pkts lost (signed!) */
    unsigned int RTCPLast_seq;    /* extended last seq. no. received */
    unsigned int RTCPJitter;      /* interarrival jitter */
    unsigned int RTCPLsr;         /* last SR packet from this source */
    unsigned int RTCPDlsr;        /* delay since last SR packet */
}  TRTCPRR;


/*Sender report block (SR)*/
typedef struct
{
    unsigned int RTCPNtpSec;  /* NTP timestamp */
    unsigned int RTCPNtpFrac;
    unsigned int RTCPTs;      /* RTP timestamp */
    unsigned int RTCPPsent;   /* packets sent */
    unsigned int RTCPOsent;   /* octets sent */
    TRTCPRR  RR[1];    /* variable-length list of RR's*/
} TRTCPSR;

/*BYE block*/
typedef struct
{
    unsigned char RTCPLength;   /* length of item (in octets) */
    char RTCPReason[1];         /* reason for leaving ,text, not null-terminated */
}  TRTCPBye;

/*SDES item*/
typedef struct
{
    unsigned char RTCPType;     /* type of item (rtcp_sdes_type_t) */
    unsigned char RTCPLength;   /* length of item (in octets) */
    char RTCPData[1];               /* text, not null-terminated */
} TRTCPSdesItem;


/*SDES chunk*/
typedef struct
{
    TRTCPSdesItem item[1];
} TRTCPSdes;

/*union of all reports types*/
typedef union
{
    TRTCPRR        RR[1];
    TRTCPSR        SR;
    TRTCPSdes      SDES;
    TRTCPBye       BYE;
} RTCPReport;


/*One RTCP packet*/
typedef struct
{
    TRTCPHeader Common;     /* common header */
    RTCPReport  Report;    /* report part */
} TRTCP;


typedef struct
{
  unsigned int  ReportType;    /*according to enum TRTCPEventType*/
  unsigned int  PacketCount;   /*Number of packets transmitted*/
  unsigned int  OctetCount;    /*Number of Octets transmitted*/
  unsigned int  Jitter;        /*Delay Jitter [msec]*/
  unsigned int  RoundTrip;     /*Local<->Remote round trip delay [msec]*/
  unsigned int  FractionLost;  /*Fraction of packets lost [8lsb]*/
  unsigned int  CumLost;       /*Number of packets lost [24lsb]*/
  unsigned int  ExtHighSeq;    /*Extended highest sequence number recieved*/
}TRTCPRepElement;



struct TDigit
{
        int      DigitOnTime;       /*[milisec] period of active digit*/
        int      InterDigitTime;    /*[milisec] time of silence between last and current digit*/
        int      Digit;             /*Digit Code, -1 if to be ignored*/
        int      SignalingSystem;   /*signaling system to generate/detect this digit according to enum TSignalingType*/
};


struct TFaxStatusInfo
{
    int  Relay_Bypass;        /*=1 if using FaxRelay, =0 if using FaxBypass*/
    int  Calling_Answering;   /*=1 if this is the Calling Fax, =0 if this is the answering Fax (relevant only if using FaxRelay)*/
    int  NumberOfFaxPages;    /*Number of pages received/sent (invalid in ECM mode)*/
};


typedef struct
{
        unsigned int   RTPSSRC;       /* channel's SSRC*/
        unsigned int   RTPCNAMELength;/* channel's RTCP canonical name length*/
        char           RTPCNAME[255]; /* channel's RTCP canonical name*/
        unsigned short MaxSeq;        /* highest seq. number seen */
        unsigned int   Cycles;        /* shifted count of seq. number cycles */
        unsigned int   BaseSeq;       /* base seq number */
        unsigned int   BadSeq;        /* last 'bad' seq number + 1 */
        unsigned int   Received;      /* packets received */
        unsigned int   ExpectedPrior; /* packet expected at last interval */
        unsigned int   ReceivedPrior; /* packet received at last interval */
        unsigned int   Transit;       /* relative trans time for prev pkt */
        unsigned int   RTCPJitter;    /* estimated jitter */
        unsigned int   RemoteSSRC;    /* the SSRC of the remote source */
        char           RemoteCNAME[255];/* the CNAME of the remote source */
        unsigned int   SomePacketReceived; /* marks if first RTCP packet received */
        unsigned int   PacketRcvdSinceSR; /* marks if first RTCP packet received */
        unsigned int   PacketSentSinceSR; /* marks if first RTCP packet received */
        unsigned int   SenderPacketCount;  /* counts how many packets were sent */
        unsigned int   SenderOctetCount;   /* counts how many byte (octets) were sent */
        unsigned int   Lsr;           /* last SR timestamp (32 middle bits of its NTP timestamp) */
        unsigned int   LastSRArrival; /* time of arrival of last SR or RR ,to calculate DLSR */
        char           TxExtension[255];/*For RTCP RR/SR extensions - to be sent*/
        unsigned int   TxExtLength;   /*For RTCP RR/SR extensions - to be sent*/
        unsigned int   SendExtOnce;   /*For RTCP RR/SR extensions*/
        char           RxExtension[255];/*For RTCP RR/SR received extensions*/
        unsigned int   RxExtLength;   /*For RTCP RR/SR received extensions*/
}TRTCPInfo;

unsigned int RTCPJitter(UINT8 CID,unsigned int Timestamp,unsigned int Arrival,int Update);
void  RTCPInitSeq(UINT8 CID, unsigned short seq); /*changed by zhouwx 1999/12/2*/
int   RTCPUpdateSeq(UINT8 CID, unsigned short Seq,unsigned int ssrc);
int   RTCPPacketValidate(char *Buffer,unsigned int PacketLen);
char *RTCPBuildSRPacket(UINT8 CID,char *Buffer);
char *RTCPBuildRRPacket(UINT8 CID,char *Buffer);
void RTCPDecodePacket(UINT8 CID, char *RTCPFrame, int FrameLen);
void RTCPUpdateTxStatistics(UINT8 CID, int TxOctets);
void RTCPSendPacket(UINT8 CID);

void RTCPDecodeSRPacket(UINT8 CID, char *RTCPFrame);
void RTCPDecodeRRPacket(UINT8 CID, char *RTCPFrame);

void RTCPSRLostFill(TRTCP *LRTCPPacket,UINT8 CID);
void RTCPRRLostFill(TRTCP *LRTCPPacket,UINT8 CID);
void InitRTCPInfo(TRTCPInfo *pCh,UINT8 CID);
void M803xx_SendRtcpPacket(UINT8 PortNo);

#endif   /*end of #ifndef TYPEDEF_H*/

⌨️ 快捷键说明

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