os/mm/devsoundextensions/mmfcustominterfaces/G729EncoderIntfc/G729EncoderIntfcMsgHdlr/src/G729EncoderIntfcMsgHdlr.cpp
Update contrib.
2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Message handler for G729 encoder interface
21 #include "G729EncoderIntfcMsgHdlr.h"
22 #include "G729EncoderIntfcMsgs.h"
23 #include <G729EncoderIntfc.h>
25 // EXTERNAL DATA STRUCTURES
27 // EXTERNAL FUNCTION PROTOTYPES
33 // LOCAL CONSTANTS AND MACROS
35 // MODULE DATA STRUCTURES
37 // LOCAL FUNCTION PROTOTYPES
39 // FORWARD DECLARATIONS
41 // ============================= LOCAL FUNCTIONS ===============================
43 // ============================ MEMBER FUNCTIONS ===============================
45 // -----------------------------------------------------------------------------
46 // CG729EncoderIntfcMsgHdlr::CG729EncoderIntfcMsgHdlr
47 // C++ default constructor can NOT contain any code, that
49 // -----------------------------------------------------------------------------
51 CG729EncoderIntfcMsgHdlr::CG729EncoderIntfcMsgHdlr(
52 CG729EncoderIntfc* aG729EncoderIntfcCI) :
53 CMMFObject(KUidG729EncoderIntfc)
55 iG729EncoderIntfcCI = aG729EncoderIntfcCI;
58 // -----------------------------------------------------------------------------
59 // CG729EncoderIntfcMsgHdlr::ConstructL
60 // Symbian 2nd phase constructor can leave.
61 // -----------------------------------------------------------------------------
63 void CG729EncoderIntfcMsgHdlr::ConstructL()
67 // -----------------------------------------------------------------------------
68 // CG729EncoderIntfcMsgHdlr::NewL
69 // Two-phased constructor.
70 // -----------------------------------------------------------------------------
72 EXPORT_C CG729EncoderIntfcMsgHdlr* CG729EncoderIntfcMsgHdlr::NewL(
73 TAny* aG729EncoderIntfcCI)
75 CG729EncoderIntfc* errorConcealmentIntfcCI =
76 (CG729EncoderIntfc*)aG729EncoderIntfcCI;
77 CG729EncoderIntfcMsgHdlr* self =
78 new (ELeave) CG729EncoderIntfcMsgHdlr(errorConcealmentIntfcCI);
79 CleanupStack::PushL( self );
81 CleanupStack::Pop( self );
87 EXPORT_C CG729EncoderIntfcMsgHdlr::~CG729EncoderIntfcMsgHdlr()
89 delete iG729EncoderIntfcCI;
92 // ---------------------------------------------------------
93 // CG729EncoderIntfcMsgHdlr::HandleRequest
94 // Handles the messages from the proxy.
95 // Calls a subfunction which determines which custom interface to call.
96 // A subfunction is used to contain multiple leaving functions for a single
98 // (other items were commented in a header).
99 // ---------------------------------------------------------
101 EXPORT_C void CG729EncoderIntfcMsgHdlr::HandleRequest(
102 TMMFMessage& aMessage)
104 ASSERT(aMessage.Destination().InterfaceId() == KUidG729EncoderIntfc);
105 TRAPD(error,DoHandleRequestL(aMessage));
108 aMessage.Complete(error);
112 // ---------------------------------------------------------
113 // CG729EncoderIntfcMsgHdlr::DoHandleRequestL
114 // Determines which custom interface to call.
115 // (other items were commented in a header).
116 // ---------------------------------------------------------
118 void CG729EncoderIntfcMsgHdlr::DoHandleRequestL(TMMFMessage& aMessage)
120 switch(aMessage.Function())
122 case EG729eimSetVadMode:
124 DoSetVadModeL(aMessage);
127 case EG729eimGetVadMode:
129 DoGetVadModeL(aMessage);
134 aMessage.Complete(KErrNotSupported);
139 // ---------------------------------------------------------
140 // CG729EncoderIntfcMsgHdlr::DoSetVadModeL
141 // Handles the message from the proxy and calls the custom interface method.
142 // The data passed from the proxy is read from the message and passed to
143 // the custom interface.
144 // (other items were commented in a header).
145 // ---------------------------------------------------------
147 void CG729EncoderIntfcMsgHdlr::DoSetVadModeL(TMMFMessage& aMessage)
149 TPckgBuf<TBool> pckgBuf;
150 aMessage.ReadData1FromClientL(pckgBuf);
151 TInt status = iG729EncoderIntfcCI->SetVadMode(pckgBuf());
152 aMessage.Complete(status);
155 // ---------------------------------------------------------
156 // CG729EncoderIntfcMsgHdlr::DoGetVadModeL
157 // Handles the message from the proxy and calls the custom interface.
158 // The custom interface returns the data requested and this function
159 // writes it back to the proxy.
160 // (other items were commented in a header).
161 // ---------------------------------------------------------
163 void CG729EncoderIntfcMsgHdlr::DoGetVadModeL(TMMFMessage& aMessage)
166 TInt status = iG729EncoderIntfcCI->GetVadMode(vadMode);
167 if (status == KErrNone)
169 TPckgBuf<TBool> pckgBuf;
171 aMessage.WriteDataToClientL(pckgBuf);
173 aMessage.Complete(status);