source: svn/trunk/newcon3bcm2_21bu/dta/src/dvb/dvb_bat.c @ 31

Last change on this file since 31 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 2.9 KB
Line 
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
32BDBG_MODULE(dvb_bat);
33
34static uint8_t bat_version_num;
35static uint8_t bat_last_section;
36static uint32_t bat_section_mask[8];
37
38void dvb_bat_init(void)
39{
40        int i;
41
42        bat_version_num = 32;
43        bat_last_section = 0;
44        for (i=0; i<8; i++) {
45                bat_section_mask[i] = 0;
46        }
47}
48
49int dvb_bat_parse(const uint8_t *bat_buf, size_t *psize)
50{
51        uint8_t tid, version_num, section_num, last_section;
52        uint16_t bouquet_id, section_len, desc_len, loop_len, parsed;
53        uint16_t stream_id, network_id;
54        struct bit_state_t bs;
55
56        BDBG_ASSERT(bat_buf && psize);
57        BDBG_MSG(("%s: enter", __FUNCTION__));
58
59        bs.data = (unsigned char *)bat_buf;
60        bs.bindex = 0;
61
62        tid = get_bits(8, &bs);
63        if (tid != DVB_TID_BAT) {
64                BDBG_WRN(("%s: invalid table id (0x%x)", __FUNCTION__, tid));
65                return 0;
66        }
67
68        get_bits(4, &bs); /* skip section_syntax_indicator, reserved field */
69        section_len = get_bits(12, &bs);
70        bouquet_id = get_bits(16, &bs);
71        get_bits(2, &bs); /* skip reserved */
72        version_num = get_bits(5, &bs);
73        get_bits(1, &bs); /* skip current_next_indicator */
74
75        section_num = get_bits(8, &bs);
76        last_section = get_bits(8, &bs);
77        get_bits(4, &bs);
78
79        if (version_num != bat_version_num) {
80                SI_Init_Section_Mask((unsigned long *)bat_section_mask, last_section);
81                bat_last_section = last_section;
82        }
83        else if (SI_Chk_Section_mask((unsigned long *)bat_section_mask, section_num)) {
84                /* same version deliver */
85                return 0;
86        }
87
88        SI_Set_Section_mask((unsigned long *)bat_section_mask, section_num);
89
90        desc_len = get_bits(12, &bs);
91        dvb_parse_descriptors((uint8_t *)&bat_buf[bs.bindex/8], desc_len, DVB_TID_BAT, NULL);
92       
93        bs.bindex = bs.bindex + desc_len*8;
94        get_bits(4, &bs); 
95
96        loop_len = get_bits(12, &bs);
97        parsed = 0;
98
99        while (parsed<loop_len) {
100                stream_id = get_bits(16, &bs);
101                network_id = get_bits(16, &bs);
102                get_bits(4, &bs);
103                desc_len = get_bits(12, &bs);
104                parsed += 6;
105               
106                dvb_parse_descriptors((uint8_t *)&bat_buf[bs.bindex/8], desc_len, DVB_TID_BAT, NULL);
107                bs.bindex = bs.bindex + desc_len*8;
108                parsed += desc_len;             
109        }
110        return 1;       
111}
112
113bool dvb_bat_complete(void)
114{
115        return (SI_Chk_Section_complete((unsigned long *)bat_section_mask, bat_last_section) == SI_SUCCESS);
116}
Note: See TracBrowser for help on using the repository browser.