root/branches/streaming-rework/src/libavc/avc_extended_plug_info.cpp

Revision 413, 23.1 kB (checked in by pieterpalmers, 17 years ago)

- moved all generic IEEE1394 classes into libieee1394

src/libieee1394/ieee1394service.h
src/libieee1394/csr1212.h
src/libieee1394/configrom.cpp
src/libieee1394/configrom.h
src/libieee1394/ieee1394service.cpp
src/libieee1394/csr1212.c

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* avc_extended_plug_info.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 "avc_extended_plug_info.h"
22 #include "avc_serialize.h"
23 #include "libieee1394/ieee1394service.h"
24
25 #include <netinet/in.h>
26 #include <iostream>
27
28 using namespace std;
29
30 /////////////////////////////////////////
31 /////////////////////////////////////////
32
33 ExtendedPlugInfoPlugTypeSpecificData::ExtendedPlugInfoPlugTypeSpecificData( EExtendedPlugInfoPlugType ePlugType )
34     : IBusData()
35     , m_plugType( ePlugType )
36 {
37 }
38
39 ExtendedPlugInfoPlugTypeSpecificData::~ExtendedPlugInfoPlugTypeSpecificData()
40 {
41 }
42
43 bool
44 ExtendedPlugInfoPlugTypeSpecificData::serialize( IOSSerialize& se )
45 {
46     se.write( m_plugType, "ExtendedPlugInfoPlugTypeSpecificData plugType" );
47     return true;
48 }
49
50
51 bool
52 ExtendedPlugInfoPlugTypeSpecificData::deserialize( IISDeserialize& de )
53 {
54     de.read( &m_plugType );
55     return true;
56 }
57
58 ExtendedPlugInfoPlugTypeSpecificData* ExtendedPlugInfoPlugTypeSpecificData::clone() const
59 {
60     return new ExtendedPlugInfoPlugTypeSpecificData( *this );
61 }
62
63 const char* extendedPlugInfoPlugTypeStrings[] =
64 {
65     "IsoStream",
66     "AsyncStream",
67     "Midi",
68     "Sync",
69     "Analog",
70     "Digital",
71     "Unknown",
72 };
73
74 const char* extendedPlugInfoPlugTypeToString( plug_type_t plugType )
75 {
76     if ( plugType > sizeof( extendedPlugInfoPlugTypeStrings ) ) {
77         return "Unknown";
78     } else {
79         return extendedPlugInfoPlugTypeStrings[plugType];
80     }
81 }
82
83 /////////////////////////////////////////
84 /////////////////////////////////////////
85
86 ExtendedPlugInfoPlugNameSpecificData::ExtendedPlugInfoPlugNameSpecificData()
87     : IBusData()
88 {
89 }
90
91 ExtendedPlugInfoPlugNameSpecificData::~ExtendedPlugInfoPlugNameSpecificData()
92 {
93 }
94
95 bool
96 ExtendedPlugInfoPlugNameSpecificData::serialize( IOSSerialize& se )
97 {
98     byte_t length = strlen( m_name.c_str() );
99     se.write( length,
100               "ExtendedPlugInfoPlugNameSpecificData: string length" );
101     for ( unsigned int i = 0; i < length; ++i ) {
102         se.write( static_cast<byte_t>( m_name[i] ),
103                   "ExtendedPlugInfoPlugNameSpecificData: char" );
104     }
105
106     return true;
107 }
108
109 bool
110 ExtendedPlugInfoPlugNameSpecificData::deserialize( IISDeserialize& de )
111 {
112     byte_t length;
113     de.read( &length );
114     m_name.clear();
115     char* name;
116     de.read( &name, length );
117     m_name = name;
118
119     return true;
120 }
121
122 ExtendedPlugInfoPlugNameSpecificData::ExtendedPlugInfoPlugNameSpecificData*
123 ExtendedPlugInfoPlugNameSpecificData::clone() const
124 {
125     return new ExtendedPlugInfoPlugNameSpecificData( *this );
126 }
127
128
129 /////////////////////////////////////////
130 /////////////////////////////////////////
131
132 ExtendedPlugInfoPlugNumberOfChannelsSpecificData::ExtendedPlugInfoPlugNumberOfChannelsSpecificData()
133     : IBusData()
134     , m_nrOfChannels( 0 )
135 {
136 }
137
138 ExtendedPlugInfoPlugNumberOfChannelsSpecificData::~ExtendedPlugInfoPlugNumberOfChannelsSpecificData()
139 {
140 }
141
142 bool
143 ExtendedPlugInfoPlugNumberOfChannelsSpecificData::serialize( IOSSerialize& se )
144 {
145     se.write( m_nrOfChannels,
146               "ExtendedPlugInfoPlugNumberOfChannelsSpecificData: "
147               "number of channels" );
148     return true;
149 }
150
151 bool
152 ExtendedPlugInfoPlugNumberOfChannelsSpecificData::deserialize( IISDeserialize& de )
153 {
154     de.read( &m_nrOfChannels );
155     return true;
156 }
157
158 ExtendedPlugInfoPlugNumberOfChannelsSpecificData::ExtendedPlugInfoPlugNumberOfChannelsSpecificData*
159 ExtendedPlugInfoPlugNumberOfChannelsSpecificData::clone() const
160 {
161     return new ExtendedPlugInfoPlugNumberOfChannelsSpecificData( *this );
162 }
163
164 /////////////////////////////////////////
165 /////////////////////////////////////////
166
167 ExtendedPlugInfoPlugChannelPositionSpecificData::ExtendedPlugInfoPlugChannelPositionSpecificData()
168     : IBusData()
169     , m_nrOfClusters( 0 )
170 {
171 }
172
173 ExtendedPlugInfoPlugChannelPositionSpecificData::~ExtendedPlugInfoPlugChannelPositionSpecificData()
174 {
175 }
176
177 bool
178 ExtendedPlugInfoPlugChannelPositionSpecificData::serialize( IOSSerialize& se )
179 {
180     se.write( m_nrOfClusters,
181               "ExtendedPlugInfoPlugChannelPositionSpecificData: "
182               "number of clusters" );
183
184     for ( ClusterInfoVector::const_iterator it = m_clusterInfos.begin();
185           it != m_clusterInfos.end();
186           ++it )
187     {
188         const ClusterInfo* clusterInfo = &( *it );
189
190         se.write( clusterInfo->m_nrOfChannels,
191                   "ExtendedPlugInfoPlugChannelPositionSpecificData: "
192                   "number of channels" );
193         for ( ChannelInfoVector::const_iterator cit
194                   = clusterInfo->m_channelInfos.begin();
195               cit != clusterInfo->m_channelInfos.end();
196               ++cit )
197         {
198             const ChannelInfo* channelInfo = &( *cit );
199             se.write( channelInfo->m_streamPosition,
200                       "ExtendedPlugInfoPlugChannelPositionSpecificData: "
201                       "stream position" );
202             se.write( channelInfo->m_location,
203                       "ExtendedPlugInfoPlugChannelPositionSpecificData: "
204                       "location" );
205         }
206     }
207
208     return true;
209 }
210
211 bool
212 ExtendedPlugInfoPlugChannelPositionSpecificData::deserialize( IISDeserialize& de )
213 {
214     m_clusterInfos.clear();
215
216     de.read( &m_nrOfClusters );
217     for ( int i = 0; i < m_nrOfClusters; ++i ) {
218         ClusterInfo clusterInfo;
219         de.read ( &clusterInfo.m_nrOfChannels );
220         for ( int j = 0; j < clusterInfo.m_nrOfChannels; ++j ) {
221             ChannelInfo channelInfo;
222             de.read( &channelInfo.m_streamPosition );
223             de.read( &channelInfo.m_location );
224             clusterInfo.m_channelInfos.push_back( channelInfo );
225         }
226         m_clusterInfos.push_back( clusterInfo );
227     }
228     return true;
229 }
230
231 ExtendedPlugInfoPlugChannelPositionSpecificData::ExtendedPlugInfoPlugChannelPositionSpecificData*
232 ExtendedPlugInfoPlugChannelPositionSpecificData::clone() const
233 {
234     return new ExtendedPlugInfoPlugChannelPositionSpecificData( *this );
235 }
236
237 /////////////////////////////////////////
238 /////////////////////////////////////////
239
240 ExtendedPlugInfoPlugChannelNameSpecificData::ExtendedPlugInfoPlugChannelNameSpecificData()
241     : IBusData()
242     , m_streamPosition( 0 )
243     , m_stringLength( 0xff )
244 {
245 }
246
247 ExtendedPlugInfoPlugChannelNameSpecificData::~ExtendedPlugInfoPlugChannelNameSpecificData()
248 {
249 }
250
251 bool
252 ExtendedPlugInfoPlugChannelNameSpecificData::serialize( IOSSerialize& se )
253 {
254     se.write( m_streamPosition,
255               "ExtendedPlugInfoPlugChannelNameSpecificData: stream position" );
256     se.write( m_stringLength,
257               "ExtendedPlugInfoPlugChannelNameSpecificData: string length" );
258     for ( unsigned int i = 0; i < m_plugChannelName.size(); ++i ) {
259         se.write( static_cast<byte_t>( m_plugChannelName[i] ),
260                   "ExtendedPlugInfoPlugChannelNameSpecificData: char" );
261     }
262
263     return true;
264 }
265
266 bool
267 ExtendedPlugInfoPlugChannelNameSpecificData::deserialize( IISDeserialize& de )
268 {
269     de.read( &m_streamPosition );
270     de.read( &m_stringLength );
271
272     char* name = new char[m_stringLength+1];
273     for ( int i = 0; i < m_stringLength; ++i ) {
274         byte_t c;
275         de.read( &c );
276         // \todo do correct encoding
277         if ( c == '&' ) {
278             c = '+';
279         }
280         name[i] = c;
281     }
282     name[m_stringLength] = '\0';
283     m_plugChannelName = name;
284     delete[] name;
285
286     return true;
287 }
288
289 ExtendedPlugInfoPlugChannelNameSpecificData::ExtendedPlugInfoPlugChannelNameSpecificData*
290 ExtendedPlugInfoPlugChannelNameSpecificData::clone() const
291 {
292     return new ExtendedPlugInfoPlugChannelNameSpecificData( *this );
293 }
294
295 /////////////////////////////////////////
296 /////////////////////////////////////////
297 ExtendedPlugInfoPlugInputSpecificData::ExtendedPlugInfoPlugInputSpecificData()
298     : IBusData()
299 {
300     UnitPlugSpecificDataPlugAddress
301         unitPlug( UnitPlugSpecificDataPlugAddress::ePT_PCR,  0x00 );
302     m_plugAddress
303         = new PlugAddressSpecificData( PlugAddressSpecificData::ePD_Output,
304                                        PlugAddressSpecificData::ePAM_Unit,
305                                        unitPlug );
306 }
307
308 ExtendedPlugInfoPlugInputSpecificData::ExtendedPlugInfoPlugInputSpecificData(const ExtendedPlugInfoPlugInputSpecificData& rhs )
309 {
310     m_plugAddress = rhs.m_plugAddress->clone();
311 }
312
313
314 ExtendedPlugInfoPlugInputSpecificData::~ExtendedPlugInfoPlugInputSpecificData()
315 {
316     delete m_plugAddress;
317     m_plugAddress = 0;
318 }
319
320 bool
321 ExtendedPlugInfoPlugInputSpecificData::serialize( IOSSerialize& se )
322 {
323     if ( m_plugAddress ) {
324         return m_plugAddress->serialize( se );
325     } else {
326         return false;
327     }
328 }
329
330 bool
331 ExtendedPlugInfoPlugInputSpecificData::deserialize( IISDeserialize& de )
332 {
333     return m_plugAddress->deserialize( de );
334 }
335
336 ExtendedPlugInfoPlugInputSpecificData::ExtendedPlugInfoPlugInputSpecificData*
337 ExtendedPlugInfoPlugInputSpecificData::clone() const
338 {
339     return new ExtendedPlugInfoPlugInputSpecificData( *this );
340 }
341
342 /////////////////////////////////////////
343 /////////////////////////////////////////
344
345 ExtendedPlugInfoPlugOutputSpecificData::ExtendedPlugInfoPlugOutputSpecificData()
346     : IBusData()
347     , m_nrOfOutputPlugs( 0 )
348 {
349 }
350
351 ExtendedPlugInfoPlugOutputSpecificData::ExtendedPlugInfoPlugOutputSpecificData( const ExtendedPlugInfoPlugOutputSpecificData& rhs)
352     : IBusData()
353     , m_nrOfOutputPlugs( rhs.m_nrOfOutputPlugs )
354 {
355     for ( PlugAddressVector::const_iterator it = rhs.m_outputPlugAddresses.begin();
356           it != rhs.m_outputPlugAddresses.end();
357           ++it )
358     {
359         m_outputPlugAddresses.push_back( ( *it )->clone() );
360     }
361
362 }
363
364
365 ExtendedPlugInfoPlugOutputSpecificData::~ExtendedPlugInfoPlugOutputSpecificData()
366 {
367     for ( PlugAddressVector::iterator it = m_outputPlugAddresses.begin();
368           it != m_outputPlugAddresses.end();
369           ++it )
370     {
371         delete *it;
372     }
373 }
374
375 bool
376 ExtendedPlugInfoPlugOutputSpecificData::serialize( IOSSerialize& se )
377 {
378     se.write( m_nrOfOutputPlugs, "ExtendedPlugInfoPlugOutputSpecificData: number of output plugs" );
379     for ( PlugAddressVector::const_iterator it = m_outputPlugAddresses.begin();
380           it != m_outputPlugAddresses.end();
381           ++it )
382     {
383         ( *it )->serialize( se );
384     }
385
386     return true;
387 }
388
389 bool
390 ExtendedPlugInfoPlugOutputSpecificData::deserialize( IISDeserialize& de )
391 {
392     de.read( &m_nrOfOutputPlugs );
393
394     for ( int i = 0; i < m_nrOfOutputPlugs; ++i )
395     {
396         UnitPlugSpecificDataPlugAddress
397             unitPlug( UnitPlugSpecificDataPlugAddress::ePT_PCR,  0x00 );
398         PlugAddressSpecificData* plugAddress
399             = new PlugAddressSpecificData( PlugAddressSpecificData::ePD_Output,
400                                            PlugAddressSpecificData::ePAM_Unit,
401                                            unitPlug );
402         if ( !plugAddress->deserialize( de ) ) {
403             return false;
404         }
405
406         m_outputPlugAddresses.push_back( plugAddress );
407     }
408
409     return true;
410 }
411
412 ExtendedPlugInfoPlugOutputSpecificData::ExtendedPlugInfoPlugOutputSpecificData*
413 ExtendedPlugInfoPlugOutputSpecificData::clone() const
414 {
415     return new ExtendedPlugInfoPlugOutputSpecificData( *this );
416 }
417
418 /////////////////////////////////////////
419 /////////////////////////////////////////
420 ExtendedPlugInfoClusterInfoSpecificData::ExtendedPlugInfoClusterInfoSpecificData()
421     : IBusData()
422     , m_clusterIndex( 0 )
423     , m_portType( ePT_NoType )
424     , m_stringLength( 0xff )
425 {
426 }
427
428 ExtendedPlugInfoClusterInfoSpecificData::~ExtendedPlugInfoClusterInfoSpecificData()
429 {
430 }
431
432 bool
433 ExtendedPlugInfoClusterInfoSpecificData::serialize( IOSSerialize& se )
434 {
435     se.write( m_clusterIndex,
436               "ExtendedPlugInfoClusterInfoSpecificData: cluster index" );
437     se.write( m_portType,
438               "ExtendedPlugInfoClusterInfoSpecificData: port type" );
439     se.write( m_stringLength,
440               "ExtendedPlugInfoClusterInfoSpecificData: string length" );
441     for ( unsigned int i = 0; i < m_clusterName.length(); ++i ) {
442         se.write( static_cast<byte_t>( m_clusterName[i] ),
443                   "ExtendedPlugInfoClusterInfoSpecificData: char" );
444     }
445
446     return true;
447 }
448
449 bool
450 ExtendedPlugInfoClusterInfoSpecificData::deserialize( IISDeserialize& de )
451 {
452
453     de.read( &m_clusterIndex );
454     de.read( &m_portType );
455     de.read( &m_stringLength );
456
457     char* name = new char[m_stringLength+1];
458     for ( int i = 0; i < m_stringLength; ++i ) {
459         byte_t c;
460         de.read( &c );
461         // \todo do correct encoding
462         if ( c == '&' ) {
463             c = '+';
464         }
465         name[i] = c;
466     }
467     name[m_stringLength] = '\0';
468     m_clusterName = name;
469     delete[] name;
470
471     return true;
472 }
473
474 ExtendedPlugInfoClusterInfoSpecificData::ExtendedPlugInfoClusterInfoSpecificData*
475 ExtendedPlugInfoClusterInfoSpecificData::clone() const
476 {
477     return new ExtendedPlugInfoClusterInfoSpecificData( *this );
478 }
479
480 const char* extendedPlugInfoPortTypeStrings[] =
481 {
482     "Speaker",
483     "Headphone",
484     "Microphone",
485     "Line",
486     "SPDIF",
487     "ADAT",
488     "TDIF",
489     "MADI",
490     "Analog",
491     "Digital",
492     "MIDI",
493 };
494
495 const char* extendedPlugInfoClusterInfoPortTypeToString( port_type_t portType )
496 {
497     if ( portType > ( ( sizeof( extendedPlugInfoPortTypeStrings ) )
498                       / ( sizeof( extendedPlugInfoPortTypeStrings[0] ) ) ) ) {
499         return "Unknown";
500     } else {
501         return extendedPlugInfoPortTypeStrings[portType];
502     }
503 }
504
505 /////////////////////////////////////////
506 /////////////////////////////////////////
507 /////////////////////////////////////////
508 /////////////////////////////////////////
509
510 ExtendedPlugInfoInfoType::ExtendedPlugInfoInfoType(EInfoType eInfoType)
511     : IBusData()
512     , m_infoType( eInfoType )
513     , m_plugType( 0 )
514     , m_plugName( 0 )
515     , m_plugNrOfChns( 0 )
516     , m_plugChannelPosition( 0 )
517     , m_plugChannelName( 0 )
518     , m_plugInput( 0 )
519     , m_plugOutput( 0 )
520     , m_plugClusterInfo( 0 )
521 {
522 }
523
524 ExtendedPlugInfoInfoType::ExtendedPlugInfoInfoType( const ExtendedPlugInfoInfoType& rhs )
525     : IBusData()
526     , m_infoType( rhs.m_infoType )
527     , m_plugType( 0 )
528     , m_plugName( 0 )
529     , m_plugNrOfChns( 0 )
530     , m_plugChannelPosition( 0 )
531     , m_plugChannelName( 0 )
532     , m_plugInput( 0 )
533     , m_plugOutput( 0 )
534     , m_plugClusterInfo( 0 )
535 {
536     switch( m_infoType ) {
537     case eIT_PlugType:
538         m_plugType =
539             new ExtendedPlugInfoPlugTypeSpecificData( *rhs.m_plugType );
540         break;
541     case eIT_PlugName:
542         m_plugName =
543             new ExtendedPlugInfoPlugNameSpecificData( *rhs.m_plugName );
544         break;
545     case eIT_NoOfChannels:
546         m_plugNrOfChns =
547             new ExtendedPlugInfoPlugNumberOfChannelsSpecificData( *rhs.m_plugNrOfChns );
548         break;
549     case eIT_ChannelPosition:
550         m_plugChannelPosition =
551             new ExtendedPlugInfoPlugChannelPositionSpecificData( *rhs.m_plugChannelPosition );
552         break;
553     case eIT_ChannelName:
554         m_plugChannelName =
555             new ExtendedPlugInfoPlugChannelNameSpecificData( *rhs.m_plugChannelName );
556         break;
557     case eIT_PlugInput:
558         m_plugInput =
559             new ExtendedPlugInfoPlugInputSpecificData( *rhs.m_plugInput );
560         break;
561     case eIT_PlugOutput:
562         m_plugOutput =
563             new ExtendedPlugInfoPlugOutputSpecificData( *rhs.m_plugOutput );
564         break;
565     case eIT_ClusterInfo:
566         m_plugClusterInfo =
567             new ExtendedPlugInfoClusterInfoSpecificData( *rhs.m_plugClusterInfo );
568         break;
569     }
570 }
571
572 ExtendedPlugInfoInfoType::~ExtendedPlugInfoInfoType()
573 {
574     delete( m_plugType );
575     delete( m_plugName );
576     delete( m_plugNrOfChns );
577     delete( m_plugChannelPosition );
578     delete( m_plugChannelName );
579     delete( m_plugInput );
580     delete( m_plugOutput );
581     delete( m_plugClusterInfo );
582  }
583
584 bool
585 ExtendedPlugInfoInfoType::initialize()
586 {
587     switch ( m_infoType ) {
588     case eIT_PlugType:
589         m_plugType = new ExtendedPlugInfoPlugTypeSpecificData;
590         break;
591     case eIT_PlugName:
592         m_plugName = new ExtendedPlugInfoPlugNameSpecificData;
593         break;
594     case eIT_NoOfChannels:
595         m_plugNrOfChns = new ExtendedPlugInfoPlugNumberOfChannelsSpecificData;
596         break;
597     case eIT_ChannelPosition:
598         m_plugChannelPosition = new ExtendedPlugInfoPlugChannelPositionSpecificData;
599         break;
600     case eIT_ChannelName:
601         m_plugChannelName = new ExtendedPlugInfoPlugChannelNameSpecificData;
602         break;
603     case eIT_PlugInput:
604         m_plugInput = new ExtendedPlugInfoPlugInputSpecificData;
605         break;
606     case eIT_PlugOutput:
607         m_plugOutput = new ExtendedPlugInfoPlugOutputSpecificData;
608         break;
609     case eIT_ClusterInfo:
610         m_plugClusterInfo = new ExtendedPlugInfoClusterInfoSpecificData;
611         break;
612     default:
613         return false;
614     }
615
616     return true;
617 }
618
619 bool
620 ExtendedPlugInfoInfoType::serialize( IOSSerialize& se )
621 {
622     // XXX \todo improve IOSSerialize::write interface
623     char* buf;
624     asprintf( &buf, "ExtendedPlugInfoInfoType infoType (%s)",
625               extendedPlugInfoInfoTypeToString( m_infoType ) );
626     se.write( m_infoType, buf );
627
628     free(buf);
629
630     switch ( m_infoType ) {
631     case eIT_PlugType:
632         if ( m_plugType ) {
633             m_plugType->serialize( se );
634         }
635         break;
636     case eIT_PlugName:
637         if ( m_plugName ) {
638             m_plugName->serialize( se );
639         }
640         break;
641     case eIT_NoOfChannels:
642         if ( m_plugNrOfChns ) {
643             m_plugNrOfChns->serialize( se );
644         }
645         break;
646     case eIT_ChannelPosition:
647         if ( m_plugChannelPosition ) {
648             m_plugChannelPosition->serialize( se );
649         }
650         break;
651     case eIT_ChannelName:
652         if ( m_plugChannelName ) {
653             m_plugChannelName->serialize( se );
654         }
655         break;
656     case eIT_PlugInput:
657         if ( m_plugInput ) {
658             m_plugInput->serialize( se );
659         }
660         break;
661     case eIT_PlugOutput:
662         if ( m_plugOutput ) {
663             m_plugOutput->serialize( se );
664         }
665         break;
666     case eIT_ClusterInfo:
667         if ( m_plugClusterInfo ) {
668             m_plugClusterInfo->serialize( se );
669         }
670         break;
671     default:
672         return false;
673     }
674
675     return true;
676 }
677
678 bool
679 ExtendedPlugInfoInfoType::deserialize( IISDeserialize& de )
680 {
681     bool status = false;
682
683     de.read( &m_infoType );
684
685     switch ( m_infoType ) {
686     case eIT_PlugType:
687         if ( !m_plugType ) {
688             m_plugType = new ExtendedPlugInfoPlugTypeSpecificData;
689         }
690         status = m_plugType->deserialize( de );
691         break;
692     case eIT_PlugName:
693         if ( !m_plugName ) {
694             m_plugName = new ExtendedPlugInfoPlugNameSpecificData;
695         }
696         status = m_plugName->deserialize( de );
697         break;
698     case eIT_NoOfChannels:
699         if ( !m_plugNrOfChns ) {
700             m_plugNrOfChns =
701                 new ExtendedPlugInfoPlugNumberOfChannelsSpecificData;
702         }
703         status = m_plugNrOfChns->deserialize( de );
704         break;
705     case eIT_ChannelPosition:
706         if ( !m_plugChannelPosition ) {
707             m_plugChannelPosition =
708                 new ExtendedPlugInfoPlugChannelPositionSpecificData;
709         }
710         status = m_plugChannelPosition->deserialize( de );
711         break;
712     case eIT_ChannelName:
713         if ( !m_plugChannelName ) {
714             m_plugChannelName =
715                 new ExtendedPlugInfoPlugChannelNameSpecificData;
716         }
717         status = m_plugChannelName->deserialize( de );
718         break;
719     case eIT_PlugInput:
720         if ( !m_plugInput ) {
721             m_plugInput = new ExtendedPlugInfoPlugInputSpecificData;
722         }
723         status = m_plugInput->deserialize( de );
724         break;
725     case eIT_PlugOutput:
726         if ( !m_plugOutput ) {
727             m_plugOutput = new ExtendedPlugInfoPlugOutputSpecificData;
728         }
729         status = m_plugOutput->deserialize( de );
730         break;
731     case eIT_ClusterInfo:
732         if ( !m_plugClusterInfo ) {
733             m_plugClusterInfo = new ExtendedPlugInfoClusterInfoSpecificData;
734         }
735         status =m_plugClusterInfo->deserialize( de );
736         break;
737     default:
738         return false;
739     }
740
741     return status;
742 }
743
744 ExtendedPlugInfoInfoType*
745 ExtendedPlugInfoInfoType::clone() const
746 {
747    ExtendedPlugInfoInfoType* extPlugInfoInfoType
748        = new ExtendedPlugInfoInfoType( *this );
749    extPlugInfoInfoType->initialize();
750    return extPlugInfoInfoType;
751 }
752
753 const char* extendedPlugInfoInfoTypeStrings[] =
754 {
755     "PlugType",
756     "PlugName",
757     "NoOfChannels",
758     "ChannelPosition",
759     "ChannelName",
760     "PlugInput",
761     "PlugOutput",
762     "ClusterInfo",
763 };
764
765 const char* extendedPlugInfoInfoTypeToString( info_type_t infoType )
766 {
767     if ( infoType > ( ( sizeof( extendedPlugInfoInfoTypeStrings ) )
768                       / ( sizeof( extendedPlugInfoInfoTypeStrings[0] ) ) ) )  {
769         return "Unknown";
770     } else {
771         return extendedPlugInfoInfoTypeStrings[infoType];
772     }
773 }
774
775
776 //////////////////////////////////////////////
777
778 ExtendedPlugInfoCmd::ExtendedPlugInfoCmd( Ieee1394Service& ieee1394service,
779                                           ESubFunction eSubFunction )
780     : AVCCommand( ieee1394service, AVC1394_CMD_PLUG_INFO )
781 {
782     setSubFunction( eSubFunction );
783     UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 0x00 );
784     m_plugAddress = new PlugAddress( PlugAddress::ePD_Output,
785                                       PlugAddress::ePAM_Unit,
786                                       unitPlugAddress );
787     m_infoType =
788         new ExtendedPlugInfoInfoType( ExtendedPlugInfoInfoType::eIT_PlugType );
789     m_infoType->initialize();
790 }
791
792 ExtendedPlugInfoCmd::ExtendedPlugInfoCmd( const ExtendedPlugInfoCmd& rhs )
793     : AVCCommand( rhs )
794 {
795     m_subFunction = rhs.m_subFunction;
796     m_plugAddress = new PlugAddress( *rhs.m_plugAddress );
797     m_infoType = new ExtendedPlugInfoInfoType( *rhs.m_infoType );
798 }
799
800 ExtendedPlugInfoCmd::~ExtendedPlugInfoCmd()
801 {
802     delete m_plugAddress;
803     m_plugAddress = 0;
804     delete m_infoType;
805     m_infoType = 0;
806 }
807
808 bool
809 ExtendedPlugInfoCmd::serialize( IOSSerialize& se )
810 {
811     bool status = false;
812     AVCCommand::serialize( se );
813     se.write( m_subFunction, "ExtendedPlugInfoCmd subFunction" );
814     status = m_plugAddress->serialize( se );
815     status &= m_infoType->serialize( se );
816
817     return status;
818 }
819
820 bool
821 ExtendedPlugInfoCmd::deserialize( IISDeserialize& de )
822 {
823     bool status = false;
824     AVCCommand::deserialize( de );
825     de.read( &m_subFunction );
826     status = m_plugAddress->deserialize( de );
827     status &= m_infoType->deserialize( de );
828
829     return status;
830 }
831
832 bool
833 ExtendedPlugInfoCmd::setPlugAddress( const PlugAddress& plugAddress )
834 {
835     delete m_plugAddress;
836     m_plugAddress = plugAddress.clone();
837     return true;
838 }
839
840 bool
841 ExtendedPlugInfoCmd::setSubFunction( ESubFunction subFunction )
842 {
843     m_subFunction = subFunction;
844     return true;
845 }
846
847 bool
848 ExtendedPlugInfoCmd::setInfoType( const ExtendedPlugInfoInfoType& infoType )
849 {
850     delete m_infoType;
851     m_infoType = infoType.clone();
852     return true;
853 }
Note: See TracBrowser for help on using the browser.