/**************************************************************************** * Copyright (c) 2004 DST Technologies Inc. All Rights Reserved. * * file name : dsthalPsiScteSi.c * Author: jina * Description: SCTE SI Table/Section Parse/Get/Monitor * * * update info ************************************************************* * ***************************************************************************/ #include "dsthalcommon.h" #include "dsthaldebug.h" #include #include #include #include "dsthalerror.h" #include "dsthalPsiMemChain.h" #include "dsthalPsiBitBuffer.h" #include "dsthalPsiAtscPsip.h" #include "dsthalPsiMpegSi.h" #include "dsthalPsiScteSi.h" #ifdef DMALLOC #include #endif /****************************************************************************** * Global variable declaration ******************************************************************************/ /****************************************************************************** * Imported variable declaration ******************************************************************************/ extern DS_U32 gdhlPsiDbgLvl; /****************************************************************************** * Imported function declaration ******************************************************************************/ /****************************************************************************** * Local definitions ******************************************************************************/ #define MEM_LIMIT 0x00004000*5 /* 16k */ #define SI_BASE_PID 0x1FFC #define MAX_SECTION_LENGTH 4093 #define SI_PROTOCOL_VERSION 0 #ifndef HAL_ABS #define HAL_ABS(x) ( (x) >= 0 )?(x):-(x) #endif #define checkMemoryError(p) if (p == NULL) {err = DHL_FAIL_OUT_OF_RESOURCE ; \ DHL_DbgPrintf( 0, DHLDBG_PSI, "[Error] %d lines \n",__LINE__); \ goto ParseExit; } #define checkMemoryError2(p) if (p == NULL) { DHL_DbgPrintf( 0, DHLDBG_PSI, "[Error] %d lines \n",__LINE__); \ return(DHL_FAIL_OUT_OF_RESOURCE); } /****************************************************************************** * Local typedefs ******************************************************************************/ /****************************************************************************** * Local variables declaration ******************************************************************************/ /****************************************************************************** * Local function prototypes ******************************************************************************/ /*============================================================================== void SiSyncEventProc (PSIEvent event, PSIControl *psiCtl, DS_U32 userParam) event: Callback function to catch monitor events. psiCtl: Callback data. userParam: Request ID for PSI layer. Callback function which catches PSI events on the filters set using the MonitorPSIPid() function. ==============================================================================*/ static void cbSiSyncEventProc ( PSIEvent event, DHL_TBL_HANDLE hTblHandle , DS_U32 userParam) { PSIDataArray_t *desc; DHL_RESULT err; PSIEventProcData_t *procData = (PSIEventProcData_t *)userParam; switch (event) { case psiDataReceived: err = DD_PSI_ReadPSIData( hTblHandle, &desc); if (err) { DHL_DbgPrintf( 0, DHLDBG_PSI, " ReadPSIData returned 0x%x\n", err); } else { procData->desc = desc; } procData->err = err; if( procData->hEvent ) //AtiCore_EventSet(/*(ACL_HANDLE)*/(procData->hEvent)); OS_GiveSemaphore(procData->hEvent); break; default: break; } } /*input argumentÀÎ sectionArr´Â raw data °¡ ¾Æ´Ï¶ó, ÀÌ¹Ì parsingµÈ sectionµéÀÌ´Ù.*/ DHL_RESULT DHL_PSI_ParseNit( DS_U8 **sectionArr , nitPtr_t *nitPtr ) { DS_U8 numSections; int recordNumbers = 0; nitSectionPtr_t nitSectPtr; DS_U16 i,j; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; memId_t memId = NULL; DHL_RESULT err = DHL_OK; DS_U8 subTableType; int iDescriptorCount = 0; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the ParseNit....\r\n"); #endif if (sectionArr == NULL || (nitPtr == NULL)) { return DHL_FAIL_NULL_POINTER; } nitSectPtr =(nitSectionPtr_t)(sectionArr[0]); if (nitSectPtr == NULL) { return DHL_FAIL_NULL_POINTER; } else { numSections = nitSectPtr->last_section_number + 1; subTableType = nitSectPtr->table_subtype; } #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseNit : numSections = %d , subTableType = %d\r\n" , numSections , subTableType); #endif /* now verify all other sections are present */ for (i=1; iCRC32 = 0; /* Get the total number of channels in all sections */ recordNumbers = 0; for (i=0; inumber_of_records; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseNit : %d-th section - recordNums = %d\r\n", i , recordNumbers); #endif } (*nitPtr)->number_of_records = recordNumbers; switch( subTableType ) { case st_CDS: /*allocate space for CDS records....*/ if(recordNumbers > 0) { (*nitPtr)->CDSs = (CDSPtr_t)memChainAlloc(memId , recordNumbers*sizeof(CDS_t)); checkMemoryError((*nitPtr)->CDSs); } break; case st_MMS: /*allocate space for MMS records....*/ if(recordNumbers > 0) { (*nitPtr)->MMSs = (MMSPtr_t)memChainAlloc(memId , recordNumbers*sizeof(MMS_t)); checkMemoryError((*nitPtr)->MMSs); } break; } /*switch( subTableType )*/ /* Parse each section and copy records */ recordNumbers = 0; for (i=0; itable_version_number = nitSectPtr->table_version_number; (*nitPtr)->protocol_version = nitSectPtr->protocol_version; (*nitPtr)->first_index = nitSectPtr->first_index; (*nitPtr)->transmission_medium = nitSectPtr->transmission_medium; (*nitPtr)->table_subtype = nitSectPtr->table_subtype; if( nitSectPtr->descriptors_length > 0 ) { DS_U8 *pDescriptor = nitSectPtr->descriptor; DS_U8 iDescriptorGo = 0; DS_U8 iRemainDescriptorLength = 0; /*revision detection descriptor´Â Ç×»ó ¸Ç óÀ½ ¿Â´Ù. ÀÌ´Â section parsingÈÄ¿£ µû·Î ÀúÀåÇÒ Çʿ䰡 ¾øÀ¸¹Ç·Î Á¦¿ÜÇÑ´Ù.*/ if( pDescriptor[0] == Revision_Detection_Descriptor_tag ) { iDescriptorGo += 5; } iRemainDescriptorLength = nitSectPtr->descriptors_length - iDescriptorGo ; if( iRemainDescriptorLength > 0) { (*nitPtr)->descriptor = (DS_U8 *)memChainAlloc( memId , iRemainDescriptorLength ); checkMemoryError( (*nitPtr)->descriptor ); (*nitPtr)->descriptors_length = iRemainDescriptorLength; memcpy( (*nitPtr)->descriptor , &(pDescriptor[iDescriptorGo]) , iRemainDescriptorLength ); } } /*if( nitSectPtr->descriptors_length > 0 )*/ } switch( subTableType ) { case st_CDS: /*copy CDS records of each section to a total table....*/ for( j = 0 ; j < nitSectPtr->number_of_records ; j++) { memcpy( &((*nitPtr)->CDSs[recordNumbers]) , &(nitSectPtr->CDSs[j]) , sizeof(CDS_t)); iDescriptorCount = nitSectPtr->CDSs[j].descriptors_count; if( iDescriptorCount > 0 ) { generalDescriptor_t *pDescriptorS = NULL; generalDescriptor_t *pDescriptorD = NULL; int descriptorIndex = 0; int descriptorDataLength = 0; (*nitPtr)->CDSs[recordNumbers].descriptor_structure = (generalDescriptorPtr_t)memChainAlloc( memId , iDescriptorCount*sizeof(generalDescriptor_t) ); checkMemoryError( (*nitPtr)->CDSs[recordNumbers].descriptor_structure ); for( descriptorIndex = 0 ; descriptorIndex < iDescriptorCount ; descriptorIndex++ ) { pDescriptorD = &( (*nitPtr)->CDSs[recordNumbers].descriptor_structure[descriptorIndex] ); pDescriptorS = &( nitSectPtr->CDSs[j].descriptor_structure[descriptorIndex] ); pDescriptorD->descriptor_tag = pDescriptorS->descriptor_tag; descriptorDataLength = pDescriptorD->descriptor_length = pDescriptorS->descriptor_length; if(!descriptorDataLength ) break; pDescriptorD->descriptor_data = (DS_U8 *)memChainAlloc( memId , descriptorDataLength ) ; memcpy( pDescriptorD->descriptor_data , pDescriptorS->descriptor_data , descriptorDataLength ); } } /*if( iDescriptorCount > 0 )*/ recordNumbers++; } /*for( j = 0 ; j < nitSectPtr->number_of_records ; j++)*/ break; case st_MMS: /*copy MMS records of each section to a total table....*/ for ( j = 0; j < nitSectPtr->number_of_records ; j++ ) { memcpy( &((*nitPtr)->MMSs[recordNumbers]) , &(nitSectPtr->MMSs[j]) , sizeof(MMS_t)); iDescriptorCount = nitSectPtr->MMSs[j].descriptors_count; if( iDescriptorCount > 0 ) { generalDescriptor_t *pDescriptorS = NULL; generalDescriptor_t *pDescriptorD = NULL; int descriptorIndex = 0; int descriptorDataLength = 0; (*nitPtr)->MMSs[recordNumbers].descriptor_structure = (generalDescriptorPtr_t)memChainAlloc( memId , iDescriptorCount*sizeof(generalDescriptor_t) ); checkMemoryError( (*nitPtr)->MMSs[recordNumbers].descriptor_structure ); for( descriptorIndex = 0 ; descriptorIndex < iDescriptorCount ; descriptorIndex++ ) { pDescriptorD = &( (*nitPtr)->MMSs[recordNumbers].descriptor_structure[descriptorIndex] ); pDescriptorS = &( nitSectPtr->MMSs[j].descriptor_structure[descriptorIndex] ); pDescriptorD->descriptor_tag = pDescriptorS->descriptor_tag; descriptorDataLength = pDescriptorD->descriptor_length = pDescriptorS->descriptor_length; if(!descriptorDataLength ) break; pDescriptorD->descriptor_data = (DS_U8 *)memChainAlloc( memId , descriptorDataLength ) ; memcpy( pDescriptorD->descriptor_data , pDescriptorS->descriptor_data , descriptorDataLength ); } } /*if( iDescriptorCount > 0 )*/ recordNumbers++; } /*for ( j = 0; j < nitSectPtr->number_of_records ; j++ )*/ break; } /*switch( subTableType )*/ #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "before : %d -th nit sect crc = 0x%x , nit crc = 0x%x \r\n" , i , nitSectPtr->CRC32 , (*nitPtr)->CRC32 ); #endif (*nitPtr)->CRC32 += (nitSectPtr->CRC32); } /*for (i=0; ilast_section_number + 1; subTableType = nttSectPtr->table_subtype; } #ifdef _SI_PARSE_DEBUG_MSG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseNtt : numSections = %d , subTableType : %d\r\n ", numSections , subTableType); #endif /* now verify all other sections are present */ for (i=1; iCRC32 = 0; /* Get the total number of channels in all sections */ for (i=0; inumber_of_SNS_records; #ifdef _SI_PARSE_DEBUG_MSG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseNtt : %d-th section : recordNumbers = %d\r\n", i , recordNumbers); #endif } (*nttPtr)->number_of_SNS_records = recordNumbers; if( subTableType == st_SNS && (recordNumbers > 0) ) { (*nttPtr)->SNS_records = (snsRecord_t *)memChainAlloc( memId , recordNumbers*sizeof(snsRecord_t)); checkMemoryError((*nttPtr)->SNS_records); } /* Parse each section and copy records */ recordNumbers = 0; for (i=0; itable_version_number = nttSectPtr->table_version_number; (*nttPtr)->protocol_version = nttSectPtr->protocol_version; (*nttPtr)->ISO_639_language_code = nttSectPtr->ISO_639_language_code; (*nttPtr)->transmission_medium = nttSectPtr->transmission_medium; (*nttPtr)->table_subtype = nttSectPtr->table_subtype; if( nttSectPtr->descriptors_length > 0 ) { DS_U8 *pDescriptor = nttSectPtr->descriptor; DS_U8 iDescriptorGo = 0; DS_U8 iRemainDescriptorLength = 0; /*revision detection descriptor´Â Ç×»ó ¸Ç óÀ½ ¿Â´Ù. ÀÌ´Â section parsingÈÄ¿£ µû·Î ÀúÀåÇÒ Çʿ䰡 ¾øÀ¸¹Ç·Î Á¦¿ÜÇÑ´Ù.*/ if( pDescriptor[0] == Revision_Detection_Descriptor_tag ) { iDescriptorGo += 5; } iRemainDescriptorLength = nttSectPtr->descriptors_length - iDescriptorGo ; if( iRemainDescriptorLength > 0) { (*nttPtr)->descriptor = (DS_U8 *)memChainAlloc( memId , iRemainDescriptorLength ); checkMemoryError( (*nttPtr)->descriptor ); (*nttPtr)->descriptors_length = iRemainDescriptorLength; memcpy( (*nttPtr)->descriptor , &(pDescriptor[iDescriptorGo]) , iRemainDescriptorLength ); } } /*if( nttSectPtr->descriptors_length > 0 )*/ } /*if (i == 0)*/ for( j = 0 ; j < nttSectPtr->number_of_SNS_records ; j++ ) { memcpy( &((*nttPtr)->SNS_records[recordNumbers]) , &(nttSectPtr->SNS_records[j]) , sizeof(snsRecord_t) ); jCount = nttSectPtr->SNS_records[j].name_length; if( jCount > 0 ) { (*nttPtr)->SNS_records[recordNumbers].source_name = (DS_U8 *)memChainAlloc( memId , jCount*sizeof(DS_U8) ); checkMemoryError( (*nttPtr)->SNS_records[recordNumbers].source_name ); memcpy( (*nttPtr)->SNS_records[recordNumbers].source_name ,nttSectPtr->SNS_records[j].source_name , jCount ); } jCount = nttSectPtr->SNS_records[j].SNS_descriptors_count; if( jCount > 0 ) { generalDescriptor_t *pDescriptorS = NULL; generalDescriptor_t *pDescriptorD = NULL; int descriptorIndex = 0; int descriptorDataLength = 0; (*nttPtr)->SNS_records[recordNumbers].descriptor_structure = (generalDescriptorPtr_t)memChainAlloc( memId , jCount*sizeof(generalDescriptor_t) ); checkMemoryError( (*nttPtr)->SNS_records[recordNumbers].descriptor_structure ); for( descriptorIndex = 0 ; descriptorIndex < jCount ; descriptorIndex++ ) { pDescriptorD = &( (*nttPtr)->SNS_records[recordNumbers].descriptor_structure[descriptorIndex] ); pDescriptorS = &( nttSectPtr->SNS_records[recordNumbers].descriptor_structure[descriptorIndex] ); pDescriptorD->descriptor_tag = pDescriptorS->descriptor_tag; descriptorDataLength = pDescriptorD->descriptor_length = pDescriptorS->descriptor_length; if(!descriptorDataLength ) break; pDescriptorD->descriptor_data = (DS_U8 *)memChainAlloc( memId , descriptorDataLength ) ; memcpy( pDescriptorD->descriptor_data , pDescriptorS->descriptor_data , descriptorDataLength ); } } /*if( jCount > 0 )*/ recordNumbers++; /*this recordNumber is for counting SNS rerords....*/ } /*for( j = 0 ; j < nttSectPtr->number_of_SNS_records ; j++ )*/ #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "before : %d -th ntt sect crc = 0x%x , ntt crc = 0x%x \r\n" , i , nttSectPtr->CRC32 , (*nttPtr)->CRC32 ); #endif (*nttPtr)->CRC32 += (nttSectPtr->CRC32); } /*for (i=0; ilast_section_number + 1; subTableType = svctSectPtr->table_subtype; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseSvct : numSections = %d , subTableType = %d\r\n", numSections , subTableType); #endif /* now verify all other sections are present */ for (i=0; iCRC32 = 0; /* decide the total number of channels in all sections & alloc memory.*/ switch( subTableType ) { case st_VCM: #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseSvct : subTableType = st_VCM\r\n"); #endif for (i=0; iVCM ) recordNumbers += ((svctSectionPtr_t)(sectionArr[i]))->VCM->number_of_VC_records; } (*svctPtr)->VCM = (VCM_t *)memChainAlloc( memId , sizeof(VCM_t)); checkMemoryError( (*svctPtr)->VCM ); (*svctPtr)->VCM->number_of_VC_records = recordNumbers; if( recordNumbers > 0 ) { (*svctPtr)->VCM->virtual_channel = (virtualChannel_t *)memChainAlloc( memId , recordNumbers * sizeof(virtualChannel_t)); checkMemoryError( (*svctPtr)->VCM->virtual_channel ); } break; case st_DCM: #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseSvct : subTableType = st_DCM\r\n"); #endif for (i=0; iDCM ) recordNumbers += ((svctSectionPtr_t)(sectionArr[i]))->DCM->DCM_data_length; } (*svctPtr)->DCM = (DCM_t *)memChainAlloc( memId , sizeof(DCM_t)); checkMemoryError( (*svctPtr)->DCM ); (*svctPtr)->DCM->DCM_data_length = recordNumbers; if( recordNumbers > 0 ) { (*svctPtr)->DCM->DCM_data = (dcm_data_t *)memChainAlloc( memId , recordNumbers * sizeof(dcm_data_t)); checkMemoryError( (*svctPtr)->DCM->DCM_data ); } break; case st_ICM: #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseSvct : subTableType = st_ICM\r\n"); #endif for (i=0; iICM ) recordNumbers += ((svctSectionPtr_t)(sectionArr[i]))->ICM->record_count; } (*svctPtr)->ICM = (ICM_t *)memChainAlloc( memId , sizeof(ICM_t)); checkMemoryError( (*svctPtr)->ICM ); (*svctPtr)->ICM->record_count = recordNumbers; if( recordNumbers > 0 ) { (*svctPtr)->ICM->icmRecords = (icmRecord_t *)memChainAlloc( memId , recordNumbers * sizeof(icmRecord_t)); checkMemoryError( (*svctPtr)->ICM->icmRecords ); } break; } /*switch( subTableType )*/ /* Parse each section and copy records */ recordIndex = 0; for (i=0; i < numSections; i++) { /* Parse the section */ svctSectPtr = (svctSectionPtr_t)((sectionArr[i])); if (i == 0) { /* duplicate fields copied once */ (*svctPtr)->table_version_number = svctSectPtr->table_version_number; (*svctPtr)->protocol_version = svctSectPtr->protocol_version; (*svctPtr)->transmission_medium = svctSectPtr->transmission_medium; (*svctPtr)->table_subtype = svctSectPtr->table_subtype; (*svctPtr)->VCT_ID = svctSectPtr->VCT_ID; if( svctSectPtr->descriptors_length > 0 ) { DS_U8 *pDescriptor = svctSectPtr->descriptor; DS_U8 iDescriptorGo = 0; DS_U8 iRemainDescriptorLength = 0; /*revision detection descriptor´Â Ç×»ó ¸Ç óÀ½ ¿Â´Ù. ÀÌ´Â section parsingÈÄ¿£ µû·Î ÀúÀåÇÒ Çʿ䰡 ¾øÀ¸¹Ç·Î Á¦¿ÜÇÑ´Ù.*/ if( pDescriptor[0] == Revision_Detection_Descriptor_tag ) { iDescriptorGo += 5; } iRemainDescriptorLength = svctSectPtr->descriptors_length - iDescriptorGo ; if( iRemainDescriptorLength > 0) { (*svctPtr)->descriptor = (DS_U8 *)memChainAlloc( memId , iRemainDescriptorLength ); checkMemoryError( (*svctPtr)->descriptor ); (*svctPtr)->descriptors_length = iRemainDescriptorLength; memcpy( (*svctPtr)->descriptor , &(pDescriptor[iDescriptorGo]) , iRemainDescriptorLength ); } } /*if( nttSectPtr->descriptors_length > 0 )*/ } /*if (i == 0)*/ switch( subTableType ) { case st_VCM: if( i == 0 ) { (*svctPtr)->VCM->descriptors_included = svctSectPtr->VCM->descriptors_included; (*svctPtr)->VCM->splice = svctSectPtr->VCM->splice; (*svctPtr)->VCM->activation_time = svctSectPtr->VCM->activation_time; } for( j = 0 ; j < svctSectPtr->VCM->number_of_VC_records ; j++ ) { memcpy( &((*svctPtr)->VCM->virtual_channel[recordIndex]) , &(svctSectPtr->VCM->virtual_channel[j]) , sizeof(virtualChannel_t) ); countj = svctSectPtr->VCM->virtual_channel[j].descriptors_count; if( countj > 0 ) { generalDescriptor_t *pDescriptorS = NULL; generalDescriptor_t *pDescriptorD = NULL; int descriptorIndex = 0; int descriptorDataLength = 0; (*svctPtr)->VCM->virtual_channel[recordIndex].descriptor_structure = (generalDescriptorPtr_t)memChainAlloc( memId , countj*sizeof(generalDescriptor_t) ); checkMemoryError( (*svctPtr)->VCM->virtual_channel[recordIndex].descriptor_structure ); for( descriptorIndex = 0 ; descriptorIndex < countj ; descriptorIndex++ ) { pDescriptorD = &( (*svctPtr)->VCM->virtual_channel[recordIndex].descriptor_structure[descriptorIndex] ); pDescriptorS = &( svctSectPtr->VCM->virtual_channel[j].descriptor_structure[descriptorIndex] ); pDescriptorD->descriptor_tag = pDescriptorS->descriptor_tag; descriptorDataLength = pDescriptorD->descriptor_length = pDescriptorS->descriptor_length; if(!descriptorDataLength ) break; pDescriptorD->descriptor_data = (DS_U8 *)memChainAlloc( memId , descriptorDataLength ) ; memcpy( pDescriptorD->descriptor_data , pDescriptorS->descriptor_data , descriptorDataLength ); } } /*if( jCount > 0 )*/ ++recordIndex; /*this record index is for number of vc records....*/ } break; case st_DCM: if ( i == 0 ) (*svctPtr)->DCM->first_virtual_channel = svctSectPtr->DCM->first_virtual_channel; for( j = 0 ; j < svctSectPtr->DCM->DCM_data_length ; j++ ) { memcpy( &((*svctPtr)->DCM->DCM_data[recordIndex]) , &(svctSectPtr->DCM->DCM_data[j]) , sizeof(dcm_data_t) ); ++recordIndex; } break; case st_ICM: if( i == 0 ) (*svctPtr)->ICM->first_map_index = svctSectPtr->ICM->first_map_index; for( j = 0 ; j < svctSectPtr->ICM->record_count ; j++ ) { memcpy( &((*svctPtr)->ICM->icmRecords[recordIndex]) , &(svctSectPtr->ICM->icmRecords[j]) , sizeof(icmRecord_t)); ++recordIndex; } break; } /*switch( subTableType )*/ #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "before : %d -th svct sect crc = 0x%x , svct crc = 0x%x \r\n" , i , svctSectPtr->CRC32 , (*svctPtr)->CRC32 ); #endif (*svctPtr)->CRC32 += (svctSectPtr->CRC32); } /*for (i=0; i 4093) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "NIT: section_length=%d\r\n",section_length); err = DHL_FAIL_INVALID_PARAM; goto ParseExit; } /* create the bitBuffer */ err = bitBufferCreate(&bits,section+3,section_length); if (err) { goto ParseExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseExit; } /* allocate memory for nitSection */ nitSectionPtr = (nitSectionPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(nitSection_t)+sizeof(memId_t))) + 1); checkMemoryError(nitSectionPtr); /* parse section */ bitBufferSkipBits( bits ,3 ); /*zero : 3bits*/ nitSectionPtr->protocol_version = bitBufferGetBits(bits,5); /*5 bits*/ if (nitSectionPtr->protocol_version > SI_PROTOCOL_VERSION) { err = DHL_FAIL_INVALID_PARAM; goto ParseExit; } nitSectionPtr->first_index = bitBufferGetBits(bits,8); count_i = nitSectionPtr->number_of_records = bitBufferGetBits(bits,8); nitSectionPtr->transmission_medium = bitBufferGetBits(bits,4); nitSectionPtr->table_subtype = bitBufferGetBits(bits,4); switch( nitSectionPtr->table_subtype ) { case st_CDS : nitSectionPtr->CDSs = (CDSPtr_t)memChainAlloc(memId , count_i*sizeof(CDS_t)); checkMemoryError( nitSectionPtr->CDSs); for( i = 0 ; i < count_i ; i++ ) { int iDescriptorCount = 0; int iGo = 0; nitSectionPtr->CDSs[i].number_of_carriers = bitBufferGetBits(bits , 8); nitSectionPtr->CDSs[i].spacing_unit = bitBufferGetBits(bits , 1); bitBufferSkipBits(bits ,1); /*zero : 1bit*/ nitSectionPtr->CDSs[i].frequency_spacing = bitBufferGetBits(bits , 14); nitSectionPtr->CDSs[i].frequency_unit = bitBufferGetBits(bits , 1); nitSectionPtr->CDSs[i].first_carrier_frequency = bitBufferGetBits(bits , 15); iDescriptorCount = nitSectionPtr->CDSs[i].descriptors_count = bitBufferGetBits(bits,8); if( iDescriptorCount > 0 ) { int jGo = 0; int iDescriptorLength = 0; generalDescriptor_t *pDescriptor = NULL; nitSectionPtr->CDSs[i].descriptor_structure = (generalDescriptor_t *)memChainAlloc(memId , iDescriptorCount * sizeof(generalDescriptor_t)); checkMemoryError( nitSectionPtr->CDSs[i].descriptor_structure ); for( iGo = 0 ; iGo < iDescriptorCount ; iGo++) { pDescriptor = &(nitSectionPtr->CDSs[i].descriptor_structure[iGo]); pDescriptor->descriptor_tag = bitBufferGetBits(bits ,8); iDescriptorLength = pDescriptor->descriptor_length = bitBufferGetBits(bits, 8); if( iDescriptorLength > 0 ) { pDescriptor->descriptor_data = (DS_U8 *)memChainAlloc( memId , iDescriptorLength ); checkMemoryError( pDescriptor->descriptor_data ); } for( jGo = 0; jGo < iDescriptorLength ; jGo++ ) { pDescriptor->descriptor_data[jGo] = bitBufferGetBits(bits, 8); } } /*for( iGo = 0 ; iGo < iDescriptorCount ; iGo++)*/ } /*if( iDescriptorCount > 0 )*/ } /*for( i = 0 ; i < count+i ; i++ )*/ break; case st_MMS : nitSectionPtr->MMSs = (MMSPtr_t)memChainAlloc(memId , count_i*sizeof(MMS_t)); checkMemoryError( nitSectionPtr->MMSs); for( i = 0 ; i < count_i ; i++ ) { int iDescriptorCount = 0; int iGo = 0; nitSectionPtr->MMSs[i].transmission_system = bitBufferGetBits(bits , 4); nitSectionPtr->MMSs[i].inner_coding_mode = bitBufferGetBits(bits , 4); nitSectionPtr->MMSs[i].split_bitstream_mode = bitBufferGetBits(bits , 1); bitBufferSkipBits(bits , 2); /*zero : 2bit*/ nitSectionPtr->MMSs[i].modulation_format = bitBufferGetBits(bits , 5); bitBufferSkipBits(bits , 4); /*zero : 4bits*/ nitSectionPtr->MMSs[i].symbol_rate = bitBufferGetBits(bits ,28); iDescriptorCount = nitSectionPtr->MMSs[i].descriptors_count = bitBufferGetBits(bits,8); if( iDescriptorCount > 0 ) { int jGo = 0; int iDescriptorLength = 0; generalDescriptor_t *pDescriptor = NULL; nitSectionPtr->CDSs[i].descriptor_structure = (generalDescriptor_t *)memChainAlloc(memId , iDescriptorCount * sizeof(generalDescriptor_t)); checkMemoryError( nitSectionPtr->CDSs[i].descriptor_structure ); for( iGo = 0 ; iGo < iDescriptorCount ; iGo++) { pDescriptor = &(nitSectionPtr->CDSs[i].descriptor_structure[iGo]); pDescriptor->descriptor_tag = bitBufferGetBits(bits ,8); iDescriptorLength = pDescriptor->descriptor_length = bitBufferGetBits(bits, 8); if( iDescriptorLength > 0 ) { pDescriptor->descriptor_data = (DS_U8 *)memChainAlloc( memId , iDescriptorLength ); checkMemoryError( pDescriptor->descriptor_data ); } for( jGo = 0; jGo < iDescriptorLength ; jGo++ ) { pDescriptor->descriptor_data[jGo] = bitBufferGetBits(bits, 8); } } /*for( iGo = 0 ; iGo < iDescriptorCount ; iGo++)*/ } /*if( iDescriptorCount > 0 )*/ } /*for( i = 0 ; i < count_i ; i++ )*/ break; } /*switch( nitSectionPtr->table_subtype )*/ count_i = section_length - 4 - (bitBufferGetBytePointer(bits) - (section+3)); #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseNitSection : descriptorLength = %d\r\n" , count_i); #endif if( count_i > 0) { nitSectionPtr->descriptors_length = count_i; nitSectionPtr->descriptor = (DS_U8 *)memChainAlloc(memId , sizeof(DS_U8)*count_i); checkMemoryError( nitSectionPtr->descriptor ); for( i = 0 ; i < count_i ; i++ ) { nitSectionPtr->descriptor[i] = bitBufferGetBits( bits , 8 ); } } nitSectionPtr->CRC32 = bitBufferGetBits( bits , 32 ); /* parsing complete */ *(((memId_t *)nitSectionPtr)-1) = memId; memId = NULL; /* so memChain not deleted */ ParseExit: if (bits) { /* clean up the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the cvctSection memory */ memChainDestroy(memId); } *nitSectPtr = nitSectionPtr; return (err); } /*============================================================================== DHL_RESULT DHL_PSI_ParseNttSection (DS_U8 *section, nttSectionPtr_t *nttSectionPtr) *section: Pointer to the first byte of the section. *nttSectionPtr: Return pointer to a parsed NTT section. Parses an NTT section and returns the decoded section via the provided handle. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseNttSection (DS_U8 *section, nttSectionPtr_t *nttSectionPtr) { nttSectionPtr_t nttSectPtr = NULL; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U16 section_length; //DS_U16 table_id_extension; memId_t memId = NULL; bitBufferPtr_t bits = NULL; DS_S32 i; DS_S32 count_i; DHL_RESULT err = DHL_OK; int len = 0; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the ParseNttSection....\r\n"); #endif if( section == NULL) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseNttSection : bad parameter.\r\n"); return DHL_FAIL_INVALID_PARAM; } if( get_table_id(section) != tid_network_text_table ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseNttSection():invalid table_id"); return DHL_FAIL_INVALID_PARAM; } section_length = get_section_length(section); if (section_length > 4093) { DHL_DbgPrintf( 0, DHLDBG_PSI, "NTT: section_length=%d\r\n",section_length); err = DHL_FAIL_INVALID_PARAM; goto ParseExit; } /* create the bitBuffer */ err = bitBufferCreate(&bits,section+3,section_length); if (err) { goto ParseExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseExit; } /* allocate memory for ettSection */ nttSectPtr = (nttSectionPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(nttSection_t)+sizeof(memId_t))) + 1); checkMemoryError(nttSectPtr); /* parse section */ bitBufferSkipBits(bits, 3); /*zero : 3bits*/ nttSectPtr->protocol_version = bitBufferGetBits(bits, 5); nttSectPtr->ISO_639_language_code = bitBufferGetBits(bits,24); nttSectPtr->transmission_medium = bitBufferGetBits(bits, 4); nttSectPtr->table_subtype = bitBufferGetBits(bits, 4); #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseNttSection. ntt_subtype = %d\r\n" , nttSectPtr->table_subtype); #endif switch( nttSectPtr->table_subtype ) { case st_SNS : count_i = nttSectPtr->number_of_SNS_records = bitBufferGetBits(bits, 8); if( count_i > 0 ) { #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseNttSection. recordCount = %d\r\n", count_i); #endif nttSectPtr->SNS_records = (snsRecordPtr_t)memChainAlloc(memId, count_i*sizeof(snsRecord_t)); checkMemoryError( nttSectPtr->SNS_records ); } for( i = 0 ; i < count_i ; i++ ) { int applicationType = 0; int j = 0; int count_j = 0; applicationType = nttSectPtr->SNS_records[i].application_type = bitBufferGetBits(bits, 1); bitBufferSkipBits(bits, 7); /*zero : 7bits*/ if(applicationType) { nttSectPtr->SNS_records[i].application_ID = bitBufferGetBits(bits, 16); } else { nttSectPtr->SNS_records[i].source_ID = bitBufferGetBits(bits, 16); } count_j = nttSectPtr->SNS_records[i].name_length = bitBufferGetBits(bits, 8); if( count_j > 0 ) { nttSectPtr->SNS_records[i].source_name = (DS_U8 *)memChainAlloc(memId, count_j*sizeof(DS_U8)); for( j = 0 ; j < count_j ; j++) { nttSectPtr->SNS_records[i].source_name[j] = bitBufferGetBits(bits,8); } } count_j = nttSectPtr->SNS_records[i].SNS_descriptors_count = bitBufferGetBits(bits, 8); if( count_j > 0 ) { int iGo , jGo ; int iDescriptorLength = 0; generalDescriptor_t *pDescriptor = NULL; nttSectPtr->SNS_records[i].descriptor_structure = (generalDescriptor_t *)memChainAlloc(memId , count_j * sizeof(generalDescriptor_t)); checkMemoryError( nttSectPtr->SNS_records[i].descriptor_structure ); for( iGo = 0 ; iGo < count_j ; iGo++) { pDescriptor = &(nttSectPtr->SNS_records[i].descriptor_structure[iGo]); pDescriptor->descriptor_tag = bitBufferGetBits(bits ,8); iDescriptorLength = pDescriptor->descriptor_length = bitBufferGetBits(bits, 8); if( iDescriptorLength > 0 ) { pDescriptor->descriptor_data = (DS_U8 *)memChainAlloc( memId , iDescriptorLength ); checkMemoryError( pDescriptor->descriptor_data ); } for( jGo = 0; jGo < iDescriptorLength ; jGo++ ) { pDescriptor->descriptor_data[jGo] = bitBufferGetBits(bits, 8); } } /*for( iGo = 0 ; iGo < count_j ; iGo++)*/ } /*if( count_j > 0 )*/ /* //temporary..... for( j = 0 ; j < count_j ; j++ ) { nttSectPtr->SNS_records[i].descriptor[j] = bitBufferGetBits(bits, 8); } */ } /*for( i = 0 ; i < count_i ; i++ )*/ break; } /*switch( nttSectPtr->table_subtype )*/ len = HAL_ABS((DS_U32)bitBufferGetBytePointer(bits) - (DS_U32)(section+3) );/*current offset*/ count_i = section_length - len - 4/*crc count*/; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseNttSection : descriptorLength = %d\r\n" , count_i); #endif if( count_i > 0) { nttSectPtr->descriptors_length = count_i; nttSectPtr->descriptor = (DS_U8 *)memChainAlloc(memId , sizeof(DS_U8)*count_i); checkMemoryError( nttSectPtr->descriptor ); for( i = 0 ; i < count_i ; i++ ) { nttSectPtr->descriptor[i] = bitBufferGetBits( bits , 8 ); } } nttSectPtr->CRC32 = bitBufferGetBits( bits , 32 ); /* parsing complete */ *(((memId_t *)nttSectPtr)-1) = memId; memId = NULL; /* so memChain not deleted */ ParseExit: if (bits) { /* clean up the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the cvctSection memory */ memChainDestroy(memId); } *nttSectionPtr = nttSectPtr; return (err); } DHL_RESULT DHL_PSI_ParseDCM ( bitBufferPtr_t bits , memId_t memId , DCMPtr_t dcmPtr ) { int i = 0; int count_i = 0; if(bits == NULL || dcmPtr == NULL || memId == NULL) return DHL_FAIL_NULL_POINTER; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_ParseDCM.\n"); #endif bitBufferSkipBits(bits,4); /*zero : 4bits*/ dcmPtr->first_virtual_channel = bitBufferGetBits(bits,12); bitBufferSkipBits(bits,1); /*zero : 1bit*/ count_i = dcmPtr->DCM_data_length = bitBufferGetBits(bits,7); if(count_i > 0) { #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_ParseDCM : data length = %d\n" , count_i); #endif dcmPtr->DCM_data = (dcm_dataPtr_t)memChainAlloc(memId , count_i * sizeof(dcm_data_t)); checkMemoryError2( dcmPtr->DCM_data ); for( i = 0 ; i < count_i ; i++ ) { dcmPtr->DCM_data[i].range_defined = bitBufferGetBits(bits,1); dcmPtr->DCM_data[i].channels_count = bitBufferGetBits(bits,7); #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_ParseDCM : ranged_defined : %d , channels_count = %d\n", dcmPtr->DCM_data[i].range_defined , dcmPtr->DCM_data[i].channels_count); #endif } } /*if(count_i > 0)*/ return DHL_OK; } DHL_RESULT DHL_PSI_ParseICM ( bitBufferPtr_t bits ,memId_t memId , ICMPtr_t icmPtr ) { int count_i = 0 ; int i = 0; if( bits == NULL || icmPtr == NULL || memId == NULL) return DHL_FAIL_NULL_POINTER; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_ParseICM.\n"); #endif bitBufferSkipBits(bits, 4); /*zero : 4 bits*/ icmPtr->first_map_index = bitBufferGetBits(bits, 12); bitBufferSkipBits(bits,1); /*zero : 1bit*/ count_i = icmPtr->record_count = bitBufferGetBits(bits, 7); if(count_i > 0) { icmPtr->icmRecords = (icmRecordPtr_t)memChainAlloc(memId , count_i*sizeof(icmRecord_t)); checkMemoryError2(icmPtr->icmRecords); for( i = 0 ; i < count_i ; i++ ) { icmPtr->icmRecords[i].source_ID = bitBufferGetBits(bits,16); bitBufferSkipBits(bits,4); icmPtr->icmRecords[i].virtual_channel_number = bitBufferGetBits(bits,12); } } /*if(count_i > 0)*/ return DHL_OK; } DHL_RESULT DHL_PSI_ParseVCM ( bitBufferPtr_t bits , memId_t memId , VCMPtr_t vcmPtr ) { int count_i = 0; int i = 0; if(bits == NULL || vcmPtr == NULL || memId == NULL) return DHL_FAIL_NULL_POINTER; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_ParseVCM.\n"); #endif bitBufferGetBits(bits , 2); /*zero : 2 bits*/ vcmPtr->descriptors_included = bitBufferGetBits(bits, 1); bitBufferSkipBits(bits, 5); /*zero : 5 bits*/ vcmPtr->splice = bitBufferGetBits(bits, 1); bitBufferSkipBits(bits, 7); /*zero : 7 bits*/ vcmPtr->activation_time = bitBufferGetBits(bits,32); count_i = vcmPtr->number_of_VC_records = bitBufferGetBits(bits,8); if( count_i > 0 ) { virtualChannel_t *pvc = NULL; vcmPtr->virtual_channel = (virtualChannelPtr_t)memChainAlloc(memId , count_i*sizeof(virtualChannel_t)); checkMemoryError2(vcmPtr->virtual_channel); for ( i = 0 ; i < count_i ; i++ ) { int count_j = 0; pvc = &(vcmPtr->virtual_channel[i]); bitBufferSkipBits(bits,4); /*zero : 4bits*/ pvc->virtual_channel_number = bitBufferGetBits(bits,12); pvc->application_virtual_channel = bitBufferGetBits(bits,1); bitBufferSkipBits(bits,1); /*zero : 1bit*/ pvc->path_select = bitBufferGetBits(bits,1); pvc->transport_type = bitBufferGetBits(bits,1); pvc->channel_type = bitBufferGetBits(bits , 4); if( pvc->application_virtual_channel ) { pvc->application_ID = bitBufferGetBits(bits,16); pvc->source_ID = 0; /*just initializaiton*/ } else { pvc->source_ID = bitBufferGetBits(bits,16); pvc->application_ID = 0; /*just initialization*/ } if( pvc->transport_type == tt_MPEG2_transport ) { pvc->CDS_reference = bitBufferGetBits(bits,8); /*1-255*/ pvc->program_number = bitBufferGetBits(bits,16); pvc->MMS_reference = bitBufferGetBits(bits,8); /*1-255*/ pvc->scrambled = 0; pvc->video_standard = 0; } else /*non-MPEG-2*/ { pvc->CDS_reference = bitBufferGetBits(bits,8); pvc->scrambled = bitBufferGetBits(bits,1); bitBufferSkipBits(bits,3); /*zero : 3bits*/ pvc->video_standard = bitBufferGetBits(bits,4); bitBufferSkipBits(bits,16); pvc->program_number = 0; pvc->MMS_reference = 0; } if( vcmPtr->descriptors_included ) { count_j = pvc->descriptors_count = bitBufferGetBits(bits,8); if( count_j > 0 ) { int iGo , jGo ; int iDescriptorLength = 0; generalDescriptor_t *pDescriptor = NULL; pvc->descriptor_structure = (generalDescriptor_t *)memChainAlloc(memId , count_j * sizeof(generalDescriptor_t)); checkMemoryError2( pvc->descriptor_structure ); for( iGo = 0 ; iGo < count_j ; iGo++) { pDescriptor = &(pvc->descriptor_structure[iGo]); pDescriptor->descriptor_tag = bitBufferGetBits(bits ,8); iDescriptorLength = pDescriptor->descriptor_length = bitBufferGetBits(bits, 8); if( iDescriptorLength > 0 ) { pDescriptor->descriptor_data = (DS_U8 *)memChainAlloc( memId , iDescriptorLength ); checkMemoryError2( pDescriptor->descriptor_data ); } for( jGo = 0; jGo < iDescriptorLength ; jGo++ ) { pDescriptor->descriptor_data[jGo] = bitBufferGetBits(bits, 8); } } /*for( iGo = 0 ; iGo < count_j ; iGo++)*/ } /*if( count_j > 0 )*/ } /*if( vcmPtr->descriptors_included )*/ } /*for ( i = 0 ; i < count_i ; i++ )*/ } /*if( count_i > 0 )*/ return DHL_OK; } /*============================================================================== DHL_RESULT DHL_PSI_ParseSvctSection (DS_U8 *section, svctSection_t *svctSectPtr) *section: Pointer to the first byte of the section. *svctSectionPtr: Return pointer to a parsed NIT section. Parses an SVCT section and returns the decoded section via the provided handle. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseSvctSection (DS_U8 *section, svctSectionPtr_t *svctSectPtr ) { svctSectionPtr_t svctSectionPtr = NULL; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U16 section_length; memId_t memId = NULL; bitBufferPtr_t bits = NULL; DS_S32 i; DS_S32 count_i; DHL_RESULT err = DHL_OK; int len = 0; if( section == NULL) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseSvctSection : Bad Parameter\r\n"); return DHL_FAIL_NULL_POINTER; } if ( get_table_id(section) != tid_shortform_virtual_channel_table ) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseSvctSection : invalid table_id.\r\n"); return DHL_FAIL_INVALID_PARAM; } section_length = get_section_length(section); if (section_length > 4093) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "SVCT: section_length=%d\r\n",section_length); err = DHL_FAIL_INVALID_PARAM; goto ParseExit; } /* create the bitBuffer */ err = bitBufferCreate(&bits,section+3,section_length); if (err) { goto ParseExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseExit; } /* allocate memory for nitSection */ svctSectionPtr = (svctSectionPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(svctSection_t)+sizeof(memId_t))) + 1); checkMemoryError(svctSectionPtr); /* parse section */ bitBufferSkipBits( bits ,3 ); /*zero : 3bits*/ svctSectionPtr->protocol_version = bitBufferGetBits(bits,5); /*5 bits*/ if (svctSectionPtr->protocol_version > SI_PROTOCOL_VERSION) { err = DHL_FAIL_INVALID_PARAM; goto ParseExit; } svctSectionPtr->transmission_medium = bitBufferGetBits(bits,4); svctSectionPtr->table_subtype = bitBufferGetBits(bits,4); svctSectionPtr->VCT_ID = bitBufferGetBits(bits, 16); switch( svctSectionPtr->table_subtype ) { case st_DCM: #ifdef DUMP_SI_TABLE memdump( section, section_length, "DUMP SVCT-DCM"); #endif svctSectionPtr->DCM = (DCMPtr_t)memChainAlloc(memId , sizeof(DCM_t)); checkMemoryError( svctSectionPtr->DCM ); err = DHL_PSI_ParseDCM( bits , memId , svctSectionPtr->DCM ); break; case st_VCM: #ifdef DUMP_SI_TABLE memdump( section, section_length, "DUMP SVCT-VCM"); #endif svctSectionPtr->VCM = (VCMPtr_t)memChainAlloc(memId , sizeof(VCM_t)); checkMemoryError( svctSectionPtr->VCM ); err = DHL_PSI_ParseVCM( bits , memId , svctSectionPtr->VCM ); break; case st_ICM: #ifdef DUMP_SI_TABLE memdump( section, section_length, "DUMP SVCT-ICM"); #endif svctSectionPtr->ICM = (ICMPtr_t)memChainAlloc(memId , sizeof(ICM_t)); checkMemoryError( svctSectionPtr->ICM ); err = DHL_PSI_ParseICM( bits , memId , svctSectionPtr->ICM ); break; } /*switch( svctSectionPtr->table_subtype )*/ if(err != DHL_OK) goto ParseExit; len = HAL_ABS((DS_U32)bitBufferGetBytePointer(bits) - (DS_U32)(section+3) );/*current offset*/ count_i = section_length - len - 4/*crc count*/; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "section_length = %d\r\n" , section_length); DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "bitBufferGetBytePointer(bits) = 0x%x , (section+3) = 0x%x HAL_ABS(x) = %d\r\n" ,(DS_U32)bitBufferGetBytePointer(bits) , (DS_U32)(section+3) , HAL_ABS ( (DS_U32)bitBufferGetBytePointer(bits) - (DS_U32)(section+3) )); #endif #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseSvctSection : DescriptorLength = %d\r\n" , count_i); #endif if( count_i > 0) { svctSectionPtr->descriptors_length = count_i; svctSectionPtr->descriptor = (DS_U8 *)memChainAlloc(memId , sizeof(DS_U8)*count_i); checkMemoryError( svctSectionPtr->descriptor ); for( i = 0 ; i < count_i ; i++ ) { svctSectionPtr->descriptor[i] = bitBufferGetBits( bits , 8 ); } } svctSectionPtr->CRC32 = bitBufferGetBits( bits , 32 ); /* parsing complete */ *(((memId_t *)svctSectionPtr)-1) = memId; memId = NULL; /* so memChain not deleted */ ParseExit: if (bits) { /* clean up the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the cvctSection memory */ memChainDestroy(memId); } *svctSectPtr = svctSectionPtr; return (err); } /*============================================================================== DHL_RESULT DHL_PSI_ParseSiSttSection (DS_U8 *section, SI_sttSectionPtr_t *sttSectionPtr) *section: Pointer to the first byte of the section. *nttSectionPtr: Return pointer to a parsed NTT section. Parses an NTT section and returns the decoded section via the provided handle. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseSiSttSection (DS_U8 *section, SI_sttSectionPtr_t *sttSectionPtr) { SI_sttSectionPtr_t sttSectPtr = NULL; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U16 section_length; memId_t memId = NULL; bitBufferPtr_t bits = NULL; DS_S32 i; DS_S32 count_i; DHL_RESULT err = DHL_OK; int len = 0; if( section == NULL ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParsetSiSttSection : bad parameter\r\n"); return DHL_FAIL_NULL_POINTER; } if( get_table_id(section) != tid_si_system_time_table ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseSiSttSection : invalid table_id\r\n"); return DHL_FAIL_INVALID_PARAM; } section_length = get_section_length(section); if (section_length > 4093) { DHL_DbgPrintf( 0, DHLDBG_PSI, "SiSTT: section_length=%d\r\n",section_length); err = DHL_FAIL_INVALID_PARAM; goto ParseExit; } /* create the bitBuffer */ err = bitBufferCreate(&bits,section+3,section_length); if (err) { goto ParseExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseExit; } /* allocate memory for ettSection */ sttSectPtr = (SI_sttSectionPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(SI_sttSection_t)+sizeof(memId_t))) + 1); checkMemoryError(sttSectPtr); /* parse section */ bitBufferSkipBits(bits, 3); /*zero : 3bits*/ sttSectPtr->protocol_version = bitBufferGetBits(bits, 5); if (sttSectPtr->protocol_version > SI_PROTOCOL_VERSION) { err = DHL_FAIL_INVALID_PARAM; goto ParseExit; } bitBufferSkipBits(bits, 8); sttSectPtr->system_time = bitBufferGetBits( bits , 32); sttSectPtr->GPS_UTC_offset = bitBufferGetBits(bits, 8); len = HAL_ABS( (DS_U32)bitBufferGetBytePointer(bits) - (DS_U32)(section+3));/*current offset*/ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "len = %d\n", len ); count_i = section_length - len - 4/*crc count*/; if( count_i > 0 && count_i < (section_length - 11)) { sttSectPtr->descriptors_length = count_i; sttSectPtr->descriptor = (DS_U8 *)memChainAlloc(memId , sizeof(DS_U8)*count_i); checkMemoryError( sttSectPtr->descriptor ); for( i = 0 ; i < count_i ; i++ ) { sttSectPtr->descriptor[i] = bitBufferGetBits( bits , 8 ); } } /* if( section_length - 11 < count_i ) DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in th DHL_PSI_ParseSiSttSection : sction_length = %d , count_i = %d\n", section_length , count_i); */ /* parsing complete */ *(((memId_t *)sttSectPtr)-1) = memId; memId = NULL; /* so memChain not deleted */ ParseExit: if (bits) { /* clean up the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the cvctSection memory */ memChainDestroy(memId); } *sttSectionPtr = sttSectPtr; return (err); } /*============================================================================== DHL_RESULT DHL_PSI_ParseAeitSection (DS_U8 *section, aeitSectionPtr_t *aeitSectionPtr) *section: Pointer to the first byte of the section. *nttSectionPtr: Return pointer to a parsed AEIT section. Parses an AEIT section and returns the decoded section via the provided handle. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseAeitSection(DS_U8 *section, aeitSectionPtr_t *aeitSectionPtr) { aeitSectionPtr_t aeitSectPtr = NULL; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U16 section_length; memId_t memId = NULL; bitBufferPtr_t bits = NULL; DS_S32 i; DS_S32 count_i; DHL_RESULT err = DHL_OK; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the ParseAeitSection.....\r\n"); #endif if( section == NULL ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseAeitSection : bad parameter.\r\n"); return DHL_FAIL_NULL_POINTER; } if( get_table_id(section) != tid_aggregate_event_information_table ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseAeitSection : invalid table_id\r\n"); return DHL_FAIL_INVALID_PARAM; } section_length = get_section_length(section); if (section_length > 4093) { DHL_DbgPrintf( 0, DHLDBG_PSI, "AEIT: section_length=%d\r\n",section_length); err = DHL_FAIL_INVALID_PARAM; goto ParseExit; } /* create the bitBuffer */ err = bitBufferCreate(&bits,section+3,section_length); if (err) { goto ParseExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseExit; } /* allocate memory for aeitSection */ aeitSectPtr = (aeitSectionPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(aeitSection_t)+sizeof(memId_t))) + 1); checkMemoryError(aeitSectPtr); /* parse section */ aeitSectPtr->AEIT_subtype = bitBufferGetBits(bits, 8); aeitSectPtr->MGT_tag = bitBufferGetBits(bits,8); bitBufferSkipBits(bits,2); /*reserved : 2bits*/ aeitSectPtr->version_number = bitBufferGetBits(bits,5); aeitSectPtr->current_next_indicator = bitBufferGetBits(bits,1); aeitSectPtr->section_number = bitBufferGetBits(bits,8); aeitSectPtr->last_section_number = bitBufferGetBits(bits, 8); if(aeitSectPtr->AEIT_subtype == 0) { count_i = aeitSectPtr->num_sources_in_section = bitBufferGetBits(bits, 8); #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseAeitSection : num_sources_in_section = %d\r\n" , count_i); #endif if(count_i > 0) { int count_j = 0; int j = 0; SI_eitSection_t *pEitSect = NULL; aeitSectPtr->eits = (SI_eitSectionPtr_t )memChainAlloc(memId , count_i * sizeof(SI_eitSection_t)); checkMemoryError(aeitSectPtr->eits); for( i = 0 ; i < count_i ; i++ ) { pEitSect = &(aeitSectPtr->eits[i]); pEitSect->source_ID = bitBufferGetBits(bits,16); count_j = pEitSect->num_events= bitBufferGetBits(bits,8); #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseAeitSection : num_events = %d\r\n", count_j); #endif if( count_j > 0 ) { int count_k = 0; int k = 0; SI_event_t *pEvent = NULL; pEitSect->events = (SI_eventPtr_t)memChainAlloc(memId,count_j*sizeof(SI_event_t)); checkMemoryError(pEitSect->events); for( j = 0 ; j < count_j ; j++ ) { pEvent = &(aeitSectPtr->eits[i].events[j]); bitBufferSkipBits(bits,2); /*reserved : 2bits*/ pEvent->event_ID = bitBufferGetBits(bits,14); pEvent->start_time = bitBufferGetBits(bits,32); bitBufferSkipBits(bits,2); /*reserved : 2bits*/ pEvent->ETM_present = bitBufferGetBits(bits,2); pEvent->duration = bitBufferGetBits(bits,20); count_k = pEvent->title_length = bitBufferGetBits(bits, 8); if( count_k > 0 ) { pEvent->title_text = (DS_U8 *)memChainAlloc(memId, count_k*sizeof(DS_U8)); checkMemoryError(pEvent->title_text); for( k = 0 ; k < count_k ; k++ ) { pEvent->title_text[k] = bitBufferGetBits(bits,8); } } /*if( count_k > 0 )*/ bitBufferSkipBits(bits,4); /*reserved : 4bits*/ count_k = pEvent->descriptors_length = bitBufferGetBits(bits,12); if( count_k > 0 ) { pEvent->descriptor = (DS_U8 *)memChainAlloc(memId,count_k *sizeof(DS_U8)); checkMemoryError(pEvent->descriptor); for( k = 0 ; k < count_k ; k++ ) { pEvent->descriptor[k] = bitBufferGetBits(bits, 8); } } } /*for( j = 0 ; j < count_j ; j++ )*/ } /*if( count_j > 0 )*/ } /*for( i = 0 ; i < count_i ; i++ )*/ } /*if(count_i > 0)*/ } /*if(aeitSectPtr->AEIT_subtype == 0)*/ aeitSectPtr->CRC32 = bitBufferGetBits( bits , 32 ); /* parsing complete */ *(((memId_t *)aeitSectPtr)-1) = memId; memId = NULL; /* so memChain not deleted */ ParseExit: if (bits) { /* clean up the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the cvctSection memory */ memChainDestroy(memId); } *aeitSectionPtr = aeitSectPtr; return (err); } /*============================================================================== DHL_RESULT DHL_PSI_ParseAeit (DS_U8 **sectionArr, aeitPtr_t *aeitPtr) **sectionArr: Array of pointers to all AEIT sections. *tvctPtr: Returned pointer to the parsed AEIT. Parses an AEIT and returns the parsed table via the return pointer. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseAeit(DS_U8 **sectionArr, aeitPtr_t *aeitPtr) { DS_U8 numSections; DS_U16 numEits; aeitSectionPtr_t aeitSectPtr; DS_U16 i,j; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; memId_t memId = NULL; DHL_RESULT err; int numEvents; int iSizeLength; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the ParseAeit....\r\n"); #endif if (sectionArr == NULL || (aeitPtr == NULL)) { return (DHL_FAIL_NULL_POINTER); } if (sectionArr[0] == NULL) { return (DHL_FAIL_NULL_POINTER); } else { numSections = get_last_section_number(sectionArr[0]) + 1; } #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseAeit : numSections = %d\r\n" ,numSections); #endif /* now verify all other sections are present */ for (i=1; iCRC32 = 0; /* Get the total number of channels in all sections */ numEits = 0; for (i=0; ieits = (SI_eitSectionPtr_t)memChainAlloc(memId,numEits*sizeof(SI_eitSection_t)); checkMemoryError((*aeitPtr)->eits); (*aeitPtr)->num_sources = numEits; /* Parse each section and copy channels */ numEits = 0; for (i=0; iAEIT_subtype = aeitSectPtr->AEIT_subtype; (*aeitPtr)->MGT_tag = aeitSectPtr->MGT_tag; (*aeitPtr)->version_number = aeitSectPtr->version_number; } for (j=0; j< aeitSectPtr->num_sources_in_section ; j++) { SI_eitSection_t *D_eitSectPtr = &((*aeitPtr)->eits[numEits]); SI_eitSection_t *S_eitSectPtr = &(aeitSectPtr->eits[j]); D_eitSectPtr->source_ID = S_eitSectPtr->source_ID; numEvents = D_eitSectPtr->num_events = S_eitSectPtr->num_events; if ( numEvents > 0 ) { int eventGo = 0; D_eitSectPtr->events = (SI_eventPtr_t)memChainAlloc(memId , sizeof(SI_event_t)*numEvents); if( D_eitSectPtr->events == NULL ) { DHL_PSI_FreeSISection(aeitSectPtr); err = DHL_FAIL_OUT_OF_RESOURCE; goto ParseExit; } /*if( D_eitSectPtr->events == NULL )*/ for( eventGo = 0 ; eventGo < numEvents ; eventGo++ ) { D_eitSectPtr->events[eventGo].event_ID = S_eitSectPtr->events[eventGo].event_ID; D_eitSectPtr->events[eventGo].start_time = S_eitSectPtr->events[eventGo].start_time; D_eitSectPtr->events[eventGo].ETM_present = S_eitSectPtr->events[eventGo].ETM_present; D_eitSectPtr->events[eventGo].duration = S_eitSectPtr->events[eventGo].duration; iSizeLength = D_eitSectPtr->events[eventGo].title_length = S_eitSectPtr->events[eventGo].title_length; if(iSizeLength > 0) { D_eitSectPtr->events[eventGo].title_text = (DS_U8*)memChainAlloc(memId , sizeof(DS_U8)*iSizeLength); if( D_eitSectPtr->events[eventGo].title_text == NULL) { DHL_PSI_FreeSISection(aeitSectPtr); err = DHL_FAIL_OUT_OF_RESOURCE; goto ParseExit; } memcpy( (D_eitSectPtr->events[eventGo].title_text) , S_eitSectPtr->events[eventGo].title_text , iSizeLength ); } iSizeLength = D_eitSectPtr->events[eventGo].descriptors_length = S_eitSectPtr->events[eventGo].descriptors_length; if( iSizeLength > 0 ) { D_eitSectPtr->events[eventGo].descriptor = (DS_U8 *)memChainAlloc(memId , sizeof(DS_U8)*iSizeLength); if( D_eitSectPtr->events[eventGo].descriptor == NULL ) { DHL_PSI_FreeSISection(aeitSectPtr); err = DHL_FAIL_OUT_OF_RESOURCE; goto ParseExit; } memcpy( (D_eitSectPtr->events[eventGo].descriptor) , (S_eitSectPtr->events[eventGo].descriptor) , sizeof(DS_U8)*iSizeLength); } /*if( iSizeLength > 0 )*/ } /*for( eventGo = 0 ; eventGo < numEvents ; eventGo++ )*/ } /*if ( numEvents > 0 )*/ numEits++; } /*for (j=0; j< aeitSectPtr->num_sources_in_section ; j++) */ #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "before : %d -th aeit sect crc = 0x%x , aeit crc = 0x%x \r\n" , i , aeitSectPtr->CRC32 , (*aeitPtr)->CRC32 ); #endif (*aeitPtr)->CRC32 += (aeitSectPtr->CRC32); DHL_PSI_FreeSISection(aeitSectPtr); } /*for (i=0; iCRC32 = 0; /* Get the total number of channels in all sections */ numEtts = 0; for (i=0; ietts = (SI_ettSectionPtr_t)memChainAlloc(memId,numEtts*sizeof(SI_ettSection_t)); checkMemoryError((*aettPtr)->etts); (*aettPtr)->num_blocks = numEtts; } /* Parse each section and copy channels */ numEtts = 0; for (i=0; iAETT_subtype = bitBufferGetBits(bits,8); (*aettPtr)->MGT_tag = bitBufferGetBits(bits,8); bitBufferSkipBits(bits,2); /*reserved : 2bits*/ (*aettPtr)->version_number = bitBufferGetBits(bits,5); bitBufferSkipBits(bits,1); /* current_next_indicator */ bitBufferSkipBits(bits,8); /* section_number */ bitBufferSkipBits(bits,8); /* last_section_number */ if( (*aettPtr)->AETT_subtype == 0 ) { int iBlockCount = 0; int iBlockGo = 0; iBlockCount = bitBufferGetBits(bits,8); /*num_block_in_section*/ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseAeit : %d-th AETT . blockCount = %d\r\n" , numSections , iBlockCount ); for( iBlockGo = 0 ; iBlockGo < iBlockCount ; iBlockGo++ ) { int iTextCount = 0; SI_ettSectionPtr_t ettPtr = &((*aettPtr)->etts[numEtts]); ettPtr->ETM_ID = bitBufferGetBits(bits,32); bitBufferSkipBits(bits,4); iTextCount = ettPtr->extended_text_length = bitBufferGetBits(bits,12); if(iTextCount > 0) { int iTextgo = 0; ettPtr->extended_text_message = (DS_U8 *)memChainAlloc(memId, iTextCount*sizeof(DS_U8)); checkMemoryError(ettPtr->extended_text_message); for( iTextgo = 0 ; iTextgo < iTextCount ; iTextgo++ ) ettPtr->extended_text_message[iTextgo] = bitBufferGetBits(bits,8); } /*if(iTextCount > 0)*/ numEtts++; } /*for( iBlockGo = 0 ; iBlockGo < iBlockCount ; iBlockGo++ )*/ } /*if( (*aettPtr)->AETT_subtype == 0 )*/ /*2004.03.12 added by jina*/ crc32 = bitBufferGetBits(bits,32); #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "before : %d -th aett sect crc = 0x%x , aett crc = 0x%x \r\n" , i , crc32 , (*aettPtr)->CRC32 ); #endif (*aettPtr)->CRC32 += crc32; if (bits) { /* clean up the bitBuffer */ bitBufferDestroy(bits); } } /*for (i=0; i 4093) { DHL_DbgPrintf( 0, DHLDBG_PSI, "AETT: section_length=%d\r\n",section_length); err = DHL_FAIL_INVALID_PARAM; goto ParseExit; } /* create the bitBuffer */ err = bitBufferCreate(&bits,section+3,section_length); if (err) { goto ParseExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseExit; } /* allocate memory for aettSection */ aettSectPtr = (aettSectionPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(aettSection_t)+sizeof(memId_t))) + 1); checkMemoryError(aettSectPtr); /* parse section */ aettSectPtr->AETT_subtype = bitBufferGetBits(bits, 8); aettSectPtr->MGT_tag = bitBufferGetBits(bits,8); bitBufferSkipBits(bits,2); /*reserved : 2bits*/ aettSectPtr->version_number = bitBufferGetBits(bits,5); aettSectPtr->current_next_indicator = bitBufferGetBits(bits,1); aettSectPtr->section_number = bitBufferGetBits(bits,8); aettSectPtr->last_section_number = bitBufferGetBits(bits, 8); if(aettSectPtr->AETT_subtype == 0) { count_i = aettSectPtr->num_blocks_in_section = bitBufferGetBits(bits, 8); if(count_i > 0) { int count_j = 0; int j = 0; SI_ettSection_t *pEttSect = NULL; aettSectPtr->etts = (SI_ettSectionPtr_t )memChainAlloc(memId , count_i * sizeof(SI_ettSection_t)); for( i = 0 ; i < count_i ; i++ ) { pEttSect = &(aettSectPtr->etts[i]); pEttSect->ETM_ID = bitBufferGetBits(bits,32); bitBufferSkipBits(bits,4); /*reserved : 4bits*/ count_j = pEttSect->extended_text_length = bitBufferGetBits(bits,12); if( count_j > 0) { pEttSect->extended_text_message = (DS_U8 *)memChainAlloc(memId , count_j * sizeof(DS_U8)); for( j = 0 ; j < count_j ; j++ ) { pEttSect->extended_text_message[j] = bitBufferGetBits(bits, 8); } /*for( j = 0 ; j < count_j ; j++ )*/ } /*if( count_j > 0 )*/ } /*for( i = 0 ; i < count_i ; i++ )*/ } /*if(count_i > 0)*/ } /*if(aettSectPtr->AETT_subtype /== 0)*/ aettSectPtr->CRC32 = bitBufferGetBits( bits , 32 ); /* parsing complete */ *(((memId_t *)aettSectPtr)-1) = memId; memId = NULL; /* so memChain not deleted */ ParseExit: if (bits) { /* clean up the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the cvctSection memory */ memChainDestroy(memId); } *aettSectionPtr = aettSectPtr; return (err); } /*============================================================================== void DHL_PSI_FreeSISection (void *sectionPtr) *sectionPtr: Pointer to a section. Frees the memory associated with a section. ==============================================================================*/ void DHL_PSI_FreeSISection (void *sectionPtr) { memChainDestroy(*(((memId_t *)sectionPtr)-1)); } void DHL_PSI_FreeSITable (void *tablePtr) { DHL_RESULT err; err = memChainDestroy(*(((memId_t *)tablePtr)-1)); } void DHL_PSI_FreeSIDescriptor ( void *descriptorPtr ) { memChainDestroy(*(((memId_t *)descriptorPtr)-1)); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorNit(SIUpdateMode updateMode, PSIEventProc eventProc, DS_U32 userParam, PSIControl **psiCtl) updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorNit ( PSIMode psiMode, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; DS_U32 maxSections; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorNit.\r\n"); #endif maxSections = (psiMode == tableMode || psiMode == eagerTableMode || psiMode == si_privateTableMode_RD ) ? 256 : 1; if ((err = DD_PSI_GetTIDPSISimpleMask (&pref, tid_network_information_table))) { return(err); } if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, psiMode, updateMode, pref, 4096, maxSections, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorNit_Ex ( SI_nit_subtype_k subType , SIUpdateMode updateMode, SIEventProc eventProc, DS_U32 userParam, SIControl **psiCtl) subType: nit subtype. updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ /*NIT¸¦ subtable typeº°·Î ±¸ºÐÇØ¼­ monitorinÇÑ´Ù.*/ DHL_RESULT DHL_PSI_MonitorNit_Ex ( SI_nit_subtype_k subType, PSIMode psiMode, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl ) { PSIMask_t *pref; DHL_RESULT err; DS_U32 maxSections; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorNit_Ex.\r\n"); #endif /* Set up the Table ID filter */ if ((err = DD_PSI_GetTIDPrivateSubtypePSIMask(&pref,tid_network_information_table, 5+2 , subType , BOTTOM_FIELD ))) { return(err); } maxSections = (psiMode == tableMode || psiMode == eagerTableMode || psiMode == si_privateTableMode_RD ) ? 256 : 1; if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, psiMode, updateMode, pref, 4096, maxSections, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorNtt ( SI_ntt_subtype_k subType , SIUpdateMode updateMode, SIEventProc eventProc, DS_U32 userParam, SIControl **psiCtl) subType: nit subtype. updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorNtt ( PSIMode psiMode, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; DS_U32 maxSections; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorNtt.\r\n"); #endif maxSections = (psiMode == tableMode || psiMode == eagerTableMode || psiMode == si_privateTableMode_RD ) ? 256 : 1; if ((err = DD_PSI_GetTIDPSISimpleMask (&pref, tid_network_text_table))) { return(err); } if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, psiMode, updateMode, pref, 4096, maxSections, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorNtt_Ex ( SI_ntt_subtype_k subType , SIUpdateMode updateMode, SIEventProc eventProc, DS_U32 userParam, SIControl **psiCtl) subType: nit subtype. updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorNtt_Ex ( SI_ntt_subtype_k subType, PSIMode psiMode, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl ) { PSIMask_t *pref; DHL_RESULT err; DS_U32 maxSections; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorNtt_Ex.\r\n"); #endif /* Set up the Table ID filter */ if ((err = DD_PSI_GetTIDPrivateSubtypePSIMask(&pref,tid_network_text_table, 6+2 , subType , BOTTOM_FIELD ))) { return(err); } maxSections = (psiMode == tableMode || psiMode == eagerTableMode || psiMode == si_privateTableMode_RD ) ? 256 : 1; if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, psiMode, updateMode, pref, 4096, maxSections, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorSvct(SIUpdateMode updateMode, PSIEventProc eventProc, DS_U32 userParam, PSIControl **psiCtl) updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorSvct ( PSIMode psiMode, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; DS_U32 maxSections; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorSvct.\r\n"); #endif maxSections = (psiMode == tableMode || psiMode == eagerTableMode || psiMode == si_privateTableMode_RD ) ? 256 : 1; if ((err = DD_PSI_GetTIDPSISimpleMask (&pref, tid_shortform_virtual_channel_table))) { return(err); } if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, psiMode, updateMode, pref, 4096, maxSections, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorSvct_Ex ( SI_svct_subtype_k subType , SIUpdateMode updateMode, SIEventProc eventProc, DS_U32 userParam, SIControl **psiCtl) subType: nit subtype. updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorSvct_Ex ( SI_nit_subtype_k subType, PSIMode psiMode, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl ) { PSIMask_t *pref; DHL_RESULT err; DS_U32 maxSections; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorSvct_Ex.\r\n"); #endif /* Set up the Table ID filter */ if ((err = DD_PSI_GetTIDPrivateSubtypePSIMask(&pref,tid_shortform_virtual_channel_table, 3+2 , subType , BOTTOM_FIELD ))) { return(err); } maxSections = (psiMode == tableMode || psiMode == eagerTableMode || psiMode == si_privateTableMode_RD ) ? 256 : 1; if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, psiMode, updateMode, pref, 4096, maxSections, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorSiStt(SIUpdateMode updateMode, SIEventProc eventProc, DS_U32 userParam, SIControl **psiCtl) updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorSiStt ( PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorSiStt.\r\n"); #endif if ((err = DD_PSI_GetTIDPSISimpleMask ( &pref, tid_si_system_time_table))) { return(err); } if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, sectionMode, updateMode, pref, 4096, 1, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorSiMgt( PSIEventProc eventProc, DS_U32 userParam, PSIControl **psiCtl) updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorSiMgt ( PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorSiMgt.\r\n"); #endif if ((err = DD_PSI_GetTIDPSIMask ( &pref, tid_si_master_guide_table, _TRUE_ ))) { return(err); } if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, sectionMode, updateMode, pref, 4096, 1, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorLvct(SIUpdateMode updateMode, PSIEventProc eventProc, DS_U32 userParam, PSIControl **psiCtl) updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorLvct( PSIMode psiMode, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; DS_U32 maxSections; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorLvct.\r\n"); #endif maxSections = (psiMode == tableMode || psiMode == eagerTableMode ) ? 256 : 1; if ((err = DD_PSI_GetTIDPSIMask ( &pref, tid_lf_virtual_channel_table, _TRUE_ ))) { return(err); } if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, psiMode, updateMode, pref, 4096, maxSections, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorAeit ( SIMode psiMode, SIUpdateMode updateMode, SIEventProc eventProc, DS_U32 userParam, SIControl **psiCtl) updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorAeit ( DS_U32 pid, PSIMode psiMode, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; DS_U32 maxSections; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorAeit.\r\n"); #endif maxSections = (psiMode == tableMode || psiMode == eagerTableMode ) ? 256 : 1; if ((err = DD_PSI_GetTIDPSIMask ( &pref, tid_aggregate_event_information_table, _TRUE_ ))) { return(err); } if ((err = DHL_PSI_MonitorPSIPidSw( pid, psiMode, updateMode, pref, 4096, maxSections, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorAett ( SIMode psiMode, SIUpdateMode updateMode, SIEventProc eventProc, DS_U32 userParam, SIControl **psiCtl) updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorAett ( DS_U32 pid, PSIMode psiMode, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; DS_U32 maxSections; #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "in the DHL_PSI_MonitorAeit.\r\n"); #endif maxSections = (psiMode == tableMode || psiMode == eagerTableMode ) ? 256 : 1; if ((err = DD_PSI_GetTIDPSIMask ( &pref, tid_aggregate_extended_text_table, _TRUE_ ))) { return(err); } if ((err = DHL_PSI_MonitorPSIPidSw( pid, psiMode, updateMode, pref, 4096, maxSections, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorSiRrt(SIUpdateMode updateMode, PSIEventProc eventProc, DS_U32 userParam, PSIControl **psiCtl) updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for System Time Table sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorSiRrt ( DS_U8 region, PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; /* Set up the Table ID ETT filter */ if ((err = DD_PSI_GetExTIDFieldPSIMask( &pref, tid_si_rating_region_table, (DS_U16)region, BOTTOM_FIELD, _TRUE_))) { return(err); } /* Set up PID Filter */ if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, sectionMode, updateMode, pref, 4096, 1, eventProc, userParam, returnPSICtl ))) { PSI_Free(pref); } return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetSiSttSection ( SI_sttSectionPtr_t *sttSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *sttSectPtr: Return pointer to an STT section. timeOut: Synchronous wait timeout for STT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an STT section. If the STT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetSiSttSection ( SI_sttSectionPtr_t *sttSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *sttSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ procData.hEvent = (DS_U32)(OS_CreateCountingSemaphore( "PSISiSema4", 0, 0 )); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorSiStt( psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_GetSiSttSection : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseSiSttSection(procData.desc->sectPtr[0], sttSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetSiMgtSection ( SI_mgtSectionPtr_t *mgtSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetSiMgtSection ( mgtSectionPtr_t *mgtSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *mgtSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32)DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PSISiMgtSema4", 0, 0 ); if (procData.hEvent == (DS_U32)0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorSiMgt( psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_GetSiMgtSection : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseMGTSection (procData.desc->sectPtr[0], mgtSectPtr ); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetSiRrtSection ( rrtSectionPtr_t *rrtSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetSiRrtSection ( DS_U8 region , rrtSectionPtr_t *rrtSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *rrtSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PSISiRrtSema4", 0, 0 ); if (procData.hEvent == (DS_U32)0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorSiRrt( region, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( 0, DHLDBG_PSI, "DHL_PSI_GetSiRrtSection : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseRRTSection(procData.desc->sectPtr[0], rrtSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetNit ( nitSectionPtr_t *nitSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetNit ( nitPtr_t *nitPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *nitPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PSINitSema4", 0, 0 ); if (procData.hEvent == (DS_U32)0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorNit( si_privateTableMode_RD, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_GetNit : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseNit(procData.desc->sectPtr, nitPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetNitSection ( nitSectionPtr_t *nitSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetNitSection ( nitSectionPtr_t *nitSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *nitSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PSIGetNITSema4", 0, 0 ); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorNit( sectionMode, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_GetNitSection : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseNitSection(procData.desc->sectPtr[0], nitSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetNit_Ex ( SI_nit_subtype_k subType , nitSectionPtr_t *nitSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetNit_Ex ( SI_nit_subtype_k subType , nitPtr_t *nitPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *nitPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PSIGetNitExSema4", 0, 0 ); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorNit_Ex( subType, si_privateTableMode_RD, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_GetNit_Ex : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseNit(procData.desc->sectPtr, nitPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetNitSection_Ex ( SI_nit_subtype_k subType , nitSectionPtr_t *nitSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetNitSection_Ex ( SI_nit_subtype_k subType , nitSectionPtr_t *nitSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *nitSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PSIGetNitSectSema4", 0, 0 ); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorNit_Ex( subType, sectionMode, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_GetNitSection_Ex : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseNitSection(procData.desc->sectPtr[0], nitSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetNtt ( nttPtr_t *nttPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetNtt ( nttPtr_t *nttPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *nttPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PSINTTSema4", 0, 0 ); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorNtt( si_privateTableMode_RD, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_GetNtt : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseNtt(procData.desc->sectPtr, nttPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetNttSection ( nttSectionPtr_t *nttSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetNttSection ( nttSectionPtr_t *nttSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *nttSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PSINttSectSema4", 0, 0 ); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorNtt( sectionMode, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_GetNttSection : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseNttSection(procData.desc->sectPtr[0], nttSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetNtt_Ex ( SI_ntt_subtype_k subType , nttPtr_t *nttPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetNtt_Ex ( SI_ntt_subtype_k subType , nttPtr_t *nttPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *nttPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PsiNttExSema4", 0, 0 ); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorNtt_Ex( subType, si_privateTableMode_RD, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( 0, DHLDBG_PSI, "DHL_PSI_GetNtt_Ex : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseNtt(procData.desc->sectPtr, nttPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetNttSection_Ex ( SI_ntt_subtype_k subType , nttSectionPtr_t *nttSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetNttSection_Ex ( SI_ntt_subtype_k subType , nttSectionPtr_t *nttSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *nttSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PsiNttSectSema4", 0, 0 ); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorNtt_Ex( subType, sectionMode, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( 0, DHLDBG_PSI, "DHL_PSI_GetNttSection_Ex : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseNttSection(procData.desc->sectPtr[0], nttSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetLvct ( cvctPtr_t *lvctSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetLvct ( cvctPtr_t *lvctSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *lvctSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PsiLvctSema4", 0, 0 ); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorLvct( tableMode , psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( 0, DHLDBG_PSI, "DHL_PSI_GetLvct : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseCVCT(procData.desc->sectPtr, lvctSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetSvct ( svctPtr_t *svctPtr, int timeOut) *pSIFM Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetSvct ( svctPtr_t *svctPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *svctPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PsiSvctSema4", 0, 0 ); if (procData.hEvent == 0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorSvct( si_privateTableMode_RD , psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( 0, DHLDBG_PSI, "DHL_PSI_GetSvct : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseSvct(procData.desc->sectPtr, svctPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetSvctSection ( svctSectionPtr_t *svctSectPtr, int timeOut) *pSIFM Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetSvctSection ( svctSectionPtr_t *svctSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *svctSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PsiSvctSectSema4", 0, 0 ); if (procData.hEvent == (DS_U32)0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorSvct( sectionMode , psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( 0, DHLDBG_PSI, "DHL_PSI_GetSvctSection : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseSvctSection(procData.desc->sectPtr[0], svctSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetSvct_Ex ( SI_svct_subtype_k subType , svctPtr_t *svctSectPtr, int timeOut) *pSIFM Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetSvct_Ex ( SI_svct_subtype_k subType , svctPtr_t *svctPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *svctPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PsiSvctExSema4", 0, 0 ); if (procData.hEvent == (DS_U32)0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorSvct_Ex( subType, si_privateTableMode_RD , psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( 0, DHLDBG_PSI, "DHL_PSI_GetSvct_Ex : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseSvct(procData.desc->sectPtr, svctPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetSvctSection_Ex ( SI_svct_subtype_k subType , svctSectionPtr_t *svctSectPtr, int timeOut) *pSIFM Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetSvctSection_Ex ( SI_svct_subtype_k subType , svctSectionPtr_t *svctSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *svctSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PsiSvctSectExSema4", 0, 0); if (procData.hEvent == (DS_U32)0) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorSvct_Ex( subType, sectionMode, psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "DHL_PSI_GetSvctSection_Ex : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseSvctSection(procData.desc->sectPtr[0], svctSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetAeit ( aeitPtr_t *aeitSectPtr, int timeOut) *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetAeit ( DS_U32 pid , aeitPtr_t *aeitSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *aeitSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PsiAeitSema4", 0, 0 ); if (procData.hEvent == (DS_U32)0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorAeit( pid, tableMode , psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( 0, DHLDBG_PSI, "DHL_PSI_GetAeit : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseAeit(procData.desc->sectPtr, aeitSectPtr); done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } /*============================================================================== DHL_RESULT DHL_PSI_GetAett ( aettPtr_t *aettSectPtr, int timeOut) *tsd Pointer to a TSD structure from which this stream is coming *mgtSectPtr: Return pointer to an MGT section. timeOut: Synchronous wait timeout for MGT. ^Synchronous function which waits (up to the timeout specified) for the arrival of an MGT section. If the MGT section arrives before the timeout, the section is parsed and returned to the caller. ==============================================================================*/ DHL_RESULT DHL_PSI_GetAett ( DS_U32 pid , aettPtr_t *aettSectPtr, int timeOut) { void *returnPSICtl = NULL; DHL_RESULT err = DHL_OK; PSIEventProcData_t procData; int res = 0; *aettSectPtr = NULL; procData.desc = NULL; procData.err = (DS_U32) DHL_OK; /*creae a no-name , non-signaled event.*/ //procData.hEvent = (DS_U32)(AtiCore_EventCreate( 0, _FALSE_ )); procData.hEvent = (DS_U32)OS_CreateCountingSemaphore( "PsiAettSema4", 0, 0 ); if (procData.hEvent == (DS_U32)0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d\n", __LINE__); return DHL_FAIL_OUT_OF_RESOURCE; } if ((err = DHL_PSI_MonitorAett( pid, tableMode , psiOneShot, cbSiSyncEventProc, (DS_U32)&procData, &returnPSICtl))) { goto done; } //res = AtiCore_EventWait( procData.hEvent , _TRUE_ , timeOut ); res = OS_TakeSemaphore_Wait( procData.hEvent, timeOut ); if (res != 0) { #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "ERROR, LINE=%d, timeOut=%d\n", __LINE__, timeOut); #endif //AtiCore_EventReset( procData.hEvent ); err = DHL_FAIL_NULL_POINTER; goto done2; } if ((err = (DHL_RESULT)(procData.err))) { DHL_DbgPrintf( 0, DHLDBG_PSI, "DHL_PSI_GetAett : procData.err = %d \r\n", err ); goto done2; } err = DHL_PSI_ParseAett(procData.desc->sectPtr, aettSectPtr); ; done2: DHL_PSI_CancelMonitorSw(returnPSICtl); if( procData.desc ) DHL_PSI_FreePSIArray(procData.desc); done: if(procData.hEvent) //AtiCore_EventDelete(procData.hEvent); OS_DeleteSemaphore(procData.hEvent); return(err); } void DHL_PSI_GetInfoFromRevisionDetectionDescriptor ( DS_U8 *pDescriptorDump , int iDescriptorLength , DS_U8* sectionNumber , DS_U8* lastSectionNumber , DS_U8* versionNumber ) { int iDescGo = 0; *sectionNumber = 0; *lastSectionNumber = 0; *versionNumber = 0; DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "GetInfoFromRevisionDetectionDescriptor.\r\n"); if( pDescriptorDump == NULL || iDescriptorLength == 0 ) return; while( (iDescriptorLength - iDescGo) > 0 ) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "GetInfoFromRevisionDetectionDescriptor : descriptorTag = 0x%x\r\n" , pDescriptorDump[iDescGo]); if( pDescriptorDump[iDescGo] == Revision_Detection_Descriptor_tag ) { DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "found RevisionDetection Descriptor....\r\n"); *versionNumber = (pDescriptorDump[iDescGo+2]&0x1f); *sectionNumber = pDescriptorDump[iDescGo+3]; *lastSectionNumber = pDescriptorDump[iDescGo+4]; break; } iDescGo += ( pDescriptorDump[iDescGo+1] + 2 ); } /*while( (iDescriptorLength - iDescGo) > 0 )*/ } /*============================================================================== DHL_RESULT DHL_PSI_ParseRevisionDetectionDescriptor (DS_U8* p, revisionDetectionDescriptorPtr_t *descripPtr) { *p: Pointer to the un-parsed descriptor. *descripPtr Pointer to parsed descriptor passed here. Parses the descriptor and passes the result back via the descripPtr variable. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseRevisionDetectionDescriptor (DS_U8* p, revisionDetectionDescriptorPtr_t *descripPtr) { bitBufferPtr_t bits = NULL; memId_t memId; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U8 length; DHL_RESULT err; if( p == NULL) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseRevisionDetectionDescriptor():bad parameter.\r\n"); return DHL_FAIL_INVALID_PARAM; } if( *p != Revision_Detection_Descriptor_tag ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Bad descriptor tag.\r\n"); return DHL_FAIL_INVALID_PARAM; } length = p[1]; /* create the bitBuffer */ err = bitBufferCreate(&bits,p+2,length); if (err) { goto ParseDescriptorExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseDescriptorExit; } /* create the descriptor memory */ *descripPtr = (revisionDetectionDescriptorPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(revisionDetectionDescriptor_t)+sizeof(memId_t))) + 1); if (*descripPtr == NULL) { err = DHL_FAIL_OUT_OF_RESOURCE; goto ParseDescriptorExit; } /* parse the descriptor */ bitBufferSkipBits(bits,3); /*reserved : 3 bits*/ (*descripPtr)->table_version_number = bitBufferGetBits(bits,5); (*descripPtr)->section_number = bitBufferGetBits(bits,8); (*descripPtr)->last_section_number = bitBufferGetBits(bits,8); /* parsing complete */ *(((memId_t *)(*descripPtr))-1) = memId; memId = NULL; /* so memChain not deleted */ ParseDescriptorExit: if (bits) { /* delete the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the descriptor memory */ memChainDestroy(memId); } return (err); } /*============================================================================== DHL_RESULT DHL_PSI_ParseTwoPartChannelNumberDescriptor (DS_U8* p, twoPartChannelNumberDescriptorPtr_t *descripPtr) { *p: Pointer to the un-parsed descriptor. *descripPtr Pointer to parsed descriptor passed here. Parses the descriptor and passes the result back via the descripPtr variable. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseTwoPartChannelNumberDescriptor (DS_U8* p, twoPartChannelNumberDescriptorPtr_t *descripPtr) { bitBufferPtr_t bits = NULL; memId_t memId; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U8 length; DHL_RESULT err; if( p == NULL ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseTwoPartChannelNumberDescriptor():bad parameter\r\n"); return DHL_FAIL_INVALID_PARAM; } if ( *p != Two_Part_Channel_Number_Descriptor_tag ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Bad descriptor tag.\r\n"); return DHL_FAIL_INVALID_PARAM; } length = p[1]; /* create the bitBuffer */ err = bitBufferCreate(&bits,p+2,length); if (err) { goto ParseDescriptorExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseDescriptorExit; } /* create the descriptor memory */ *descripPtr = (twoPartChannelNumberDescriptorPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(twoPartChannelNumberDescriptor_t)+sizeof(memId_t))) + 1); if (*descripPtr == NULL) { err = DHL_FAIL_OUT_OF_RESOURCE; goto ParseDescriptorExit; } /* parse the descriptor */ bitBufferSkipBits(bits,6); /*reserved : 6 bits*/ (*descripPtr)->major_channel_number = bitBufferGetBits(bits,10); bitBufferSkipBits(bits,6); /*reserved : 6 bits*/ (*descripPtr)->minor_channel_number = bitBufferGetBits(bits,10); /* parsing complete */ *(((memId_t *)(*descripPtr))-1) = memId; memId = NULL; /* so memChain not deleted */ ParseDescriptorExit: if (bits) { /* delete the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the descriptor memory */ memChainDestroy(memId); } return (err); } /*============================================================================== DHL_RESULT DHL_PSI_ParseTwoPartChannelNumberDescriptor (DS_U8* p, twoPartChannelNumberDescriptorPtr_t *descripPtr) { *p: Pointer to the un-parsed descriptor. *descripPtr Pointer to parsed descriptor passed here. Parses the descriptor and passes the result back via the descripPtr variable. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseTwoPartChannelNumberDescriptor_Ex (generalDescriptorPtr_t genDescPtr , twoPartChannelNumberDescriptorPtr_t *descripPtr) { bitBufferPtr_t bits = NULL; memId_t memId; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U8 length; DHL_RESULT err; if( genDescPtr == NULL) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseTwoPartChannelNumberDescriptor():bad parameter\r\n"); return DHL_FAIL_INVALID_PARAM; } if( genDescPtr->descriptor_tag != Two_Part_Channel_Number_Descriptor_tag ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Bad descriptor tag\r\n"); return DHL_FAIL_INVALID_PARAM; } length = genDescPtr->descriptor_length; /* create the bitBuffer */ err = bitBufferCreate(&bits, (genDescPtr->descriptor_data) ,length); if (err) { goto ParseDescriptorExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseDescriptorExit; } /* create the descriptor memory */ *descripPtr = (twoPartChannelNumberDescriptorPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(twoPartChannelNumberDescriptor_t)+sizeof(memId_t))) + 1); if (*descripPtr == NULL) { err = DHL_FAIL_OUT_OF_RESOURCE; goto ParseDescriptorExit; } /* parse the descriptor */ bitBufferSkipBits(bits,6); /*reserved : 6 bits*/ (*descripPtr)->major_channel_number = bitBufferGetBits(bits,10); bitBufferSkipBits(bits,6); /*reserved : 6 bits*/ (*descripPtr)->minor_channel_number = bitBufferGetBits(bits,10); /* parsing complete */ *(((memId_t *)(*descripPtr))-1) = memId; memId = NULL; /* so memChain not deleted */ ParseDescriptorExit: if (bits) { /* delete the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the descriptor memory */ memChainDestroy(memId); } return (err); } /*============================================================================== DHL_RESULT DHL_PSI_ParseChannelPropertiesDescriptor (DS_U8* p, channelPropertiesDescriptorPtr_t *descripPtr) { *p: Pointer to the un-parsed descriptor. *descripPtr Pointer to parsed descriptor passed here. Parses the descriptor and passes the result back via the descripPtr variable. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseChannelPropertiesDescriptor (DS_U8* p, channelPropertiesDescriptorPtr_t *descripPtr) { bitBufferPtr_t bits = NULL; memId_t memId; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U8 length; DHL_RESULT err; if( p == NULL) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseChannelPropertiesDescriptor():bad parameter\r\n"); return DHL_FAIL_INVALID_PARAM; } if( *p != Channel_Properties_Descriptor_tag ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Bad descriptor tag.\r\n"); return DHL_FAIL_INVALID_PARAM; } length = p[1]; /* create the bitBuffer */ err = bitBufferCreate(&bits,p+2,length); if (err) { goto ParseDescriptorExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseDescriptorExit; } /* create the descriptor memory */ *descripPtr = (channelPropertiesDescriptorPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(channelPropertiesDescriptor_t)+sizeof(memId_t))) + 1); if (*descripPtr == NULL) { err = DHL_FAIL_OUT_OF_RESOURCE; goto ParseDescriptorExit; } /* parse the descriptor */ (*descripPtr)->channel_TSID = bitBufferGetBits(bits,16); bitBufferSkipBits(bits,6); /*reserved : 6 bits*/ (*descripPtr)->out_of_band_channel = bitBufferGetBits(bits,1); (*descripPtr)->access_controlled = bitBufferGetBits(bits,1); (*descripPtr)->hide_guide = bitBufferGetBits(bits,1); bitBufferSkipBits(bits,1); /*reserved : 1 bits*/ (*descripPtr)->service_type = bitBufferGetBits(bits,6); /* parsing complete */ *(((memId_t *)(*descripPtr))-1) = memId; memId = NULL; /* so memChain not deleted */ ParseDescriptorExit: if (bits) { /* delete the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the descriptor memory */ memChainDestroy(memId); } return (err); } /*============================================================================== DHL_RESULT DHL_PSI_ParseChannelPropertiesDescriptor (DS_U8* p, channelPropertiesDescriptorPtr_t *descripPtr) { *p: Pointer to the un-parsed descriptor. *descripPtr Pointer to parsed descriptor passed here. Parses the descriptor and passes the result back via the descripPtr variable. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseChannelPropertiesDescriptor_Ex ( generalDescriptorPtr_t genDescPtr , channelPropertiesDescriptorPtr_t *descripPtr) { bitBufferPtr_t bits = NULL; memId_t memId; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U8 length; DHL_RESULT err; if( genDescPtr == NULL ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseChannelPropertiesDescriptor():bad parameter\r\n"); return DHL_FAIL_INVALID_PARAM; } if( genDescPtr->descriptor_tag != Channel_Properties_Descriptor_tag ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Bad decriptor tab.\r\n"); return DHL_FAIL_INVALID_PARAM; } length = genDescPtr->descriptor_length; /* create the bitBuffer */ err = bitBufferCreate(&bits, (genDescPtr->descriptor_data) ,length); if (err) { goto ParseDescriptorExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseDescriptorExit; } /* create the descriptor memory */ *descripPtr = (channelPropertiesDescriptorPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(channelPropertiesDescriptor_t)+sizeof(memId_t))) + 1); if (*descripPtr == NULL) { err = DHL_FAIL_OUT_OF_RESOURCE; goto ParseDescriptorExit; } /* parse the descriptor */ (*descripPtr)->channel_TSID = bitBufferGetBits(bits,16); bitBufferSkipBits(bits,6); /*reserved : 6 bits*/ (*descripPtr)->out_of_band_channel = bitBufferGetBits(bits,1); (*descripPtr)->access_controlled = bitBufferGetBits(bits,1); (*descripPtr)->hide_guide = bitBufferGetBits(bits,1); bitBufferSkipBits(bits,1); /*reserved : 1 bits*/ (*descripPtr)->service_type = bitBufferGetBits(bits,6); /* parsing complete */ *(((memId_t *)(*descripPtr))-1) = memId; memId = NULL; /* so memChain not deleted */ ParseDescriptorExit: if (bits) { /* delete the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the descriptor memory */ memChainDestroy(memId); } return (err); } /*============================================================================== DHL_RESULT DHL_PSI_ParseDaylightSavingsTimeDescriptor (DS_U8* p, daylightSavingsTimeDescriptorPtr_t *descripPtr) { *p: Pointer to the un-parsed descriptor. *descripPtr Pointer to parsed descriptor passed here. Parses the descriptor and passes the result back via the descripPtr variable. ==============================================================================*/ DHL_RESULT DHL_PSI_ParseDaylightSavingsTimeDescriptor (DS_U8* p, daylightSavingsTimeDescriptorPtr_t *descripPtr) { bitBufferPtr_t bits = NULL; memId_t memId; memChainSetup_t memSetup = {MEM_LIMIT,NULL,NULL}; DS_U8 length; DHL_RESULT err; if( p == NULL) { DHL_DbgPrintf( 0, DHLDBG_PSI, "ParseDaylightSavingsTimeDescriptor():bad parameter\r\n"); return DHL_FAIL_INVALID_PARAM; } if ( *p != Daylight_Savings_Time_Descriptor_tag ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Bad Descriptor Tag.\r\n"); return DHL_FAIL_INVALID_PARAM; } length = p[1]; /* create the bitBuffer */ err = bitBufferCreate(&bits,p+2,length); if (err) { goto ParseDescriptorExit; } /* create the memChain */ err = memChainCreate(&memId,&memSetup); if (err) { goto ParseDescriptorExit; } /* create the descriptor memory */ *descripPtr = (daylightSavingsTimeDescriptorPtr_t)((memId_t *)(memChainAlloc(memId,sizeof(daylightSavingsTimeDescriptor_t)+sizeof(memId_t))) + 1); if (*descripPtr == NULL) { err = DHL_FAIL_OUT_OF_RESOURCE; goto ParseDescriptorExit; } /* parse the descriptor */ (*descripPtr)->DS_status = bitBufferGetBits(bits,1); bitBufferSkipBits(bits,2); /*reserved : 2 bits*/ (*descripPtr)->DS_day_of_month = bitBufferGetBits(bits,5); (*descripPtr)->DS_hour = bitBufferGetBits(bits,8); /* parsing complete */ *(((memId_t *)(*descripPtr))-1) = memId; memId = NULL; /* so memChain not deleted */ ParseDescriptorExit: if (bits) { /* delete the bitBuffer */ bitBufferDestroy(bits); } if (memId) { /* delete the descriptor memory */ memChainDestroy(memId); } return (err); } /*============================================================================== DHL_RESULT DHL_PSI_MonitorCEA_OOB (PSIUpdateMode updateMode, PSIEventProc eventProc, DS_U32 userParam, PSIControl **psiCtl) updateMode: Update mode (psiOneShot,psiVersionChange,psiContinuous). eventProc: Callback function to catch monitor events. userParam: Passed back to the eventProc. psiCtl: PSI Object for PSI layer. Configures the TID & PID filters for Cable Emergency Alert sections. ==============================================================================*/ DHL_RESULT DHL_PSI_MonitorCEA_OOB( PSIUpdateMode updateMode, PSIEventProc_f eventProc, DS_U32 userParam, DHL_TBL_HANDLE *returnPSICtl) { PSIMask_t *pref; DHL_RESULT err; #ifdef PSI_DBG DHL_DbgPrintf( 0, DHLDBG_PSI, "in the DHL_PSI_MonitorCEA_OOB.\r\n"); #endif if ((err = DD_PSI_GetTIDPSIMask (&pref, tid_cable_emergency_alert_message, _TRUE_))) { return(err); } if ((err = DHL_PSI_MonitorPSIPidSw( SI_BASE_PID, sectionMode, updateMode, pref, 4096, 1, eventProc, userParam, returnPSICtl))) { PSI_Free(pref); } return(err); } /* typedef struct NetworkInfoTableSection { DS_U8 protocol_version; DS_U8 first_index; DS_U8 number_of_records; DS_U8 transmission_medium; SI_nit_subtype_k table_subtype; CDS_t * CDSs; MMS_t * MMSs; DS_U8 descriptors_count; DS_U8 *descriptor; } nitSection_t , *nitSectionPtr_t; typedef struct CarrierDefinitionSubtable { DS_U8 number_of_carriers; DS_U8 spacing_unit; DS_U16 frequency_spacing; DS_U8 frequency_unit; DS_U16 first_carrier_frequency; DS_U8 descriptors_count; DS_U8 *descriptor; } CDS_t , *CDSPtr_t; typedef struct ModulationModeSubtable { DS_U8 transmission_system; SI_inner_coding_mode_k inner_coding_mode; DS_U8 split_bitstream_mode; SI_modulation_format_k modulation_format; DS_U32 symbol_rate; DS_U8 descriptors_count; DS_U8 *descriptor; } MMS_t , *MMSPtr_t; */ void DHL_PSI_PrintNit( nitPtr_t pNit ) { int i; CDSPtr_t pCds; MMSPtr_t pMms; DHL_DbgPrintf( 0, DHLDBG_PSI, "\n\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "@@@@@@@@@@@=====================@@@@@@@@@@@@@\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Network Interface Table....\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "protocol_version : %d\n", pNit->protocol_version); DHL_DbgPrintf( 0, DHLDBG_PSI, "first_index : %d\n", pNit->first_index); DHL_DbgPrintf( 0, DHLDBG_PSI, "number_of_records : %d\n", pNit->number_of_records); DHL_DbgPrintf( 0, DHLDBG_PSI, "transmission_medium : %d\n", pNit->transmission_medium); for( i = 0 ; i < pNit->number_of_records ; i++ ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "\n"); switch(pNit->table_subtype) { case st_CDS: pCds = &(pNit->CDSs[i]); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t === table_subtype : Carrier Definition Subtable === \n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tnumber_of_carriers : %d\n" , pCds->number_of_carriers); if( pCds->spacing_unit == fu_10Khz ) DHL_DbgPrintf( 0, DHLDBG_PSI, "\tspacing_unit : 10 kHz Spacing\n"); else DHL_DbgPrintf( 0, DHLDBG_PSI, "\tspacing_unit : 125 kHz Spacing\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tfrequency_spacing : %d\n" , pCds->frequency_spacing); if( pCds->frequency_unit == fu_10Khz ) DHL_DbgPrintf( 0, DHLDBG_PSI, "\tfrequency_unit : 10 kHz Frequency Unit\n"); else DHL_DbgPrintf( 0, DHLDBG_PSI, "\tfrequency_unit : 125 kHz Frequency Unit\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tfirst_carrier_frequency : %d\n" , pCds->first_carrier_frequency); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tdescriptors_count : %d\n", pCds->descriptors_count); break; case st_MMS: pMms = &(pNit->MMSs[i]); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t === table_subtype : Modulation Mode Subtable === \n"); if( pMms->transmission_system == 2 ) DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttransmission_system : ITU North American standard.\n"); else if ( pMms->transmission_system == 4 ) DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttransmission_system : ATSC Digital Televsion Standard.\n"); else DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttransmission_system : unknouwn...\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tinner_coding_mode : %d\n", pMms->inner_coding_mode); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tsplit_bitstream_mode : %d\n", pMms->split_bitstream_mode); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tmodulation_format : %d\n", pMms->modulation_format); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tsymbol_rate : %ld\n", pMms->symbol_rate); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tdescriptors_count : %d\n", pMms->descriptors_count); break; } } DHL_DbgPrintf( 0, DHLDBG_PSI, "descriptors_length : %d\n", pNit->descriptors_length); } void DHL_PSI_PrintNitSection( nitSectionPtr_t pNit ) { int i; CDSPtr_t pCds; MMSPtr_t pMms; DHL_DbgPrintf( 0, DHLDBG_PSI, "\n\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "@@@@@@@@@@@=====================@@@@@@@@@@@@@\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Network Interface Table Section....\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "protocol_version : %d\n", pNit->protocol_version); DHL_DbgPrintf( 0, DHLDBG_PSI, "first_index : %d\n", pNit->first_index); DHL_DbgPrintf( 0, DHLDBG_PSI, "number_of_records : %d\n", pNit->number_of_records); DHL_DbgPrintf( 0, DHLDBG_PSI, "transmission_medium : %d\n", pNit->transmission_medium); for( i = 0 ; i < pNit->number_of_records ; i++ ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "\n"); switch(pNit->table_subtype) { case st_CDS: pCds = &(pNit->CDSs[i]); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t === table_subtype : Carrier Definition Subtable === \n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tnumber_of_carriers : %d\n" , pCds->number_of_carriers); if( pCds->spacing_unit == fu_10Khz ) DHL_DbgPrintf( 0, DHLDBG_PSI, "\tspacing_unit : 10 kHz Spacing\n"); else DHL_DbgPrintf( 0, DHLDBG_PSI, "\tspacing_unit : 125 kHz Spacing\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tfrequency_spacing : %d\n" , pCds->frequency_spacing); if( pCds->frequency_unit == fu_10Khz ) DHL_DbgPrintf( 0, DHLDBG_PSI, "\tfrequency_unit : 10 kHz Frequency Unit\n"); else DHL_DbgPrintf( 0, DHLDBG_PSI, "\tfrequency_unit : 125 kHz Frequency Unit\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tfirst_carrier_frequency : %d\n" , pCds->first_carrier_frequency); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tdescriptors_count : %d\n", pCds->descriptors_count); break; case st_MMS: pMms = &(pNit->MMSs[i]); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t === table_subtype : Modulation Mode Subtable === \n"); if( pMms->transmission_system == 2 ) DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttransmission_system : ITU North American standard.\n"); else if ( pMms->transmission_system == 4 ) DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttransmission_system : ATSC Digital Televsion Standard.\n"); else DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttransmission_system : unknouwn...\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tinner_coding_mode : %d\n", pMms->inner_coding_mode); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tsplit_bitstream_mode : %d\n", pMms->split_bitstream_mode); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tmodulation_format : %d\n", pMms->modulation_format); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tsymbol_rate : %ld\n", pMms->symbol_rate); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tdescriptors_count : %d\n", pMms->descriptors_count); break; } } DHL_DbgPrintf( 0, DHLDBG_PSI, "descriptors_length : %d\n", pNit->descriptors_length); } /* typedef struct DcmData { DS_U8 range_defined; DS_U8 channels_count; } dcm_data_t , *dcm_dataPtr_t; typedef struct DefinedChannelMap { DS_U16 first_virtual_channel; DS_U8 DCM_data_length; dcm_data_t * DCM_data; } DCM_t, *DCMPtr_t; typedef struct VirtualChannel { DS_U16 virtual_channel_number; DS_U8 application_virtual_channel; SI_svct_pathselect_k path_select; SI_svct_transporttype_k transport_type; SI_svct_channeltype_k channel_type; DS_U16 application_ID; DS_U16 source_ID; //if transport == MEPG_2 DS_U8 CDS_reference; DS_U16 program_number; DS_U8 MMS_reference; //else : non-MPEG_2 DS_U8 scrambled; SI_svct_videostandard_k video_standard; DS_U8 descriptors_count; DS_U8 *descriptor; } virtualChannel_t , *virtualChannelPtr_t; typedef struct VirtualChannelMap { DS_U8 descriptors_included; DS_U8 splice; DS_U32 activation_time; DS_U8 number_of_VC_records; virtualChannel_t *virtual_channel; } VCM_t , *VCMPtr_t; typedef struct icmRecord { DS_U16 source_ID; DS_U16 virtual_channel_number; } icmRecord_t , *icmRecordPtr_t; typedef struct InverseChannelMap { DS_U16 first_map_index; DS_U8 record_count; icmRecord_t * icmRecords; } ICM_t , *ICMPtr_t; typedef struct ShortformVirtualChannelTableSection { DS_U8 protocol_version; DS_U8 transmission_medium; SI_svct_subtype_k table_subtype; DS_U16 VCT_ID; DCM_t *DCM; VCM_t *VCM; ICM_t *ICM; DS_U8 descriptors_count; DS_U8 *descriptor; } svctSection_t , *svctSectionPtr_t; */ void DHL_PSI_PrintVCM ( VCMPtr_t pvcm ) { int iCountgo = 0; virtualChannelPtr_t pvirtualChannel = NULL; if( !pvcm ) return; DHL_DbgPrintf( 0, DHLDBG_PSI, "\t descriptors_included : %d\n", pvcm->descriptors_included); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t splice : %d\n", pvcm->splice); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t activation_time : %ld\n", pvcm->activation_time); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t number_of_VC_records : %d\n", pvcm->number_of_VC_records); for( iCountgo = 0; iCountgo < pvcm->number_of_VC_records ; iCountgo++ ) { pvirtualChannel = &(pvcm->virtual_channel[iCountgo]); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t virtual_channel_number = %d\n", pvirtualChannel->virtual_channel_number); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t application_virtual_channel = %d\n", pvirtualChannel->application_virtual_channel); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t path_select = %d\n", pvirtualChannel->path_select); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t transport_type = %d\n", pvirtualChannel->transport_type); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t channel_type = %d\n", pvirtualChannel->channel_type); if( pvirtualChannel->application_virtual_channel ) DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t application_ID = %d\n", pvirtualChannel->application_ID); else DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t source_ID = %d\n", pvirtualChannel->source_ID); if ( pvirtualChannel->transport_type == tt_MPEG2_transport ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t CDS_reference = %d\n", pvirtualChannel->CDS_reference); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t program_number = %d\n", pvirtualChannel->program_number); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t MMS_reference = %d\n", pvirtualChannel->MMS_reference); } else { DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t CDS_reference = %d\n", pvirtualChannel->CDS_reference); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t scrambled = %d\n", pvirtualChannel->scrambled); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t video_standard = %d\n", pvirtualChannel->video_standard); } if ( pvcm->descriptors_included ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t descriptors_count = %d\n", pvirtualChannel->descriptors_count); } DHL_DbgPrintf( 0, DHLDBG_PSI, "\n"); } /*for( iCountgo = 0; iCountgo < pvcm->number_of_VC_records ; iCountgo++ )*/ } void DHL_PSI_PrintDCM( DCMPtr_t pDcm ) { int i = 0; DHL_DbgPrintf( 0, DHLDBG_PSI, "\t first_virtual_channel = %d\n" , pDcm->first_virtual_channel ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t DCM_data_length = %d\n", pDcm->DCM_data_length ); for( i = 0 ; i < pDcm->DCM_data_length ; i++ ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t DCM_Data[%d]...\n", i); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t range_defined: %d\n", pDcm->DCM_data[i].range_defined); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t channels_count : %d\n", pDcm->DCM_data[i].channels_count); } } void DHL_PSI_PrintICM( ICMPtr_t pIcm ) { int i = 0; DHL_DbgPrintf( 0, DHLDBG_PSI, "\t first_map_index = %d\n" , pIcm->first_map_index); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t record_count = %d\n" , pIcm->record_count); for( i = 0 ; i < pIcm->record_count ; i++ ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t source_ID = %d\n", pIcm->icmRecords[i].source_ID); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t virtual_channel_number = %d\n", pIcm->icmRecords[i].virtual_channel_number); } } void DHL_PSI_PrintSvct ( svctPtr_t pSvct ) { if( !pSvct ) return; DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Short Virtual Channel Table....\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "protocol_version : %d\n", pSvct->protocol_version); DHL_DbgPrintf( 0, DHLDBG_PSI, "transmission_medium : %d\n", pSvct->transmission_medium); DHL_DbgPrintf( 0, DHLDBG_PSI, "VCT_ID : %d\n", pSvct->VCT_ID); switch(pSvct->table_subtype ) { case st_VCM: DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttable_subtype : Virtual Channel Map.\n"); if( pSvct->VCM ) DHL_PSI_PrintVCM( pSvct->VCM ); break; case st_DCM: DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttable_subtype : Defined Channel Map.\n"); if( pSvct->DCM ) DHL_PSI_PrintDCM ( pSvct->DCM ); break; case st_ICM: DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttable_subtype : Inversel Channel Map.\n"); if( pSvct->ICM ) DHL_PSI_PrintICM( pSvct->ICM ); break; } /*switch( table_subtype )*/ } void DHL_PSI_PrintSvctSection ( svctSectionPtr_t pSvct ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Short Virtual Channel Table Section....\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "protocol_version : %d\n", pSvct->protocol_version); DHL_DbgPrintf( 0, DHLDBG_PSI, "transmission_medium : %d\n", pSvct->transmission_medium); DHL_DbgPrintf( 0, DHLDBG_PSI, "VCT_ID : %d\n", pSvct->VCT_ID); switch(pSvct->table_subtype ) { case st_VCM: DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttable_subtype : Virtual Channel Map.\n"); if( pSvct->VCM ) DHL_PSI_PrintVCM( pSvct->VCM ); break; case st_DCM: DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttable_subtype : Defined Channel Map.\n"); if( pSvct->DCM ) DHL_PSI_PrintDCM ( pSvct->DCM ); break; case st_ICM: DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttable_subtype : Inversel Channel Map.\n"); if( pSvct->ICM ) DHL_PSI_PrintICM( pSvct->ICM ); break; } /*switch( table_subtype )*/ } /* typedef struct systemTimeTableSection { DS_U8 protocol_version; DS_U32 system_time; DS_U8 GPS_UTC_offset; DS_U8 descriptors_count; DS_U8 *descriptor; } SI_sttSection_t , * SI_sttSectionPtr_t; */ void DHL_PSI_PrintSiSttSection( SI_sttSectionPtr_t pSiStt ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Print SI System Time Table Section....\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "protocol_version : %d \n", pSiStt->protocol_version); DHL_DbgPrintf( 0, DHLDBG_PSI, "system_time : %ld \n", pSiStt->system_time); DHL_DbgPrintf( 0, DHLDBG_PSI, "GPS_UTC_offset : %d \n",pSiStt->GPS_UTC_offset); DHL_DbgPrintf( 0, DHLDBG_PSI, "descriptors_length : %d \n", pSiStt->descriptors_length); } /* typedef struct SnsRecord { DS_U8 application_type; DS_U16 application_ID; DS_U16 source_ID; DS_U8 name_length; DS_U8 *source_name; DS_U8 SNS_descriptors_count; DS_U8 *descriptor; } snsRecord_t, *snsRecordPtr_t; typedef struct SourceNameSubtable { DS_U8 number_of_SNS_records; snsRecord_t *SNS_records; } SNS_t , *SNSPtr_t; typedef struct NetworkTextTableSection { DS_U8 protocol_version; DS_U32 ISO_639_language_code; DS_U8 transmission_medium; SI_ntt_subtype_k table_subtype; SNS_t * SNS; DS_U8 descriptors_count; DS_U8 *descriptor; } nttSection_t , *nttSectionPtr_t; */ void DHL_PSI_PrintNtt( nttPtr_t pNttSect ) { DS_U8 langcode[3]; langcode[0] = (DS_U8)((pNttSect->ISO_639_language_code)>>16); langcode[1] = (DS_U8)((pNttSect->ISO_639_language_code)>>8); langcode[2] = (DS_U8)(pNttSect->ISO_639_language_code); DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Network Text Table....\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "protocol_version : %d\n", pNttSect->protocol_version); DHL_DbgPrintf( 0, DHLDBG_PSI, "ISO_639_language_code : %c%c%c\n", langcode[0],langcode[1],langcode[2]); DHL_DbgPrintf( 0, DHLDBG_PSI, "transmission_medium : %d\n", pNttSect->transmission_medium); DHL_DbgPrintf( 0, DHLDBG_PSI, "table_subtype : %d\n", pNttSect->table_subtype); DHL_DbgPrintf( 0, DHLDBG_PSI, "number_of_SNS_records : %d\n", pNttSect->number_of_SNS_records); if( pNttSect ) { if( pNttSect->number_of_SNS_records > 0 ) { int i = 0; snsRecordPtr_t pSnsr = NULL; for( i = 0 ; i < pNttSect->number_of_SNS_records ; i++ ) { pSnsr = &(pNttSect->SNS_records[i]); if(pSnsr) { DHL_DbgPrintf( 0, DHLDBG_PSI, "\t application_type = %d\n", pSnsr->application_type ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t application_ID = %d\n", pSnsr->application_ID ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t source_ID = %d\n", pSnsr->source_ID ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t name_length = %d\n", pSnsr->name_length ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t source_name = ....\n" ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t SNS_descriptors_count = %d\n", pSnsr->SNS_descriptors_count ); } /*if(pSnsr)*/ } /*for( i = 0 ; i < pNttSect->number_of_SNS_records ; i++ )*/ } /*if( pNttSect->number_of_SNS_records > 0 )*/ } /*if( pNttSect->SNS )*/ DHL_DbgPrintf( 0, DHLDBG_PSI, "descriptors_length : %d\n", pNttSect->descriptors_length); } void DHL_PSI_PrintNttSection( nttSectionPtr_t pNttSect ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Network Text Table Section....\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "protocol_version : %d\n", pNttSect->protocol_version); DHL_DbgPrintf( 0, DHLDBG_PSI, "ISO_639_language_code : %ld\n", pNttSect->ISO_639_language_code); DHL_DbgPrintf( 0, DHLDBG_PSI, "transmission_medium : %d\n", pNttSect->transmission_medium); DHL_DbgPrintf( 0, DHLDBG_PSI, "table_subtype : %d\n", pNttSect->table_subtype); if( pNttSect ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "number_of_SNS_records : %d\n", pNttSect->number_of_SNS_records); if( pNttSect->number_of_SNS_records > 0 ) { int i = 0; snsRecordPtr_t pSnsr = NULL; for( i = 0 ; i < pNttSect->number_of_SNS_records ; i++ ) { pSnsr = &(pNttSect->SNS_records[i]); if(pSnsr) { DHL_DbgPrintf( 0, DHLDBG_PSI, "\t application_type = %d\n", pSnsr->application_type ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t application_ID = %d\n", pSnsr->application_ID ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t source_ID = %d\n", pSnsr->source_ID ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t name_length = %d\n", pSnsr->name_length ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t source_name = ....\n" ); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t SNS_descriptors_count = %d\n", pSnsr->SNS_descriptors_count ); } /*if(pSnsr)*/ } /*for( i = 0 ; i < pNttSect->number_of_SNS_records ; i++ )*/ } /*if( pNttSect->number_of_SNS_records > 0 )*/ } /*if( pNttSect->SNS )*/ DHL_DbgPrintf( 0, DHLDBG_PSI, "descriptors_length : %d\n", pNttSect->descriptors_length); } /* typedef struct siEvent { DS_U16 event_ID; DS_U32 start_time; DS_U8 ETM_present; DS_U32 duration; DS_U8 title_length; DS_U8 *title_text; DS_U16 descriptors_length; DS_U8 *descriptor; } SI_event_t , *SI_eventPtr_t; typedef struct siEventInformationTableSection { DS_U16 source_ID; DS_U8 num_events; SI_eventPtr_t events; } SI_eitSection_t , *SI_eitSectionPtr_t; typedef struct aggregateEventInformationTable { DS_U8 AEIT_subtype; DS_U8 MGT_tag; DS_U8 version_number; DS_U8 num_sources; SI_eitSectionPtr_t eits; } aeit_t , *aeitPtr_t; */ void DHL_PSI_PrintAeit ( aeitPtr_t pAeit ) { int i = 0; int j = 0; SI_eitSectionPtr_t pEit = NULL; SI_eventPtr_t pEvent = NULL; DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Aggregate Event Information Table....\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "AEIT_subtype : %d\n" , pAeit->AEIT_subtype ); DHL_DbgPrintf( 0, DHLDBG_PSI, "MGT_tag : %d\n" , pAeit->MGT_tag); DHL_DbgPrintf( 0, DHLDBG_PSI, "version_number : %d\n" , pAeit->version_number ); DHL_DbgPrintf( 0, DHLDBG_PSI, "num_sources : %d\n" , pAeit->num_sources); DHL_DbgPrintf( 0, DHLDBG_PSI, "AEIT_subtype : %d\n" , pAeit->AEIT_subtype ); for( i = 0 ; i < pAeit->num_sources ; i++ ) { pEit = &(pAeit->eits[i]); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t %d-th channel....\n" , i); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t source_ID : %d\n", pEit->source_ID); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t num_events : %d\n", pEit->num_events); for ( j = 0 ; j < pEit->num_events ; j++ ) { pEvent = &(pEit->events[j]); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t %d-th event....\n" , j); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t event_ID : %d\n", pEvent->event_ID); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t start_time : %ld\n", pEvent->start_time); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t duration : %ld\n", pEvent->duration); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t ETM_present : %d\n", pEvent->ETM_present); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t title_length : %d\n", pEvent->title_length); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t descriptors_length : %d\n", pEvent->descriptors_length); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t\t event_ID : %d\n", pEvent->event_ID); } /*for ( j = 0 ; j < pEit->num_events ; j++ )*/ } /*for( i = 0 ; i < pAeit->num_sources ; i++ )*/ } /* typedef struct siExtendedTextTableSection { DS_U32 ETM_ID; DS_U16 extended_text_length; DS_U8 *extended_text_message; } SI_ettSection_t , *SI_ettSectionPtr_t; typedef struct aggregateExtendedTextTable { DS_U8 AETT_subtype; DS_U8 MGT_tag; DS_U8 version_number; DS_U8 num_blocks; SI_ettSectionPtr_t etts; } aett_t , *aettPtr_t; */ void DHL_PSI_PrintAett( aettPtr_t pAett ) { int i = 0; DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Aggregate Extended Text Table....\r\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "AETT_subtype : %d\r\n", pAett->AETT_subtype ); DHL_DbgPrintf( 0, DHLDBG_PSI, "MGT_tag : %d\r\n", pAett->MGT_tag); DHL_DbgPrintf( 0, DHLDBG_PSI, "version_number : %d\r\n", pAett->version_number); DHL_DbgPrintf( 0, DHLDBG_PSI, "num_blocks : %d\r\n", pAett->num_blocks); for( i = 0 ; i < pAett->num_blocks ; i++ ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "\t %d-th block.....\r\n" , i); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t ETM_ID : %ld\r\n", pAett->etts[i].ETM_ID); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t extended_text_length : %d\r\n", pAett->etts[i].extended_text_length); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t extended_text_message : 0x%lx\r\n", (DS_U32)pAett->etts[i].extended_text_message); } } /* typedef struct revisionDetectionDescriptor { DS_U8 table_version_number; DS_U8 section_number; DS_U8 last_section_number; } revisionDetectionDescriptor_t , *revisionDetectionDescriptorPtr_t; */ void DHL_PSI_PrintRevisionDetectionDescriptor ( revisionDetectionDescriptorPtr_t pRDD ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Revision Detection Descriptor....\r\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t table_version_number : %d\r\n", pRDD->table_version_number); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t table_version_number : %d\r\n", pRDD->table_version_number); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t last_section_number : %d\r\n", pRDD->last_section_number); } void DHL_PSI_PrintTwoPartChannelNumberDescriptor( twoPartChannelNumberDescriptorPtr_t pTPCN ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Print TwoPart Channel Number Descriptor....\r\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t major_channel_number : %d\r\n", pTPCN->major_channel_number); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t minor_channel_number : %d\r\n", pTPCN->minor_channel_number); } void DHL_PSI_PrintChannelPropertiesDescriptor ( channelPropertiesDescriptorPtr_t pCPD ) { DHL_DbgPrintf( 0, DHLDBG_PSI, "Print Channel Properties Descriptor....\r\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t channel_TSID : %d\r\n", pCPD->channel_TSID); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t out_of_band_channel : %d\r\n", pCPD->out_of_band_channel); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t access_controlled : %d\r\n", pCPD->access_controlled); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t hide_guide : %d\r\n", pCPD->hide_guide); DHL_DbgPrintf( 0, DHLDBG_PSI, "\t service_type : %d\r\n", pCPD->service_type); } #if 0 typedef struct siEvent { DS_U16 event_ID; /*14bits*/ DS_U32 start_time; /*32bits*/ DS_U8 ETM_present; /*2bits*/ DS_U32 duration; /*32bits*/ DS_U8 title_length; /*8bits*/ DS_U8 *title_text; DS_U16 descriptors_length; /*12bits*/ DS_U8 *descriptor; } SI_event_t , *SI_eventPtr_t; typedef struct siEventInformationTableSection { DS_U16 source_ID; /*16bits*/ DS_U8 num_events; /*8bits*/ SI_eventPtr_t events; } SI_eitSection_t , *SI_eitSectionPtr_t; typedef struct aggregateEventInformationTable { DS_U8 AEIT_subtype; /*8bits*/ DS_U8 MGT_tag; /*8bits*/ DS_U8 version_number; /*5bits*/ DS_U8 num_sources; SI_eitSectionPtr_t eits; } aeit_t , *aeitPtr_t; void DHL_PSI_PrintAeit( aeitPtr_t pAeit ) { int i , j; SI_eitSectionPtr_t pEit; SI_eventPtr_t pEvent; DHL_DbgPrintf( 0, DHLDBG_PSI, "=========PRINT AEIT==============\r\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "AEIT_subtype = %d\r\n" , pAeit->AEIT_subtype); DHL_DbgPrintf( 0, DHLDBG_PSI, "MGT_tag = %d\r\n" , pAeit->MGT_tag); DHL_DbgPrintf( 0, DHLDBG_PSI, "version_number = %d\r\n" , pAeit->version_number); DHL_DbgPrintf( 0, DHLDBG_PSI, "num_sources = %d\r\n" , pAeit->num_sources); for( i = 0 ; i < pAeit->num_sources ; i++ ) { pEit = &(pAeit->eits[i]); DHL_DbgPrintf( 0, DHLDBG_PSI, " ----------%d-th one eit--------------\r\n" , i); DHL_DbgPrintf( 0, DHLDBG_PSI, " source_ID = %d\r\n" , pEit->source_ID); DHL_DbgPrintf( 0, DHLDBG_PSI, " num_events = %d\r\n" , pEit->num_events); for( j = 0 ; j < pEit->num_events ; j++ ) { pEvent = &(pEit->events[j]); DHL_DbgPrintf( 0, DHLDBG_PSI, " -------%d-th one event-----------\r\n" , j); DHL_DbgPrintf( 0, DHLDBG_PSI, " event_ID = %d\r\n" , pEvent->event_ID); DHL_DbgPrintf( 0, DHLDBG_PSI, " start_time = %d\r\n" , pEvent->start_time); DHL_DbgPrintf( 0, DHLDBG_PSI, " ETM_present = %d\r\n" , pEvent->ETM_present); DHL_DbgPrintf( 0, DHLDBG_PSI, " duration = %d\r\n" , pEvent->duration); DHL_DbgPrintf( 0, DHLDBG_PSI, " title_length = %d\r\n" , pEvent->title_length); DHL_DbgPrintf( 0, DHLDBG_PSI, " title_text = %0x%x\r\n", (DS_U32)(pEvent->title_text)); DHL_DbgPrintf( 0, DHLDBG_PSI, " descriptors_length = %d\r\n" , pEvent->descriptors_length); DHL_DbgPrintf( 0, DHLDBG_PSI, " descriptor = 0x%x\r\n", (DS_U32)(pEvent->descriptor)); } /*for( j = 0 ; j < pEit->num_events ; j++ )*/ } /*for( i = 0 ; i < pAeit->num_sources ; i++ )*/ } #endif //#if 0 void DHL_PSI_PrintSiMgtSection ( mgtSectionPtr_t mgtSectPtr ) { DS_S32 i; DS_U16 table_type; DHL_DbgPrintf( 0, DHLDBG_PSI, "\r\n------ MGT Section ------\r\n"); DHL_DbgPrintf( 0, DHLDBG_PSI, "version_number: %d\r\n", mgtSectPtr->version_number); DHL_DbgPrintf( 0, DHLDBG_PSI, "tables_defined: %d\r\n", mgtSectPtr->tables_defined); for (i=0; itables_defined; i++) { DHL_DbgPrintf( 0, DHLDBG_PSI, "table[%ld]:\r\n", i); DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttable_type: 0x%04X ", mgtSectPtr->table[i].table_type); table_type = mgtSectPtr->table[i].table_type; if (table_type == tt_NIT_cds) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(Network Information Table-CDS Table Subtype)\r\n"); } else if (table_type == tt_NIT_mms) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(Network Information Table-MMS Table Subtype)\r\n"); } else if (table_type == tt_lf_VCT_cni_0) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(Long-form Cable VCT with current_next_indicator=0)\r\n"); } else if (table_type == tt_lf_VCT_cni_1) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(Long-form Cable VCT with current_next_indicator=1)\r\n"); } else if (table_type == tt_NTT) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(Network Text Table - SNS Table SubType)\r\n"); } else if (table_type == tt_sf_VCT_vcm) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(Short-form Cable VCT - VCM Subtype)\r\n"); } else if (table_type == tt_sf_VCT_dcm) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(Short-form Cable VCT - DCM Subtype)\r\n"); } else if (table_type == tt_sf_VCT_icm) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(Short-form Cable VCT - ICM Subtype)\r\n"); } else if (table_type == tt_channel_ETT) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(channel ETT)\r\n"); } else if (table_type >= tt_AEIT_0 && table_type <= tt_AEIT_255) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(AEIT-%d)\r\n",table_type-tt_AEIT_0); } else if (table_type >= tt_AETT_0 && table_type <= tt_AETT_255) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(AETT-%d)\r\n",table_type-tt_AETT_0); } else if (table_type >= tt_RRT_region_1 && table_type <= tt_RRT_region_255) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(RRT with rating_region %d)\r\n",table_type-0x0300); } else if (table_type >= 0x0400 && table_type <= 0x0FFF) { DHL_DbgPrintf( 0, DHLDBG_PSI, "(User Private)\r\n"); } else { DHL_DbgPrintf( 0, DHLDBG_PSI, "(Reserved for future ATSC use)\r\n"); } DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttable_type_PID: 0x%04X (%d)\r\n", mgtSectPtr->table[i].table_type_PID,mgtSectPtr->table[i].table_type_PID); DHL_DbgPrintf( 0, DHLDBG_PSI, "\ttable_type_version_number: %d\r\n", mgtSectPtr->table[i].table_type_version_number); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tnumber_bytes: %ld\r\n", mgtSectPtr->table[i].number_bytes); DHL_DbgPrintf( 0, DHLDBG_PSI, "\tdescriptor_length: %d\r\n", mgtSectPtr->table[i].descriptor_length); } DHL_DbgPrintf( 0, DHLDBG_PSI, "descriptor_length: %d\r\n", mgtSectPtr->descriptor_length); } /*2004.02.15. added by jina.*/ void DHL_PSI_ParseMultipleTextString( unsigned char *pInText , unsigned int iInSize , unsigned char **pOutText , unsigned int *iOutSize , unsigned char* nMode ) { int igo = 0; DS_U8 mode = 0; DS_U8 length = 0; if( !pInText || !iInSize ) return; *pOutText = NULL; *iOutSize = 0; *nMode = 0; while( (iInSize - igo) > 0 ) { mode = pInText[igo]; length = pInText[igo+1]; #ifdef _SI_PARSE_DEBUG_ DHL_DbgPrintf( gdhlPsiDbgLvl, DHLDBG_PSI, "ParseMTS : mode = %d , length = %d\n", mode , length); #endif if( length > 0 ) { *nMode = mode; if( mode < 0x3F ) { *pOutText = malloc( sizeof(DS_U8)*(length+1) ); if( *pOutText != NULL ) { *iOutSize = length+1; memset( (*pOutText) , 0 , length+1 ); memcpy( (*pOutText) , &(pInText[igo+2]) , length ); } break; /*Çѹø ãÀ¸¸é ±×³É ³ª°¡ÀÚ.*/ } else if ( mode == 0x3F ) { *pOutText = malloc( sizeof(DS_U16) *(length+1) ); if( *pOutText != NULL ) { *iOutSize =length+1; //memset( (*pOutText) , 0 , (length+1)*2 ); memcpy( (*pOutText) , &(pInText[igo+2]) ,length*2 ); } break; /*Çѹø ãÀ¸¸é ±×³É ³ª°¡ÀÚ.*/ } } /*if( length > 0 )*/ igo += (length+2); } /*while( (iSize - igo) > 0 )*/ }