os/mm/devsoundextensions/mmfcustominterfaces/IlbcDecoderIntfc/IlbcDecoderIntfcMsgHdlr/src/IlbcDecoderIntfcMsgHdlr.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsoundextensions/mmfcustominterfaces/IlbcDecoderIntfc/IlbcDecoderIntfcMsgHdlr/src/IlbcDecoderIntfcMsgHdlr.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,200 @@
     1.4 +/*
     1.5 +* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:   Message handler for Ilbc decoder interface
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +// INCLUDE FILES
    1.24 +#include    "IlbcDecoderIntfcMsgHdlr.h"
    1.25 +#include    "IlbcDecoderIntfcMsgs.h"
    1.26 +#include    <IlbcDecoderIntfc.h>
    1.27 +
    1.28 +// EXTERNAL DATA STRUCTURES
    1.29 +
    1.30 +// EXTERNAL FUNCTION PROTOTYPES  
    1.31 +
    1.32 +// CONSTANTS
    1.33 +
    1.34 +// MACROS
    1.35 +
    1.36 +// LOCAL CONSTANTS AND MACROS
    1.37 +
    1.38 +// MODULE DATA STRUCTURES
    1.39 +
    1.40 +// LOCAL FUNCTION PROTOTYPES
    1.41 +
    1.42 +// FORWARD DECLARATIONS
    1.43 +
    1.44 +// ============================= LOCAL FUNCTIONS ===============================
    1.45 +
    1.46 +// ============================ MEMBER FUNCTIONS ===============================
    1.47 +
    1.48 +// -----------------------------------------------------------------------------
    1.49 +// CIlbcDecoderIntfcMsgHdlr::CIlbcDecoderIntfcMsgHdlr
    1.50 +// C++ default constructor can NOT contain any code, that
    1.51 +// might leave.
    1.52 +// -----------------------------------------------------------------------------
    1.53 +//
    1.54 +CIlbcDecoderIntfcMsgHdlr::CIlbcDecoderIntfcMsgHdlr(
    1.55 +                             CIlbcDecoderIntfc* aIlbcDecoderIntfcCI) :
    1.56 +	CMMFObject(KUidIlbcDecoderIntfc)
    1.57 +    {
    1.58 +    iIlbcDecoderIntfcCI = aIlbcDecoderIntfcCI;
    1.59 +    }
    1.60 +
    1.61 +// -----------------------------------------------------------------------------
    1.62 +// CIlbcDecoderIntfcMsgHdlr::ConstructL
    1.63 +// Symbian 2nd phase constructor can leave.
    1.64 +// -----------------------------------------------------------------------------
    1.65 +//
    1.66 +void CIlbcDecoderIntfcMsgHdlr::ConstructL()
    1.67 +    {
    1.68 +    }
    1.69 +
    1.70 +// -----------------------------------------------------------------------------
    1.71 +// CIlbcDecoderIntfcMsgHdlr::NewL
    1.72 +// Two-phased constructor.
    1.73 +// -----------------------------------------------------------------------------
    1.74 +//
    1.75 +EXPORT_C CIlbcDecoderIntfcMsgHdlr* CIlbcDecoderIntfcMsgHdlr::NewL(
    1.76 +                                                TAny*  aIlbcDecoderIntfcCI)
    1.77 +    {
    1.78 +    CIlbcDecoderIntfc* errorConcealmentIntfcCI = 
    1.79 +                              (CIlbcDecoderIntfc*)aIlbcDecoderIntfcCI;
    1.80 +    CIlbcDecoderIntfcMsgHdlr* self = 
    1.81 +            new (ELeave) CIlbcDecoderIntfcMsgHdlr(errorConcealmentIntfcCI);
    1.82 +    CleanupStack::PushL( self );
    1.83 +    self->ConstructL();
    1.84 +    CleanupStack::Pop( self );
    1.85 +
    1.86 +    return self;
    1.87 +    }
    1.88 +
    1.89 +// Destructor
    1.90 +EXPORT_C CIlbcDecoderIntfcMsgHdlr::~CIlbcDecoderIntfcMsgHdlr()
    1.91 +	{
    1.92 +	delete iIlbcDecoderIntfcCI;
    1.93 +	}
    1.94 +
    1.95 +// ---------------------------------------------------------
    1.96 +// CIlbcDecoderIntfcMsgHdlr::HandleRequest
    1.97 +// Handles the messages from the proxy.
    1.98 +// Calls a subfunction which determines which custom interface to call.
    1.99 +// A subfunction is used to contain multiple leaving functions for a single
   1.100 +// trap.
   1.101 +// (other items were commented in a header).
   1.102 +// ---------------------------------------------------------
   1.103 +//
   1.104 +EXPORT_C void CIlbcDecoderIntfcMsgHdlr::HandleRequest(
   1.105 +                                                       TMMFMessage& aMessage)
   1.106 +	{
   1.107 +	ASSERT(aMessage.Destination().InterfaceId() == KUidIlbcDecoderIntfc);
   1.108 +	TRAPD(error,DoHandleRequestL(aMessage));
   1.109 +	if(error)
   1.110 +		{
   1.111 +		aMessage.Complete(error);
   1.112 +		}
   1.113 +	}
   1.114 +
   1.115 +// ---------------------------------------------------------
   1.116 +// CIlbcDecoderIntfcMsgHdlr::DoHandleRequestL
   1.117 +// Determines which custom interface to call.
   1.118 +// (other items were commented in a header).
   1.119 +// ---------------------------------------------------------
   1.120 +//
   1.121 +void CIlbcDecoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
   1.122 +	{
   1.123 +	switch(aMessage.Function())
   1.124 +		{
   1.125 +		case EIlbcdimSetDecoderMode:
   1.126 +			{
   1.127 +    		DoSetDecoderModeL(aMessage);
   1.128 +			break;
   1.129 +			}
   1.130 +		case EIlbcdimSetCng:
   1.131 +			{
   1.132 +    		DoSetCngL(aMessage);
   1.133 +			break;
   1.134 +			}
   1.135 +		case EIlbcdimGetCng:
   1.136 +			{
   1.137 +    		DoGetCngL(aMessage);
   1.138 +			break;
   1.139 +			}
   1.140 +		default:
   1.141 +			{
   1.142 +			aMessage.Complete(KErrNotSupported);
   1.143 +			}
   1.144 +		}
   1.145 +	}
   1.146 +
   1.147 +// ---------------------------------------------------------
   1.148 +// CIlbcDecoderIntfcMsgHdlr::DoSetDecoderModeL
   1.149 +// Handles the message from the proxy and calls the custom interface method.
   1.150 +// The data passed from the proxy is read from the message and passed to
   1.151 +// the custom interface.
   1.152 +// (other items were commented in a header).
   1.153 +// ---------------------------------------------------------
   1.154 +//
   1.155 +void CIlbcDecoderIntfcMsgHdlr::DoSetDecoderModeL(TMMFMessage& aMessage)
   1.156 +    {
   1.157 +	TPckgBuf<CIlbcDecoderIntfc::TDecodeMode> pckgBuf;
   1.158 +	aMessage.ReadData1FromClientL(pckgBuf);
   1.159 +	TInt status = iIlbcDecoderIntfcCI->SetDecoderMode(pckgBuf());
   1.160 +    aMessage.Complete(status);
   1.161 +    }
   1.162 +
   1.163 +// ---------------------------------------------------------
   1.164 +// CIlbcDecoderIntfcMsgHdlr::DoSetCngL
   1.165 +// Handles the message from the proxy and calls the custom interface method.
   1.166 +// The data passed from the proxy is read from the message and passed to
   1.167 +// the custom interface.
   1.168 +// (other items were commented in a header).
   1.169 +// ---------------------------------------------------------
   1.170 +//
   1.171 +void CIlbcDecoderIntfcMsgHdlr::DoSetCngL(TMMFMessage& aMessage)
   1.172 +    {
   1.173 +	TPckgBuf<TBool> pckgBuf;
   1.174 +	aMessage.ReadData1FromClientL(pckgBuf);
   1.175 +	TInt status = iIlbcDecoderIntfcCI->SetCng(pckgBuf());
   1.176 +    aMessage.Complete(status);
   1.177 +    }
   1.178 +    
   1.179 +// ---------------------------------------------------------
   1.180 +// CIlbcDecoderIntfcMsgHdlr::DoGetCngL
   1.181 +// Handles the message from the proxy and calls the custom interface method.
   1.182 +// The custom interface returns the data requested and this function
   1.183 +// writes it back to the proxy.
   1.184 +// (other items were commented in a header).
   1.185 +// ---------------------------------------------------------
   1.186 +//
   1.187 +void CIlbcDecoderIntfcMsgHdlr::DoGetCngL(TMMFMessage& aMessage)
   1.188 +    {
   1.189 +	TBool cng;
   1.190 +	TInt status = iIlbcDecoderIntfcCI->GetCng(cng);
   1.191 +	if (status == KErrNone)
   1.192 +    	{
   1.193 +    	TPckgBuf<TBool> pckgBuf;
   1.194 +	    pckgBuf() = cng;
   1.195 +    	aMessage.WriteDataToClientL(pckgBuf);
   1.196 +    	}
   1.197 +    aMessage.Complete(status);
   1.198 +    }
   1.199 +    
   1.200 +    
   1.201 +
   1.202 +
   1.203 +// End of File