aboutsummaryrefslogtreecommitdiff
path: root/lib/dvb_si/ac3_descriptor.cpp
blob: ece1e794bb00eb48c921276cf6d6e9e07c3448de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * $Id$
 *
 * (C) 2002-2003 Andreas Oberritter <obi@saftware.de>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#include <lib/dvb_si/ac3_descriptor.h>

Ac3Descriptor::Ac3Descriptor(const uint8_t * const buffer) : Descriptor(buffer)
{
	if (buffer[1] >= 1)
	{
		ac3TypeFlag = (buffer[2] >> 7) & 0x01;
		bsidFlag = (buffer[2] >> 6) & 0x01;
		mainidFlag = (buffer[2] >> 5) & 0x01;
		asvcFlag = (buffer[2] >> 4) & 0x01;
		reserved = buffer[2] & 0x0F;
		if (ac3TypeFlag == 1)
			ac3Type = buffer[3];

		if (bsidFlag == 1)
			bsid = buffer[ac3TypeFlag + 3];

		if (mainidFlag == 1)
			mainid = buffer[ac3TypeFlag + mainidFlag + 3];

		if (asvcFlag == 1)
			avsc = buffer[ac3TypeFlag + bsidFlag + mainidFlag + 3];
		
		if (descriptorLength > ac3TypeFlag + bsidFlag + mainidFlag + asvcFlag)
			for (uint16_t i = 0; i < descriptorLength - ac3TypeFlag - bsidFlag - mainidFlag - asvcFlag - 1; ++i)
				additionalInfo.push_back(buffer[ac3TypeFlag + bsidFlag + mainidFlag + asvcFlag + i + 3]);
	} else
	{
		ac3TypeFlag = 0;
		bsidFlag = 0;
		mainidFlag = 0;
		asvcFlag = 0;
		reserved = 0;
	}
}

uint8_t Ac3Descriptor::getAc3TypeFlag(void) const
{
	return ac3TypeFlag;
}

uint8_t Ac3Descriptor::getBsidFlag(void) const
{
	return bsidFlag;
}

uint8_t Ac3Descriptor::getMainidFlag(void) const
{
	return mainidFlag;
}

uint8_t Ac3Descriptor::getAsvcFlag(void) const
{
	return asvcFlag;
}

uint8_t Ac3Descriptor::getAc3Type(void) const
{
	return ac3Type;
}

uint8_t Ac3Descriptor::getBsid(void) const
{
	return bsid;
}

uint8_t Ac3Descriptor::getMainid(void) const
{
	return mainid;
}

uint8_t Ac3Descriptor::getAvsc(void) const
{
	return avsc;
}

const AdditionalInfoVector *Ac3Descriptor::getAdditionalInfo(void) const
{
	return &additionalInfo;
}