root/trunk/libffado/src/libavc/general/avc_extended_plug_info.h

Revision 618, 10.8 kB (checked in by ppalmers, 13 years ago)

move serialization routines to libutil such that they can be used for non-AVC stuff too (fireworks EFC)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #ifndef AVCEXTENDEDPLUGINFO_H
25 #define AVCEXTENDEDPLUGINFO_H
26
27 #include "avc_extended_cmd_generic.h"
28 #include "avc_generic.h"
29
30 #include <libavc1394/avc1394.h>
31
32 #include <string>
33 #include <vector>
34
35 namespace AVC {
36
37 class ExtendedPlugInfoPlugTypeSpecificData : public IBusData
38 {
39 public:
40     enum EExtendedPlugInfoPlugType {
41         eEPIPT_IsoStream   = 0x0,
42         eEPIPT_AsyncStream = 0x1,
43         eEPIPT_Midi        = 0x2,
44         eEPIPT_Sync        = 0x3,
45         eEPIPT_Analog      = 0x4,
46         eEPIPT_Digital     = 0x5,
47
48         eEPIPT_Unknown     = 0xff,
49     };
50
51     ExtendedPlugInfoPlugTypeSpecificData( EExtendedPlugInfoPlugType ePlugType =  eEPIPT_Unknown);
52     virtual ~ExtendedPlugInfoPlugTypeSpecificData();
53
54     virtual bool serialize( Util::IOSSerialize& se );
55     virtual bool deserialize( Util::IISDeserialize& de );
56     virtual ExtendedPlugInfoPlugTypeSpecificData* clone() const;
57
58     typedef byte_t plug_type_t;
59
60     plug_type_t m_plugType;
61 };
62
63 const char* extendedPlugInfoPlugTypeToString( plug_type_t plugType );
64
65 /////////////////////////////////////////
66
67 class ExtendedPlugInfoPlugNameSpecificData : public IBusData
68 {
69 public:
70     ExtendedPlugInfoPlugNameSpecificData();
71     virtual ~ExtendedPlugInfoPlugNameSpecificData();
72
73     virtual bool serialize( Util::IOSSerialize& se );
74     virtual bool deserialize( Util::IISDeserialize& de );
75     virtual ExtendedPlugInfoPlugNameSpecificData* clone() const;
76
77     std::string m_name;
78 };
79
80 /////////////////////////////////////////
81
82 class ExtendedPlugInfoPlugNumberOfChannelsSpecificData : public IBusData
83 {
84 public:
85     ExtendedPlugInfoPlugNumberOfChannelsSpecificData();
86     virtual ~ExtendedPlugInfoPlugNumberOfChannelsSpecificData();
87
88     virtual bool serialize( Util::IOSSerialize& se );
89     virtual bool deserialize( Util::IISDeserialize& de );
90     virtual ExtendedPlugInfoPlugNumberOfChannelsSpecificData* clone() const;
91
92     nr_of_channels_t m_nrOfChannels;
93 };
94
95
96 /////////////////////////////////////////
97
98 class ExtendedPlugInfoPlugChannelPositionSpecificData : public IBusData
99 {
100 public:
101     enum ELocation {
102         eEPI_LeftFront        = 0x01,
103         eEPI_RightFront       = 0x02,
104         eEPI_Center           = 0x03,
105         eEPI_Subwoofer        = 0x04,
106         eEPI_LeftSurround     = 0x05,
107         eEPI_RightSurround    = 0x06,
108         eEPI_LeftOfCenter     = 0x07,
109         eEPI_RightOfCenter    = 0x08,
110         eEPI_Surround         = 0x09,
111         eEPI_SideLeft         = 0x0a,
112         eEPI_SideRight        = 0x0b,
113         eEPI_Top              = 0x0c,
114         eEPI_Bottom           = 0x0d,
115         eEPI_LeftFrontEffect  = 0x0e,
116         eEPI_RightFrontEffect = 0x0f,
117         eEPI_NoPostion        = 0xff,
118     };
119
120     struct ChannelInfo {
121         stream_position_t          m_streamPosition;
122         stream_position_location_t m_location;
123     };
124
125     typedef std::vector<ChannelInfo> ChannelInfoVector;
126
127     struct ClusterInfo {
128         nr_of_channels_t         m_nrOfChannels;
129         ChannelInfoVector        m_channelInfos;
130     };
131
132     ExtendedPlugInfoPlugChannelPositionSpecificData();
133     virtual ~ExtendedPlugInfoPlugChannelPositionSpecificData();
134
135     virtual bool serialize( Util::IOSSerialize& se );
136     virtual bool deserialize( Util::IISDeserialize& de );
137     virtual ExtendedPlugInfoPlugChannelPositionSpecificData* clone() const;
138
139     typedef std::vector<ClusterInfo> ClusterInfoVector;
140
141     nr_of_clusters_t         m_nrOfClusters;
142     ClusterInfoVector        m_clusterInfos;
143 };
144
145 /////////////////////////////////////////
146
147 class ExtendedPlugInfoPlugChannelNameSpecificData : public IBusData
148 {
149 public:
150     ExtendedPlugInfoPlugChannelNameSpecificData();
151     virtual ~ExtendedPlugInfoPlugChannelNameSpecificData();
152
153     virtual bool serialize( Util::IOSSerialize& se );
154     virtual bool deserialize( Util::IISDeserialize& de );
155     virtual ExtendedPlugInfoPlugChannelNameSpecificData* clone() const;
156
157     stream_position_t m_streamPosition;
158     string_length_t   m_stringLength;
159     std::string       m_plugChannelName;
160 };
161
162 /////////////////////////////////////////
163
164 class ExtendedPlugInfoPlugInputSpecificData : public IBusData
165 {
166 public:
167     ExtendedPlugInfoPlugInputSpecificData();
168     ExtendedPlugInfoPlugInputSpecificData( const ExtendedPlugInfoPlugInputSpecificData& rhs );
169     virtual ~ExtendedPlugInfoPlugInputSpecificData();
170
171     virtual bool serialize( Util::IOSSerialize& se );
172     virtual bool deserialize( Util::IISDeserialize& de );
173     virtual ExtendedPlugInfoPlugInputSpecificData* clone() const;
174
175     PlugAddressSpecificData* m_plugAddress;
176 };
177
178
179 /////////////////////////////////////////
180
181 class ExtendedPlugInfoPlugOutputSpecificData : public IBusData
182 {
183 public:
184     ExtendedPlugInfoPlugOutputSpecificData();
185     ExtendedPlugInfoPlugOutputSpecificData( const ExtendedPlugInfoPlugOutputSpecificData& rhs );
186     virtual ~ExtendedPlugInfoPlugOutputSpecificData();
187
188     virtual bool serialize( Util::IOSSerialize& se );
189     virtual bool deserialize( Util::IISDeserialize& de );
190     virtual ExtendedPlugInfoPlugOutputSpecificData* clone() const;
191
192     number_of_output_plugs_t m_nrOfOutputPlugs;
193
194     typedef std::vector<PlugAddressSpecificData*> PlugAddressVector;
195     PlugAddressVector m_outputPlugAddresses;
196 };
197
198 /////////////////////////////////////////
199
200 class ExtendedPlugInfoClusterInfoSpecificData : public IBusData
201 {
202 public:
203     enum EPortType {
204         ePT_Speaker            = 0x00,
205         ePT_Headphone          = 0x01,
206         ePT_Microphone         = 0x02,
207         ePT_Line               = 0x03,
208         ePT_SPDIF              = 0x04,
209         ePT_ADAT               = 0x05,
210         ePT_TDIF               = 0x06,
211         ePT_MADI               = 0x07,
212         ePT_Analog             = 0x08,
213         ePT_Digital            = 0x09,
214         ePT_MIDI               = 0x0a,
215         ePT_NoType             = 0xff,
216     };
217
218     ExtendedPlugInfoClusterInfoSpecificData();
219     virtual ~ExtendedPlugInfoClusterInfoSpecificData();
220
221     virtual bool serialize( Util::IOSSerialize& se );
222     virtual bool deserialize( Util::IISDeserialize& de );
223     virtual ExtendedPlugInfoClusterInfoSpecificData* clone() const;
224
225     cluster_index_t m_clusterIndex;
226     port_type_t     m_portType;
227     string_length_t m_stringLength;
228     std::string     m_clusterName;
229 };
230
231 const char* extendedPlugInfoClusterInfoPortTypeToString( port_type_t portType );
232
233 /////////////////////////////////////////
234
235 #define AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_TYPE                   0x00
236 #define AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_NAME                   0x01
237 #define AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_NO_OF_CHANNELS         0x02
238 #define AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_CHANNEL_POSITION       0x03
239 #define AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_CHANNEL_NAME           0x04
240 #define AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_INPUT                  0x05
241 #define AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_OUTPUT                 0x06
242 #define AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_CLUSTER_INFO           0x07
243
244 class ExtendedPlugInfoInfoType : public IBusData
245 {
246 public:
247     enum EInfoType {
248         eIT_PlugType        = AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_TYPE,
249         eIT_PlugName        = AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_NAME,
250         eIT_NoOfChannels    = AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_NO_OF_CHANNELS,
251         eIT_ChannelPosition = AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_CHANNEL_POSITION,
252         eIT_ChannelName     = AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_CHANNEL_NAME,
253         eIT_PlugInput       = AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_INPUT,
254         eIT_PlugOutput      = AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_OUTPUT,
255         eIT_ClusterInfo     = AVC1394_EXTENDED_PLUG_INFO_INFO_TYPE_PLUG_CLUSTER_INFO,
256     };
257
258     ExtendedPlugInfoInfoType(EInfoType eInfoType);
259     ExtendedPlugInfoInfoType( const ExtendedPlugInfoInfoType& rhs );
260     virtual ~ExtendedPlugInfoInfoType();
261
262     bool initialize();
263
264     virtual bool serialize( Util::IOSSerialize& se );
265     virtual bool deserialize( Util::IISDeserialize& de );
266     virtual ExtendedPlugInfoInfoType* clone() const;
267
268     info_type_t m_infoType;
269
270     ExtendedPlugInfoPlugTypeSpecificData*               m_plugType;
271     ExtendedPlugInfoPlugNameSpecificData*               m_plugName;
272     ExtendedPlugInfoPlugNumberOfChannelsSpecificData*   m_plugNrOfChns;
273     ExtendedPlugInfoPlugChannelPositionSpecificData*    m_plugChannelPosition;
274     ExtendedPlugInfoPlugChannelNameSpecificData*        m_plugChannelName;
275     ExtendedPlugInfoPlugInputSpecificData*              m_plugInput;
276     ExtendedPlugInfoPlugOutputSpecificData*             m_plugOutput;
277     ExtendedPlugInfoClusterInfoSpecificData*            m_plugClusterInfo;
278 };
279
280 const char* extendedPlugInfoInfoTypeToString( info_type_t infoType );
281
282 /////////////////////////////////////////////////////////
283
284 #define AVC1394_PLUG_INFO_SUBFUNCTION_EXTENDED_PLUG_INFO_CMD   0xC0
285 #define AVC1394_PLUG_INFO_SUBFUNCTION_SERIAL_BUS_NOT_USED      0xFF
286
287
288 class ExtendedPlugInfoCmd: public AVCCommand
289 {
290 public:
291     enum ESubFunction {
292         eSF_ExtendedPlugInfoCmd                  = AVC1394_PLUG_INFO_SUBFUNCTION_EXTENDED_PLUG_INFO_CMD,
293         eSF_NotUsed                              = AVC1394_PLUG_INFO_SUBFUNCTION_SERIAL_BUS_NOT_USED,
294     };
295
296     ExtendedPlugInfoCmd( Ieee1394Service& ieee1394service,
297                          ESubFunction eSubFunction = eSF_ExtendedPlugInfoCmd );
298     ExtendedPlugInfoCmd( const ExtendedPlugInfoCmd& rhs );
299     virtual ~ExtendedPlugInfoCmd();
300
301     virtual bool serialize( Util::IOSSerialize& se );
302     virtual bool deserialize( Util::IISDeserialize& de );
303
304     bool setPlugAddress( const PlugAddress& plugAddress );
305     bool setSubFunction( ESubFunction subFunction );
306     subfunction_t getSubFunction( ) {return m_subFunction;};
307     bool setInfoType( const ExtendedPlugInfoInfoType& infoType );
308     ExtendedPlugInfoInfoType* getInfoType()
309     { return m_infoType; }
310
311     virtual const char* getCmdName() const
312     { return "ExtendedPlugInfoCmd"; }
313
314 protected:
315     subfunction_t             m_subFunction;
316     PlugAddress*              m_plugAddress;
317     ExtendedPlugInfoInfoType* m_infoType;
318 };
319
320 }
321
322 #endif
Note: See TracBrowser for help on using the browser.