sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "ilbcencoderconfigci.h" sl@0: sl@0: sl@0: // MUX // sl@0: sl@0: TInt CMMFIlbcEncoderIntfcMux::OpenInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: // attempt to open the interface link with the sl@0: // remote slave device sl@0: iRemoteHandle = -1; sl@0: TUid slaveId = {KMmfUidCustomInterfaceIlbcEncoderIntfcDeMux}; sl@0: sl@0: TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8); sl@0: if (handle >= 0) sl@0: { sl@0: iRemoteHandle = handle; sl@0: } sl@0: sl@0: return iRemoteHandle; sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcMux::Release() sl@0: { sl@0: // close the slave device if it exists sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // we assume the slave is closed correctly sl@0: iUtility->CloseSlave(iRemoteHandle); sl@0: } sl@0: sl@0: TUid key = iKey; sl@0: delete this; sl@0: sl@0: // tell ECom to destroy us sl@0: REComSession::DestroyedImplementation(key); sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcMux::PassDestructorKey(TUid aDestructorKey) sl@0: { sl@0: // store the destructor key sl@0: iKey = aDestructorKey; sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility) sl@0: { sl@0: // store a pointer to the utility sl@0: iUtility = aCustomUtility; sl@0: } sl@0: sl@0: sl@0: MMMFDevSoundCustomInterfaceMuxPlugin* CMMFIlbcEncoderIntfcMux::NewL() sl@0: { sl@0: CMMFIlbcEncoderIntfcMux* self = new (ELeave) CMMFIlbcEncoderIntfcMux; sl@0: return self; sl@0: } sl@0: sl@0: sl@0: TAny* CMMFIlbcEncoderIntfcMux::CustomInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: MIlbcEncoderIntfc* interface = this; sl@0: return interface; sl@0: } sl@0: sl@0: sl@0: CMMFIlbcEncoderIntfcMux::CMMFIlbcEncoderIntfcMux() : sl@0: iRemoteHandle(-1) sl@0: { sl@0: } sl@0: sl@0: sl@0: CMMFIlbcEncoderIntfcMux::~CMMFIlbcEncoderIntfcMux() sl@0: { sl@0: } sl@0: sl@0: sl@0: // from MIlbcEncoderIntfc sl@0: TInt CMMFIlbcEncoderIntfcMux::SetEncoderMode(TEncodeMode aEncodeMode) sl@0: { sl@0: TInt result = KErrBadHandle; sl@0: sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // send encodeMode in the sync command. sl@0: TPckgBuf encodeMode(aEncodeMode); sl@0: sl@0: // any return code other than zero is an error sl@0: result = iUtility->SendSlaveSyncCommand(iRemoteHandle, sl@0: EMMFDevSoundCIIlbcEncoderIntfcSetEncoderMode, sl@0: encodeMode); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // from MIlbcEncoderIntfc sl@0: TInt CMMFIlbcEncoderIntfcMux::GetEncoderMode(TEncodeMode& aEncodeMode) sl@0: { sl@0: TInt result = KErrBadHandle; sl@0: sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // send encodeMode in the sync command. sl@0: TPckgBuf retEncodeMode; sl@0: sl@0: // any return code other than zero is an error sl@0: result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle, sl@0: EMMFDevSoundCIIlbcEncoderIntfcGetEncoderMode, sl@0: KNullDesC8, sl@0: retEncodeMode); sl@0: sl@0: // assign return values to aEncodeMode. Do nothing if there is an error sl@0: if(result == KErrNone) sl@0: { sl@0: aEncodeMode = retEncodeMode(); sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // from MIlbcEncoderIntfc sl@0: TInt CMMFIlbcEncoderIntfcMux::SetVadMode (TBool aVadModeOn) sl@0: { sl@0: TInt result = KErrBadHandle; sl@0: sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // send vadModeOn in the sync command. sl@0: TPckgBuf vadModeOn(aVadModeOn); sl@0: sl@0: // any return code other than zero is an error sl@0: result = iUtility->SendSlaveSyncCommand(iRemoteHandle, sl@0: EMMFDevSoundCIIlbcEncoderIntfcSetVadMode, sl@0: vadModeOn); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // from MIlbcEncoderIntfc sl@0: TInt CMMFIlbcEncoderIntfcMux::GetVadMode (TBool& aVadModeOn) sl@0: { sl@0: TInt result = KErrBadHandle; sl@0: sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // holds the returned value. sl@0: TPckgBuf retVadModeOn; sl@0: sl@0: // any return code other than zero is an error sl@0: result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle, sl@0: EMMFDevSoundCIIlbcEncoderIntfcGetVadMode, sl@0: KNullDesC8, sl@0: retVadModeOn); sl@0: sl@0: // assign return values to aVadModeOn. Do nothing if there is an error sl@0: if(result == KErrNone) sl@0: { sl@0: aVadModeOn = retVadModeOn(); sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: sl@0: // DEMUX // sl@0: sl@0: TInt CMMFIlbcEncoderIntfcDeMux::OpenInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcDeMux::Release() sl@0: { sl@0: TUid key = iKey; sl@0: sl@0: delete this; sl@0: sl@0: // tell ECom to destroy us sl@0: REComSession::DestroyedImplementation(key); sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcDeMux::PassDestructorKey(TUid aDestructorKey) sl@0: { sl@0: // store the destructor key sl@0: iKey = aDestructorKey; sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget) sl@0: { sl@0: iTarget = aTarget; sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility) sl@0: { sl@0: // store a pointer to the utility sl@0: iUtility = aCustomUtility; sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcDeMux::RefreshL() sl@0: { sl@0: // refetch the Ilbc encoder intfc custom interface if we already have a target sl@0: if (iTarget) sl@0: { sl@0: iInterfaceIlbcEncoderIntfc = static_cast (iTarget->CustomInterface(KUidIlbcEncoderIntfc)); sl@0: sl@0: if (!iInterfaceIlbcEncoderIntfc) sl@0: { sl@0: iInterfaceIlbcEncoderIntfc = NULL; sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFIlbcEncoderIntfcDeMux::NewL() sl@0: { sl@0: CMMFIlbcEncoderIntfcDeMux* self = new (ELeave) CMMFIlbcEncoderIntfcDeMux; sl@0: return self; sl@0: } sl@0: sl@0: sl@0: CMMFIlbcEncoderIntfcDeMux::CMMFIlbcEncoderIntfcDeMux() sl@0: { sl@0: } sl@0: sl@0: sl@0: CMMFIlbcEncoderIntfcDeMux::~CMMFIlbcEncoderIntfcDeMux() sl@0: { sl@0: } sl@0: sl@0: sl@0: TInt CMMFIlbcEncoderIntfcDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/) sl@0: { sl@0: // fetch the Ilbc encoder intfc Hw Device custom interface sl@0: iInterfaceIlbcEncoderIntfc = static_cast (iTarget->CustomInterface(KUidIlbcEncoderIntfc)); sl@0: sl@0: if (!iInterfaceIlbcEncoderIntfc) sl@0: { sl@0: iInterfaceIlbcEncoderIntfc = NULL; sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcDeMux::DoCloseSlaveL(TInt /*aHandle*/) sl@0: { sl@0: // nothing to do sl@0: } sl@0: sl@0: sl@0: // original RMessage is supplied so that remote demux plugin can extract necessary details sl@0: // using DeMux utility sl@0: TInt CMMFIlbcEncoderIntfcDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage) sl@0: { sl@0: TMMFDevSoundCIMessageData data; sl@0: TInt result = KErrGeneral; sl@0: sl@0: // decode message sl@0: iUtility->GetSyncMessageDataL(aMessage, data); sl@0: sl@0: switch (data.iCommand) sl@0: { sl@0: case EMMFDevSoundCIIlbcEncoderIntfcSetEncoderMode: sl@0: { sl@0: TPckgBuf encodeMode; sl@0: iUtility->ReadFromInputDesL(aMessage, &encodeMode); sl@0: sl@0: result = DoSetEncoderModeL(encodeMode()); sl@0: sl@0: break; sl@0: } sl@0: case EMMFDevSoundCIIlbcEncoderIntfcSetVadMode: sl@0: { sl@0: TPckgBuf vadModeOn; sl@0: iUtility->ReadFromInputDesL(aMessage, &vadModeOn); sl@0: sl@0: result = DoSetVadModeL(vadModeOn()); sl@0: sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // original RMessage is supplied so that remote demux plugin can extract necessary details sl@0: // using DeMux utility sl@0: TInt CMMFIlbcEncoderIntfcDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage) sl@0: { sl@0: TMMFDevSoundCIMessageData data; sl@0: TInt result = KErrNone; sl@0: sl@0: // decode message sl@0: iUtility->GetSyncMessageDataL(aMessage, data); sl@0: sl@0: switch (data.iCommand) sl@0: { sl@0: case EMMFDevSoundCIIlbcEncoderIntfcGetEncoderMode: sl@0: { sl@0: TPckgBuf encodeMode; sl@0: iUtility->ReadFromInputDesL(aMessage, &encodeMode); sl@0: sl@0: result = DoGetEncoderModeL(encodeMode()); sl@0: sl@0: TPckgBuf des(encodeMode()); sl@0: iUtility->WriteToOutputDesL(aMessage, des); sl@0: sl@0: break; sl@0: } sl@0: case EMMFDevSoundCIIlbcEncoderIntfcGetVadMode: sl@0: { sl@0: TPckgBuf vadModeOn; sl@0: iUtility->ReadFromInputDesL(aMessage, &vadModeOn); sl@0: sl@0: result = DoGetVadModeL(vadModeOn()); sl@0: sl@0: TPckgBuf des(vadModeOn()); sl@0: iUtility->WriteToOutputDesL(aMessage, des); sl@0: sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/) sl@0: { sl@0: // not used in this interface sl@0: } sl@0: sl@0: sl@0: void CMMFIlbcEncoderIntfcDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/) sl@0: { sl@0: // not used in this interface sl@0: } sl@0: sl@0: sl@0: // Ilbc encoder intfc custom interface implementation sl@0: TInt CMMFIlbcEncoderIntfcDeMux::DoSetEncoderModeL(MIlbcEncoderIntfc::TEncodeMode aEncodeMode) sl@0: { sl@0: TInt result = KErrNotFound; sl@0: sl@0: if (iInterfaceIlbcEncoderIntfc) sl@0: { sl@0: result = iInterfaceIlbcEncoderIntfc->SetEncoderMode(aEncodeMode); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // Ilbc encoder intfc custom interface implementation sl@0: TInt CMMFIlbcEncoderIntfcDeMux::DoGetEncoderModeL(MIlbcEncoderIntfc::TEncodeMode& aEncodeMode) sl@0: { sl@0: TInt result = KErrNotFound; sl@0: sl@0: if (iInterfaceIlbcEncoderIntfc) sl@0: { sl@0: result = iInterfaceIlbcEncoderIntfc->GetEncoderMode(aEncodeMode); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // Ilbc encoder intfc custom interface implementation sl@0: TInt CMMFIlbcEncoderIntfcDeMux::DoSetVadModeL(TBool aVadModeOn) sl@0: { sl@0: TInt result = KErrNotFound; sl@0: sl@0: if (iInterfaceIlbcEncoderIntfc) sl@0: { sl@0: result = iInterfaceIlbcEncoderIntfc->SetVadMode(aVadModeOn); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // Ilbc encoder intfc custom interface implementation sl@0: TInt CMMFIlbcEncoderIntfcDeMux::DoGetVadModeL(TBool& aVadModeOn) sl@0: { sl@0: TInt result = KErrNotFound; sl@0: sl@0: if (iInterfaceIlbcEncoderIntfc) sl@0: { sl@0: result = iInterfaceIlbcEncoderIntfc->GetVadMode(aVadModeOn); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // sl@0: // ImplementationTable sl@0: // sl@0: const TImplementationProxy ImplementationTable[] = sl@0: { sl@0: IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceIlbcEncoderIntfcMux, CMMFIlbcEncoderIntfcMux::NewL), sl@0: IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceIlbcEncoderIntfcDeMux, CMMFIlbcEncoderIntfcDeMux::NewL), sl@0: }; sl@0: sl@0: // sl@0: // ImplementationGroupProxy sl@0: // sl@0: EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) sl@0: { sl@0: aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); sl@0: sl@0: return ImplementationTable; sl@0: } sl@0: sl@0: