multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdRemoveCodec.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:    Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "MCEConstants.h"
       
    21 #include "TCmdRemoveCodec.h"
       
    22 #include "CTcMCEContext.h"
       
    23 
       
    24 #include <badesca.h>
       
    25 //#include <MceInSession.h>
       
    26 #include <MCEAudioStream.h>
       
    27 //#include <MCEMicSource.h>
       
    28 //#include <MceRtpSink.h>
       
    29 //#include <MceRtpSource.h>
       
    30 //#include <MCESpeakerSink.h>
       
    31 #include <MCEAudioCodec.h>
       
    32 //#include <MCEAMRCodec.h>
       
    33 
       
    34 void TCmdRemoveCodec::ExecuteL()
       
    35 	{	
       
    36 
       
    37 	// ---------- Setup --------------------------------------------------------
       
    38 
       
    39 	// Get existing stream
       
    40 	CMceAudioStream* stream = reinterpret_cast<CMceAudioStream*>
       
    41 		(GetObjectForIdL(KStreamId, EFalse));	
       
    42 
       
    43 	// ---------- Execution ----------------------------------------------------
       
    44 
       
    45 		
       
    46 	// Modify codecs
       
    47 	CDesC8Array* codecs = ExtractArrayL( KParamCodecs, EFalse );
       
    48 	
       
    49 	if ( codecs )
       
    50 		{
       
    51 		CleanupStack::PushL( codecs );
       
    52 		if ( codecs->Count() > 0)
       
    53 			{
       
    54 			const RPointerArray<CMceAudioCodec>& streamCodecs = stream->Codecs();
       
    55 			
       
    56 			if ( (*codecs)[0] == KValueCodecAll )
       
    57 				{
       
    58 			    // Remove all codecs from stream
       
    59                 for (TInt i = streamCodecs.Count(); i > 0;  i-- )
       
    60                     {
       
    61                     stream->RemoveCodecL( *(streamCodecs[i-1]) );
       
    62                     }
       
    63 				}
       
    64 			else 
       
    65 				{
       
    66 			    // Loop all codecs from stream
       
    67                 for (TInt i = streamCodecs.Count(); i > 0;  i-- )
       
    68                     {
       
    69                     for (TInt ii = 0; ii < codecs->Count(); ii++) 
       
    70                     	{
       
    71                         if ( streamCodecs[i-1]->SdpName() == (*codecs)[ii] )
       
    72                     		{
       
    73                     		stream->RemoveCodecL( *(streamCodecs[i-1]) );
       
    74                     		}
       
    75                     
       
    76                     	}	
       
    77                     }
       
    78 				
       
    79 				}
       
    80 			}
       
    81 		CleanupStack::PopAndDestroy( codecs );
       
    82 		}
       
    83 	
       
    84 	// ---------- Response creation --------------------------------------------
       
    85  
       
    86 	AddIdResponseL(KStreamId, *stream); 
       
    87 	
       
    88 	}
       
    89 	
       
    90 TBool TCmdRemoveCodec::Match( const TTcIdentifier& aId )
       
    91 	{
       
    92 	return TTcMceCommandBase::Match( aId, _L8("RemoveCodec") );
       
    93 	}
       
    94 
       
    95 TTcCommandBase* TCmdRemoveCodec::CreateL( MTcTestContext& aContext )
       
    96 	{
       
    97 	return new( ELeave ) TCmdRemoveCodec( aContext );
       
    98 	}
       
    99 	
       
   100 	
       
   101 CMceAudioCodec* TCmdRemoveCodec::GetAudioCodecCloneL( const TDesC8& aParamCodecName )
       
   102     {
       
   103     
       
   104     const RPointerArray<const CMceAudioCodec>& managerAudioCodecs =
       
   105         iContext.MCEManager().SupportedAudioCodecs();
       
   106     for ( TInt i = 0; i < managerAudioCodecs.Count(); i++ )
       
   107         {
       
   108         const CMceAudioCodec* managerAudioCodec = managerAudioCodecs[i];
       
   109         
       
   110         if ( managerAudioCodec->SdpName() == aParamCodecName )
       
   111             {
       
   112             return managerAudioCodec->CloneL();
       
   113             }
       
   114         
       
   115         }
       
   116     
       
   117     // If the requested codec is not supported
       
   118     User::Leave( KErrNotSupported );
       
   119     return NULL; // To keep compiler happy
       
   120     }