- skins are now loaded first and applied later
[enigma2.git] / lib / dvb_si / local_time_offset_descriptor.cpp
1 /*
2  * $Id: local_time_offset_descriptor.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/local_time_offset_descriptor.h>
23
24 LocalTimeOffset::LocalTimeOffset(const uint8_t * const buffer)
25 {
26         countryCode.assign((char *)&buffer[0], 3);
27         countryRegionId = (buffer[3] >> 2) & 0x3f;
28         reserved = (buffer[3] >> 1) & 0x01;
29         localTimeOffsetPolarity = buffer[3] & 0x01;
30         localTimeOffset = (buffer[4] << 8) | buffer[5];
31         timeOfChangeMjd = (buffer[6] << 8) | buffer[7];
32         timeOfChangeBcd = (buffer[8] << 16) | (buffer[9] << 8) | buffer[10];
33         nextTimeOffset = (buffer[11] << 8) | buffer[12];
34 }
35
36 std::string LocalTimeOffset::getCountryCode(void) const
37 {
38         return countryCode;
39 }
40
41 uint8_t LocalTimeOffset::getCountryRegionId(void) const
42 {
43         return countryRegionId;
44 }
45
46 uint8_t LocalTimeOffset::getLocalTimeOffsetPolarity(void) const
47 {
48         return localTimeOffsetPolarity;
49 }
50
51 uint16_t LocalTimeOffset::getLocalTimeOffset(void) const
52 {
53         return localTimeOffset;
54 }
55
56 uint16_t LocalTimeOffset::getTimeOfChangeMjd(void) const
57 {
58         return timeOfChangeMjd;
59 }
60
61 uint32_t LocalTimeOffset::getTimeOfChangeBcd(void) const
62 {
63         return timeOfChangeBcd;
64 }
65
66 uint16_t LocalTimeOffset::getNextTimeOffset(void) const
67 {
68         return nextTimeOffset;
69 }
70
71 LocalTimeOffsetDescriptor::LocalTimeOffsetDescriptor(const uint8_t * const buffer) : Descriptor(buffer)
72 {
73         for (uint16_t i = 0; i < descriptorLength; i += 13)
74                 localTimeOffsets.push_back(new LocalTimeOffset(&buffer[i + 2]));
75 }
76
77
78 LocalTimeOffsetDescriptor::~LocalTimeOffsetDescriptor(void)
79 {
80         for (LocalTimeOffsetIterator i = localTimeOffsets.begin(); i != localTimeOffsets.end(); ++i)
81                 delete *i;
82 }
83
84 const LocalTimeOffsetVector *LocalTimeOffsetDescriptor::getLocalTimeOffsets(void) const
85 {
86         return &localTimeOffsets;
87 }
88