removed testcode
[enigma2.git] / lib / dvb_si / sdt.cpp
1 /*
2  * $Id: sdt.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/sdt.h>
23
24 ServiceDescription::ServiceDescription(const uint8_t * const buffer)
25 {
26         serviceId = (buffer[0] << 8) | buffer[1];
27         reserved1 = (buffer[2] >> 2) & 0x3F;
28         eitScheduleFlag = (buffer[2] >> 1) & 0x01;
29         eitPresentFollowingFlag = buffer[2] & 0x01;
30         runningStatus = (buffer[3] >> 5) & 0x07;
31         freeCaMode = (buffer[3] >> 4) & 0x01;
32         descriptorsLoopLength = ((buffer[3] & 0x0F) << 8) | buffer[4];
33
34         for (uint16_t i = 5; i < descriptorsLoopLength + 5; i += buffer[i + 1] + 2)
35                 descriptor(&buffer[i]);
36 }
37
38 uint16_t ServiceDescription::getServiceId(void) const
39 {
40         return serviceId;
41 }
42
43 uint8_t ServiceDescription::getEitScheduleFlag(void) const
44 {
45         return eitScheduleFlag;
46 }
47
48 uint8_t ServiceDescription::getEitPresentFollowingFlag(void) const
49 {
50         return eitPresentFollowingFlag;
51 }
52
53 uint8_t ServiceDescription::getRunningStatus(void) const
54 {
55         return runningStatus;
56 }
57
58 uint8_t ServiceDescription::getFreeCaMode(void) const
59 {
60         return freeCaMode;
61 }
62
63 ServiceDescriptionTable::ServiceDescriptionTable(const uint8_t * const buffer) : LongCrcTable (buffer)
64 {
65         originalNetworkId = (buffer[8] << 8) | buffer[9];
66         reserved4 = buffer[10];
67
68         for (uint16_t i = 11; i < sectionLength - 1; i += ((buffer[i + 3] & 0x0F) | buffer[i + 4]) + 5)
69                 description.push_back(new ServiceDescription(&buffer[i]));
70 }
71
72 ServiceDescriptionTable::~ServiceDescriptionTable(void)
73 {
74         for (ServiceDescriptionIterator i = description.begin(); i != description.end(); ++i)
75                 delete *i;
76 }
77
78 uint16_t ServiceDescriptionTable::getOriginalNetworkId(void) const
79 {
80         return originalNetworkId;
81 }
82
83 const ServiceDescriptionVector *ServiceDescriptionTable::getDescriptions(void) const
84 {
85         return &description;
86 }
87