2 * $Id: capmt.cpp,v 1.1 2003-10-17 15:36:37 tmbinc Exp $
4 * (C) 2002-2003 Andreas Oberritter <obi@saftware.de>
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.
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.
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.
22 #include <lib/dvb_si/descriptor_tag.h>
23 #include <lib/dvb_si/capmt.h>
25 CaLengthField::CaLengthField(const uint64_t length)
38 while ((length & mask) != length) {
40 mask = ((uint64_t)(mask << 8)) | ((uint64_t)0xFFULL);
43 for (uint8_t i = lengthFieldSize; i > 0; i--)
44 lengthValueByte.push_back((length >> ((i - 1) << 3)) & 0xFF);
48 CaElementaryStreamInfo::CaElementaryStreamInfo(const ElementaryStreamInfo * const info, const uint8_t cmdId)
50 streamType = info->streamType;
51 reserved1 = info->reserved1;
52 elementaryPid = info->elementaryPid;
53 reserved2 = info->reserved2;
56 for (DescriptorConstIterator i = info->getDescriptors()->begin(); i != info->getDescriptors()->end(); ++i)
57 if ((*i)->getTag() == CA_DESCRIPTOR) {
58 descriptors.push_back(new CaDescriptor(*(CaDescriptor *)*i));
59 esInfoLength += (*i)->getLength() + 2;
68 CaElementaryStreamInfo::~CaElementaryStreamInfo(void)
70 for (CaDescriptorIterator i = descriptors.begin(); i != descriptors.end(); ++i)
74 uint16_t CaElementaryStreamInfo::getLength(void) const
76 return esInfoLength + 5;
79 CaProgramMapTable::CaProgramMapTable(const ProgramMapTable * const pmt, const uint8_t listManagement, const uint8_t cmdId)
84 caPmtListManagement = listManagement;
86 programNumber = pmt->tableIdExtension;
87 reserved1 = pmt->reserved3;
88 versionNumber = pmt->versionNumber;
89 currentNextIndicator = pmt->currentNextIndicator;
90 reserved2 = pmt->reserved5;
91 programInfoLength = 0;
93 for (DescriptorConstIterator i = pmt->getDescriptors()->begin(); i != pmt->getDescriptors()->end(); ++i)
94 if ((*i)->getTag() == CA_DESCRIPTOR) {
95 descriptors.push_back(new CaDescriptor(*(CaDescriptor *)*i));
96 programInfoLength += (*i)->getLength() + 2;
99 if (programInfoLength) {
102 length += programInfoLength;
105 for (ElementaryStreamInfoConstIterator i = pmt->esInfo.begin(); i != pmt->esInfo.end(); ++i) {
106 CaElementaryStreamInfo *info = new CaElementaryStreamInfo(*i, cmdId);
107 esInfo.push_back(info);
108 length += info->getLength();
111 lengthField = new CaLengthField(length);
114 CaProgramMapTable::~CaProgramMapTable(void)
116 for (CaDescriptorIterator i = descriptors.begin(); i != descriptors.end(); ++i)
119 for (CaElementaryStreamInfoIterator i = esInfo.begin(); i != esInfo.end(); ++i)