📄 sdcreceive.cpp
字号:
/* Shift by one bit to get information for next service */ iServRestr >>= 1; } } else { /* All services are supported */ AltFreq.veciServRestrict.Reset(1); } /* Set frequencies */ for (i = 0; i < iNumFreq; i++) AltFreq.veciFrequencies.Add(veciFrequencies[i]); /* Now apply temporary object to global struct (first check if new object is not already there) */ int iCurNumAltFreq = Parameter.AltFreqSign.vecAltFreq.Size(); _BOOLEAN bAltFreqIsAlreadyThere = FALSE; for (i = 0; i < iCurNumAltFreq; i++) { if (Parameter.AltFreqSign.vecAltFreq[i] == AltFreq) bAltFreqIsAlreadyThere = TRUE; } if (bAltFreqIsAlreadyThere == FALSE) Parameter.AltFreqSign.vecAltFreq.Add(AltFreq); } return FALSE;}/******************************************************************************\* Data entity Type 4 (Alternative frequency signalling: Schedule definition) *\******************************************************************************/_BOOLEAN CSDCReceive::DataEntityType4(CVector<_BINARY>* pbiData, const int iLengthOfBody, CParameter& Parameter, const _BOOLEAN bVersion){ /* Check length -> must be 4 bytes */ if (iLengthOfBody != 4) return TRUE; /* Schedule Id: this field indicates the Schedule Id for the defined schedule. Up to 15 different schedules with an individual Schedule Id (values 1 to 15) can be defined; the value 0 shall not be used, since it indicates "unspecified schedule" in data entity type 3 and 11 */ const int iScheduleID = (*pbiData).Separate(4); /* Day Code: this field indicates which days the frequency schedule (the following Start Time and Duration) applies to. The msb indicates Monday, the lsb Sunday. Between one and seven bits may be set to 1 */ const int iDayCode = (*pbiData).Separate(7); /* Start Time: this field indicates the time from when the frequency is valid. The time is expressed in minutes since midnight UTC. Valid values range from 0 to 1439 (representing 00:00 to 23:59) */ const int iStartTime = (*pbiData).Separate(11); /* Duration: this field indicates how long the frequency is valid starting from the indicated Start Time. The time is expressed in minutes. Valid values range from 1 to 16383 */ const int iDuration = (*pbiData).Separate(14); /* Error checking */ if ((iScheduleID == 0) || (iDayCode == 0) || (iStartTime > 1439) || (iDuration > 16383) || (iDuration == 0)) { return TRUE; } else return FALSE;}/******************************************************************************\* Data entity Type 5 (Application information data entity) *\******************************************************************************/_BOOLEAN CSDCReceive::DataEntityType5(CVector<_BINARY>* pbiData, const int iLengthOfBody, CParameter& Parameter){ /* Short ID (the short ID is the index of the service-array) */ const int iTempShortID = (*pbiData).Separate(2); /* Load data parameters class with current parameters */ CParameter::CDataParam DataParam = Parameter.GetDataParam(iTempShortID); /* Stream Id */ DataParam.iStreamID = (*pbiData).Separate(2); /* Packet mode indicator */ switch ((*pbiData).Separate(1)) { case 0: /* 0 */ DataParam.ePacketModInd = CParameter::PM_SYNCHRON_STR_MODE; /* Descriptor (not used) */ (*pbiData).Separate(7); break; case 1: /* 1 */ DataParam.ePacketModInd = CParameter::PM_PACKET_MODE; /* Descriptor */ /* Data unit indicator */ switch ((*pbiData).Separate(1)) { case 0: /* 0 */ DataParam.eDataUnitInd = CParameter::DU_SINGLE_PACKETS; break; case 1: /* 1 */ DataParam.eDataUnitInd = CParameter::DU_DATA_UNITS; break; } /* Packet Id */ DataParam.iPacketID = (*pbiData).Separate(2); /* Application domain */ switch ((*pbiData).Separate(4)) { case 0: /* 0000 */ DataParam.eAppDomain = CParameter::AD_DRM_SPEC_APP; break; case 1: /* 0001 */ DataParam.eAppDomain = CParameter::AD_DAB_SPEC_APP; break; default: /* 2 - 15 reserved */ DataParam.eAppDomain = CParameter::AD_OTHER_SPEC_APP; break; } /* Packet length */ DataParam.iPacketLen = (*pbiData).Separate(8); break; } /* Application data */ if (DataParam.ePacketModInd == CParameter::PM_SYNCHRON_STR_MODE) { /* Not used */ (*pbiData).Separate(iLengthOfBody * 8 - 8); } else if (DataParam.eAppDomain == CParameter::AD_DAB_SPEC_APP) { /* rfu */ (*pbiData).Separate(5); /* User application identifier */ DataParam.iUserAppIdent = (*pbiData).Separate(11); /* Data fields as required by DAB application specification, not used */ (*pbiData).Separate(iLengthOfBody * 8 - 32); } else { /* Not used */ (*pbiData).Separate(iLengthOfBody * 8 - 16); } /* Set new parameters in global struct */ Parameter.SetDataParam(iTempShortID, DataParam); return FALSE;}/******************************************************************************\* Data entity Type 7 (Alternative frequency signalling: Region definition) *\******************************************************************************/_BOOLEAN CSDCReceive::DataEntityType7(CVector<_BINARY>* pbiData, const int iLengthOfBody, CParameter& Parameter, const _BOOLEAN bVersion){ /* Region Id: this field indicates the identifier for this region definition. Up to 15 different geographic regions with an individual Region Id (values 1 to 15) can be defined; the value 0 shall not be used, since it indicates "unspecified geographic area" in data entity type 3 and 11 */ const int iRegionID = (*pbiData).Separate(4); /* Latitude: this field specifies the southerly point of the area in degrees, as a 2's complement number between -90 (south pole) and +90 (north pole) */ const int iLatitude = (*pbiData).Separate(8); /* Longitude: this field specifies the westerly point of the area in degrees, as a 2's complement number between -180 (west) and +179 (east) */ const int iLongitude = (*pbiData).Separate(9); /* Latitude Extent: this field specifies the size of the area to the north, in 1 degree steps; the value of Latitude plus the value of Latitude Extent shall be equal or less than 90 */ const int iLatitudeEx = (*pbiData).Separate(7); /* Longitude Extent: this field specifies the size of the area to the east, in 1 degree steps; the value of Longitude plus the value of Longitude Extent may exceed the value +179 (i.e. wrap into the region of negative longitude values) */ const int iLongitudeEx = (*pbiData).Separate(8); /* n CIRAF Zones: this field carries n CIRAF zones (n in the range 0 to 16). The number of CIRAF zones, n, is determined from the length field of the header - 4 */ for (int i = 0; i < iLengthOfBody - 4; i++) { /* Each CIRAF zone is coded as an 8 bit unsigned binary number in the range 1 to 85 */ const int iCIRAFZone = (*pbiData).Separate(8); if ((iCIRAFZone == 0) || (iCIRAFZone > 85)) return TRUE; /* Error *//* TODO: To check whether a certain longitude value is inside the specified longitude range, the following formula in pseudo program code shall be used (with my_longitude in the range -180 to +179): inside_area = ( (my_longitude >= longitude) AND (my_longitude <= (longitude + longitude_extent) ) OR ( ((longitude + longitude_extent) >= +180) AND (my_longitude <= (longitude + longitude_extent - 360)) )*/ } /* Error checking */ if ((iRegionID == 0) || (iLatitude + iLatitudeEx > 90)) { return TRUE; /* Error */ } else return FALSE;}/******************************************************************************\* Data entity Type 8 (Time and date information data entity) *\******************************************************************************/_BOOLEAN CSDCReceive::DataEntityType8(CVector<_BINARY>* pbiData, const int iLengthOfBody, CParameter& Parameter){ /* Check length -> must be 3 bytes */ if (iLengthOfBody != 3) return TRUE; /* Decode date */ CModJulDate ModJulDate((*pbiData).Separate(17)); Parameter.iDay = ModJulDate.GetDay(); Parameter.iMonth = ModJulDate.GetMonth(); Parameter.iYear = ModJulDate.GetYear(); /* UTC (hours and minutes) */ Parameter.iUTCHour = (*pbiData).Separate(5); Parameter.iUTCMin = (*pbiData).Separate(6); return FALSE;}/******************************************************************************\* Data entity Type 9 (Audio information data entity) *\******************************************************************************/_BOOLEAN CSDCReceive::DataEntityType9(CVector<_BINARY>* pbiData, const int iLengthOfBody, CParameter& Parameter){ /* Check length -> must be 2 bytes */ if (iLengthOfBody != 2) return TRUE; /* Init error flag with "no error" */ _BOOLEAN bError = FALSE; /* Short ID (the short ID is the index of the service-array) */ const int iTempShortID = (*pbiData).Separate(2); /* Load audio parameters class with current parameters */ CParameter::CAudioParam AudParam = Parameter.GetAudioParam(iTempShortID); /* Stream Id */ AudParam.iStreamID = (*pbiData).Separate(2); /* Audio coding */ switch ((*pbiData).Separate(2)) { case 0: /* 00 */ AudParam.eAudioCoding = CParameter::AC_AAC; break; case 1: /* 01 */ AudParam.eAudioCoding = CParameter::AC_CELP; break; case 2: /* 10 */ AudParam.eAudioCoding = CParameter::AC_HVXC; break; default: /* reserved */ bError = TRUE; break; } /* SBR flag */ switch ((*pbiData).Separate(1)) { case 0: /* 0 */ AudParam.eSBRFlag = CParameter::SB_NOT_USED; break; case 1: /* 1 */ AudParam.eSBRFlag = CParameter::SB_USED; break; } /* Audio mode */ switch (AudParam.eAudioCoding) { case CParameter::AC_AAC: /* Channel type */ switch ((*pbiData).Separate(2)) { case 0: /* 00 */ AudParam.eAudioMode = CParameter::AM_MONO; break; case 1: /* 01 */ AudParam.eAudioMode = CParameter::AM_P_STEREO; break; case 2: /* 10 */ AudParam.eAudioMode = CParameter::AM_STEREO; break; default: /* reserved */ bError = TRUE; break; } break; case CParameter::AC_CELP: /* rfa */ (*pbiData).Separate(1); /* CELP_CRC */ switch ((*pbiData).Separate(1)) { case 0: /* 0 */ AudParam.bCELPCRC = FALSE; break; case 1: /* 1 */ AudParam.bCELPCRC = TRUE; break; } break; case CParameter::AC_HVXC: /* HVXC_rate */ switch ((*pbiData).Separate(1)) { case 0: /* 0 */ AudParam.eHVXCRate = CParameter::HR_2_KBIT; break; case 1: /* 1 */ AudParam.eHVXCRate = CParameter::HR_4_KBIT; break; } /* HVXC CRC */ switch ((*pbiData).Separate(1)) { case 0: /* 0 */ AudParam.bHVXCCRC = FALSE; break; case 1: /* 1 */ AudParam.bHVXCCRC = TRUE; break; } break; } /* Audio sampling rate */ switch ((*pbiData).Separate(3)) { case 0: /* 000 */ AudParam.eAudioSamplRate = CParameter::AS_8_KHZ; break; case 1: /* 001 */ AudParam.eAudioSamplRate = CParameter::AS_12KHZ; break; case 2: /* 010 */ AudParam.eAudioSamplRate = CParameter::AS_16KHZ; break; case 3: /* 011 */ AudParam.eAudioSamplRate = CParameter::AS_24KHZ; break; default: /* reserved */ bError = TRUE; break; } /* Text flag */ switch ((*pbiData).Separate(1)) { case 0: /* 0 */ AudParam.bTextflag = FALSE; break; case 1: /* 1 */ AudParam.bTextflag = TRUE; break; } /* Enhancement flag */ switch ((*pbiData).Separate(1)) { case 0: /* 0 */ AudParam.bEnhanceFlag = FALSE; break; case 1: /* 1 */ AudParam.bEnhanceFlag = TRUE; break; } /* Coder field */ if (AudParam.eAudioCoding == CParameter::AC_CELP) { /* CELP index */ AudParam.iCELPIndex = (*pbiData).Separate(5); } else { /* rfa 5 bit */ (*pbiData).Separate(5); } /* rfa 1 bit */ (*pbiData).Separate(1); /* Set new parameters in global struct */ if (bError == FALSE) { Parameter.SetAudioParam(iTempShortID, AudParam); return FALSE; } else return TRUE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -