- sdl is now default output
[enigma2.git] / lib / dvb_si / cell_list_descriptor.cpp
1 /*
2  * $Id: cell_list_descriptor.cpp,v 1.1 2003-10-17 15:36:37 tmbinc Exp $
3  *
4  * (C) 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
23 #include <lib/dvb_si/cell_list_descriptor.h>
24
25 Subcell::Subcell(const uint8_t * const buffer)
26 {
27         cellIdExtension = buffer[0];
28         subcellLatitude = (buffer[1] << 8) | buffer[2];
29         subcellLongitude = (buffer[3] << 8) | buffer[4];
30         subcellExtendOfLatitude = (buffer[5] << 4) | ((buffer[6] >> 4) & 0x0f);
31         subcellExtendOfLongitude = ((buffer[6] & 0x0f) << 8) | buffer[7];
32 }
33
34 uint8_t Subcell::getCellIdExtension(void) const
35 {
36         return cellIdExtension;
37 }
38
39 uint16_t Subcell::getSubcellLatitude(void) const
40 {
41         return subcellLatitude;
42 }
43
44 uint16_t Subcell::getSubcellLongtitude(void) const
45 {
46         return subcellLongitude;
47 }
48
49 uint16_t Subcell::getSubcellExtendOfLatitude(void) const
50 {
51         return subcellExtendOfLatitude;
52 }
53
54 uint16_t Subcell::getSubcellExtendOfLongtitude(void) const
55 {
56         return subcellExtendOfLongitude;
57 }
58
59 Cell::Cell(const uint8_t * const buffer)
60 {
61         cellId = (buffer[0] << 8) | buffer[1];
62         cellLatitude = (buffer[2] << 8) | buffer[3];
63         cellLongtitude = (buffer[4] << 8) | buffer[5];
64         cellExtendOfLatitude = (buffer[6] << 4) | ((buffer[7] >> 4) & 0x0f);
65         cellExtendOfLongtitude = ((buffer[7] & 0x0f) << 8) | buffer[8];
66         subcellInfoLoopLength = buffer[9];
67
68         for (uint16_t i = 0; i < subcellInfoLoopLength; i += 8)
69                 subcells.push_back(new Subcell(&buffer[i + 10]));
70 }
71
72 Cell::~Cell(void)
73 {
74         for (SubcellIterator i = subcells.begin(); i != subcells.end(); ++i)
75                 delete *i;
76 }
77
78 uint16_t Cell::getCellId(void) const
79 {
80         return cellId;
81 }
82
83 uint16_t Cell::getCellLatitude(void) const
84 {
85         return cellLatitude;
86 }
87
88 uint16_t Cell::getCellLongtitude(void) const
89 {
90         return cellLongtitude;
91 }
92
93 uint16_t Cell::getCellExtendOfLatitude(void) const
94 {
95         return cellExtendOfLatitude;
96 }
97
98 uint16_t Cell::getCellExtendOfLongtitude(void) const
99 {
100         return cellExtendOfLongtitude;
101 }
102
103 const SubcellVector *Cell::getSubcells(void) const
104 {
105         return &subcells;
106 }
107
108 CellListDescriptor::CellListDescriptor(const uint8_t * const buffer) : Descriptor(buffer)
109 {
110         for (uint16_t i = 0; i < descriptorLength; i += buffer[i + 11] + 10)
111                 cells.push_back(new Cell(&buffer[i + 2]));
112 }
113
114 CellListDescriptor::~CellListDescriptor(void)
115 {
116         for (CellIterator i = cells.begin(); i != cells.end(); ++i)
117                 delete *i;
118 }
119
120 const CellVector *CellListDescriptor::getCells(void) const
121 {
122         return &cells;
123 }
124