source: svn/newcon3bcm2_21bu/BSEAV/lib/mpeg2_ts_parse/psip_eit.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: 2.8 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_eit.c $
11 * $brcm_Revision: 1 $
12 * $brcm_Date: 2/7/05 11:25p $
13 *
14 * [File Description:]
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /BSEAV/lib/mpeg2_ts_parse/psip_eit.c $
19 *
20 * 1   2/7/05 11:25p 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:03p marcusk
28 * Initial Version.
29 *
30 ***************************************************************************/
31#include "bstd.h"
32#include "psip_priv.h"
33#include "psip_eit.h"
34BDBG_MODULE(psip_eit);
35
36#define TITLE_LENGTH_BYTE_OFFSET                (byteOffset+9)
37#define DESCRIPTOR_LENGTH_BYTE_OFFSET   (TITLE_LENGTH_BYTE_OFFSET+1+buf[TITLE_LENGTH_BYTE_OFFSET])
38
39static int PSIP_EIT_P_getEventByteOffset( const uint8_t *buf, int eventNum )
40{
41        uint8_t i;
42        int byteOffset = PSIP_TABLE_DATA_OFFSET + 1;
43
44        if( eventNum == -1 )
45        {
46                eventNum = buf[PSIP_TABLE_DATA_OFFSET];
47        }
48
49        /* Jump to correct table (or first byte after last table) */
50        for( i = 0; i < eventNum; i++ )
51        {
52                byteOffset += 12 + buf[TITLE_LENGTH_BYTE_OFFSET] + (TS_READ_16(&buf[DESCRIPTOR_LENGTH_BYTE_OFFSET]) & 0x0FFF);
53
54                CHECK( byteOffset <= TS_PSI_MAX_BYTE_OFFSET(buf) );
55        }
56
57        return byteOffset;
58}
59
60
61uint8_t PSIP_EIT_getNumEvents( const uint8_t *buf )
62{
63        return buf[PSIP_TABLE_DATA_OFFSET];
64}
65
66BERR_Code PSIP_EIT_getEvent( const uint8_t *buf, int eventNum, PSIP_EIT_event *p_event )
67{
68        int byteOffset;
69
70        if( eventNum >= buf[PSIP_TABLE_DATA_OFFSET] )
71        {
72                return BERR_INVALID_PARAMETER;
73        }
74
75        byteOffset = PSIP_EIT_P_getEventByteOffset( buf, eventNum );
76
77        p_event->event_id = (uint16_t)(TS_READ_16( &buf[byteOffset] ) & 0x3FFF);
78        p_event->start_time = TS_READ_32( &buf[byteOffset+2] );
79        p_event->ETM_location = (buf[byteOffset+6]>>4)&3;
80        p_event->length_in_seconds = (TS_READ_32(&buf[byteOffset+6])>>8)&0x000FFFFF;
81        p_event->p_title_text = &buf[TITLE_LENGTH_BYTE_OFFSET+1];
82
83        return BERR_SUCCESS;
84}
85
86TS_PSI_descriptor PSIP_EIT_getEventDescriptor( const uint8_t *buf, int eventNum, int descriptorNum )
87{
88        int byteOffset;
89
90        if( eventNum >= buf[PSIP_TABLE_DATA_OFFSET] )
91        {
92                return NULL;
93        }
94
95        byteOffset = PSIP_EIT_P_getEventByteOffset( buf, eventNum );
96
97        return TS_P_getDescriptor( &buf[DESCRIPTOR_LENGTH_BYTE_OFFSET+2], (TS_READ_16(&buf[DESCRIPTOR_LENGTH_BYTE_OFFSET]) & 0xFFF), descriptorNum );
98}
Note: See TracBrowser for help on using the repository browser.