multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdEstablish.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 "TCmdEstablish.h"
       
    22 #include "CTcMCEContext.h"
       
    23 
       
    24 #include <MCEMicSource.h>
       
    25 #include <MceRtpSink.h>
       
    26 #include <MCEAudioStream.h>
       
    27 #include <MceRtpSource.h>
       
    28 #include <MCESpeakerSink.h>
       
    29 #include <MceOutSession.h>
       
    30 #include <MCEManager.h>
       
    31 
       
    32 #include "CTcMCEFloorControlObserver.h"
       
    33 
       
    34 #include "sipprofile.h"
       
    35 
       
    36 void TCmdEstablish::ExecuteL()
       
    37 	{
       
    38 	
       
    39 	// --- Setup ---------------------------------------------------------------
       
    40 
       
    41 	// Get session
       
    42 	CMceOutSession* outSession = 
       
    43 		reinterpret_cast<CMceOutSession*>(GetObjectForIdL(KSessionId, ETrue));	
       
    44 
       
    45 	// --- Execute -------------------------------------------------------------
       
    46 	
       
    47 	// Get timeout 
       
    48 	TInt timeout = ExtractIntegerL( KParamTimeout, 0, EFalse );
       
    49         
       
    50 	// Get ContentType
       
    51 	HBufC8* contentType = HBufCParameterL(ExtractTextL(KParamContentType, 
       
    52 													   EFalse));
       
    53 	CleanupStack::PushL( contentType );
       
    54 	
       
    55 	// Get Headers
       
    56 	CDesC8Array* headers = ExtractHeadersL( EFalse );
       
    57 	if (!headers)
       
    58 		{
       
    59 		headers = new (ELeave) CDesC8ArrayFlat(1);	
       
    60 		}
       
    61 	headers->AppendL(_L8("event: ttcn"));	
       
    62 	CleanupStack::PushL( headers );
       
    63 	
       
    64 	// Get Body
       
    65 	HBufC8* body = HBufCParameterL(ExtractTextL(KParamBody, EFalse));
       
    66 	CleanupStack::PushL( body );
       
    67 
       
    68 	// Floor control usage
       
    69 	TBool useFC = ExtractBooleanL( KParamUseFloorControl, EFalse );
       
    70 	
       
    71 	if (useFC )
       
    72 		{
       
    73 		TInt fcPort = ExtractIntegerL(KParamFCPort, 2000, ETrue);
       
    74 	 	iContext.FC().InitializeL( *outSession, fcPort, iContext.FCObserver() );
       
    75 		
       
    76 		// Floor control preparations
       
    77 		CDesC8Array* array = new (ELeave) CDesC8ArrayFlat(1);
       
    78 		CleanupStack::PushL( array );	
       
    79 		array->AppendL(
       
    80 			_L8("a=fmtp:TBCP queuing=1; tb_priority=2; timestamp=1\r\n"));
       
    81 		iContext.FC().UpdateL( *outSession, array );
       
    82 		CleanupStack::Pop( array );
       
    83 		}
       
    84 
       
    85 	// Establish
       
    86 	if ( !headers && !body && !contentType && timeout == 0 )
       
    87 		{
       
    88 		CleanupStack::PopAndDestroy( body ); body = NULL;
       
    89 		CleanupStack::PopAndDestroy( headers ); headers = NULL;
       
    90 		CleanupStack::PopAndDestroy( contentType ); contentType = NULL;
       
    91 		outSession->EstablishL();
       
    92 		}
       
    93 	else
       
    94 		{
       
    95 		outSession->EstablishL( timeout, headers, contentType, body );
       
    96 		CleanupStack::Pop( body );
       
    97 		CleanupStack::Pop( headers );
       
    98 		CleanupStack::Pop( contentType );	
       
    99 		}
       
   100 
       
   101 	CMceSession::TState state = outSession->State();
       
   102 
       
   103 	// --- Construct response --------------------------------------------------
       
   104 
       
   105 	AddIdResponseL(KSessionId, *outSession);	
       
   106 
       
   107 	// Add Session state	
       
   108 	AddIntegerResponseL( KResponseState, state );
       
   109 	AddTextualSessionStateL( state );
       
   110 
       
   111 	}
       
   112 
       
   113 TBool TCmdEstablish::Match( const TTcIdentifier& aId )
       
   114 	{
       
   115 	return TTcMceCommandBase::Match( aId, _L8("Establish") );
       
   116 	}
       
   117 
       
   118 TTcCommandBase* TCmdEstablish::CreateL( MTcTestContext& aContext )
       
   119 	{
       
   120 	return new( ELeave ) TCmdEstablish( aContext );
       
   121 	}
       
   122