📄 baseelements.h
字号:
/////////////////
//Wenson Chen.
//Innofidei.com
//2007/Dec/01
/*++ Demux Base Core Code for CMMB, which provided the demuxing service
Copyright (C) 2007-2008 Innofidei, Inc.
Module Name: Demux.h
Abstract:
Master include file for CMMB Demuxing Service
--*/
#ifndef FRAMEDEF_H
#define FRAMEDEF_H
#include "FrameHeader.h"
#include "rtp.h"
const int AUDIO_UNIT_CNTHOLD_BYTE = 1;
const int ONE_AUDIO_UNIT_PARAMS_HOLD_BYTE = 5;
const int DATA_UNIT_CNTHOLD_BYTE = 1;
const int ONE_DATA_UNIT_PARAMS_HOLD_BYTE = 3;
const int STARTCODE_HEADER_LEN_BYTE = 5;
const int MIN_HEADER_LEN_BYTE = 15;
const int MIN_SUBHEADER_LEN_BYTE = 8;
const int MIN_ONEVIDEOUNIT_PARAMSHOLD_BYTE = 3;
// Frame Header structure definition
enum
{
STATUS_DEMUX_FRAME_HEADER_CRC_ERROR = 0x000000001,
STATUS_DEMUX_SUB_HEADER_CRC_ERROR = 0x000000002,
STATUS_DEMUX_AUDIO_HEADER_CRC_ERROR = 0x000000004,
STATUS_DEMUX_VIDEO_HEADER_CRC_ERROR = 0x000000008,
STATUS_DEMUX_DATA_HEADER_CRC_ERROR = 0x000000010
};
enum CONTROL_TABLE_ID
{
TABLE_SN_NIT = 1,
TABLE_SN_CMCT = 2,
TABLE_SN_CSCT = 3,
TABLE_SN_SMCT = 4,
TABLE_SN_SSCT = 5,
TABLE_SN_ESG = 6,
TABLE_SN_CA = 7,
TABLE_SN_EMERGENCY =0x10
};
struct CXpe
{
WORD startFlag:1;
WORD endFlag:1;
WORD flag:1; //Apr 15, 2008, 0 means XPE, while 1 means XPE_FEC
WORD pl:12;
BYTE crcFlag:1;
BYTE transSN:7;
//struct
//{
BYTE serviceModeFlag:1;
BYTE reserve:7;
//};
WORD dataLength;//exist if ((startFlag==1) && (endFlag==0))
struct
{
BYTE FEC_type;
BYTE FEC_Length;
BYTE FEC[255];
}fec;
BYTE checksum8;
bool ParseHeader(LPBYTE& rlpIn, DWORD len);
};
//*********************************************************************************************************
//* NIT table structure definition */
//*********************************************************************************************************
struct CNIT
{
BYTE nTableSn;
BYTE nNitUpdateSn;
WORD MJDDate;
BYTE nHour;
BYTE nMinute;
BYTE nSecond;
char CountryCode[4];
BYTE nNetLevel;
BYTE NetNameLen;
WORD wZoneNetNum;
char NetName[40];
BYTE nFreq;
BYTE nNearNetNum;
BYTE nBandWidth;
BYTE nOtherFreqDotNum;
DWORD dwCenterFreq;
struct COtherFreqDotPara
{
BYTE nFreq;
BYTE nBandWidth;
DWORD dwFreq;
}tOtherFreqDot[MAX_FREQ_DOT_NUM];
struct CNeighborZonePara
{
BYTE nNetLevel;
WORD wNetZoneSn;
DWORD dwFreq;
BYTE nFreq;
BYTE nBandWidth;
}tNeighborZoneInfo[MAX_NEIGHBOR_ZONE_NUM];
DWORD Parse(LPBYTE lpIn, DWORD dwNitLen);
};
//*********************************************************************************************************
//* MCT table structure definition
//*********************************************************************************************************
struct CFrameDescPara
{
BYTE nMfId; //6bits
BYTE demod; // the combination of RS, INterLeave and Modulator
BYTE nScramble; //3 bits
BYTE nSubFrameNum;
BYTE nSlotNum; //count of time slot, 6 bits
BYTE nStartTs; //It is not allowed for using uncontinous slots
struct CSubFramAndServicePara
{
BYTE nSubFrame;
WORD wServiceId;
} tSubFramAndService[MAX_SUBFRAME_NUM];
};
struct CMCT
{
BYTE nTableSn;
BYTE nFreq;
BYTE nMctUpdateSn;
BYTE nMfNum; //复用帧数量
CFrameDescPara tFrameDesc[MAX_MF_NUM];
DWORD Parse(LPBYTE lpIn, DWORD dwMctLen);
};
//*********************************************************************************************************
//* CSCT table structure definition
//*********************************************************************************************************
#ifdef USE_SCT
struct CSCT
{
BYTE nTableSn ;
BYTE nSegSn ;
WORD wSegLen ;
BYTE nSegNum;
BYTE nSctUpdateSn;
WORD wServiceNum;
struct CServiceDesc
{
WORD wServiceSign;
BYTE nFreq;
} pServiceDesc[512];
DWORD Parse(LPBYTE lpIn, DWORD dwSctLen);
};
#endif
//*********************************************************************************************************
//* ESG Basic description table structure definition
//*********************************************************************************************************
struct CESG // Basic ESG information
{
DWORD nTableSn :8; // Table ID
DWORD nUpdateSn :4; // Update Sequence
DWORD nSegLen :12; // Segment Length
DWORD nSegSn :4; // Segment Sequence number
DWORD nSegNumber :4; // Segment count
DWORD nNetworkLevel:4; // Network Level
DWORD nNetworkID :12; // Network ID
DWORD nReserve :2;
DWORD nTimeDis :6; // Time Zone
DWORD nCharType :4; // Language Zone
DWORD nEsgServiceCount:4; // ESG Channel Count
struct CEsgDesc
{
BYTE nReserve; //
BYTE nEsgIndexId; // ESG Index ID
WORD nEsgId; // ESG Service ID
}tEsgService[16];
BYTE nReserve2 :4; //ESG Service Count
BYTE nDataTypeCount :4; //data type count
struct CEsgDataTypeDesc
{
BYTE nDataType; //数据类型标识:4
BYTE nDataCount; //数据块数量 8 bits
struct CDataDesc //数据块描述
{
BYTE nDataTypeId; //数据块标识8bits
BYTE nDataVersion:4; //数据块版本号4bits
BYTE ESGServiceIndexId:4; //ESG业务索引标识4bits
} tDataDesc[256];
}tEsgDataType[16];
int Parse(LPBYTE lpIn, WORD);
};
//*********************************************************************************************************
//* CEBFragment table structure definition
//*********************************************************************************************************
struct API CEBFragment //
{
BYTE nTableSn; //
BYTE nConcurrentMsgCount;// 4 bits
BYTE nSquence; // 2 bits
WORD wLen; //
BYTE mProtocolVer; //4 bits
BYTE mProtocolLowestVer; //4 bits
BYTE mNetLevel; //4 bits
WORD mNetID; //12 bits
WORD mMsgID; //16 bits
BYTE mSegSN; //8 bits, 0~255
BYTE mLastSegSN; //8 bits, 0~255
WORD wDataLen; //13 bits.
LPBYTE lpMessage;
int Parse(LPBYTE lpIn, WORD);
};
// The user has to combine emergency message before do CEBContent::Parse
struct API CEBContent
{
BYTE tiggerFlag; // 1 bits
BYTE msgType; // 7 bits, Whether, earthquake, fire, traffic......
BYTE msgLevel; // 3 bits
BYTE charset; // 3 bits, 0: GB2312-1980, other is invalid
WORD mjdDate; // the time and date the message send
BYTE nHour;
BYTE nMinute;
BYTE nSecond;
DWORD duration; // 20 bits, duration in seconds
BYTE langCount; // 4 bits
struct CLangDesc // Language
{
char language[4]; // 24, e.g. "zho"
BYTE refServiceFlag; // 1
BYTE publisherNameLen;// low 8 bits
WORD textLen; // 12 bit
WORD refService; // 16
char *text;
char *publisherName;
} mLangDesc[16];
BYTE auxInfoCount; // 4 bit
struct CAuxDesc
{
/*
0, 5-255 reserved
1 audio/wav
2 video/avi
3 img/gif
4 img/png
*/
BYTE auxDataType;
WORD auxDataLen;
char* auxData;
}mAuxDesc[16];
BYTE triggerMsgLevel; // 3 bits
BYTE nBandWidth; // Bandwidth, 4 bits
BYTE nFreq; // Target freq in which the message is broadcasting, 8 bits
BYTE netLevel; // Network Level
WORD netID; // Network ID, 16 bits
DWORD dwCenterFreq; // frequency, which is no use, 32 bits
int Parse(LPBYTE lpIn, WORD length);
};
//*********************************************************************************************************
//* SubFrame Header structure definition */
//*********************************************************************************************************
struct CVideoStreamPara
{
BYTE nAlgorithmType;
BYTE nFrameRate;
bool nBRFlag; /*video bit rate flag*/
bool nPPFlag; /*picture display flag*/
bool bResolution; /*Video Resolution flag*/
bool bFR; /*Frame Rate flag*/
BYTE nXCoordinate;
BYTE nYCoordinate;
BYTE nDisplayPRI;
WORD wBitRate;
WORD wXResolution;
WORD wYResolution;
};
struct CAudioStreamPara
{
BYTE nAlgorithmType;
bool nBitRateFlag;
bool nSampleRateFlag;
bool nStreamDescFlag;
BYTE nSampleRate;
WORD wBitRate;
DWORD dwAudioStreamDesc;
};
struct CDataDataSegHeader
{
BYTE nUnitNum;
struct CDataUnitPara
{
BYTE nUnitType;
WORD wUnitLen;
}tDataUnitParams[MAX_DATAUNIT_NUM];
DWORD Parse(LPBYTE&, DWORD inU8DataSubFrameLen);
};
struct CSubframe
{
BYTE nHeaderLen;
BYTE nStartTimeFlag :1;
BYTE nVideoSegLenFlag:1;
BYTE nAudioSegLenFlag:1;
BYTE nDataSegLenFlag :1;
BYTE nExtendZoneFlag :1;
BYTE nCyptInd :2; //2008, Jan
BYTE packetMode :1; //2008, Jan
BYTE nVideoStreamNum:3;//3 bits
BYTE nAudioStreamNum:3;//3 bits
BYTE ECMInd; //1 bit //2008, Jan
DWORD dwStartTimeStamp;
DWORD dwVideoSegLen; //21 bits
DWORD dwAudioSegLen; //21 bits
DWORD dwDataSegLen ; //21 bits
CVideoStreamPara taVideoPara[MAX_VIDEO_SEG_NUM];
CAudioStreamPara taAudioPara[MAX_AUDIO_SEG_NUM];
DWORD ParseHeader(LPBYTE lpIn);
};
struct CVideoUnitPara
{
WORD wUnitLen;
BYTE nType;
BYTE nStreamNum;
BYTE nEndFlag;
BYTE nRTFlag;
WORD wRelativeTime;
};
struct CVideoDataSegHeader
{
WORD wSegHeaderLen;
WORD wVideoUnitNum;
CVideoUnitPara tVideoUnitParams[MAX_VIDEO_UNIT_NUM];
int getHeaderLen()
{
return 4 + wSegHeaderLen;
}
DWORD Parse(LPBYTE&);
};
/*********************************************************************************************************/
/* Audio data segment Header structure definition */
/*********************************************************************************************************/
struct CAudioUnitPara
{
WORD wUnitLen;
BYTE nTrackNum;
BYTE nReserve;
WORD wRelativeTime;
};
struct CAudioDataSegHeader
{
BYTE nUnitNum;
CAudioUnitPara tAudioUnitParams[MAX_AUDIO_UNIT_NUM];
int getHeaderLen()
{
return (1 + nUnitNum) * 5;
}
DWORD Parse(LPBYTE&);
};
inline BYTE MakeDemod(BYTE rsType, BYTE interleaveMode, BYTE ldpcRate, BYTE modulateType)
{
return (modulateType<<6) | ldpcRate | (interleaveMode<<2) | (rsType<<4);
}
struct API CService
{
WORD serviceid; //
BYTE serviceType; //
//0 AudioVideo
//1 ESG
//2 EMM
//3 Data Stream
//4 Audio
//5 Data File
BYTE serviceNameLen; //
BYTE serviceName[40]; // 2-40Bytes channel name, e.g. CCTV-1
BYTE demod; // the combination of the above four
BYTE freq; // Frequency
BYTE nts; // the count of timeslot
BYTE startTs; // the start timeslot
BYTE nSubFrame; // the subframe id
BYTE mfId; // Frame id
bool free; // true: free
};
struct CCA
{
BYTE tableId;
WORD Section_Length;
BYTE Update_Number;
BYTE Section_Number;
BYTE Section_Quantity;
struct
{
WORD CA_System_ID;
WORD Service_ID;
BYTE EMM_Data_Type;
BYTE ECM_Data_Type;
BYTE ECM_Transport_Type;
}section[256];
DWORD crc32;
DWORD Parse(LPBYTE, DWORD len);
};
/*********************************************************************************************************/
/* ESG data information structure definition */
/*********************************************************************************************************/
struct CProgramGuide
{
BYTE nRecordCount; // 2 bits
struct
{
WORD MJDate;
BYTE nHour;
BYTE nMinute;
BYTE nSecond;
WORD durationTime; // 16 bits
char language[4]; // 24 bits
BYTE themeLength; // 8 bits
LPBYTE theme; //
} record[4];
DWORD Parse(LPBYTE, DWORD len);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -