source: svn/trunk/newcon3bcm2_21bu/BSEAV/lib/mpeg2_ts_parse/psip_vct.c

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

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 3.6 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003, 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: psip_vct.c $
11 * $brcm_Revision: 1 $
12 * $brcm_Date: 2/7/05 11:27p $
13 *
14 * [File Description:]
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /BSEAV/lib/mpeg2_ts_parse/psip_vct.c $
19 *
20 * 1   2/7/05 11:27p dlwin
21 * Merge down for release 2005_REFSW_MERGETOMAIN:
22 *
23 * Irvine_BSEAVSW_Devel/2   2/4/04 9:56a erickson
24 * PR9217: converted BDBG_ASSERT calls to CHECK calls. Don't assert on bad
25 * data.
26 *
27 * Irvine_BSEAVSW_Devel/1   8/29/03 5:04p marcusk
28 * Initial Version.
29 *
30 ***************************************************************************/
31#include "bstd.h"
32#include "psip_priv.h"
33#include "psip_vct.h"
34BDBG_MODULE(psip_vct);
35
36static int PSIP_VCT_P_getChannelByteOffset( const uint8_t *buf, int channelNum )
37{
38        uint8_t i;
39        int byteOffset = PSIP_TABLE_DATA_OFFSET + 1;
40
41        if( channelNum == -1 )
42        {
43                channelNum = buf[PSIP_TABLE_DATA_OFFSET];
44        }
45
46        /* Jump to correct table (or first byte after last table) */
47        for( i = 0; i < channelNum; i++ )
48        {
49                byteOffset += 32 + (TS_READ_16(&buf[byteOffset+30]) & 0x03FF);
50
51                CHECK( byteOffset <= TS_PSI_MAX_BYTE_OFFSET(buf) );
52        }
53
54        return byteOffset;
55}
56
57uint8_t PSIP_VCT_getNumChannels( const uint8_t *buf )
58{
59        CHECK( (buf[0] == 0xC8 || buf[0] == 0xC9) );
60
61        return buf[PSIP_TABLE_DATA_OFFSET];
62}
63
64TS_PSI_descriptor PSIP_VCT_getAdditionalDescriptor( const uint8_t *buf, int descriptorNum )
65{
66        int byteOffset;
67
68        CHECK( (buf[0] == 0xC8 || buf[0] == 0xC9) );
69
70        byteOffset = PSIP_VCT_P_getChannelByteOffset( buf, -1 );
71        return TS_P_getDescriptor( &buf[byteOffset+2], (TS_READ_16(&buf[byteOffset]) & 0x03FF), descriptorNum );
72}
73
74BERR_Code PSIP_VCT_getChannel( const uint8_t *buf, int channelNum, PSIP_VCT_channel *p_channel )
75{
76        int byteOffset;
77        int i;
78
79        CHECK( (buf[0] == 0xC8 || buf[0] == 0xC9) );
80
81        if( channelNum >= buf[PSIP_TABLE_DATA_OFFSET] )
82        {
83                return BERR_INVALID_PARAMETER;
84        }
85
86        byteOffset = PSIP_VCT_P_getChannelByteOffset( buf, channelNum );
87
88        for( i = 0; i < 7; i++ )
89        {
90                p_channel->short_name[i] = TS_READ_16( &buf[byteOffset+(i*2)] );
91        }
92
93        p_channel->major_channel_number = (uint16_t)((TS_READ_16( &buf[byteOffset+14] ) >> 2) & 0x3FF);
94        p_channel->minor_channel_number = (uint16_t)(TS_READ_16( &buf[byteOffset+15] ) & 0x3FF);
95        p_channel->modulation_mode = buf[byteOffset+17];
96        p_channel->carrier_frequency = TS_READ_32( &buf[byteOffset+18] );
97        p_channel->channel_TSID = TS_READ_16( &buf[byteOffset+22] );
98        p_channel->program_number = TS_READ_16( &buf[byteOffset+24] );
99        p_channel->ETM_location = (buf[byteOffset+26]>>6)&3;
100        p_channel->access_controlled = (uint8_t)((buf[byteOffset+26]>>5)&1);
101        p_channel->hidden = (buf[byteOffset+26]>>4)&1;
102        p_channel->path_select = (buf[byteOffset+26]>>3)&1;
103        p_channel->out_of_band = (buf[byteOffset+26]>>2)&1;
104        p_channel->hide_guide = (buf[byteOffset+26]>>1)&1;
105        p_channel->service_type = buf[byteOffset+27]&0x3F;
106        p_channel->source_id = TS_READ_16( &buf[byteOffset+28] );
107
108        return BERR_SUCCESS;
109}
110
111TS_PSI_descriptor PSIP_VCT_getChannelDescriptor( const uint8_t *buf, int channelNum, int descriptorNum )
112{
113        int byteOffset;
114
115        CHECK( (buf[0] == 0xC8 || buf[0] == 0xC9) );
116
117        byteOffset = PSIP_VCT_P_getChannelByteOffset( buf, channelNum );
118        return TS_P_getDescriptor( &buf[byteOffset+32], (TS_READ_16(&buf[byteOffset+30]) & 0x3FF), descriptorNum );
119}
Note: See TracBrowser for help on using the repository browser.