fix return value
[enigma2.git] / lib / dvb_si / announcement_support_descriptor.cpp
1 /*
2  * $Id: announcement_support_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/announcement_support_descriptor.h>
23
24 Announcement::Announcement(const uint8_t * const buffer)
25 {
26         announcementType = (buffer[0] >> 4) & 0x0f;
27         reserved = (buffer[0] >> 3) & 0x01;
28         referenceType = buffer[0] & 0x07;
29
30         if ((referenceType >= 0x01) && (referenceType <= 0x03)) {
31                 originalNetworkId = (buffer[1] << 8) | buffer[2];
32                 transportStreamId = (buffer[3] << 8) | buffer[4];
33                 serviceId = (buffer[5] << 8) | buffer[6];
34                 componentTag = buffer[7];
35         }
36 }
37
38 uint8_t Announcement::getAnnouncementType(void) const
39 {
40         return announcementType;
41 }
42
43 uint8_t Announcement::getReferenceType(void) const
44 {
45         return referenceType;
46 }
47
48 uint16_t Announcement::getOriginalNetworkId(void) const
49 {
50         return originalNetworkId;
51 }
52
53 uint16_t Announcement::getTransportStreamId(void) const
54 {
55         return transportStreamId;
56 }
57
58 uint16_t Announcement::getServiceId(void) const
59 {
60         return serviceId;
61 }
62
63 uint8_t Announcement::getComponentTag(void) const
64 {
65         return componentTag;
66 }
67
68 AnnouncementSupportDescriptor::AnnouncementSupportDescriptor(const uint8_t * const buffer) : Descriptor(buffer)
69 {
70         Announcement *a;
71
72         announcementSupportIndicator = (buffer[2] << 8) | buffer[3];
73         
74         if (descriptorLength < 2)
75                 return;
76
77         for (uint16_t i = 0; i < descriptorLength - 2; ++i) {
78                 a = new Announcement(&buffer[i + 4]);
79                 announcements.push_back(a);
80                 switch (a->getReferenceType()) {
81                 case 0x01:
82                 case 0x02:
83                 case 0x03:
84                         i += 7;
85                         break;
86                 default:
87                         break;
88                 }
89         }
90 }
91
92 AnnouncementSupportDescriptor::~AnnouncementSupportDescriptor(void)
93 {
94         for (AnnouncementIterator i = announcements.begin(); i != announcements.end(); ++i)
95                 delete *i;
96 }
97
98 uint16_t AnnouncementSupportDescriptor::getAnnouncementSupportIndicator(void) const
99 {
100         return announcementSupportIndicator;
101 }
102
103 const AnnouncementVector *AnnouncementSupportDescriptor::getAnnouncements(void) const
104 {
105         return &announcements;
106 }
107