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

Revision 188, 5.0 kB (checked in by wagi, 17 years ago)

2006-05-04 Daniel Wagner <wagi@monom.org>

  • configure.ac: Version bumped to 0.8.0
  • Discovering code ported stable 0.2.0 version
    to head and activated for default discovering.
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             debugOutput( debugLevel,
117                          "stream position: %d\n",
118                          channelInfo->m_streamPosition );
119             debugOutput( debugLevel,
120                          "location: %d\n",
121                          channelInfo->m_location );
122         }
123     }
124 }
125
126 AvPlug::ClusterInfo*
127 AvPlug::getClusterInfoByIndex(int index)
128 {
129     for ( AvPlug::ClusterInfoVector::iterator clit =
130               m_clusterInfos.begin();
131           clit != m_clusterInfos.end();
132           ++clit )
133     {
134         ClusterInfo* info = &*clit;
135         if ( info->m_index == index ) {
136             return info;
137         }
138     }
139     return 0;
140 }
141
142 int
143 AvPlug::getNrOfStreams()
144 {
145     int nrOfChannels = 0;
146     for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin();
147           it != m_clusterInfos.end();
148           ++it )
149     {
150         const ClusterInfo* clusterInfo = &( *it );
151         nrOfChannels += clusterInfo->m_nrOfChannels;
152     }
153     return nrOfChannels;
154 }
155
156 int
157 AvPlug::getNrOfChannels()
158 {
159     return m_nrOfChannels;
160 }
161
162 int
163 AvPlug::getSampleRate()
164 {
165     return convertESamplingFrequency( static_cast<ESamplingFrequency>( m_samplingFrequency ) );
166 }
167
168 ////////////////////////////////////
169
170 AvPlugCluster::AvPlugCluster()
171 {
172 }
173
174 AvPlugCluster::~AvPlugCluster()
175 {
176 }
177
178 ////////////////////////////////////
179
180 AvPlugConnection::AvPlugConnection()
181 {
182 }
183
184 AvPlugConnection::~AvPlugConnection()
185 {
186 }
187
188 }
Note: See TracBrowser for help on using the browser.