multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/TCmdAddSink.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 "TCmdAddSink.h"
       
    22 #include "CTcMCEContext.h"
       
    23 #include <MceMediaStream.h>
       
    24 #include <MCEAudioStream.h>
       
    25 #include <MceRtpSink.h>
       
    26 #include <MCESpeakerSink.h>
       
    27 #include <MCERtpSource.h>
       
    28 
       
    29 void TCmdAddSink::ExecuteL()
       
    30 	{	
       
    31 	// ---------- Setup --------------------------------------------------------
       
    32 
       
    33 	// Get stream
       
    34 	CMceMediaStream* mediaStream = reinterpret_cast<CMceMediaStream*>
       
    35 		(GetObjectForIdL(KStreamId, ETrue));		
       
    36 
       
    37 	if ( mediaStream->Type() != KMceAudio )
       
    38 		{
       
    39 		User::Leave( KErrNotSupported );
       
    40 		}
       
    41 	
       
    42 	CMceAudioStream* audioStream = static_cast<CMceAudioStream*>(mediaStream);
       
    43 
       
    44 	// Get type
       
    45 	TPtrC8 sink = ExtractTextL( KParamSink, ETrue );
       
    46 
       
    47 	//get path for media file sink
       
    48 	TPtrC8 mediaFileSink = ExtractTextL( KParamMediaFileSink, EFalse );
       
    49 	
       
    50 	// ---------- Execution ----------------------------------------------------
       
    51 
       
    52 	if (sink == KValueSinkRTP )
       
    53 		{
       
    54 		//CMceRtpSink* rtpSink = CMceRtpSink::NewLC();
       
    55 		CMceRtpSink* rtpSink = CMceRtpSink::NewL(EFalse);
       
    56 		CleanupStack::PushL(rtpSink);
       
    57 		audioStream->AddSinkL(rtpSink);
       
    58 		CleanupStack::Pop(rtpSink);	
       
    59 		AddIdResponseL( KSinkId, *rtpSink );		
       
    60 		}
       
    61 	else if (sink == KValueSinkSpeaker )
       
    62 		{
       
    63 		CMceSpeakerSink* speaker = CMceSpeakerSink::NewLC();
       
    64 		audioStream->AddSinkL( speaker );	
       
    65 		CleanupStack::Pop( speaker );
       
    66 		AddIdResponseL( KSinkId, *speaker );
       
    67 		}
       
    68 	else if ( sink == KValueSinkFile )
       
    69 		{
       
    70 		CMceAudioStream* audioOutStreamFile = CMceAudioStream::NewL();
       
    71 		CleanupStack::PushL( audioOutStreamFile );
       
    72 
       
    73 		//use the same source which was used for outgoing audio stream	
       
    74 		if( audioStream->Source()->Type() != KMceRTPSource )
       
    75 			{
       
    76 			audioOutStreamFile->SetSourceL( audioStream->Source() );
       
    77 			}
       
    78 		else
       
    79 			{
       
    80 			if(audioStream->BoundStream())
       
    81 				if( audioStream->BoundStreamL().Source()->Type() != KMceRTPSource )
       
    82 					audioOutStreamFile->SetSourceL(audioStream->BoundStreamL().Source());
       
    83 			}
       
    84 		
       
    85 		if( mediaFileSink.Compare( KNullDesC8 ) != 0 )
       
    86 			{
       
    87 			iSessionHelper.SetMediaFileSinkL(*audioOutStreamFile, mediaFileSink);
       
    88 			}
       
    89 		else
       
    90 			{
       
    91 			iSessionHelper.SetMediaFileSinkL(*audioOutStreamFile, TPtrC8( KTestAudioFileName ));
       
    92 			}
       
    93 		//add the stream to the session
       
    94 		audioStream->Session()->AddStreamL(audioOutStreamFile);
       
    95 		CleanupStack::Pop( audioOutStreamFile );
       
    96 		}
       
    97 	else 
       
    98 		{
       
    99 		User::Leave( KErrNotSupported );
       
   100 		}
       
   101 
       
   102 	// ---------- Response creation --------------------------------------------
       
   103 
       
   104 	AddIdResponseL( KStreamId, *audioStream ); 
       
   105 	// Sink added to response during execution
       
   106 	
       
   107 	}
       
   108 	
       
   109 TBool TCmdAddSink::Match( const TTcIdentifier& aId )
       
   110 	{
       
   111 	return TTcMceCommandBase::Match( aId, _L8("AddSink") );
       
   112 	}
       
   113 
       
   114 TTcCommandBase* TCmdAddSink::CreateL( MTcTestContext& aContext )
       
   115 	{
       
   116 	return new( ELeave ) TCmdAddSink( aContext );
       
   117 	}