multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/CSessionHelper.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2008 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 "CSessionHelper.h"
       
    21 
       
    22 #include "MceMediaStream.h"
       
    23 #include "MceAudioStream.h"
       
    24 #include "MceVideoStream.h"
       
    25 #include "MCERtpSource.h"
       
    26 #include "MceCodec.h"
       
    27 #include "mcefilesource.h"
       
    28 #include "mcefilesink.h"
       
    29 #include <MCEManager.h>
       
    30 
       
    31 #include "mcedefs.h"
       
    32 
       
    33 #include <mcefilesource.h>
       
    34 
       
    35 const TUint KAudioPriorityPocAudioUplink        = 100;//95;
       
    36 const TUint KAudioPriorityPocAudioDownlink      = 100;//95;
       
    37 const TUint KAudioPrefPocAudioUplink            = 0x05230001;//0x05130001;
       
    38 const TUint KAudioPrefPocAudioDownlink          = 0x05210001; //0x05120001; 
       
    39 
       
    40 const TUint KDtmfAudioPriority					= 45;
       
    41 const TUint KDtmfAudioPref						= 0x00150001;
       
    42 
       
    43 void CSessionHelper::SetCodecPrioritiesL(CMceCodec& aCodec, priorities aPri)
       
    44 	{
       
    45 	if (aPri == downlink) 
       
    46 		{
       
    47 		aCodec.SetMMFPriorityL( KAudioPriorityPocAudioDownlink );
       
    48 	    aCodec.SetMMFPriorityPreferenceL( KAudioPrefPocAudioDownlink ); 
       
    49 		}
       
    50 	else if (aPri == uplink) 
       
    51 		{
       
    52 		aCodec.SetMMFPriorityL( KAudioPriorityPocAudioUplink );
       
    53 	    aCodec.SetMMFPriorityPreferenceL( KAudioPrefPocAudioUplink );
       
    54 		}
       
    55 	else if (aPri == dtmf)
       
    56 		{
       
    57 		//TODO: set dtmf priorities
       
    58 		aCodec.SetMMFPriorityL( KDtmfAudioPriority );
       
    59 	    aCodec.SetMMFPriorityPreferenceL( KDtmfAudioPref );	
       
    60 		}
       
    61 	else
       
    62 		User::LeaveIfError(KErrUnknown);
       
    63 	}
       
    64 
       
    65 void
       
    66 CSessionHelper::SetCodecPriPrefL(CMceCodec& aCodec, TUint aPri, TUint aPref)
       
    67 	{
       
    68 	aCodec.SetMMFPriorityL( aPri );
       
    69 	aCodec.SetMMFPriorityPreferenceL( aPref );
       
    70 	}
       
    71 	
       
    72 /*
       
    73 The idea here is 
       
    74 to set the same payload type as the main codec for the keep alive timer 
       
    75 later on, we can then check with TTCN is MCE using the correct codec.
       
    76 */
       
    77 void CSessionHelper::SetKeepaliveL(CMceCodec& aCodec, TInt aKeepaliveTimeSec)
       
    78 	{
       
    79 	aCodec.SetKeepAliveTimerL( aKeepaliveTimeSec );
       
    80 	if (!aCodec.SdpName().Compare(KMceSDPNameAMR))
       
    81 		{
       
    82 		aCodec.SetKeepAlivePayloadTypeL( 96 );
       
    83 		}
       
    84 	else if(!aCodec.SdpName().Compare(KMceSDPNameG729))
       
    85 		{
       
    86 		aCodec.SetKeepAlivePayloadTypeL( 18 );
       
    87 		}
       
    88 	else if(!aCodec.SdpName().Compare(KMceSDPNameiLBC))
       
    89 		{
       
    90 		aCodec.SetKeepAlivePayloadTypeL( 97 );
       
    91 		}
       
    92 	else if(!aCodec.SdpName().Compare(KMceSDPNameAMRWB))
       
    93 		{
       
    94 		aCodec.SetKeepAlivePayloadTypeL( 100 );
       
    95 		}
       
    96 	else
       
    97 		{
       
    98 		// Keep pc-lint happy
       
    99 		}
       
   100 	}
       
   101 
       
   102 void CSessionHelper::SetRtpInactivityTimerL(CMceMediaStream& aStream, TInt aInactivityTimer)
       
   103 	{
       
   104 	
       
   105 	//for audio
       
   106 	 if ( aStream.Type() == KMceAudio )
       
   107 		{	
       
   108 		CMceAudioStream* audioStream = 
       
   109 								static_cast<CMceAudioStream*>(&aStream);
       
   110 								
       
   111 		if ( audioStream->Source()->Type() == KMceRTPSource )
       
   112 			{
       
   113 			//set inactivity timer
       
   114 			CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>(audioStream->Source());
       
   115 			rtpSource->EnableInactivityTimerL(aInactivityTimer * 1000);
       
   116 			}
       
   117 		const CMceAudioStream* boundAudioStream = NULL;
       
   118 		if (audioStream->BoundStream()) 
       
   119 			{
       
   120 			boundAudioStream = static_cast<CMceAudioStream*>(&audioStream->BoundStreamL());
       
   121 			if ( boundAudioStream->Source()->Type() == KMceRTPSource )
       
   122 				{
       
   123 				//set
       
   124 				CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>(boundAudioStream->Source());
       
   125 				rtpSource->EnableInactivityTimerL(aInactivityTimer * 1000);
       
   126 				}
       
   127 			}
       
   128 	
       
   129 		}
       
   130 	 
       
   131 	 //for video
       
   132 	 if ( aStream.Type() == KMceVideo )
       
   133 		{	
       
   134 		CMceVideoStream* videoStream = 
       
   135 								static_cast<CMceVideoStream*>(&aStream);
       
   136 								
       
   137 		if ( videoStream->Source()->Type() == KMceRTPSource )
       
   138 			{
       
   139 			//set inactivity timer
       
   140 			CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>(videoStream->Source());
       
   141 			rtpSource->EnableInactivityTimerL(aInactivityTimer * 1000);
       
   142 			}
       
   143 		const CMceVideoStream* boundVideoStream = NULL;
       
   144 		if (videoStream->BoundStream()) 
       
   145 			{
       
   146 			boundVideoStream = static_cast<CMceVideoStream*>(&videoStream->BoundStreamL());
       
   147 			if ( boundVideoStream->Source()->Type() == KMceRTPSource )
       
   148 				{
       
   149 				//set
       
   150 				CMceRtpSource* rtpSource = static_cast<CMceRtpSource*>(boundVideoStream->Source());
       
   151 				rtpSource->EnableInactivityTimerL(aInactivityTimer * 1000);
       
   152 				}
       
   153 			}
       
   154 		}
       
   155 		
       
   156 	}
       
   157 
       
   158 // ----------------------------------------------------------------------------
       
   159 // CSessionHelper::SetMediaFileSourceL
       
   160 // ----------------------------------------------------------------------------
       
   161 void CSessionHelper::SetMediaFileSourceL(CMceManager& aManager, CMceMediaStream& aStream, TPtrC8 aFilename )
       
   162 	{
       
   163 	TFileName filename;
       
   164 	filename.Copy(aFilename);
       
   165 	CMceFileSource* fileSource = CMceFileSource::NewL( aManager, filename );
       
   166 	if(!fileSource)
       
   167 		User::Leave( KErrNotFound );
       
   168 	CleanupStack::PushL(fileSource);
       
   169 
       
   170    	fileSource->SetPositionL( TTimeIntervalMicroSeconds( 1 ) );		
       
   171 	fileSource->EnableL();
       
   172 	aStream.SetSourceL( fileSource );
       
   173 	aStream.SynchronizeWithFileL(*fileSource);
       
   174 
       
   175 	CleanupStack::Pop(fileSource);
       
   176 	}
       
   177 
       
   178 // ----------------------------------------------------------------------------
       
   179 // CSessionHelper::SetMediaFileSinkL
       
   180 // ----------------------------------------------------------------------------
       
   181 void CSessionHelper::SetMediaFileSinkL(CMceMediaStream& aStream, TPtrC8 aFilename )
       
   182 	{
       
   183 	TFileName filename;
       
   184 	filename.Copy(aFilename);
       
   185 	CMceFileSink* fileSink = CMceFileSink::NewL( filename );
       
   186 	if(!fileSink)
       
   187 		User::Leave( KErrNotFound );
       
   188 	
       
   189 	CleanupStack::PushL(fileSink);
       
   190 //	fileSink->EnableL();
       
   191 	aStream.AddSinkL( fileSink );
       
   192 	
       
   193 	CleanupStack::Pop(fileSink);
       
   194 	}