/*************************************************************************** * Copyright (c) 2011, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * $brcm_Log: $ * ****************************************************************************/ #include "bstd.h" #include "bkni.h" #include "ts_priv.h" #include "ts_psi.h" #include "ministd.h" #include "dvb_parser.h" #include "si.h" #include "si_util.h" BDBG_MODULE(dvb_smi); void dvb_smi_init(void) { } int dvb_dit_parse(const uint8_t *dit_buf, size_t *psize) { uint8_t tid, transition_flag; uint16_t section_len; struct bit_state_t bs; BDBG_ASSERT(dit_buf && psize); bs.bindex = 0; bs.data = (unsigned char *)dit_buf; tid = get_bits(8, &bs); if (tid != DVB_TID_DIT) { BDBG_WRN(("%s: invalid table id (0x%x)", __FUNCTION__, tid)); return 0; } get_bits(4, &bs); section_len = get_bits(12, &bs); if (*psize < (section_len+3)) { BDBG_WRN(("%s: incomplete section", __FUNCTION__)); return 0; } transition_flag = get_bits(1, &bs); return 1; } int dvb_sit_parse(const uint8_t *sit_buf, size_t *psize) { uint8_t tid, running_status; uint16_t section_len, version_num, section_num, last_section, desc_len; uint16_t remain, parsed, service_id; struct bit_state_t bs; BDBG_ASSERT(sit_buf && psize); bs.bindex = 0; bs.data = (unsigned char *)sit_buf; tid = get_bits(8, &bs); if (tid != DVB_TID_SIT) { BDBG_WRN(("%s: invalid table id (0x%x)", __FUNCTION__, tid)); return 0; } get_bits(4, &bs); section_len = get_bits(12, &bs); if (*psize < (section_len+3)) { BDBG_WRN(("%s: incomplete section", __FUNCTION__)); return 0; } get_bits(16, &bs); /* DVB_reserved_future_use */ get_bits(2, &bs); /* ISO_reserved */ version_num = get_bits(5, &bs); get_bits(1, &bs); section_num = get_bits(16, &bs); last_section = get_bits(16, &bs); get_bits(4, &bs); /* DVB_reserved_for_future_use */ desc_len = get_bits(12, &bs); dvb_parse_descriptors((uint8_t *)&sit_buf[bs.bindex/8], desc_len, DVB_TID_SIT, NULL); bs.bindex = bs.bindex + desc_len*8; remain = *psize - bs.bindex/8 - 4; parsed = 0; while (parsed < remain) { service_id = get_bits(16, &bs); get_bits(1, &bs); running_status = get_bits(3, &bs); desc_len = get_bits(12, &bs); dvb_parse_descriptors((uint8_t *)&sit_buf[bs.bindex/8], desc_len, DVB_TID_SIT, NULL); bs.bindex = bs.bindex + desc_len*8; parsed += desc_len + 4; } return 1; }