/*************************************************************************** * 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_bat); static uint8_t bat_version_num; static uint8_t bat_last_section; static uint32_t bat_section_mask[8]; void dvb_bat_init(void) { int i; bat_version_num = 32; bat_last_section = 0; for (i=0; i<8; i++) { bat_section_mask[i] = 0; } } int dvb_bat_parse(const uint8_t *bat_buf, size_t *psize) { uint8_t tid, version_num, section_num, last_section; uint16_t bouquet_id, section_len, desc_len, loop_len, parsed; uint16_t stream_id, network_id; struct bit_state_t bs; BDBG_ASSERT(bat_buf && psize); BDBG_MSG(("%s: enter", __FUNCTION__)); bs.data = (unsigned char *)bat_buf; bs.bindex = 0; tid = get_bits(8, &bs); if (tid != DVB_TID_BAT) { BDBG_WRN(("%s: invalid table id (0x%x)", __FUNCTION__, tid)); return 0; } get_bits(4, &bs); /* skip section_syntax_indicator, reserved field */ section_len = get_bits(12, &bs); bouquet_id = get_bits(16, &bs); get_bits(2, &bs); /* skip reserved */ version_num = get_bits(5, &bs); get_bits(1, &bs); /* skip current_next_indicator */ section_num = get_bits(8, &bs); last_section = get_bits(8, &bs); get_bits(4, &bs); if (version_num != bat_version_num) { SI_Init_Section_Mask((unsigned long *)bat_section_mask, last_section); bat_last_section = last_section; } else if (SI_Chk_Section_mask((unsigned long *)bat_section_mask, section_num)) { /* same version deliver */ return 0; } SI_Set_Section_mask((unsigned long *)bat_section_mask, section_num); desc_len = get_bits(12, &bs); dvb_parse_descriptors((uint8_t *)&bat_buf[bs.bindex/8], desc_len, DVB_TID_BAT, NULL); bs.bindex = bs.bindex + desc_len*8; get_bits(4, &bs); loop_len = get_bits(12, &bs); parsed = 0; while (parsed