os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/speechencoderconfigci.cpp
Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <ecom/implementationproxy.h>
17 #include <ecom/implementationproxy.h>
18 #include <ecom/ecom.h>
21 #include "speechencoderconfigci.h"
26 TInt CMMFSpeechEncoderConfigMux::OpenInterface(TUid /*aInterfaceId*/)
28 // attempt to open the interface link with the
29 // remote slave device
31 TUid slaveId = {KMmfUidCustomInterfaceSpeechEncoderConfigDeMux};
33 TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
36 iRemoteHandle = handle;
43 void CMMFSpeechEncoderConfigMux::Release()
45 // close the slave device if it exists
46 if (iRemoteHandle > 0)
48 // we assume the slave is closed correctly
49 iUtility->CloseSlave(iRemoteHandle);
55 // tell ECom to destroy us
56 REComSession::DestroyedImplementation(key);
60 void CMMFSpeechEncoderConfigMux::PassDestructorKey(TUid aDestructorKey)
62 // store the destructor key
63 iKey = aDestructorKey;
67 void CMMFSpeechEncoderConfigMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
69 // store a pointer to the utility
70 iUtility = aCustomUtility;
74 MMMFDevSoundCustomInterfaceMuxPlugin* CMMFSpeechEncoderConfigMux::NewL()
76 CMMFSpeechEncoderConfigMux* self = new (ELeave) CMMFSpeechEncoderConfigMux;
81 TAny* CMMFSpeechEncoderConfigMux::CustomInterface(TUid /*aInterfaceId*/)
83 MSpeechEncoderConfig* interface = this;
88 CMMFSpeechEncoderConfigMux::CMMFSpeechEncoderConfigMux() :
94 CMMFSpeechEncoderConfigMux::~CMMFSpeechEncoderConfigMux()
99 // from MSpeechEncoderConfig
100 TInt CMMFSpeechEncoderConfigMux::SetVadMode (TBool aVadModeOn)
102 TInt result = KErrBadHandle;
104 if (iRemoteHandle > 0)
106 // send the VadModeOn in the sync command
107 TPckgBuf<TBool> vadModeOn(aVadModeOn);
109 // any return code other than zero is an error
110 result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
111 EMMFDevSoundCISpeechEncoderConfigSetVadMode,
119 // from MSpeechEncoderConfig
120 TInt CMMFSpeechEncoderConfigMux::GetVadMode (TBool& aVadModeOn)
122 TInt result = KErrBadHandle;
124 if (iRemoteHandle > 0)
126 // holds the returned value.
127 TPckgBuf<TBool> retVadModeOn;
129 // any return code other than zero is an error
130 result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
131 EMMFDevSoundCISpeechEncoderConfigGetVadMode,
135 // assign return values to aVadModeOn. Do nothing if there is an error
136 if(result == KErrNone)
138 aVadModeOn = retVadModeOn();
149 TInt CMMFSpeechEncoderConfigDeMux::OpenInterface(TUid /*aInterfaceId*/)
155 void CMMFSpeechEncoderConfigDeMux::Release()
161 // tell ECom to destroy us
162 REComSession::DestroyedImplementation(key);
166 void CMMFSpeechEncoderConfigDeMux::PassDestructorKey(TUid aDestructorKey)
168 // store the destructor key
169 iKey = aDestructorKey;
173 void CMMFSpeechEncoderConfigDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
179 void CMMFSpeechEncoderConfigDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
181 // store a pointer to the utility
182 iUtility = aCustomUtility;
186 void CMMFSpeechEncoderConfigDeMux::RefreshL()
188 // refetch the Speech Encoder Config custom interface if we already have a target
191 iInterfaceSpeechEncoderConfig = static_cast <MSpeechEncoderConfig*> (iTarget->CustomInterface(KUidSpeechEncoderConfig));
193 if (!iInterfaceSpeechEncoderConfig)
195 iInterfaceSpeechEncoderConfig = NULL;
196 User::Leave(KErrNotSupported);
202 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFSpeechEncoderConfigDeMux::NewL()
204 CMMFSpeechEncoderConfigDeMux* self = new (ELeave) CMMFSpeechEncoderConfigDeMux;
209 CMMFSpeechEncoderConfigDeMux::CMMFSpeechEncoderConfigDeMux()
214 CMMFSpeechEncoderConfigDeMux::~CMMFSpeechEncoderConfigDeMux()
219 TInt CMMFSpeechEncoderConfigDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
221 // fetch the Speech Encoder Config Hw Device custom interface
222 iInterfaceSpeechEncoderConfig = static_cast<MSpeechEncoderConfig*> (iTarget->CustomInterface(KUidSpeechEncoderConfig));
224 if (!iInterfaceSpeechEncoderConfig)
226 iInterfaceSpeechEncoderConfig = NULL;
227 User::Leave(KErrNotSupported);
234 void CMMFSpeechEncoderConfigDeMux::DoCloseSlaveL(TInt /*aHandle*/)
240 // original RMessage is supplied so that remote demux plugin can extract necessary details
241 // using DeMux utility
242 TInt CMMFSpeechEncoderConfigDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
244 TMMFDevSoundCIMessageData data;
245 TInt result = KErrGeneral;
248 iUtility->GetSyncMessageDataL(aMessage, data);
250 switch (data.iCommand)
252 case EMMFDevSoundCISpeechEncoderConfigSetVadMode:
254 TPckgBuf<TBool> vadModeOn;
255 iUtility->ReadFromInputDesL(aMessage, &vadModeOn);
257 result = DoSetVadModeL(vadModeOn());
263 User::Leave(KErrNotSupported);
271 TInt CMMFSpeechEncoderConfigDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
273 TMMFDevSoundCIMessageData data;
274 TInt result = KErrNone;
277 iUtility->GetSyncMessageDataL(aMessage, data);
279 switch (data.iCommand)
281 case EMMFDevSoundCISpeechEncoderConfigGetVadMode:
283 TPckgBuf<TBool> vadModeOn;
284 iUtility->ReadFromInputDesL(aMessage, &vadModeOn);
286 result = DoGetVadModeL(vadModeOn());
288 TPckgBuf<TBool> des(vadModeOn());
289 iUtility->WriteToOutputDesL(aMessage, des);
295 User::Leave(KErrNotSupported);
303 void CMMFSpeechEncoderConfigDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
305 // not used in this interface
309 void CMMFSpeechEncoderConfigDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
311 // not used in this interface
315 // Speech Encoder Config custom interface implementation
316 TInt CMMFSpeechEncoderConfigDeMux::DoSetVadModeL(TBool aVadModeOn)
318 TInt result = KErrNotFound;
320 if (iInterfaceSpeechEncoderConfig)
322 result = iInterfaceSpeechEncoderConfig->SetVadMode(aVadModeOn);
329 // Speech Encoder Config custom interface implementation
330 TInt CMMFSpeechEncoderConfigDeMux::DoGetVadModeL(TBool& aVadModeOn)
332 TInt result = KErrNotFound;
334 if (iInterfaceSpeechEncoderConfig)
336 result = iInterfaceSpeechEncoderConfig->GetVadMode(aVadModeOn);
344 // ImplementationTable
346 const TImplementationProxy ImplementationTable[] =
348 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceSpeechEncoderConfigMux, CMMFSpeechEncoderConfigMux::NewL),
349 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceSpeechEncoderConfigDeMux, CMMFSpeechEncoderConfigDeMux::NewL),
353 // ImplementationGroupProxy
355 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
357 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
359 return ImplementationTable;