root/branches/libfreebob-1.0/src/bebob_light/bebob_light_avplug.cpp

Revision 241, 5.0 kB (checked in by pieterpalmers, 18 years ago)

* configure.ac: Version bump to 1.0.0

* Changed all FreeBob? to FreeBoB
* Removed all .cvsignore
* Added Pieter to AUTHORS
* Updated NEWS and README (release canditate date added)

by Daniel Wagner

Line 
1 /* bebob_light_avplug.cpp
2  * Copyright (C) 2006 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 "bebob_light_avplug.h"
22
23 #include "libfreebobavc/avc_extended_plug_info.h"
24 #include "libfreebobavc/avc_definitions.h"
25
26 namespace BeBoB_Light {
27
28 IMPL_DEBUG_MODULE( AvPlug, AvPlug, DEBUG_LEVEL_VERBOSE );
29
30 AvPlug::AvPlug()
31     : m_plugType( 0xff )
32     , m_plugId( 0xff )
33     , m_subunitType( 0xff )
34     , m_subunitId( 0xff )
35     , m_direction( 0xff )
36     , m_nrOfChannels( 0 )
37     , m_samplingFrequency( 0xff )
38 {
39 }
40
41 AvPlug::AvPlug( const AvPlug& rhs )
42     : m_plugType( rhs.m_plugType )
43     , m_plugId( rhs.m_plugId )
44     , m_subunitType( rhs.m_subunitType )
45     , m_subunitId( rhs.m_subunitType )
46     , m_direction( rhs.m_direction )
47     , m_name( rhs.m_name )
48     , m_nrOfChannels( rhs.m_nrOfChannels )
49     , m_samplingFrequency( rhs.m_samplingFrequency )
50     , m_clusterInfos( rhs.m_clusterInfos )
51 {
52 }
53
54 AvPlug::~AvPlug()
55 {
56 }
57
58 bool
59 AvPlug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData&
60                         channelPositionData )
61 {
62     int index = 1;
63     for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfoVector::const_iterator it
64               = channelPositionData.m_clusterInfos.begin();
65           it != channelPositionData.m_clusterInfos.end();
66           ++it )
67     {
68         const ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfo*
69             extPlugSpClusterInfo = &( *it );
70
71         ClusterInfo clusterInfo;
72         clusterInfo.m_nrOfChannels = extPlugSpClusterInfo->m_nrOfChannels;
73         clusterInfo.m_index = index;
74         index++;
75
76         for (  ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfoVector::const_iterator cit
77                   = extPlugSpClusterInfo->m_channelInfos.begin();
78               cit != extPlugSpClusterInfo->m_channelInfos.end();
79               ++cit )
80         {
81             const ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfo*
82                 extPlugSpChannelInfo = &( *cit );
83
84             ChannelInfo channelInfo;
85             channelInfo.m_streamPosition =
86                 extPlugSpChannelInfo->m_streamPosition;
87             channelInfo.m_location =
88                 extPlugSpChannelInfo->m_location;
89
90             clusterInfo.m_channelInfos.push_back( channelInfo );
91         }
92         m_clusterInfos.push_back( clusterInfo );
93     }
94
95     return true;
96 }
97
98 void
99 AvPlug::debugOutputClusterInfos( int debugLevel )
100 {
101     for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin();
102           it != m_clusterInfos.end();
103           ++it )
104     {
105         const ClusterInfo* clusterInfo = &( *it );
106
107         debugOutput( debugLevel, "number of channels: %d\n",
108                      clusterInfo->m_nrOfChannels );
109
110         for ( ChannelInfoVector::const_iterator cit
111                   = clusterInfo->m_channelInfos.begin();
112               cit != clusterInfo->m_channelInfos.end();
113               ++cit )
114         {
115             const ChannelInfo* channelInfo = &( *cit );
116             channelInfo = channelInfo;
117             debugOutput( debugLevel,
118                          "stream position: %d\n",
119                          channelInfo->m_streamPosition );
120             debugOutput( debugLevel,
121                          "location: %d\n",
122                          channelInfo->m_location );
123         }
124     }
125 }
126
127 AvPlug::ClusterInfo*
128 AvPlug::getClusterInfoByIndex(int index)
129 {
130     for ( AvPlug::ClusterInfoVector::iterator clit =
131               m_clusterInfos.begin();
132           clit != m_clusterInfos.end();
133           ++clit )
134     {
135         ClusterInfo* info = &*clit;
136         if ( info->m_index == index ) {
137             return info;
138         }
139     }
140     return 0;
141 }
142
143 int
144 AvPlug::getNrOfStreams()
145 {
146     int nrOfChannels = 0;
147     for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin();
148           it != m_clusterInfos.end();
149           ++it )
150     {
151         const ClusterInfo* clusterInfo = &( *it );
152         nrOfChannels += clusterInfo->m_nrOfChannels;
153     }
154     return nrOfChannels;
155 }
156
157 int
158 AvPlug::getNrOfChannels()
159 {
160     return m_nrOfChannels;
161 }
162
163 int
164 AvPlug::getSampleRate()
165 {
166     return convertESamplingFrequency( static_cast<ESamplingFrequency>( m_samplingFrequency ) );
167 }
168
169 ////////////////////////////////////
170
171 AvPlugCluster::AvPlugCluster()
172 {
173 }
174
175 AvPlugCluster::~AvPlugCluster()
176 {
177 }
178
179 ////////////////////////////////////
180
181 AvPlugConnection::AvPlugConnection()
182 {
183 }
184
185 AvPlugConnection::~AvPlugConnection()
186 {
187 }
188
189 }
Note: See TracBrowser for help on using the browser.