multimediacommsengine/tsrc/MCETestUI/MCETestUIEngine/src/CMCETestUIEngineAudioStream.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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 
       
    19 
       
    20 
       
    21 #include <MCESession.h>
       
    22 #include <MCEMediaStream.h>
       
    23 #include <MCEAudioStream.h>
       
    24 #include <MCEMediaSource.h>
       
    25 #include <MCEMicSource.h>
       
    26 #include <MCEMediaSink.h>
       
    27 #include <MCERtpSink.h>
       
    28 #include <MCERtpSource.h>
       
    29 #include <MCESpeakerSink.h>
       
    30 #include <MCEAudioCodec.h>
       
    31 
       
    32 #include "MCETestUIEngineConstants.h"
       
    33 #include "CMCETestUIEngineAudioStream.h"
       
    34 #include "CMCETestUIEngineCodec.h"
       
    35 #include "CMCETestUIEngineSink.h"
       
    36 #include "CMCETestUIEngineSource.h"
       
    37 
       
    38 #include "TMCETestUIEngineCmdBase.h"
       
    39 #include "TMCETestUIEngineCmdEnableStream.h"
       
    40 #include "TMCETestUIEngineCmdDisableStream.h"
       
    41 #include "TMCETestUIEngineCmdDeleteAudioCodec.h"
       
    42 #include "TMCETestUIEngineCmdRemoveStream.h"
       
    43 
       
    44 // ============================ MEMBER FUNCTIONS ===============================
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CMCETestUIEngineOutSession::NewL()
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CMCETestUIEngineAudioStream* CMCETestUIEngineAudioStream::NewL(
       
    51     CMCETestUIEngine& aEngine, 
       
    52     CMceAudioStream& aAudioStream )
       
    53     {
       
    54     CMCETestUIEngineAudioStream* self = 
       
    55         new( ELeave )CMCETestUIEngineAudioStream( aEngine, aAudioStream );
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop( self );
       
    59     return self;  
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CMCETestUIEngineAudioStream::CMCETestUIEngineAudioStream
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CMCETestUIEngineAudioStream::CMCETestUIEngineAudioStream( 
       
    67                 CMCETestUIEngine& aEngine,
       
    68                 CMceAudioStream& aAudioStream )
       
    69     : iEngine( aEngine ),
       
    70       iAudioStream( aAudioStream ),
       
    71       iOneTimeRTCPFlag(1),
       
    72       iDirection( CMCETestUIEngineAudioStream::ENotSpesified )
       
    73     {
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CMCETestUIEngineAudioStream::ConstructL()
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CMCETestUIEngineAudioStream::ConstructL()
       
    81     {
       
    82     SolveDirection();
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CMCETestUIEngineAudioStream::~CMCETestUIEngineAudioStream
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C CMCETestUIEngineAudioStream::~CMCETestUIEngineAudioStream()
       
    90     {
       
    91     iCommands.ResetAndDestroy();
       
    92     iSources.ResetAndDestroy();
       
    93     iSinks.ResetAndDestroy();
       
    94     iCodecs.ResetAndDestroy();
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CMCETestUIEngineAudioStream::GetCommands
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 const RPointerArray<TMCETestUIEngineCmdBase>& 
       
   102     CMCETestUIEngineAudioStream::GetCommandsL()
       
   103     {    
       
   104     iCommands.ResetAndDestroy();
       
   105     
       
   106     if ( iAudioStream.IsEnabled() )
       
   107         {
       
   108         iCommands.AppendL( new( ELeave )TMCETestUIEngineCmdDisableStream( 
       
   109             iEngine, *this ) );
       
   110         }
       
   111     else
       
   112         {
       
   113         iCommands.AppendL( new( ELeave )TMCETestUIEngineCmdEnableStream( 
       
   114             iEngine, *this ) );
       
   115         }	  
       
   116     iCommands.AppendL( new( ELeave )TMCETestUIEngineCmdAddCodec( 
       
   117         iEngine, *this ) );
       
   118     
       
   119     iCommands.AppendL( new( ELeave )TMCETestUIEngineCmdRemoveStream( 
       
   120         iEngine, iAudioStream ) );
       
   121                                 
       
   122     return iCommands; 
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CMCETestUIEngineAudioStream::Direction
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 EXPORT_C CMCETestUIEngineAudioStream::TDirection 
       
   130     CMCETestUIEngineAudioStream::Direction() const
       
   131     {
       
   132     return iDirection;    
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CMCETestUIEngineAudioStream::TextualDirection
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 EXPORT_C const TDesC16& CMCETestUIEngineAudioStream::TextualDirection() const
       
   140     {
       
   141     switch ( Direction() )
       
   142         {
       
   143         case CMCETestUIEngineAudioStream::EUpLink :
       
   144             {
       
   145             return KStreamDirectionUpLink;
       
   146             break;
       
   147             }
       
   148         case CMCETestUIEngineAudioStream::EDownLink :
       
   149             {
       
   150             return KStreamDirectionDownLink;
       
   151             break;
       
   152             }           
       
   153         default:
       
   154             {
       
   155             break;
       
   156             }
       
   157         }
       
   158         
       
   159     return KStreamDirectionNotSpesified;
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CMCETestUIEngineAudioStream::StreamState
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C const TDesC16& CMCETestUIEngineAudioStream::StreamState() 
       
   167     {
       
   168     TInt state = iAudioStream.State();
       
   169 
       
   170 	switch( state ) 
       
   171 		{
       
   172 		case CMceMediaStream::EUninitialized: 
       
   173 		    return KStreamUninitialized; 
       
   174 		    break;
       
   175 		case CMceMediaStream::EInitialized: 
       
   176 		    return KStreamInitialized; 
       
   177 		    break;
       
   178 		case CMceMediaStream::EBuffering: 
       
   179 		    return KStreamBuffering; 
       
   180 		    break;
       
   181 		case CMceMediaStream::EIdle: 
       
   182 		    return KStreamIdle; 
       
   183 		    break;
       
   184 		case CMceMediaStream::EStreaming: 
       
   185 		    return KStreamStreaming; 
       
   186 		    break;
       
   187 		case CMceMediaStream::EDisabled: 
       
   188 		    return KStreamDisabled; 
       
   189 		    break;
       
   190 		case CMceMediaStream::ENoResources: 
       
   191 		    return KStreamNoResources; 
       
   192 		    break;
       
   193 		case CMceMediaStream::ETranscodingRequired: 
       
   194 		    return KStreamTranscodingRequired; 
       
   195 		    break;
       
   196 		case CMceMediaStream::ETranscoding: 
       
   197 		    return KStreamTranscoding; 
       
   198 		    break;
       
   199 		default: 
       
   200 		    return KSessionStateUnknown; 
       
   201 		    break;
       
   202 		}    
       
   203     }
       
   204         
       
   205 // -----------------------------------------------------------------------------
       
   206 // CMCETestUIEngineAudioStream::State
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C const TDesC16& CMCETestUIEngineAudioStream::State() const
       
   210     {
       
   211     if ( iAudioStream.IsEnabled() )
       
   212         {
       
   213         return KStreamStateEnabled;
       
   214         }
       
   215     return KStreamStateDisabled;
       
   216     }
       
   217         
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // CMCETestUIEngineAudioStream::AudioStream
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 CMceAudioStream& CMCETestUIEngineAudioStream::AudioStream()
       
   224     {        
       
   225     return iAudioStream;
       
   226     }
       
   227 
       
   228 // -----------------------------------------------------------------------------
       
   229 // CMCETestUIEngineAudioStream::SolveDirection
       
   230 // -----------------------------------------------------------------------------
       
   231 //
       
   232 CMCETestUIEngineAudioStream::TDirection CMCETestUIEngineAudioStream::SolveDirection()
       
   233     {
       
   234     TBool isUpLink = EFalse;
       
   235     TBool isDownLink = EFalse;
       
   236           
       
   237     if ( iAudioStream.Source() )
       
   238         {
       
   239         if ( iAudioStream.Source()->Type() == KMceRTPSource )
       
   240             {
       
   241             isDownLink = ETrue;
       
   242             }
       
   243         }
       
   244         
       
   245     const RPointerArray<CMceMediaSink>& sinks = iAudioStream.Sinks();
       
   246     for ( TInt i = 0; i < sinks.Count(); ++i )
       
   247         {
       
   248         if ( sinks[i]->Type() == KMceRTPSink )
       
   249             {
       
   250             isUpLink = ETrue;
       
   251             }
       
   252         }
       
   253        
       
   254     if ( isUpLink && isDownLink )
       
   255         {
       
   256         iDirection = CMCETestUIEngineAudioStream::ENotSpesified;
       
   257         }
       
   258     else if ( isUpLink )
       
   259         {
       
   260         iDirection = CMCETestUIEngineAudioStream::EUpLink;
       
   261         }
       
   262     else if ( isDownLink )
       
   263         {
       
   264         iDirection = CMCETestUIEngineAudioStream::EDownLink;
       
   265         }  
       
   266     else
       
   267         {
       
   268         iDirection = CMCETestUIEngineAudioStream::ENotSpesified;
       
   269         }
       
   270         
       
   271     return iDirection; 
       
   272     }
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // CMCETestUIEngineAudioStream::Sources
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 EXPORT_C const RPointerArray<CMCETestUIEngineSource>& 
       
   279 				CMCETestUIEngineAudioStream::SourcesL()
       
   280     {
       
   281 	iSources.ResetAndDestroy();
       
   282 	CMceMediaSource* source = iAudioStream.Source();
       
   283 	
       
   284 	CMCETestUIEngineSource* engineSource = CMCETestUIEngineSource::NewL(iEngine,*source);
       
   285 	CleanupStack::PushL(engineSource);
       
   286 	iSources.Append(engineSource);
       
   287 	CleanupStack::Pop(engineSource);
       
   288 
       
   289 	return iSources;
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // CMCETestUIEngineAudioStream::Sinks
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 EXPORT_C const RPointerArray<CMCETestUIEngineSink>& 
       
   297     CMCETestUIEngineAudioStream::SinksL()
       
   298     {
       
   299     iSinks.ResetAndDestroy();
       
   300     const RPointerArray<CMceMediaSink>& sinks = iAudioStream.Sinks();
       
   301     
       
   302     for ( TInt i = 0; i < sinks.Count(); ++i )
       
   303         {
       
   304         CMceMediaSink* sink = sinks[i];
       
   305         CMCETestUIEngineSink* engineSink =
       
   306             CMCETestUIEngineSink::NewL( iEngine, *sink );
       
   307         CleanupStack::PushL( engineSink );
       
   308         iSinks.AppendL( engineSink );
       
   309         CleanupStack::Pop( engineSink );               
       
   310         }
       
   311 	return iSinks;
       
   312     }
       
   313 
       
   314 // -----------------------------------------------------------------------------
       
   315 // CMCETestUIEngineAudioStream::Codecs
       
   316 // -----------------------------------------------------------------------------
       
   317 //
       
   318 EXPORT_C  RPointerArray<CMCETestUIEngineCodec>& 
       
   319     CMCETestUIEngineAudioStream::CodecsL()
       
   320     {
       
   321 	iCodecs.ResetAndDestroy();
       
   322     const RPointerArray<CMceAudioCodec>& codecs = iAudioStream.Codecs();
       
   323     
       
   324     for ( TInt i = 0; i < codecs.Count(); ++i )
       
   325         {
       
   326         CMceAudioCodec* codec = codecs[i];
       
   327         CMCETestUIEngineCodec* engineCodec =
       
   328             CMCETestUIEngineCodec::NewL( iEngine, *codec );
       
   329         CleanupStack::PushL( engineCodec );
       
   330         iCodecs.AppendL( engineCodec );
       
   331         CleanupStack::Pop( engineCodec );
       
   332         }
       
   333 	return iCodecs;
       
   334     }
       
   335 
       
   336 // -----------------------------------------------------------------------------
       
   337 // CMCETestUIEngineAudioStream::CurrentCodecs
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 EXPORT_C  RPointerArray<CMCETestUIEngineCodec>& 
       
   341 	CMCETestUIEngineAudioStream::CurrentCodecs()
       
   342     {
       
   343 	return iCodecs;
       
   344     }