os/mm/devsoundextensions/mmfcustominterfaces/G729EncoderIntfc/G729EncoderIntfcMsgHdlr/src/G729EncoderIntfcMsgHdlr.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/mmfcustominterfaces/G729EncoderIntfc/G729EncoderIntfcMsgHdlr/src/G729EncoderIntfcMsgHdlr.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,179 @@
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 G729 encoder interface
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +// INCLUDE FILES
1.24 +#include "G729EncoderIntfcMsgHdlr.h"
1.25 +#include "G729EncoderIntfcMsgs.h"
1.26 +#include <G729EncoderIntfc.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 +// CG729EncoderIntfcMsgHdlr::CG729EncoderIntfcMsgHdlr
1.50 +// C++ default constructor can NOT contain any code, that
1.51 +// might leave.
1.52 +// -----------------------------------------------------------------------------
1.53 +//
1.54 +CG729EncoderIntfcMsgHdlr::CG729EncoderIntfcMsgHdlr(
1.55 + CG729EncoderIntfc* aG729EncoderIntfcCI) :
1.56 + CMMFObject(KUidG729EncoderIntfc)
1.57 + {
1.58 + iG729EncoderIntfcCI = aG729EncoderIntfcCI;
1.59 + }
1.60 +
1.61 +// -----------------------------------------------------------------------------
1.62 +// CG729EncoderIntfcMsgHdlr::ConstructL
1.63 +// Symbian 2nd phase constructor can leave.
1.64 +// -----------------------------------------------------------------------------
1.65 +//
1.66 +void CG729EncoderIntfcMsgHdlr::ConstructL()
1.67 + {
1.68 + }
1.69 +
1.70 +// -----------------------------------------------------------------------------
1.71 +// CG729EncoderIntfcMsgHdlr::NewL
1.72 +// Two-phased constructor.
1.73 +// -----------------------------------------------------------------------------
1.74 +//
1.75 +EXPORT_C CG729EncoderIntfcMsgHdlr* CG729EncoderIntfcMsgHdlr::NewL(
1.76 + TAny* aG729EncoderIntfcCI)
1.77 + {
1.78 + CG729EncoderIntfc* errorConcealmentIntfcCI =
1.79 + (CG729EncoderIntfc*)aG729EncoderIntfcCI;
1.80 + CG729EncoderIntfcMsgHdlr* self =
1.81 + new (ELeave) CG729EncoderIntfcMsgHdlr(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 CG729EncoderIntfcMsgHdlr::~CG729EncoderIntfcMsgHdlr()
1.91 + {
1.92 + delete iG729EncoderIntfcCI;
1.93 + }
1.94 +
1.95 +// ---------------------------------------------------------
1.96 +// CG729EncoderIntfcMsgHdlr::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 CG729EncoderIntfcMsgHdlr::HandleRequest(
1.105 + TMMFMessage& aMessage)
1.106 + {
1.107 + ASSERT(aMessage.Destination().InterfaceId() == KUidG729EncoderIntfc);
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 +// CG729EncoderIntfcMsgHdlr::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 CG729EncoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
1.122 + {
1.123 + switch(aMessage.Function())
1.124 + {
1.125 + case EG729eimSetVadMode:
1.126 + {
1.127 + DoSetVadModeL(aMessage);
1.128 + break;
1.129 + }
1.130 + case EG729eimGetVadMode:
1.131 + {
1.132 + DoGetVadModeL(aMessage);
1.133 + break;
1.134 + }
1.135 + default:
1.136 + {
1.137 + aMessage.Complete(KErrNotSupported);
1.138 + }
1.139 + }
1.140 + }
1.141 +
1.142 +// ---------------------------------------------------------
1.143 +// CG729EncoderIntfcMsgHdlr::DoSetVadModeL
1.144 +// Handles the message from the proxy and calls the custom interface method.
1.145 +// The data passed from the proxy is read from the message and passed to
1.146 +// the custom interface.
1.147 +// (other items were commented in a header).
1.148 +// ---------------------------------------------------------
1.149 +//
1.150 +void CG729EncoderIntfcMsgHdlr::DoSetVadModeL(TMMFMessage& aMessage)
1.151 + {
1.152 + TPckgBuf<TBool> pckgBuf;
1.153 + aMessage.ReadData1FromClientL(pckgBuf);
1.154 + TInt status = iG729EncoderIntfcCI->SetVadMode(pckgBuf());
1.155 + aMessage.Complete(status);
1.156 + }
1.157 +
1.158 +// ---------------------------------------------------------
1.159 +// CG729EncoderIntfcMsgHdlr::DoGetVadModeL
1.160 +// Handles the message from the proxy and calls the custom interface.
1.161 +// The custom interface returns the data requested and this function
1.162 +// writes it back to the proxy.
1.163 +// (other items were commented in a header).
1.164 +// ---------------------------------------------------------
1.165 +//
1.166 +void CG729EncoderIntfcMsgHdlr::DoGetVadModeL(TMMFMessage& aMessage)
1.167 + {
1.168 + TBool vadMode;
1.169 + TInt status = iG729EncoderIntfcCI->GetVadMode(vadMode);
1.170 + if (status == KErrNone)
1.171 + {
1.172 + TPckgBuf<TBool> pckgBuf;
1.173 + pckgBuf() = vadMode;
1.174 + aMessage.WriteDataToClientL(pckgBuf);
1.175 + }
1.176 + aMessage.Complete(status);
1.177 + }
1.178 +
1.179 +
1.180 +
1.181 +
1.182 +// End of File