some cleanup
[enigma2.git] / lib / dvb_si / eit.cpp
1 /*
2  * $Id: eit.cpp,v 1.1 2003-10-17 15:36:37 tmbinc Exp $
3  *
4  * (C) 2002-2003 Andreas Oberritter <obi@saftware.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */
21
22 #include <lib/dvb_si/eit.h>
23
24 Event::Event(const uint8_t * const buffer)
25 {
26         eventId = (buffer[0] << 8) | buffer[1];
27         startTimeMjd = (buffer[2] << 8) | buffer[3];
28         startTimeBcd = (buffer[4] << 16) | (buffer[5] << 8) | buffer[6];
29         duration = (buffer[7] << 16) | (buffer[8] << 8) | buffer[9];
30         runningStatus = (buffer[10] >> 5) & 0x07;
31         freeCaMode = (buffer[10] >> 4) & 0x01;
32         descriptorsLoopLength = ((buffer[10] & 0x0f) << 8) | buffer[11];
33
34         for (uint16_t i = 12; i < descriptorsLoopLength + 12; i += buffer[i + 1] + 2)
35                 descriptor(&buffer[i]);
36 }
37
38 uint16_t Event::getEventId(void) const
39 {
40         return eventId;
41 }
42
43 uint16_t Event::getStartTimeMjd(void) const
44 {
45         return startTimeMjd;
46 }
47
48 uint32_t Event::getStartTimeBcd(void) const
49 {
50         return startTimeBcd;
51 }
52
53 uint32_t Event::getDuration(void) const
54 {
55         return duration;
56 }
57
58 uint8_t Event::getRunningStatus(void) const
59 {
60         return runningStatus;
61 }
62
63 uint8_t Event::getFreeCaMode(void) const
64 {
65         return freeCaMode;
66 }
67
68 EventInformationTable::EventInformationTable(const uint8_t * const buffer) : LongCrcTable(buffer)
69 {
70         transportStreamId = (buffer[8] << 8) | buffer[9];
71         originalNetworkId = (buffer[10] << 8) | buffer[11];
72         segmentLastSectionNumber = buffer[12];
73         lastTableId = buffer[13];
74
75         for (uint16_t i = 14; i < sectionLength - 1; i += (((buffer[i + 10] & 0x0f) << 8) | buffer[i + 11]) + 12)
76                 events.push_back(new Event(&buffer[i]));
77 }
78
79 EventInformationTable::~EventInformationTable(void)
80 {
81         for (EventIterator i = events.begin(); i != events.end(); ++i)
82                 delete *i;
83 }
84
85 uint16_t EventInformationTable::getTransportStreamId(void) const
86 {
87         return transportStreamId;
88 }
89
90 uint16_t EventInformationTable::getOriginalNetworkId(void) const
91 {
92         return originalNetworkId;
93 }
94
95 uint8_t EventInformationTable::getLastSectionNumber(void) const
96 {
97         return lastSectionNumber;
98 }
99
100 uint8_t EventInformationTable::getLastTableId(void) const
101 {
102         return lastTableId;
103 }
104
105 const EventVector *EventInformationTable::getEvents(void) const
106 {
107         return &events;
108 }
109