| [2] | 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2011, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: $ |
|---|
| 11 | * $brcm_Revision: $ |
|---|
| 12 | * $brcm_Date: $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: $ |
|---|
| 19 | * |
|---|
| 20 | ****************************************************************************/ |
|---|
| 21 | |
|---|
| 22 | #include "bstd.h" |
|---|
| 23 | #include "bkni.h" |
|---|
| 24 | #include "ts_priv.h" |
|---|
| 25 | #include "ts_psi.h" |
|---|
| 26 | #include "ministd.h" |
|---|
| 27 | #include "dvb_parser.h" |
|---|
| 28 | |
|---|
| 29 | #include "si.h" |
|---|
| 30 | #include "si_util.h" |
|---|
| 31 | |
|---|
| 32 | BDBG_MODULE(dvb_smi); |
|---|
| 33 | |
|---|
| 34 | void dvb_smi_init(void) |
|---|
| 35 | { |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | int dvb_dit_parse(const uint8_t *dit_buf, size_t *psize) |
|---|
| 39 | { |
|---|
| 40 | uint8_t tid, transition_flag; |
|---|
| 41 | uint16_t section_len; |
|---|
| 42 | |
|---|
| 43 | struct bit_state_t bs; |
|---|
| 44 | |
|---|
| 45 | BDBG_ASSERT(dit_buf && psize); |
|---|
| 46 | bs.bindex = 0; |
|---|
| 47 | bs.data = (unsigned char *)dit_buf; |
|---|
| 48 | |
|---|
| 49 | tid = get_bits(8, &bs); |
|---|
| 50 | if (tid != DVB_TID_DIT) { |
|---|
| 51 | BDBG_WRN(("%s: invalid table id (0x%x)", __FUNCTION__, tid)); |
|---|
| 52 | return 0; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | get_bits(4, &bs); |
|---|
| 56 | section_len = get_bits(12, &bs); |
|---|
| 57 | if (*psize < (section_len+3)) { |
|---|
| 58 | BDBG_WRN(("%s: incomplete section", __FUNCTION__)); |
|---|
| 59 | return 0; |
|---|
| 60 | } |
|---|
| 61 | transition_flag = get_bits(1, &bs); |
|---|
| 62 | return 1; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | int dvb_sit_parse(const uint8_t *sit_buf, size_t *psize) |
|---|
| 66 | { |
|---|
| 67 | uint8_t tid, running_status; |
|---|
| 68 | uint16_t section_len, version_num, section_num, last_section, desc_len; |
|---|
| 69 | uint16_t remain, parsed, service_id; |
|---|
| 70 | struct bit_state_t bs; |
|---|
| 71 | |
|---|
| 72 | BDBG_ASSERT(sit_buf && psize); |
|---|
| 73 | bs.bindex = 0; |
|---|
| 74 | bs.data = (unsigned char *)sit_buf; |
|---|
| 75 | |
|---|
| 76 | tid = get_bits(8, &bs); |
|---|
| 77 | if (tid != DVB_TID_SIT) { |
|---|
| 78 | BDBG_WRN(("%s: invalid table id (0x%x)", __FUNCTION__, tid)); |
|---|
| 79 | return 0; |
|---|
| 80 | } |
|---|
| 81 | get_bits(4, &bs); |
|---|
| 82 | section_len = get_bits(12, &bs); |
|---|
| 83 | if (*psize < (section_len+3)) { |
|---|
| 84 | BDBG_WRN(("%s: incomplete section", __FUNCTION__)); |
|---|
| 85 | return 0; |
|---|
| 86 | } |
|---|
| 87 | get_bits(16, &bs); /* DVB_reserved_future_use */ |
|---|
| 88 | get_bits(2, &bs); /* ISO_reserved */ |
|---|
| 89 | version_num = get_bits(5, &bs); |
|---|
| 90 | get_bits(1, &bs); |
|---|
| 91 | section_num = get_bits(16, &bs); |
|---|
| 92 | last_section = get_bits(16, &bs); |
|---|
| 93 | get_bits(4, &bs); /* DVB_reserved_for_future_use */ |
|---|
| 94 | desc_len = get_bits(12, &bs); |
|---|
| 95 | dvb_parse_descriptors((uint8_t *)&sit_buf[bs.bindex/8], desc_len, DVB_TID_SIT, NULL); |
|---|
| 96 | bs.bindex = bs.bindex + desc_len*8; |
|---|
| 97 | |
|---|
| 98 | remain = *psize - bs.bindex/8 - 4; |
|---|
| 99 | parsed = 0; |
|---|
| 100 | while (parsed < remain) { |
|---|
| 101 | service_id = get_bits(16, &bs); |
|---|
| 102 | get_bits(1, &bs); |
|---|
| 103 | running_status = get_bits(3, &bs); |
|---|
| 104 | desc_len = get_bits(12, &bs); |
|---|
| 105 | dvb_parse_descriptors((uint8_t *)&sit_buf[bs.bindex/8], desc_len, DVB_TID_SIT, NULL); |
|---|
| 106 | bs.bindex = bs.bindex + desc_len*8; |
|---|
| 107 | parsed += desc_len + 4; |
|---|
| 108 | } |
|---|
| 109 | return 1; |
|---|
| 110 | } |
|---|
| 111 | |
|---|