root/trunk/libffado/src/libavc/audiosubunit/avc_function_block.cpp

Revision 2442, 22.2 kB (checked in by mocchi, 6 years ago)

[libavc] complement 'Processing function block' command

Current implement of libavc is lack of actual work for 'Processing function block' command defined in 'AV/C Audio Subunit Specification 1.0 (1394TA Document 1999008)'. I guess the reason is there are several types of the command. To implement all of the commands in the specification is too cost.

But here, a driver for BeBoB/MAudio devices needs this command to control device's internal mixer. These devices can be controlled by either 'single' or 'multiple' type of the command.

For these reasons, this commit add 'single type' of 'processing function block command'.

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  * Copyright (C) 2005-2008 by Pieter Palmers
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) version 3 of the License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #include "avc_function_block.h"
26 #include "libutil/cmd_serialize.h"
27 #include "libieee1394/ieee1394service.h"
28
29 #include <cstdio>
30
31 namespace AVC {
32
33
34 /////////////////////////////////
35
36 FunctionBlockFeatureVolume::FunctionBlockFeatureVolume()
37     : IBusData()
38     , m_controlDataLength( 2 )
39     , m_volume( 0 )
40 {
41 }
42
43 FunctionBlockFeatureVolume::FunctionBlockFeatureVolume( const FunctionBlockFeatureVolume& rhs )
44     : m_controlDataLength( rhs.m_controlDataLength )
45     , m_volume( rhs.m_volume )
46 {
47 }
48
49 FunctionBlockFeatureVolume::~FunctionBlockFeatureVolume()
50 {
51 }
52
53 bool
54 FunctionBlockFeatureVolume::serialize( Util::Cmd::IOSSerialize& se )
55 {
56     bool bStatus;
57     byte_t val;
58     bStatus = se.write( m_controlDataLength,  "FunctionBlockFeatureVolume controlDataLength" );
59     val = (byte_t)(m_volume >> 8);
60     bStatus &= se.write( val,                  "FunctionBlockFeatureVolume volume high" );
61     val = m_volume & 0xff;
62     bStatus &= se.write( val,                  "FunctionBlockFeatureVolume volume low" );
63
64     return bStatus;
65 }
66
67 bool
68 FunctionBlockFeatureVolume::deserialize( Util::Cmd::IISDeserialize& de )
69 {
70     bool bStatus;
71     byte_t val;
72     bStatus = de.read( &m_controlDataLength );
73     bStatus &= de.read( &val );
74     m_volume = val << 8;
75     bStatus &= de.read( &val );
76     m_volume |= val;
77
78     return bStatus;
79 }
80
81 FunctionBlockFeatureVolume*
82 FunctionBlockFeatureVolume::clone() const
83 {
84     return new FunctionBlockFeatureVolume( *this );
85 }
86
87 /////////////////////////////////
88
89 FunctionBlockFeatureLRBalance::FunctionBlockFeatureLRBalance()
90     : IBusData()
91     , m_controlDataLength( 2 )
92     , m_lrBalance( 0 )
93 {
94 }
95
96 FunctionBlockFeatureLRBalance::FunctionBlockFeatureLRBalance( const FunctionBlockFeatureLRBalance& rhs )
97     : m_controlDataLength( rhs.m_controlDataLength )
98     , m_lrBalance( rhs.m_lrBalance )
99 {
100 }
101
102 FunctionBlockFeatureLRBalance::~FunctionBlockFeatureLRBalance()
103 {
104 }
105
106 bool
107 FunctionBlockFeatureLRBalance::serialize( Util::Cmd::IOSSerialize& se )
108 {
109     bool bStatus;
110     byte_t val;
111     bStatus = se.write( m_controlDataLength,  "FunctionBlockFeatureLRBalance controlDataLength" );
112     val = (byte_t)(m_lrBalance >> 8);
113     bStatus &= se.write( val,                 "FunctionBlockFeatureLRBalance LR Balance high" );
114     val = m_lrBalance & 0xff;
115     bStatus &= se.write( val,                 "FunctionBlockFeatureLRBalance LR Balance low" );
116
117     return bStatus;
118 }
119
120 bool
121 FunctionBlockFeatureLRBalance::deserialize( Util::Cmd::IISDeserialize& de )
122 {
123     bool bStatus;
124     byte_t val;
125     bStatus = de.read( &m_controlDataLength );
126     bStatus &= de.read( &val );
127     m_lrBalance = val << 8;
128     bStatus &= de.read( &val );
129     m_lrBalance |= val;
130
131     return bStatus;
132 }
133
134 FunctionBlockFeatureLRBalance*
135 FunctionBlockFeatureLRBalance::clone() const
136 {
137     return new FunctionBlockFeatureLRBalance( *this );
138 }
139
140 /////////////////////////////////
141
142 FunctionBlockProcessingMixer::FunctionBlockProcessingMixer()
143     : IBusData()
144     , m_controlSelector( FunctionBlockProcessing::eCSE_Processing_Mixer )
145     , m_controlDataLength( 0x02 )
146     , m_mixerSetting( 0x0000 )
147 {
148 }
149
150 FunctionBlockProcessingMixer::FunctionBlockProcessingMixer( const FunctionBlockProcessingMixer& rhs )
151     : m_controlSelector( rhs.m_controlSelector ),
152       m_controlDataLength( 0x02 ),
153       m_mixerSetting( 0x00 )
154 {
155 }
156
157 FunctionBlockProcessingMixer::~FunctionBlockProcessingMixer()
158 {
159 }
160
161 bool
162 FunctionBlockProcessingMixer::serialize( Util::Cmd::IOSSerialize& se )
163 {
164     bool bStatus;
165     bStatus  = se.write( m_controlSelector,    "FunctionBlockProcessingMixer controlSelector" );
166     bStatus &= se.write( m_controlDataLength,  "FunctionBlockProcessingMixer controlDataLength" );
167     bStatus &= se.write( m_mixerSetting,       "FunctionBlockProcessingMixer mixerSetting" );
168
169     return bStatus;
170 }
171
172 bool
173 FunctionBlockProcessingMixer::deserialize( Util::Cmd::IISDeserialize& de )
174 {
175     bool bStatus;
176     byte_t padding;
177
178     bStatus  = de.read( &m_controlSelector );
179     bStatus &= de.read( &m_controlDataLength );
180     bStatus &= de.read( &m_mixerSetting );
181     bStatus &= de.read( &padding );
182     bStatus &= de.read( &padding );
183
184     return bStatus;
185 }
186
187 FunctionBlockProcessingMixer*
188 FunctionBlockProcessingMixer::clone() const
189 {
190     return new FunctionBlockProcessingMixer( *this );
191 }
192
193 /////////////////////////////////
194
195 FunctionBlockProcessingEnhancedMixer::FunctionBlockProcessingEnhancedMixer()
196     : IBusData()
197     , m_controlSelector( FunctionBlockProcessing::eCSE_Processing_EnhancedMixer )
198     , m_statusSelector( eSS_Level )
199     , m_controlDataLength( 0 )
200 {
201 }
202
203 FunctionBlockProcessingEnhancedMixer::FunctionBlockProcessingEnhancedMixer(
204     const FunctionBlockProcessingEnhancedMixer& rhs )
205     : m_controlSelector( rhs.m_controlSelector )
206     , m_statusSelector( rhs.m_statusSelector )
207 {
208 }
209
210 FunctionBlockProcessingEnhancedMixer::~FunctionBlockProcessingEnhancedMixer()
211 {
212 }
213
214 bool
215 FunctionBlockProcessingEnhancedMixer::serialize( Util::Cmd::IOSSerialize& se )
216 {
217     bool bStatus;
218     byte_t data_length_hi, data_length_lo;
219    
220     bStatus  = se.write( m_controlSelector, "FunctionBlockProcessingEnhancedMixer controlSelector" );
221     bStatus &= se.write( m_statusSelector,  "FunctionBlockProcessingEnhancedMixer statusSelector" );
222    
223     switch (m_statusSelector) {
224         case eSS_ProgramableState:
225                 m_controlDataLength=m_ProgramableStateData.size()/8;
226             data_length_hi=(m_controlDataLength >> 8);
227             data_length_lo=(m_controlDataLength & 0xFF);
228             bStatus &= se.write( data_length_hi,  "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" );
229             bStatus &= se.write( data_length_lo,  "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" );
230
231             for (int i=0;i<m_controlDataLength;i++) {
232                 byte_t value=0;
233                
234                 for (int j=0;j<8;j++) {
235                     control_data_ext_length_t bit_value=m_ProgramableStateData.at(i*8+j);
236                     value |= bit_value << (7-j);
237                 }
238                
239                 bStatus &= se.write( value,  "FunctionBlockProcessingEnhancedMixer data" );
240             }
241             break;
242         case eSS_Level:
243             m_controlDataLength=m_LevelData.size()*2;
244             data_length_hi=(m_controlDataLength >> 8);
245             data_length_lo=(m_controlDataLength & 0xFF);
246             bStatus &= se.write( data_length_hi,  "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" );
247             bStatus &= se.write( data_length_lo,  "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" );
248
249             for (int i=0;i<m_controlDataLength/2;i++) {
250                 mixer_level_t value=m_LevelData.at(i);
251                 byte_t value_hi=value >> 8;
252                 byte_t value_lo=value & 0xFF;
253                
254                 bStatus &= se.write( value_hi,  "FunctionBlockProcessingEnhancedMixer data" );
255                 bStatus &= se.write( value_lo,  "FunctionBlockProcessingEnhancedMixer data" );
256             }
257             break;
258     }
259     return bStatus;
260 }
261
262 bool
263 FunctionBlockProcessingEnhancedMixer::deserialize( Util::Cmd::IISDeserialize& de )
264 {
265     bool bStatus;
266     bStatus  = de.read( &m_controlSelector );
267
268     // NOTE: the returned value is currently bogus, so overwrite it
269     m_controlSelector=FunctionBlockProcessing::eCSE_Processing_EnhancedMixer;
270
271     bStatus &= de.read( &m_statusSelector );
272
273     // same here
274     m_statusSelector = eSS_Level;
275     //m_statusSelector = eSS_ProgramableState;
276
277     byte_t data_length_hi;
278     byte_t data_length_lo;
279     bStatus &= de.read( &data_length_hi );
280     bStatus &= de.read( &data_length_lo );
281
282     m_controlDataLength = (data_length_hi << 8) + data_length_lo;
283     printf("m_controlDataLength = %d\n", m_controlDataLength);
284     switch (m_statusSelector) {
285         case eSS_ProgramableState:
286             m_ProgramableStateData.clear();
287             for (int i=0;i<m_controlDataLength;i++) {
288                 byte_t value;
289                 bStatus &= de.read( &value);
290
291                 for (int j=7;j>=0;j--) {
292                     byte_t bit_value;
293                     bit_value=(((1<<j) & value) ? 1 : 0);
294                     m_ProgramableStateData.push_back(bit_value);
295                 }
296             }
297             break;
298         case eSS_Level:
299             m_LevelData.clear();
300             for (int i = 0; i < m_controlDataLength/2; i++) {
301                 byte_t mixer_value_hi = 0;
302                 byte_t mixer_value_lo = 0;
303                 bStatus &= de.read( &mixer_value_hi);
304                 bStatus &= de.read( &mixer_value_lo);
305
306                 mixer_level_t value = (mixer_value_hi << 8) + mixer_value_lo;
307
308                 printf("value = %x\n", value);
309                 m_LevelData.push_back(value);
310             }
311             break;
312     }
313
314     return bStatus;
315 }
316
317 FunctionBlockProcessingEnhancedMixer*
318 FunctionBlockProcessingEnhancedMixer::clone() const
319 {
320     return new FunctionBlockProcessingEnhancedMixer( *this );
321 }
322
323
324 /////////////////////////////////
325 /////////////////////////////////
326
327 FunctionBlockSelector::FunctionBlockSelector()
328     : IBusData()
329     , m_selectorLength( 0x02 )
330     , m_inputFbPlugNumber( 0x00 )
331     , m_controlSelector( eCSE_Selector_Selector )
332 {
333 }
334
335 FunctionBlockSelector::FunctionBlockSelector( const FunctionBlockSelector& rhs )
336     : IBusData()
337     , m_selectorLength( rhs.m_selectorLength )
338     , m_inputFbPlugNumber( rhs.m_inputFbPlugNumber )
339     , m_controlSelector( rhs.m_controlSelector )
340 {
341 }
342
343 FunctionBlockSelector::~FunctionBlockSelector()
344 {
345 }
346
347 bool
348 FunctionBlockSelector::serialize( Util::Cmd::IOSSerialize& se )
349 {
350     bool bStatus;
351     bStatus  = se.write( m_selectorLength,    "FunctionBlockSelector selectorLength" );
352     bStatus &= se.write( m_inputFbPlugNumber, "FunctionBlockSelector inputFbPlugNumber" );
353     bStatus &= se.write( m_controlSelector,   "FunctionBlockSelector controlSelector" );
354
355     return bStatus;
356 }
357
358 bool
359 FunctionBlockSelector::deserialize( Util::Cmd::IISDeserialize& de )
360 {
361     bool bStatus;
362     bStatus  = de.read( &m_selectorLength );
363     bStatus &= de.read( &m_inputFbPlugNumber );
364     bStatus &= de.read( &m_controlSelector );
365
366     return bStatus;
367 }
368
369 FunctionBlockSelector*
370 FunctionBlockSelector::clone() const
371 {
372     return new FunctionBlockSelector( *this );
373 }
374
375 /////////////////////////////////
376
377 FunctionBlockFeature::FunctionBlockFeature()
378     : IBusData()
379     , m_selectorLength( 0x02 )
380     , m_audioChannelNumber( 0x00 )
381     , m_controlSelector( eCSE_Feature_Unknown )
382     , m_pVolume( 0 )
383     , m_pLRBalance( 0 )
384 {
385 }
386
387 FunctionBlockFeature::FunctionBlockFeature( const FunctionBlockFeature& rhs )
388     : IBusData()
389     , m_selectorLength( rhs.m_selectorLength )
390     , m_audioChannelNumber( rhs.m_audioChannelNumber )
391     , m_controlSelector( rhs.m_controlSelector )
392 {
393     if ( rhs.m_pVolume ) {
394         m_pVolume = new FunctionBlockFeatureVolume( *rhs.m_pVolume );
395     } else if ( rhs.m_pLRBalance ) {
396         m_pLRBalance = new FunctionBlockFeatureLRBalance( *rhs.m_pLRBalance );
397     }
398 }
399
400 FunctionBlockFeature::~FunctionBlockFeature()
401 {
402     delete m_pVolume;
403     m_pVolume = 0;
404     delete m_pLRBalance;
405     m_pLRBalance = 0;
406 }
407
408 bool
409 FunctionBlockFeature::serialize( Util::Cmd::IOSSerialize& se )
410 {
411     bool bStatus;
412     bStatus  = se.write( m_selectorLength,     "FunctionBlockFeature selectorLength" );
413     bStatus &= se.write( m_audioChannelNumber, "FunctionBlockFeature audioChannelNumber" );
414     bStatus &= se.write( m_controlSelector,    "FunctionBlockFeature controlSelector" );
415
416     switch( m_controlSelector ) {
417     case eCSE_Feature_Volume:
418         bStatus &= m_pVolume->serialize( se );
419         break;
420     case eCSE_Feature_LRBalance:
421         bStatus &= m_pLRBalance->serialize( se );
422         break;
423     case eCSE_Feature_Mute:
424     case eCSE_Feature_FRBalance:
425     case eCSE_Feature_Bass:
426     case eCSE_Feature_Mid:
427     case eCSE_Feature_Treble:
428     case eCSE_Feature_GEQ:
429     case eCSE_Feature_AGC:
430     case eCSE_Feature_Delay:
431     case eCSE_Feature_BassBoost:
432     case eCSE_Feature_Loudness:
433     default:
434         bStatus = false;
435     }
436
437     return bStatus;
438 }
439
440 bool
441 FunctionBlockFeature::deserialize( Util::Cmd::IISDeserialize& de )
442 {
443     bool bStatus;
444     bStatus  = de.read( &m_selectorLength );
445     bStatus &= de.read( &m_audioChannelNumber );
446     bStatus &= de.read( &m_controlSelector );
447
448     switch( m_controlSelector ) {
449     case eCSE_Feature_Volume:
450         bStatus &= m_pVolume->deserialize( de );
451         break;
452     case eCSE_Feature_LRBalance:
453         bStatus &= m_pLRBalance->deserialize( de );
454         break;
455     case eCSE_Feature_Mute:
456     case eCSE_Feature_FRBalance:
457     case eCSE_Feature_Bass:
458     case eCSE_Feature_Mid:
459     case eCSE_Feature_Treble:
460     case eCSE_Feature_GEQ:
461     case eCSE_Feature_AGC:
462     case eCSE_Feature_Delay:
463     case eCSE_Feature_BassBoost:
464     case eCSE_Feature_Loudness:
465     default:
466         bStatus = false;
467     }
468
469     return bStatus;
470 }
471
472 FunctionBlockFeature*
473 FunctionBlockFeature::clone() const
474 {
475     return new FunctionBlockFeature( *this );
476 }
477
478 /////////////////////////////////
479
480 FunctionBlockProcessing::FunctionBlockProcessing()
481     : IBusData()
482     , m_selectorLength( 0x04 )
483     , m_fbInputPlugNumber( 0x00 )
484     , m_inputAudioChannelNumber( 0x00 )
485     , m_outputAudioChannelNumber( 0x00 )
486     , m_pMixer( 0 )
487     , m_pEnhancedMixer( 0 )
488 {
489 }
490
491 FunctionBlockProcessing::FunctionBlockProcessing( const FunctionBlockProcessing& rhs )
492     : m_selectorLength( rhs.m_selectorLength )
493     , m_fbInputPlugNumber( rhs.m_fbInputPlugNumber )
494     , m_inputAudioChannelNumber( rhs.m_inputAudioChannelNumber )
495     , m_outputAudioChannelNumber( rhs.m_outputAudioChannelNumber )
496 {
497     if ( rhs.m_pMixer ) {
498         m_pMixer = new FunctionBlockProcessingMixer( *rhs.m_pMixer );
499     } else if ( rhs.m_pEnhancedMixer ) {
500         m_pEnhancedMixer = new FunctionBlockProcessingEnhancedMixer( *rhs.m_pEnhancedMixer );
501     }
502 }
503
504 FunctionBlockProcessing::~FunctionBlockProcessing()
505 {
506     delete m_pMixer;
507     m_pMixer = 0;
508     delete m_pEnhancedMixer;
509     m_pEnhancedMixer = 0;
510 }
511
512 bool
513 FunctionBlockProcessing::serialize( Util::Cmd::IOSSerialize& se )
514 {
515     bool bStatus;
516     bStatus  = se.write( m_selectorLength,     "FunctionBlockProcessing selectorLength" );
517     bStatus &= se.write( m_fbInputPlugNumber,  "FunctionBlockProcessing fbInputPlugNumber" );
518     bStatus &= se.write( m_inputAudioChannelNumber,  "FunctionBlockProcessing inputAudioChannelNumber" );
519     bStatus &= se.write( m_outputAudioChannelNumber, "FunctionBlockProcessing outputAudioChannelNumber" );
520
521     if ( m_pMixer ) {
522         bStatus &= m_pMixer->serialize( se );
523     } else if ( m_pEnhancedMixer ) {
524         bStatus &= m_pEnhancedMixer->serialize( se );
525     } else {
526         bStatus = false;
527     }
528
529     return bStatus;
530 }
531
532 bool
533 FunctionBlockProcessing::deserialize( Util::Cmd::IISDeserialize& de )
534 {
535     // NOTE: apparently the fbCmd of the STATUS type,
536     // with EnhancedMixer controlSelector returns with this
537     // controlSelector type changed to Mixer, making it
538     // impossible to choose the correct response handler
539     // based upon the response only.
540    
541     // HACK: we assume that it is the same as the sent one
542     // we also look at our data structure to figure out what we sent
543     byte_t controlSelector=eCSE_Processing_Unknown;
544     if(m_pMixer) {
545         controlSelector=eCSE_Processing_Mixer;
546     } else if(m_pEnhancedMixer) {
547         controlSelector=eCSE_Processing_EnhancedMixer;
548     }
549    
550     bool bStatus;
551     bStatus  = de.read( &m_selectorLength );
552     bStatus &= de.read( &m_fbInputPlugNumber );
553     bStatus &= de.read( &m_inputAudioChannelNumber );
554     bStatus &= de.read( &m_outputAudioChannelNumber );
555
556     byte_t controlSelector_response;
557     bStatus &= de.peek( &controlSelector_response );
558 /*    debugOutput(DEBUG_LEVEL_VERBOSE,"ctrlsel: orig = %02X, resp = %02X\n",
559         controlSelector, controlSelector_response);*/
560    
561     switch( controlSelector ) {
562     case eCSE_Processing_Mixer:
563         if ( !m_pMixer ) {
564             m_pMixer = new FunctionBlockProcessingMixer;
565         }
566         bStatus &= m_pMixer->deserialize( de );
567         break;
568     case eCSE_Processing_EnhancedMixer:
569         if ( !m_pEnhancedMixer ) {
570             m_pEnhancedMixer = new FunctionBlockProcessingEnhancedMixer;
571         }
572         bStatus &= m_pEnhancedMixer->deserialize( de );
573         break;
574     case eCSE_Processing_Enable:
575     case eCSE_Processing_Mode:
576     default:
577         bStatus = false;
578     }
579
580     byte_t tmp;
581     if (de.peek(&tmp)) {
582         debugOutput(DEBUG_LEVEL_VERBOSE,"Unprocessed bytes:\n");
583         while (de.read(&tmp)) {
584             debugOutput(DEBUG_LEVEL_VERBOSE," %02X\n",tmp);
585         }
586     }
587
588     return bStatus;
589 }
590
591 FunctionBlockProcessing*
592 FunctionBlockProcessing::clone() const
593 {
594     return new FunctionBlockProcessing( *this );
595 }
596
597 /////////////////////////////////
598
599 FunctionBlockCodec::FunctionBlockCodec()
600     : IBusData()
601 {
602 }
603
604 FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs )
605     : IBusData()
606 {
607 }
608
609 FunctionBlockCodec::~FunctionBlockCodec()
610 {
611 }
612
613 bool
614 FunctionBlockCodec::serialize( Util::Cmd::IOSSerialize& se )
615 {
616     return false;
617 }
618
619 bool
620 FunctionBlockCodec::deserialize( Util::Cmd::IISDeserialize& de )
621 {
622     return false;
623 }
624
625 FunctionBlockCodec*
626 FunctionBlockCodec::clone() const
627 {
628     return new FunctionBlockCodec( *this );
629 }
630
631 /////////////////////////////////
632 /////////////////////////////////
633
634 FunctionBlockCmd::FunctionBlockCmd( Ieee1394Service& ieee1394service,
635                                     EFunctionBlockType eType,
636                                     function_block_id_t id,
637                                     EControlAttribute eCtrlAttrib )
638     : AVCCommand( ieee1394service, AVC1394_FUNCTION_BLOCK_CMD )
639     , m_functionBlockType( eType )
640     , m_functionBlockId( id )
641     , m_controlAttribute( eCtrlAttrib )
642     , m_pFBSelector( 0 )
643     , m_pFBFeature( 0 )
644     , m_pFBProcessing( 0 )
645     , m_pFBCodec( 0 )
646 {
647     setSubunitType( eST_Audio );
648
649     switch( m_functionBlockType ) {
650         case eFBT_Selector:
651             m_pFBSelector = new FunctionBlockSelector;
652             break;
653         case eFBT_Feature:
654             m_pFBFeature = new FunctionBlockFeature;
655             break;
656         case eFBT_Processing:
657             m_pFBProcessing = new FunctionBlockProcessing;
658             break;
659         case eFBT_Codec:
660             m_pFBCodec = new FunctionBlockCodec;
661             break;
662     }
663 }
664
665 FunctionBlockCmd::FunctionBlockCmd( const FunctionBlockCmd& rhs )
666     : AVCCommand( rhs )
667     , m_functionBlockType( rhs.m_functionBlockType )
668     , m_functionBlockId( rhs.m_functionBlockId )
669     , m_controlAttribute( rhs.m_controlAttribute )
670     , m_pFBSelector( new FunctionBlockSelector( *rhs.m_pFBSelector ) )
671     , m_pFBFeature( new FunctionBlockFeature( *rhs.m_pFBFeature ) )
672     , m_pFBProcessing( new FunctionBlockProcessing( *rhs.m_pFBProcessing ) )
673     , m_pFBCodec( new FunctionBlockCodec( *rhs.m_pFBCodec ) )
674 {
675 }
676
677 FunctionBlockCmd::~FunctionBlockCmd()
678 {
679     delete m_pFBSelector;
680     m_pFBSelector = 0;
681     delete m_pFBFeature;
682     m_pFBFeature = 0;
683     delete m_pFBProcessing;
684     m_pFBProcessing = 0;
685     delete m_pFBCodec;
686     m_pFBCodec = 0;
687 }
688
689 bool
690 FunctionBlockCmd::serialize( Util::Cmd::IOSSerialize& se )
691 {
692     bool bStatus;
693     bStatus  = AVCCommand::serialize( se );
694     bStatus &= se.write( m_functionBlockType, "FunctionBlockCmd functionBlockType" );
695     bStatus &= se.write( m_functionBlockId,   "FunctionBlockCmd functionBlockId" );
696     bStatus &= se.write( m_controlAttribute,  "FunctionBlockCmd controlAttribute" );
697
698     switch( m_functionBlockType ) {
699         case eFBT_Selector:
700             if ( m_pFBSelector ) {
701                 bStatus &= m_pFBSelector->serialize( se );
702             } else {
703                 bStatus = false;
704             }
705             break;
706         case eFBT_Feature:
707             if ( m_pFBFeature ) {
708                 bStatus &= m_pFBFeature->serialize( se );
709             } else {
710                 bStatus = false;
711             }
712             break;
713         case eFBT_Processing:
714             if ( m_pFBProcessing ) {
715                 bStatus &= m_pFBProcessing->serialize( se );
716             } else {
717                 bStatus = false;
718             }
719             break;
720         case eFBT_Codec:
721             if ( m_pFBCodec ) {
722                 bStatus &= m_pFBCodec->serialize( se );
723             } else {
724                 bStatus = false;
725             }
726             break;
727         default:
728             bStatus = false;
729     }
730
731     return bStatus;
732 }
733
734 bool
735 FunctionBlockCmd::deserialize( Util::Cmd::IISDeserialize& de )
736 {
737     bool bStatus;
738     bStatus  = AVCCommand::deserialize( de );
739
740     bStatus &= de.read( &m_functionBlockType );
741     bStatus &= de.read( &m_functionBlockId );
742     bStatus &= de.read( &m_controlAttribute );
743
744     switch( m_functionBlockType ) {
745         case eFBT_Selector:
746             if ( !m_pFBSelector ) {
747                 m_pFBSelector = new FunctionBlockSelector;
748             }
749             bStatus &= m_pFBSelector->deserialize( de );
750             break;
751         case eFBT_Feature:
752             if ( !m_pFBFeature ) {
753                 m_pFBFeature = new FunctionBlockFeature;
754             }
755             bStatus &= m_pFBFeature->deserialize( de );
756             break;
757         case eFBT_Processing:
758             if ( !m_pFBProcessing ) {
759                 m_pFBProcessing = new FunctionBlockProcessing;
760             }
761             bStatus &= m_pFBProcessing->deserialize( de );
762             break;
763         case eFBT_Codec:
764             if ( !m_pFBCodec ) {
765                 m_pFBCodec = new FunctionBlockCodec;
766             }
767             bStatus &= m_pFBCodec->deserialize( de );
768             break;
769         default:
770             bStatus = false;
771     }
772
773     return bStatus;
774 }
775
776 FunctionBlockCmd*
777 FunctionBlockCmd::clone() const
778 {
779     return new FunctionBlockCmd( *this );
780 }
781
782 }
Note: See TracBrowser for help on using the browser.