source: svn/newcon3bcm2_21bu/BSEAV/lib/scte_127/pmt_desc_scte_127.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 4.6 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2008, 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: pes_scte_127.c $
11 * $brcm_Revision: $
12 * $brcm_Date: $
13 *
14 * [File Description:]
15 *
16 * Revision History:
17 *
18 ***************************************************************************/
19#include "pmt_desc_scte_127.h"
20
21BDBG_MODULE(pmt_desc_scte_127);
22
23#define PMT_SECTION_LENGTH(buf) (TS_READ_16(&buf[PMT_DESC_SECTION_LEN_OFFSET]) & 0xFFF)
24
25/* return to start point of descriptors */
26uint8_t *pmt_table_parser(const uint8_t *pmt_table, size_t size, size_t *desc_bytes)
27{
28        uint32_t len, len1;
29        uint8_t *p;
30       
31        /* we assume that the size of pmt buffer must be 188 or more */
32        CHECK(pmt_table && desc_bytes);
33
34        /* table ID byte */
35        if (PMT_DESC_TABLE_CODE_ID != pmt_table[0]) {
36#ifdef  HOST_BUILD
37                printf("%s: not PMT table (0x%x)\n", __func__, pmt_table[0]);
38#endif
39                return NULL;
40        }
41       
42        p = (uint8_t *)pmt_table;
43        p++;
44        len = (TS_READ_16(p) & 0xFFF);
45#ifdef  HOST_BUILD
46        printf("%s: PMT section len = %d\n", __func__, len);
47#endif
48        p += 2;
49#ifdef  HOST_BUILD
50        printf("%s: PMT program no. = %d\n", __func__, TS_READ_16(p));
51#endif
52        p += 2;
53
54        /* skip more bytes */
55        p += 1 + 1 + 1;         /* version number + section number + last section number */
56       
57#ifdef  HOST_BUILD
58        printf("%s: PMT PID number  = 0x%04x\n", __func__, TS_READ_16(p) & 0xFFF);
59#endif
60        p += 2;
61
62        len1 = TS_READ_16(p) & 0xFFF;
63        p += 2;
64        /* skip program info length info */
65        p += len1;
66
67        size = (int)(p - pmt_table);
68
69        *desc_bytes = len - 4 - (size - 8);
70
71        return p;
72}
73
74#ifdef  HOST_BUILD
75/* return to start point of descriptors */
76uint8_t *pmt_parser_ts(const uint8_t *pmt, size_t *size, size_t *desc_bytes)
77{
78        uint32_t len;
79        uint8_t *p, adaptation_field;
80       
81        /* we assume that the size of pmt buffer must be 188 or more */
82        CHECK(pmt && size && desc_bytes);
83
84        /* sync byte */
85        CHECK(0x47 == pmt[0]);
86        adaptation_field = (pmt[PMT_DESC_ADAPTATION_OFFSET] >> 4) & 0x3;
87        if (0x01 != adaptation_field) {
88                printf("%s: invalid PMT packet (0x%x)\n", __func__, adaptation_field);
89                return NULL;
90        }
91        p = (uint8_t *)pmt + PMT_DESC_TABLE_ID_OFFSET;
92        *size -= PMT_DESC_TABLE_ID_OFFSET;
93        p = pmt_table_parser(p, *size, &len); 
94        if (p) {
95                *size = (int)(p - pmt);
96        }
97        else
98                *size = 0;
99
100        return p;
101}
102
103void pmt_desc_scte127_dump(const uint8_t *desc_data, pmt_descriptor *pmt_desc)
104{
105        uint8_t *p;
106        int len;
107
108        printf("====Dump VBI descriptor====\n");
109        printf("\tstream type = 0x%02x\n", pmt_desc->stream_type);
110        printf("\telement. PID= 0x%04x\n", pmt_desc->elementary_pid);
111        printf("\tES info len = %d\n", pmt_desc->es_info_length);
112
113        p = (uint8_t *)desc_data;
114        CHECK(PMT_DESC_VBI_DESCRIPTOR_ID == *(p));
115        p++;
116        len = *p;
117        p++;
118       
119        while (len) {
120                switch ((int)*p)
121                {
122                        case SCTE_127_DATA_SERVICE_ID_AMOL:
123                                printf("\thas AMOL 48/96 data\n");
124                                break; 
125
126                        case SCTE_127_DATA_SERVICE_ID_TVG2X:
127                                printf("\thas TVG2X data\n");
128                                break; 
129
130                        case 0xfd:
131                                printf("\thas Protected 1 data\n");
132                                break; 
133
134                        case SCTE_127_DATA_SERVICE_ID_NABTS:
135                                printf("\thas NABTS data\n");
136                                break; 
137
138                        case 0xfA:
139                                printf("\thas Protected 2 data\n");
140                                break; 
141
142                        case SCTE_127_DATA_SERVICE_ID_CP:
143                                printf("\thas Copy Protection data\n");
144                                break; 
145
146                        case 0xf8:
147                                printf("\thas Protected 3 data\n");
148                                break; 
149
150                        case SCTE_127_DATA_SERVICE_ID_VITC:
151                                printf("\thas VITC data\n");
152                                break; 
153
154                        default:
155                                break;
156                }
157                p++;
158                len--;
159                len -= (*p + 1);
160                p += (*p + 1);
161        }
162}
163#endif
164
165uint8_t *pmt_desc_find(const uint8_t *desc_data, size_t desc_bytes, pmt_descriptor *pmt_desc)
166{
167        uint8_t *p = (uint8_t *)desc_data;
168        int len;
169       
170        CHECK(desc_data && desc_bytes && pmt_desc);
171       
172        while (desc_bytes) 
173        {
174                if (*p == pmt_desc->stream_type)
175                {
176                        pmt_desc->elementary_pid = TS_READ_16(p + 1) & 0x1FFF;
177                        pmt_desc->es_info_length = TS_READ_16(p + 3) & 0xFFF;
178                        return p;       
179                }       
180                p += 3;
181                desc_bytes -= 3;
182                len = TS_READ_16(p) & 0xFFF;
183                p += len;
184                desc_bytes -= len;
185                p += 2;
186                desc_bytes -= 2;
187        };
188
189        return NULL;
190}
191
192uint8_t *pmt_desc_is_scte127(const uint8_t *desc_data, uint16_t es_info_length)
193{
194        uint8_t *p = (uint8_t *)desc_data;
195        int len;
196
197        p += 5; /* move to the start of descriptor id */
198        while (es_info_length > 0) {
199                if (PMT_DESC_VBI_DESCRIPTOR_ID == *p) {
200                        return p;
201        }
202                p++;
203                len = (int)*p;
204                p += len + 1;
205                es_info_length -= (len + 2);
206        }
207        return NULL;
208}
209
Note: See TracBrowser for help on using the repository browser.