merge some code with enigma code
[enigma2.git] / lib / dvb_si / ait.cpp
1 /*
2  * $Id: ait.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/ait.h>
23
24 ApplicationIdentifier::ApplicationIdentifier(const uint8_t * const buffer)
25 {
26         organisationId = (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
27         applicationId = (buffer[4] << 8) | buffer[5];
28 }
29
30 uint32_t ApplicationIdentifier::getOrganisationId(void) const
31 {
32         return organisationId;
33 }
34
35 uint16_t ApplicationIdentifier::getApplicationId(void) const
36 {
37         return applicationId;
38 }
39
40 ApplicationInformation::ApplicationInformation(const uint8_t * const buffer)
41 {
42         applicationIdentifier = new ApplicationIdentifier(&buffer[0]);
43         applicationControlCode = buffer[6];
44         reserved = (buffer[7] >> 4) & 0x0f;
45         applicationDescriptorsLoopLength = ((buffer[7] & 0x0f) << 8) | buffer[8];
46
47         for (uint16_t i = 0; i < applicationDescriptorsLoopLength; i += buffer[i + 10] + 2)
48                 descriptor(&buffer[i + 9]);
49 }
50
51 ApplicationInformation::~ApplicationInformation(void)
52 {
53         delete applicationIdentifier;
54 }
55
56 const ApplicationIdentifier *ApplicationInformation::getApplicationIdentifier(void) const
57 {
58         return applicationIdentifier;
59 }
60
61 uint8_t ApplicationInformation::getApplicationControlCode(void) const
62 {
63         return applicationControlCode;
64 }
65
66 ApplicationInformationTable::ApplicationInformationTable(const uint8_t * const buffer) : LongCrcTable(buffer)
67 {
68         reserved4 = (buffer[8] >> 4) & 0x0f;
69         commonDescriptorsLength = ((buffer[8] & 0x0f) << 8) | buffer[9];
70
71         for (uint16_t i = 0; i < commonDescriptorsLength; i += buffer[i + 11] + 2)
72                 descriptor(&buffer[i + 10]);
73
74         reserved5 = (buffer[commonDescriptorsLength + 10] >> 4) & 0x0f;
75         applicationLoopLength = ((buffer[commonDescriptorsLength + 10] & 0x0f) << 8) | buffer[commonDescriptorsLength + 11];
76
77         for (uint16_t i = 0; i < applicationLoopLength; i += 9) {
78                 ApplicationInformation *a = new ApplicationInformation(&buffer[commonDescriptorsLength + 12]);
79                 applicationInformation.push_back(a);
80                 i += a->applicationDescriptorsLoopLength;
81         }
82 }
83
84 ApplicationInformationTable::~ApplicationInformationTable(void)
85 {
86         for (ApplicationInformationIterator i = applicationInformation.begin(); i != applicationInformation.end(); ++i)
87                 delete *i;
88 }
89
90 const ApplicationInformationVector *ApplicationInformationTable::getApplicationInformation(void) const
91 {
92         return &applicationInformation;
93 }
94