DSMCC
15.3.1
|
00001 /******************************************************************************* 00002 * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org) 00003 * Copyright © 2004 Ocean Blue Software Ltd 00004 * Copyright © 2001 Koninklijke Philips Electronics N.V 00005 * 00006 * This file is part of a DTVKit Software Component 00007 * You are permitted to copy, modify or distribute this file subject to the terms 00008 * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org 00009 * 00010 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 00011 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 00012 * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 00013 * 00014 * If you or your organisation is not a member of DTVKit then you have access 00015 * to this source code outside of the terms of the licence agreement 00016 * and you are expected to delete this and any associated files immediately. 00017 * Further information on DTVKit, membership and terms can be found at www.dtvkit.org 00018 *******************************************************************************/ 00029 /* 00030 -- getpModuleInfo_source - Common Code 00031 -- 00032 -- Get module info from module info descriptor in DII message (compatible with 00033 -- contiguous or managed/MemSeq memory) 00034 -- 00035 -- Uses/assumes the following vars: 00036 -- valid, mpModuleInfoDescStart, *pModuleInfo 00037 -- 00038 -- mpModuleInfoDescStart references ('points' to) first byte of module info 00039 -- descriptor, valid (BOOLEAN) indicates whether module info was valid 00040 -- 00041 -- mpModuleInfoDescStart = const pUInt8/MemSeqRef, 00042 -- pModuleInfo = pModuleInfo_t 00043 -- valid = BOOLEAN 00044 -- 00045 -- NB. Only DVB (UK Profile 1) spec. currently implemented 00046 */ 00047 00048 { 00049 MemPtr mpModuleInfoDesc; 00050 U8BIT tapsCount; 00051 U8BIT userInfoLength; 00052 MemPos currPos, endPos; 00053 U8BIT descriptorTag; 00054 U8BIT descriptorLength; 00055 U8BIT ui8 = 0; 00056 U16BIT ui16 = 0; 00057 ui8 += 0; /* -- stop compiler warnings when no checking */ 00058 00059 dsmAssert(( mpModuleInfoDescStart != NULL )); 00060 dsmAssert(( pModuleInfo != NULL )); 00061 00062 00063 /* -- Open MemPtr for accessing module descriptor info */ 00064 MEMPTR_OPEN( mpModuleInfoDescStart, mpModuleInfoDesc ); 00065 00066 /* -- Read moduleId */ 00067 READ_UINT16( mpModuleInfoDesc, pModuleInfo->moduleId ); 00068 00069 /* -- Read moduleSize */ 00070 /* -- L0 check because 0 length modules are not useful */ 00071 READ_UINT32_L0CHK( mpModuleInfoDesc, pModuleInfo->moduleSize, 00072 pModuleInfo->moduleSize != 0, 00073 dsmDP2(("DATA ERROR: Module size = %u\n", pModuleInfo->moduleSize)), 00074 goto _return_False ); 00075 00076 #ifndef NDEBUG 00077 /* Initialise debug monitor flag */ 00078 pModuleInfo->blkRcvd = 0; 00079 #endif 00080 00081 /* -- Read moduleVersion */ 00082 READ_UINT8( mpModuleInfoDesc, pModuleInfo->version ); 00083 00084 /* -- Skip pModuleInfoLength */ 00085 SET_POS_REL( mpModuleInfoDesc, 1 ); 00086 00087 /* -- mpModuleInfoDesc -> BIOP::pModuleInfo */ 00088 00089 /* -- Read moduleTimeOut */ 00090 READ_UINT32( mpModuleInfoDesc, pModuleInfo->profileInfo.moduleTimeout ); 00091 00092 /* -- Read blockTimeOut */ 00093 READ_UINT32( mpModuleInfoDesc, pModuleInfo->profileInfo.blockTimeout ); 00094 00095 /* -- Read minBlockTime */ 00096 READ_UINT32( mpModuleInfoDesc, pModuleInfo->profileInfo.minBlockTime ); 00097 00098 /* -- Read/check tapsCount >= 1 (DVB) */ 00099 /* -- L1 check because this should be correct */ 00100 READ_UINT8_L1CHK( mpModuleInfoDesc, tapsCount, tapsCount >= 1, 00101 dsmDP2(("DATA ERROR: Module info tapsCount (< 1) = %u\n", ui8)), 00102 goto _return_False ); 00103 00104 00105 /* -- mpModuleInfoDesc -> start of first BIOP::Tap */ 00106 00107 /* -- Read info from first Tap */ 00108 /* -- Read tapId - TODO: Not required ? */ 00109 READ_UINT16( mpModuleInfoDesc, pModuleInfo->profileInfo.tap.id ); 00110 00111 /* -- tapUse = BIOP_OBJECT_USE (in BIOP::pModuleInfoMessage - DVB/UK DTT) */ 00112 /* -- L0 check because this must be correct */ 00113 READ_UINT16_L0CHK( mpModuleInfoDesc, ui16, ui16 == BIOP_OBJECT_USE, 00114 dsmDP2(("DATA ERROR: Module info 1st tapUse (!= BIOP_OBJECT_USE) = %u\n", ui16)), 00115 goto _return_False ); 00116 00117 /* -- Read associationTag */ 00118 READ_UINT16( mpModuleInfoDesc, pModuleInfo->profileInfo.tap.associationTag ); 00119 00120 /* -- selectorLength = 0 (DVB/UK DTT) */ 00121 ADV_UINT8_L2CHK( mpModuleInfoDesc, ui8, ui8 == 0x00, 00122 dsmDP2(("DATA ERROR: Module info tap selectorLength (!= 0) = %u\n", ui8)), 00123 goto _return_False ); 00124 00125 /* -- Skip any remaining Taps */ 00126 while (--tapsCount > 0) { 00127 00128 /* -- Skip tapId, tapUse, associationTag */ 00129 SET_POS_REL( mpModuleInfoDesc, 6 ); 00130 00131 /* -- Read selectorLength */ 00132 READ_UINT8( mpModuleInfoDesc, ui8 ); 00133 00134 /* -- Skip selector field */ 00135 SET_POS_REL( mpModuleInfoDesc, (S32BIT)ui8 ); 00136 } 00137 00138 00139 /* -- mpModuleInfoDesc -> userInfoLength */ 00140 00141 /* -- Read userInfoLength */ 00142 READ_UINT8( mpModuleInfoDesc, userInfoLength ); 00143 00144 /* -- Initialise module compression info */ 00145 pModuleInfo->profileInfo.compressed = FALSE; 00146 pModuleInfo->profileInfo.originalSize = pModuleInfo->moduleSize; 00147 00148 if (userInfoLength > 0) { 00149 00150 /* -- Search module descriptor loop for compressed module descriptor */ 00151 00152 /* -- Determine end position of search data */ 00153 GET_POS( mpModuleInfoDesc, currPos ); 00154 endPos = currPos + userInfoLength; 00155 00156 while (currPos < endPos) { 00157 00158 /* -- mpModuleInfoDesc -> current module descriptor */ 00159 00160 /* -- Read descriptorTag */ 00161 READ_UINT8( mpModuleInfoDesc, descriptorTag ); 00162 00163 /* -- Read descriptorLength */ 00164 READ_UINT8( mpModuleInfoDesc, descriptorLength ); 00165 00166 switch (descriptorTag ) 00167 { 00168 case DESCRIPTOR_COMP_MODULE_TAG: 00169 /* -- compressionMethod LSNibble == 0x8 (DVB/RFC1950)*/ 00170 /* -- L1 check because this should be correct (subsequently 00171 -- zlib inflate should also check compression method of 00172 -- module data/stream before attempting to decompress) */ 00173 ADV_UINT8_L1CHK( mpModuleInfoDesc, ui8, (ui8 & 0x0f) == 0x08, 00174 dsmDP2(("DATA ERROR: Module info compressionMethod (!= 0x08) = %u\n", ui8)), 00175 goto _return_False ); 00176 00177 /* -- Indicate module is compressed */ 00178 pModuleInfo->profileInfo.compressed = TRUE; 00179 00180 /* -- Read originalSize */ 00181 READ_UINT32( mpModuleInfoDesc, 00182 pModuleInfo->profileInfo.originalSize ); 00183 00184 /* -- Found the required info so quit the loop */ 00185 break; 00186 00187 case DESCRIPTOR_MHP_CACHING_PRIORITY: 00188 /* TS 101 812, section B.2.2.4.2 Caching priority descriptor */ 00189 READ_UINT32( mpModuleInfoDesc, pModuleInfo->priority ); 00190 READ_UINT32( mpModuleInfoDesc, pModuleInfo->transparency ); 00191 break; 00192 00193 default: 00194 dsmDP2(("INFO: Module - Unknown descriptor tag: %x\n", descriptorTag)); 00195 /* -- Skip this module descriptor */ 00196 SET_POS_REL( mpModuleInfoDesc, (S32BIT)descriptorLength ); 00197 } 00198 00199 /* -- Find next (potential) descriptor start position */ 00200 GET_POS( mpModuleInfoDesc, currPos ); 00201 } 00202 } 00203 00204 /* -- If we get here, assume we have recovered the required data */ 00205 valid = TRUE; 00206 goto _return; 00207 00208 /* -- NB. Final position of mpModuleInfoDesc ptr is irrelevant */ 00209 00210 _return_False: 00211 valid = FALSE; 00212 00213 _return: 00214 MEMPTR_CLOSE( mpModuleInfoDesc ); 00215 DEBUG_CHK( valid == TRUE, 00216 dsmDP1(("ERROR: getpModuleInfo failure (invalid)\n")) ); 00217 } 00218 00219 00220 /*----------------------------------------------------------------------------*/ 00221 00222 00223