multimediacommsengine/tsrc/MCETestUI/src/CMCETestUIStreamViewModel.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include "CMCETestUIStreamViewModel.h"
       
    21 #include "CMCETestUIEngine.h"
       
    22 #include "CMCETestUIEngineSession.h"
       
    23 #include "MMCETestUIEngineCmdProvider.h"
       
    24 #include "CMCETestUIEngineSource.h"
       
    25 #include "CMCETestUIEngineSink.h"
       
    26 #include "CMCETestUIEngineCodec.h"
       
    27 #include <MCEAudioCodec.h>
       
    28 #include <MCEAudioStream.h>
       
    29 #include "CMCETestUIEngineVideoSource.h"
       
    30 #include "CMCETestUIEngineVideoSink.h"
       
    31 #include "CMCETestUIEngineVideoCodec.h"
       
    32 #include <MCEAudioCodec.h>
       
    33 #include <MCEAudioStream.h>
       
    34 #include <MCEMediaSource.h>
       
    35 #include <MCEMicSource.h>
       
    36 #include <MCEMediaSink.h>
       
    37 #include <MCERtpSink.h>
       
    38 #include <MCERtpSource.h>
       
    39 #include <MCESpeakerSink.h>
       
    40 #include <MCEDisplaySink.h>
       
    41 #include <MCECameraSource.h>
       
    42 #include <MCEFileSource.h>
       
    43 #include <MCEfileSink.h>
       
    44 
       
    45 #include "mcetestuiengineconstants.h"
       
    46 #include "cmcetestuiengineaudiostream.h"
       
    47 #include "cmcetestuienginevideostream.h"
       
    48 
       
    49 // CONSTANTS
       
    50 
       
    51 
       
    52 // ================= MEMBER FUNCTIONS ==========================================
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CMCETestUIStreamViewModel::NewL
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CMCETestUIStreamViewModel* CMCETestUIStreamViewModel::NewL(
       
    59         CMCETestUIEngine& aEngine,
       
    60         CMCETestUIEngineAudioStream& aStream )
       
    61     {
       
    62 	CMCETestUIStreamViewModel* self = 
       
    63 	    new(ELeave) CMCETestUIStreamViewModel( aEngine, aStream );
       
    64 	CleanupStack::PushL(self);
       
    65 	self->ConstructL();
       
    66 	CleanupStack::Pop(self);
       
    67 	return self;    
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CMCETestUIStreamViewModel::CMCETestUISessionViewModel
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CMCETestUIStreamViewModel::CMCETestUIStreamViewModel(
       
    75         CMCETestUIEngine& aEngine ,
       
    76         CMCETestUIEngineAudioStream& aStream )
       
    77     :iEngine( aEngine ),
       
    78      iStream( aStream),
       
    79      audioSourceSuppressed( EFalse ),
       
    80      audioSinksSuppressed( EFalse )
       
    81     {
       
    82     }
       
    83     
       
    84 // -----------------------------------------------------------------------------
       
    85 // CMCETestUIStreamViewModel::ConstructL()
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CMCETestUIStreamViewModel::ConstructL()
       
    89     {
       
    90     iArray = new (ELeave) CDesCArrayFlat( 1 );
       
    91 
       
    92     PopulateSourcesL();
       
    93     PopulateSinksL();
       
    94     PopulateCodecsL();
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CMCETestUIStreamViewModel::~CMCETestUIStreamViewModel()
       
    99 // Destructor
       
   100 // Frees reserved resources
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 CMCETestUIStreamViewModel::~CMCETestUIStreamViewModel()
       
   104     {
       
   105     delete iArray;
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CMCETestUIStreamViewModel::MdcaCount() const
       
   110 // 
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 TInt CMCETestUIStreamViewModel::MdcaCount() const
       
   114     {
       
   115     return iArray->MdcaCount();
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CMCETestUISessionViewModel::MdcaPoint() const
       
   120 // 
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 TPtrC CMCETestUIStreamViewModel::MdcaPoint( TInt aIndex ) const
       
   124     {
       
   125     return iArray->MdcaPoint( aIndex );
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CMCETestUIStreamViewModel::IsAudioSourceSelected() const
       
   130 // 
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 TBool CMCETestUIStreamViewModel::IsAudioSourceSelected( TInt aIndex ) const
       
   134     {
       
   135     if ( aIndex == 0 && !audioSourceSuppressed )
       
   136         {
       
   137         return ETrue;
       
   138         }
       
   139     
       
   140     return EFalse;    
       
   141     }
       
   142     
       
   143 // -----------------------------------------------------------------------------
       
   144 // CMCETestUIMainViewModel::SelectedAudioSinkIndex() const
       
   145 // 
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 TInt CMCETestUIStreamViewModel::SelectedAudioSinkIndex( TInt aIndex ) const
       
   149     {
       
   150 
       
   151     if ( audioSourceSuppressed )
       
   152         {
       
   153         ++aIndex;
       
   154         }
       
   155 
       
   156     if ( aIndex == 0 )
       
   157         {
       
   158         return KErrNotFound;
       
   159         }
       
   160 
       
   161     aIndex -= 1; // Selected is not the source
       
   162 
       
   163     const RPointerArray<CMCETestUIEngineSink>& sinks = 
       
   164                 iStream.SinksL();
       
   165 
       
   166     if ( audioSinksSuppressed )
       
   167         {
       
   168         aIndex += sinks.Count();
       
   169         }
       
   170 
       
   171     if ( aIndex < sinks.Count() )
       
   172         {
       
   173         return aIndex;
       
   174         }
       
   175     
       
   176     return KErrNotFound;    
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CMCETestUIStreamViewModel::SelectedAudioCodecIndex() const
       
   181 // 
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 TInt CMCETestUIStreamViewModel::SelectedAudioCodecIndex( TInt aIndex ) const
       
   185     {
       
   186 
       
   187     const RPointerArray<CMCETestUIEngineSink>& sinks = 
       
   188                 iStream.SinksL();
       
   189 
       
   190     const RPointerArray<CMCETestUIEngineCodec>& codecs = 
       
   191                 iStream.CodecsL();               
       
   192                 
       
   193     
       
   194     // Next does not work correctly
       
   195                     
       
   196     if ( audioSourceSuppressed )
       
   197         {
       
   198         ++aIndex;
       
   199         }
       
   200 
       
   201     if ( aIndex == 0)
       
   202         {
       
   203         return KErrNotFound;
       
   204         }
       
   205 
       
   206     aIndex -= 1; // Selected is not the audio source
       
   207     
       
   208     if ( audioSinksSuppressed )
       
   209         {
       
   210         aIndex += sinks.Count();
       
   211         }
       
   212 
       
   213     if ( aIndex < sinks.Count() )
       
   214         {
       
   215         return KErrNotFound;
       
   216         }
       
   217     
       
   218     aIndex -= sinks.Count(); // Selected is not a audio sink
       
   219     
       
   220     if ( aIndex < codecs.Count()  )
       
   221         {
       
   222         return aIndex;
       
   223         }
       
   224         
       
   225     return KErrNotFound;   // default      
       
   226     }
       
   227     
       
   228 
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CMCETestUIStreamViewModel::CmdProvider()
       
   232 // 
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 MMCETestUIEngineCmdProvider& CMCETestUIStreamViewModel::CmdProvider( 
       
   236         TInt aIndex )
       
   237     {
       
   238     const RPointerArray<CMCETestUIEngineSource>& sources = 
       
   239                 iStream.SourcesL();
       
   240     
       
   241     const RPointerArray<CMCETestUIEngineSink>& sinks =
       
   242                 iStream.SinksL();
       
   243                 
       
   244     const RPointerArray<CMCETestUIEngineCodec>& codecs =
       
   245                 iStream.CodecsL();                        
       
   246     
       
   247     // Next does not work correctly
       
   248                     
       
   249     if ( audioSourceSuppressed )
       
   250         {
       
   251         ++aIndex;
       
   252         }
       
   253 
       
   254     if ( aIndex == 0)
       
   255         {
       
   256         return *(sources[aIndex]);
       
   257         }
       
   258 
       
   259     aIndex -= 1; // Selected is not the source
       
   260     
       
   261     if ( audioSinksSuppressed )
       
   262         {
       
   263         aIndex += sinks.Count();
       
   264         }
       
   265 
       
   266     if ( aIndex < sinks.Count() )
       
   267         {
       
   268         return *(sinks[aIndex]);
       
   269         }
       
   270     
       
   271     aIndex -= sinks.Count(); // Selected is not a sink
       
   272     if ( aIndex < codecs.Count() )
       
   273         {
       
   274         return *(codecs[aIndex]);
       
   275         }
       
   276     
       
   277     return iEngine;   // default         
       
   278     }
       
   279 
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CMCETestUIStreamViewModel::PopulateStreamsL
       
   283 // Populate streams of a session
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 void CMCETestUIStreamViewModel::PopulateSourcesL()
       
   287     {
       
   288     const RPointerArray<CMCETestUIEngineSource>& sources = 
       
   289             iStream.SourcesL();
       
   290 
       
   291     for ( TInt i = 0; i < sources.Count(); ++i )
       
   292         {
       
   293                               
       
   294         TInt itemLength = KSource().Length() + 
       
   295                           KLeftParenthesis().Length() +
       
   296                       //    sources[i]->TextualDirection().Length() +
       
   297                           KRightParenthesis().Length() +
       
   298                           sources[i]->State().Length() +
       
   299                           KTab().Length() * 3;
       
   300                           
       
   301         if(sources[i]->Type() == KMceRTPSource ) 
       
   302         	{
       
   303         	itemLength += KLabelRTPSource().Length();
       
   304         	}
       
   305          
       
   306         
       
   307         else if(sources[i]->Type() == KMceMicSource )         
       
   308         	{
       
   309         	itemLength += KLabelMicSource().Length();
       
   310         	}
       
   311         	
       
   312         else if(sources[i]->Type() == KMceFileSource )         
       
   313         	{
       
   314         	itemLength += KLabelFileSource().Length();
       
   315         	}
       
   316         HBufC16* item = HBufC16::NewLC( itemLength );
       
   317         TPtr16 itemPtr = item->Des();
       
   318         itemPtr.Append( KTab );
       
   319         itemPtr.Append( KSource );
       
   320         itemPtr.Append( KLeftParenthesis() );
       
   321         if(sources[i]->Type() == KMceRTPSource )     
       
   322         	{
       
   323         	itemPtr.Append(KLabelRTPSource);	
       
   324         	}
       
   325          
       
   326         else if(sources[i]->Type() == KMceMicSource )         
       
   327         	{
       
   328         	itemPtr.Append(KLabelMicSource);	
       
   329         	}
       
   330         else if(sources[i]->Type() == KMceFileSource )         
       
   331         	{
       
   332         	itemPtr.Append(KLabelFileSource);	
       
   333         	}
       
   334         
       
   335        // itemPtr.Append( sources[i]->TextualDirection() );
       
   336         itemPtr.Append( KRightParenthesis() );
       
   337         itemPtr.Append( KTab );
       
   338         itemPtr.Append( sources[i]->State() );
       
   339         itemPtr.Append( KTab );
       
   340     
       
   341         iArray->AppendL( *item );
       
   342         
       
   343         CleanupStack::PopAndDestroy( item );
       
   344         item = NULL;
       
   345         }
       
   346     }
       
   347     
       
   348 // -----------------------------------------------------------------------------
       
   349 // CMCETestUIStreamViewModel::PopulateSinksL
       
   350 // Populate streams of a session
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353     
       
   354 void CMCETestUIStreamViewModel::PopulateSinksL()
       
   355     {
       
   356     const RPointerArray<CMCETestUIEngineSink>& sinks = 
       
   357             iStream.SinksL();
       
   358 
       
   359     for ( TInt i = 0; i < sinks.Count(); ++i )
       
   360         {
       
   361                               
       
   362         TInt itemLength = KSink().Length() + 
       
   363                           KLeftParenthesis().Length() +
       
   364                      //     sinks[i]->TextualDirection().Length() +
       
   365                           KRightParenthesis().Length() +
       
   366                           sinks[i]->State().Length() +
       
   367                           KTab().Length() * 3;
       
   368                           
       
   369         if(sinks[i]->Type() == KMceRTPSink ) 
       
   370         	{
       
   371         	itemLength += KLabelRTPSink().Length();	
       
   372         	}
       
   373          
       
   374         else  if(sinks[i]->Type() == KMceSpeakerSink)         
       
   375           	{
       
   376          	itemLength += KLabelSpeakerSink().Length();
       
   377          	}
       
   378         
       
   379         HBufC16* item = HBufC16::NewLC( itemLength );
       
   380         TPtr16 itemPtr = item->Des();
       
   381         itemPtr.Append( KTab );
       
   382         itemPtr.Append( KSink );
       
   383         itemPtr.Append( KLeftParenthesis() );
       
   384         
       
   385         if(sinks[i]->Type() == KMceRTPSink ) 
       
   386         	{
       
   387         	itemPtr.Append(KLabelRTPSink);
       
   388         	}
       
   389         else if(sinks[i]->Type() == KMceSpeakerSink ) 
       
   390         	{
       
   391         	itemPtr.Append(KLabelSpeakerSink);
       
   392         	}
       
   393          
       
   394     //    itemPtr.Append( sinks[i]->TextualDirection() );
       
   395         itemPtr.Append( KRightParenthesis() );
       
   396         itemPtr.Append( KTab );
       
   397         itemPtr.Append( sinks[i]->State() );
       
   398         itemPtr.Append( KTab );
       
   399     
       
   400         iArray->AppendL( *item );
       
   401         
       
   402         CleanupStack::PopAndDestroy( item );
       
   403         item = NULL;
       
   404         }
       
   405     }
       
   406     
       
   407 // -----------------------------------------------------------------------------
       
   408 // CMCETestUIStreamViewModel::PopulateStreamsL
       
   409 // Populate streams of a session
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412     
       
   413 void CMCETestUIStreamViewModel::PopulateCodecsL()
       
   414     {
       
   415     const RPointerArray<CMCETestUIEngineCodec>& codecs = 
       
   416             iStream.CodecsL();
       
   417 
       
   418     for ( TInt i = 0; i < codecs.Count(); ++i )
       
   419         {
       
   420         TBuf8<KMceMaxSdpNameLength> name = codecs[i]->Codec().SdpName();
       
   421                               
       
   422         TInt itemLength = KCodec().Length() + 
       
   423                           KLeftParenthesis().Length() +
       
   424                    	      name.Length()+
       
   425                           KRightParenthesis().Length() +
       
   426                           codecs[i]->State().Length() +
       
   427                           KTab().Length() * 3;
       
   428       
       
   429         TBuf16<KMceMaxSdpNameLength>  name16;
       
   430         name16.Copy(name);
       
   431         
       
   432                       
       
   433         HBufC16* item = HBufC16::NewLC( itemLength );
       
   434         TPtr16 itemPtr = item->Des();
       
   435         itemPtr.Append( KTab );
       
   436         itemPtr.Append( KCodec );
       
   437         itemPtr.Append( KLeftParenthesis() );
       
   438         itemPtr.Append( name16 ) ;
       
   439         itemPtr.Append( KRightParenthesis() );
       
   440         itemPtr.Append( KTab );
       
   441         itemPtr.Append( codecs[i]->State() );
       
   442         itemPtr.Append( KTab );
       
   443         iArray->AppendL( *item );
       
   444         CleanupStack::PopAndDestroy( item );
       
   445         item = NULL;
       
   446         }
       
   447     }
       
   448 
       
   449 // ================= MEMBER FUNCTIONS ==========================================
       
   450 
       
   451 // -----------------------------------------------------------------------------
       
   452 // CMCETestUIStreamViewModel::NewL
       
   453 // -----------------------------------------------------------------------------
       
   454 //
       
   455 CMCETestUIVideoStreamViewModel* CMCETestUIVideoStreamViewModel::NewL(
       
   456         CMCETestUIEngine& aEngine,
       
   457         CMCETestUIEngineVideoStream& aStream )
       
   458     {
       
   459 	CMCETestUIVideoStreamViewModel* self = 
       
   460 	    new(ELeave) CMCETestUIVideoStreamViewModel( aEngine, aStream );
       
   461 	CleanupStack::PushL(self);
       
   462 	self->ConstructL();
       
   463 	CleanupStack::Pop(self);
       
   464 	return self;    
       
   465     }
       
   466 
       
   467 // -----------------------------------------------------------------------------
       
   468 // CMCETestUIVideoStreamViewModel::CMCETestUIVideoStreamViewModel
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 CMCETestUIVideoStreamViewModel::CMCETestUIVideoStreamViewModel(
       
   472         CMCETestUIEngine& aEngine ,
       
   473         CMCETestUIEngineVideoStream& aStream )
       
   474     :iEngine( aEngine ),
       
   475      iStream( aStream),
       
   476      videoSourceSuppressed( EFalse ),
       
   477      videoSinksSuppressed( EFalse )
       
   478     {
       
   479     }
       
   480     
       
   481 // -----------------------------------------------------------------------------
       
   482 // CMCETestUIVideoStreamViewModel::ConstructL()
       
   483 // -----------------------------------------------------------------------------
       
   484 //
       
   485 void CMCETestUIVideoStreamViewModel::ConstructL()
       
   486     {
       
   487     iArray = new (ELeave) CDesCArrayFlat( 1 );
       
   488 
       
   489     PopulateVideoSourcesL();
       
   490     PopulateVideoSinksL();
       
   491     PopulateVideoCodecsL();
       
   492     }
       
   493 
       
   494 // -----------------------------------------------------------------------------
       
   495 // CMCETestUIVideoStreamViewModel::~CMCETestUIVideoStreamViewModel()
       
   496 // Destructor
       
   497 // Frees reserved resources
       
   498 // -----------------------------------------------------------------------------
       
   499 //
       
   500 CMCETestUIVideoStreamViewModel::~CMCETestUIVideoStreamViewModel()
       
   501     {
       
   502     delete iArray;
       
   503     }
       
   504 
       
   505 // -----------------------------------------------------------------------------
       
   506 // CMCETestUIVideoStreamViewModel::MdcaCount() const
       
   507 // 
       
   508 // -----------------------------------------------------------------------------
       
   509 //
       
   510 TInt CMCETestUIVideoStreamViewModel::MdcaCount() const
       
   511     {
       
   512     return iArray->MdcaCount();
       
   513     }
       
   514 
       
   515 // -----------------------------------------------------------------------------
       
   516 // CMCETestUIVideoStreamViewModel::MdcaPoint() const
       
   517 // 
       
   518 // -----------------------------------------------------------------------------
       
   519 //
       
   520 TPtrC CMCETestUIVideoStreamViewModel::MdcaPoint( TInt aIndex ) const
       
   521     {
       
   522     return iArray->MdcaPoint( aIndex );
       
   523     }
       
   524 
       
   525 // -----------------------------------------------------------------------------
       
   526 // CMCETestUIVideoStreamViewModel::IsVideoSourceSelected() const
       
   527 // 
       
   528 // -----------------------------------------------------------------------------
       
   529 //
       
   530 TBool CMCETestUIVideoStreamViewModel::IsVideoSourceSelected( TInt aIndex ) const
       
   531     {
       
   532     if ( aIndex == 0 && !videoSourceSuppressed )
       
   533         {
       
   534         return ETrue;
       
   535         }
       
   536     
       
   537     return EFalse;    
       
   538     }
       
   539     
       
   540 // -----------------------------------------------------------------------------
       
   541 // CMCETestUIVideoStreamViewModel::SelectedVideoSinkIndex() const
       
   542 // 
       
   543 // -----------------------------------------------------------------------------
       
   544 //
       
   545 TInt CMCETestUIVideoStreamViewModel::SelectedVideoSinkIndex( TInt aIndex ) const
       
   546     {
       
   547 
       
   548     if ( videoSourceSuppressed )
       
   549         {
       
   550         ++aIndex;
       
   551         }
       
   552 
       
   553     if ( aIndex == 0 )
       
   554         {
       
   555         return KErrNotFound;
       
   556         }
       
   557 
       
   558     aIndex -= 1; // Selected is not the source
       
   559 
       
   560     const RPointerArray<CMCETestUIEngineVideoSink>& sinks = 
       
   561                 iStream.SinksL();
       
   562 
       
   563     if ( videoSinksSuppressed )
       
   564         {
       
   565         aIndex += sinks.Count();
       
   566         }
       
   567 
       
   568     if ( aIndex < sinks.Count() )
       
   569         {
       
   570         return aIndex;
       
   571         }
       
   572     
       
   573     return KErrNotFound;    
       
   574     }
       
   575 
       
   576 // -----------------------------------------------------------------------------
       
   577 // CMCETestUIVideoStreamViewModel::SelectedVideoCodecIndex() const
       
   578 // 
       
   579 // -----------------------------------------------------------------------------
       
   580 //
       
   581 TInt CMCETestUIVideoStreamViewModel::SelectedVideoCodecIndex( TInt aIndex ) const
       
   582     {
       
   583 
       
   584     const RPointerArray<CMCETestUIEngineVideoSink>& sinks = 
       
   585                 iStream.SinksL();
       
   586 
       
   587     const RPointerArray<CMCETestUIEngineVideoCodec>& codecs = 
       
   588                 iStream.CodecsL();               
       
   589                 
       
   590     
       
   591     // Next does not work correctly
       
   592                     
       
   593     if ( videoSourceSuppressed )
       
   594         {
       
   595         ++aIndex;
       
   596         }
       
   597 
       
   598     if ( aIndex == 0)
       
   599         {
       
   600         return KErrNotFound;
       
   601         }
       
   602 
       
   603     aIndex -= 1; // Selected is not the audio source
       
   604     
       
   605     if ( videoSinksSuppressed )
       
   606         {
       
   607         aIndex += sinks.Count();
       
   608         }
       
   609 
       
   610     if ( aIndex < sinks.Count() )
       
   611         {
       
   612         return KErrNotFound;
       
   613         }
       
   614     
       
   615     aIndex -= sinks.Count(); // Selected is not a audio sink
       
   616     
       
   617     if ( aIndex < codecs.Count()  )
       
   618         {
       
   619         return aIndex;
       
   620         }
       
   621         
       
   622     return KErrNotFound;   // default      
       
   623     }
       
   624     
       
   625 
       
   626 
       
   627 // -----------------------------------------------------------------------------
       
   628 // CMCETestUIVideoStreamViewModel::CmdProvider()
       
   629 // 
       
   630 // -----------------------------------------------------------------------------
       
   631 //
       
   632 MMCETestUIEngineCmdProvider& CMCETestUIVideoStreamViewModel::CmdProvider( 
       
   633         TInt aIndex )
       
   634     {
       
   635     const RPointerArray<CMCETestUIEngineVideoSource>& sources = 
       
   636                 iStream.SourcesL();
       
   637     
       
   638     const RPointerArray<CMCETestUIEngineVideoSink>& sinks =
       
   639                 iStream.SinksL();
       
   640                 
       
   641     const RPointerArray<CMCETestUIEngineVideoCodec>& codecs =
       
   642                 iStream.CodecsL();                        
       
   643     
       
   644     // Next does not work correctly
       
   645                     
       
   646     if ( videoSourceSuppressed )
       
   647         {
       
   648         ++aIndex;
       
   649         }
       
   650 
       
   651     if ( aIndex == 0)
       
   652         {
       
   653         return *(sources[aIndex]);
       
   654         }
       
   655 
       
   656     aIndex -= 1; // Selected is not the source
       
   657     
       
   658     if ( videoSinksSuppressed )
       
   659         {
       
   660         aIndex += sinks.Count();
       
   661         }
       
   662 
       
   663     if ( aIndex < sinks.Count() )
       
   664         {
       
   665         return *(sinks[aIndex]);
       
   666         }
       
   667     
       
   668     aIndex -= sinks.Count(); // Selected is not a sink
       
   669     if ( aIndex < codecs.Count() )
       
   670         {
       
   671         return *(codecs[aIndex]);
       
   672         }
       
   673     
       
   674     return iEngine;   // default         
       
   675     }
       
   676 
       
   677 // -----------------------------------------------------------------------------
       
   678 // CMCETestUIStreamViewModel::PopulateVideoStreamsL
       
   679 // Populate streams of a session
       
   680 // -----------------------------------------------------------------------------
       
   681 //
       
   682 void CMCETestUIVideoStreamViewModel::PopulateVideoSourcesL()
       
   683     {
       
   684     const RPointerArray<CMCETestUIEngineVideoSource>& sources = 
       
   685             iStream.SourcesL();
       
   686 
       
   687     for ( TInt i = 0; i < sources.Count(); ++i )
       
   688         {
       
   689                               
       
   690         TInt itemLength = KSource().Length() + 
       
   691                           KLeftParenthesis().Length() +
       
   692                       //    sources[i]->TextualDirection().Length() +
       
   693                           KRightParenthesis().Length() +
       
   694                           sources[i]->State().Length() +
       
   695                           KTab().Length() * 3;
       
   696                           
       
   697         if(sources[i]->Type() == KMceRTPSource ) 
       
   698         	{
       
   699         	itemLength += KLabelRTPSource().Length();
       
   700         	}
       
   701          
       
   702         
       
   703         else if(sources[i]->Type() == KMceCameraSource )         
       
   704         	{
       
   705         	itemLength += KLabelCamSource().Length();
       
   706         	}
       
   707         	
       
   708         else if(sources[i]->Type() == KMceFileSource )         
       
   709         	{
       
   710         	itemLength += KLabelFileSource().Length();
       
   711         	}
       
   712         
       
   713         HBufC16* item = HBufC16::NewLC( itemLength );
       
   714         TPtr16 itemPtr = item->Des();
       
   715         itemPtr.Append( KTab );
       
   716         itemPtr.Append( KSource );
       
   717         itemPtr.Append( KLeftParenthesis() );
       
   718         if(sources[i]->Type() == KMceRTPSource )     
       
   719         	{
       
   720         	itemPtr.Append(KLabelRTPSource);	
       
   721         	}
       
   722          
       
   723         else if(sources[i]->Type() == KMceCameraSource )         
       
   724         	{
       
   725         	itemPtr.Append(KLabelCamSource);	
       
   726         	}
       
   727          
       
   728         else if(sources[i]->Type() == KMceFileSource )         
       
   729         	{
       
   730         	itemPtr.Append(KLabelFileSource);	
       
   731         	}
       
   732        // itemPtr.Append( sources[i]->TextualDirection() );
       
   733         itemPtr.Append( KRightParenthesis() );
       
   734         itemPtr.Append( KTab );
       
   735         itemPtr.Append( sources[i]->State() );
       
   736         itemPtr.Append( KTab );
       
   737     
       
   738         iArray->AppendL( *item );
       
   739         
       
   740         CleanupStack::PopAndDestroy( item );
       
   741         item = NULL;
       
   742         }
       
   743     }
       
   744     
       
   745 // -----------------------------------------------------------------------------
       
   746 // CMCETestUIStreamViewModel::PopulateVideoSinksL
       
   747 // Populate streams of a session
       
   748 // -----------------------------------------------------------------------------
       
   749 //
       
   750 void CMCETestUIVideoStreamViewModel::PopulateVideoSinksL()
       
   751     {
       
   752     const RPointerArray<CMCETestUIEngineVideoSink>& sinks = 
       
   753             iStream.SinksL();
       
   754 
       
   755     for ( TInt i = 0; i < sinks.Count(); ++i )
       
   756         {
       
   757                               
       
   758         TInt itemLength = KSink().Length() + 
       
   759                           KLeftParenthesis().Length() +
       
   760                      //     sinks[i]->TextualDirection().Length() +
       
   761                           KRightParenthesis().Length() +
       
   762                           sinks[i]->State().Length() +
       
   763                           KTab().Length() * 3;
       
   764                           
       
   765         if(sinks[i]->Type() == KMceRTPSink ) 
       
   766         	{
       
   767         	itemLength += KLabelRTPSink().Length();	
       
   768         	}
       
   769          
       
   770         else  if(sinks[i]->Type() == KMceDisplaySink)         
       
   771           	{
       
   772          	itemLength += KLabelDisplaySink().Length();
       
   773          	}
       
   774         else  if(sinks[i]->Type() == KMceFileSink)         
       
   775           	{
       
   776          	itemLength += KLabelFileSink().Length();
       
   777          	}
       
   778         HBufC16* item = HBufC16::NewLC( itemLength );
       
   779         TPtr16 itemPtr = item->Des();
       
   780         itemPtr.Append( KTab );
       
   781         itemPtr.Append( KSink );
       
   782         itemPtr.Append( KLeftParenthesis() );
       
   783         
       
   784         if(sinks[i]->Type() == KMceRTPSink ) 
       
   785         	{
       
   786         	itemPtr.Append(KLabelRTPSink);
       
   787         	}
       
   788         else if(sinks[i]->Type() == KMceDisplaySink ) 
       
   789         	{
       
   790         	itemPtr.Append(KLabelDisplaySink);
       
   791         	}
       
   792         else if(sinks[i]->Type() == KMceFileSink ) 
       
   793         	{
       
   794         	itemPtr.Append(KLabelFileSink);
       
   795         	}
       
   796     //    itemPtr.Append( sinks[i]->TextualDirection() );
       
   797         itemPtr.Append( KRightParenthesis() );
       
   798         itemPtr.Append( KTab );
       
   799         itemPtr.Append( sinks[i]->State() );
       
   800         itemPtr.Append( KTab );
       
   801     
       
   802         iArray->AppendL( *item );
       
   803         
       
   804         CleanupStack::PopAndDestroy( item );
       
   805         item = NULL;
       
   806         }
       
   807     }
       
   808     
       
   809 // -----------------------------------------------------------------------------
       
   810 // CMCETestUIVideoStreamViewModel::PopulateVideoStreamsL
       
   811 // Populate streams of a session
       
   812 // -----------------------------------------------------------------------------
       
   813 //
       
   814 void CMCETestUIVideoStreamViewModel::PopulateVideoCodecsL()
       
   815     {
       
   816     const RPointerArray<CMCETestUIEngineVideoCodec>& codecs = 
       
   817             iStream.CodecsL();
       
   818 
       
   819     for ( TInt i = 0; i < codecs.Count(); ++i )
       
   820         {
       
   821         TBuf8<KMceMaxSdpNameLength> name = codecs[i]->Codec().SdpName();
       
   822                               
       
   823         TInt itemLength = KCodec().Length() + 
       
   824                           KLeftParenthesis().Length() +
       
   825                    	      name.Length()+
       
   826                           KRightParenthesis().Length() +
       
   827                           codecs[i]->State().Length() +
       
   828                           KTab().Length() * 3;
       
   829       
       
   830         TBuf16<KMceMaxSdpNameLength>  name16;
       
   831         name16.Copy(name);
       
   832         
       
   833                       
       
   834         HBufC16* item = HBufC16::NewLC( itemLength );
       
   835         TPtr16 itemPtr = item->Des();
       
   836         itemPtr.Append( KTab );
       
   837         itemPtr.Append( KCodec );
       
   838         itemPtr.Append( KLeftParenthesis() );
       
   839         itemPtr.Append( name16 ) ;
       
   840         itemPtr.Append( KRightParenthesis() );
       
   841         itemPtr.Append( KTab );
       
   842         itemPtr.Append( codecs[i]->State() );
       
   843         itemPtr.Append( KTab );
       
   844         iArray->AppendL( *item );
       
   845         CleanupStack::PopAndDestroy( item );
       
   846         item = NULL;
       
   847         }
       
   848     }
       
   849 
       
   850 // End of File