1 |
/* avplug.cpp |
---|
2 |
* Copyright (C) 2005 by Daniel Wagner |
---|
3 |
* |
---|
4 |
* This file is part of FreeBob. |
---|
5 |
* |
---|
6 |
* FreeBob 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 |
* FreeBob is distributed in the hope that it will be useful, |
---|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 |
* GNU General Public License for more details. |
---|
14 |
* |
---|
15 |
* You should have received a copy of the GNU General Public License |
---|
16 |
* along with FreeBob; if not, write to the Free Software |
---|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
18 |
* MA 02111-1307 USA. |
---|
19 |
*/ |
---|
20 |
|
---|
21 |
#include "avplug.h" |
---|
22 |
|
---|
23 |
#include "libfreebobavc/avc_extended_plug_info.h" |
---|
24 |
|
---|
25 |
IMPL_DEBUG_MODULE( AvPlug, AvPlug, DEBUG_LEVEL_VERBOSE ); |
---|
26 |
|
---|
27 |
AvPlug::AvPlug() |
---|
28 |
: m_plugType( 0xff ) |
---|
29 |
, m_plugId( 0xff ) |
---|
30 |
, m_subunitType( 0xff ) |
---|
31 |
, m_subunitId( 0xff ) |
---|
32 |
, m_direction( 0xff ) |
---|
33 |
, m_nrOfChannels( 0 ) |
---|
34 |
, m_samplingFrequency( 0xff ) |
---|
35 |
{ |
---|
36 |
} |
---|
37 |
|
---|
38 |
AvPlug::AvPlug( const AvPlug& rhs ) |
---|
39 |
: m_plugType( rhs.m_plugType ) |
---|
40 |
, m_plugId( rhs.m_plugId ) |
---|
41 |
, m_subunitType( rhs.m_subunitType ) |
---|
42 |
, m_subunitId( rhs.m_subunitType ) |
---|
43 |
, m_direction( rhs.m_direction ) |
---|
44 |
, m_name( rhs.m_name ) |
---|
45 |
, m_nrOfChannels( rhs.m_nrOfChannels ) |
---|
46 |
, m_samplingFrequency( rhs.m_samplingFrequency ) |
---|
47 |
, m_clusterInfos( rhs.m_clusterInfos ) |
---|
48 |
{ |
---|
49 |
} |
---|
50 |
|
---|
51 |
AvPlug::~AvPlug() |
---|
52 |
{ |
---|
53 |
} |
---|
54 |
|
---|
55 |
bool |
---|
56 |
AvPlug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& |
---|
57 |
channelPositionData ) |
---|
58 |
{ |
---|
59 |
int index = 1; |
---|
60 |
for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfoVector::const_iterator it |
---|
61 |
= channelPositionData.m_clusterInfos.begin(); |
---|
62 |
it != channelPositionData.m_clusterInfos.end(); |
---|
63 |
++it ) |
---|
64 |
{ |
---|
65 |
const ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfo* |
---|
66 |
extPlugSpClusterInfo = &( *it ); |
---|
67 |
|
---|
68 |
ClusterInfo clusterInfo; |
---|
69 |
clusterInfo.m_nrOfChannels = extPlugSpClusterInfo->m_nrOfChannels; |
---|
70 |
clusterInfo.m_index = index; |
---|
71 |
index++; |
---|
72 |
|
---|
73 |
for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfoVector::const_iterator cit |
---|
74 |
= extPlugSpClusterInfo->m_channelInfos.begin(); |
---|
75 |
cit != extPlugSpClusterInfo->m_channelInfos.end(); |
---|
76 |
++cit ) |
---|
77 |
{ |
---|
78 |
const ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfo* |
---|
79 |
extPlugSpChannelInfo = &( *cit ); |
---|
80 |
|
---|
81 |
ChannelInfo channelInfo; |
---|
82 |
channelInfo.m_streamPosition = |
---|
83 |
extPlugSpChannelInfo->m_streamPosition; |
---|
84 |
channelInfo.m_location = |
---|
85 |
extPlugSpChannelInfo->m_location; |
---|
86 |
|
---|
87 |
clusterInfo.m_channelInfos.push_back( channelInfo ); |
---|
88 |
} |
---|
89 |
m_clusterInfos.push_back( clusterInfo ); |
---|
90 |
} |
---|
91 |
|
---|
92 |
return true; |
---|
93 |
} |
---|
94 |
|
---|
95 |
void |
---|
96 |
AvPlug::debugOutputClusterInfos( int debugLevel ) |
---|
97 |
{ |
---|
98 |
for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin(); |
---|
99 |
it != m_clusterInfos.end(); |
---|
100 |
++it ) |
---|
101 |
{ |
---|
102 |
const ClusterInfo* clusterInfo = &( *it ); |
---|
103 |
|
---|
104 |
debugOutput( debugLevel, "number of channels: %d\n", |
---|
105 |
clusterInfo->m_nrOfChannels ); |
---|
106 |
|
---|
107 |
for ( ChannelInfoVector::const_iterator cit |
---|
108 |
= clusterInfo->m_channelInfos.begin(); |
---|
109 |
cit != clusterInfo->m_channelInfos.end(); |
---|
110 |
++cit ) |
---|
111 |
{ |
---|
112 |
const ChannelInfo* channelInfo = &( *cit ); |
---|
113 |
debugOutput( debugLevel, |
---|
114 |
"stream position: %d\n", |
---|
115 |
channelInfo->m_streamPosition ); |
---|
116 |
debugOutput( debugLevel, |
---|
117 |
"location: %d\n", |
---|
118 |
channelInfo->m_location ); |
---|
119 |
} |
---|
120 |
} |
---|
121 |
} |
---|
122 |
|
---|
123 |
AvPlug::ClusterInfo* |
---|
124 |
AvPlug::getClusterInfoByIndex(int index) |
---|
125 |
{ |
---|
126 |
for ( AvPlug::ClusterInfoVector::iterator clit = |
---|
127 |
m_clusterInfos.begin(); |
---|
128 |
clit != m_clusterInfos.end(); |
---|
129 |
++clit ) |
---|
130 |
{ |
---|
131 |
ClusterInfo* info = &*clit; |
---|
132 |
if ( info->m_index == index ) { |
---|
133 |
return info; |
---|
134 |
} |
---|
135 |
} |
---|
136 |
return 0; |
---|
137 |
} |
---|
138 |
|
---|
139 |
int |
---|
140 |
AvPlug::getNrOfChannels() |
---|
141 |
{ |
---|
142 |
int nrOfChannels = 0; |
---|
143 |
for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin(); |
---|
144 |
it != m_clusterInfos.end(); |
---|
145 |
++it ) |
---|
146 |
{ |
---|
147 |
const ClusterInfo* clusterInfo = &( *it ); |
---|
148 |
nrOfChannels += clusterInfo->m_nrOfChannels; |
---|
149 |
} |
---|
150 |
return nrOfChannels; |
---|
151 |
} |
---|
152 |
|
---|
153 |
int |
---|
154 |
AvPlug::getSampleRate() |
---|
155 |
{ |
---|
156 |
int value = 0; |
---|
157 |
switch ( m_samplingFrequency ) { |
---|
158 |
case eSF_22050Hz: |
---|
159 |
value = 22050; |
---|
160 |
break; |
---|
161 |
case eSF_24000Hz: |
---|
162 |
value = 24000; |
---|
163 |
break; |
---|
164 |
case eSF_32000Hz: |
---|
165 |
value = 32000; |
---|
166 |
break; |
---|
167 |
case eSF_44100Hz: |
---|
168 |
value = 44100; |
---|
169 |
break; |
---|
170 |
case eSF_48000Hz: |
---|
171 |
value = 48000; |
---|
172 |
break; |
---|
173 |
case eSF_88200Hz: |
---|
174 |
value = 88200; |
---|
175 |
break; |
---|
176 |
case eSF_96000Hz: |
---|
177 |
value = 96000; |
---|
178 |
break; |
---|
179 |
case eSF_176400Hz: |
---|
180 |
value = 176400; |
---|
181 |
break; |
---|
182 |
case eSF_192000Hz: |
---|
183 |
value = 192000; |
---|
184 |
break; |
---|
185 |
default: |
---|
186 |
value = 0; |
---|
187 |
} |
---|
188 |
|
---|
189 |
return value; |
---|
190 |
} |
---|
191 |
|
---|
192 |
//////////////////////////////////// |
---|
193 |
|
---|
194 |
AvPlugCluster::AvPlugCluster() |
---|
195 |
{ |
---|
196 |
} |
---|
197 |
|
---|
198 |
AvPlugCluster::~AvPlugCluster() |
---|
199 |
{ |
---|
200 |
} |
---|
201 |
|
---|
202 |
//////////////////////////////////// |
---|
203 |
|
---|
204 |
AvPlugConnection::AvPlugConnection() |
---|
205 |
{ |
---|
206 |
} |
---|
207 |
|
---|
208 |
AvPlugConnection::~AvPlugConnection() |
---|
209 |
{ |
---|
210 |
} |
---|