sl@0: // Copyright (c) 2005-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: /** sl@0: @file sl@0: @publishedPartner sl@0: @prototype sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: #include "puloader.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: static const TInt KMaxDataTypeLength = 126; sl@0: sl@0: CPuLoader* CPuLoader::NewL() sl@0: { sl@0: CPuLoader* self = new (ELeave) CPuLoader; sl@0: return self; sl@0: } sl@0: sl@0: sl@0: CMdfProcessingUnit* CPuLoader::LoadProcessingUnitL(const MMdfProcessingUnitObserver& aProcessingUnitObserver, sl@0: TUid aImplementationUid) sl@0: { sl@0: CMdfProcessingUnit* pu = NULL; sl@0: pu = CMdfProcessingUnit::NewL(aImplementationUid); sl@0: CleanupStack::PushL(pu); sl@0: User::LeaveIfError(pu->Create(aProcessingUnitObserver)); sl@0: CleanupStack::Pop(pu); sl@0: return pu; sl@0: } sl@0: sl@0: CMdfProcessingUnit* CPuLoader::LoadProcessingUnitL( const MMdfProcessingUnitObserver& aProcessingUnitObserver, sl@0: const TDesC8& aSrcDataType, const TDesC8& aDestDataType, const TUid& aImplementationType) sl@0: { sl@0: CCodecApiResolverData* customMatchData = CCodecApiResolverData::NewLC(); sl@0: customMatchData->SetMatchType(EMatchInputAndOutputDataFormat); sl@0: customMatchData->SetImplementationType(aImplementationType); sl@0: // string value of the input source data sl@0: customMatchData->SetInputDataL(aSrcDataType); sl@0: customMatchData->SetOutputDataL(aDestDataType); sl@0: sl@0: HBufC8* package = customMatchData->NewPackLC(); sl@0: sl@0: TEComResolverParams resolverParams; // Parameters on which to match sl@0: resolverParams.SetDataType(package->Des()); sl@0: sl@0: RImplInfoPtrArray ecomArray; sl@0: CleanupResetAndDestroyPushL(ecomArray); sl@0: sl@0: REComSession::ListImplementationsL(TUid::Uid(KUidMdfProcessingUnit), resolverParams, TUid::Uid(KUidCodecApiResolverImplementation), ecomArray); sl@0: sl@0: // check if there are any sl@0: TInt noOfProcessingUnits = ecomArray.Count(); sl@0: sl@0: if(noOfProcessingUnits == 0) sl@0: { sl@0: User::Leave(KErrNotFound); sl@0: } sl@0: sl@0: CMdfProcessingUnit *processingUnit = NULL; sl@0: TInt index = 0; sl@0: TInt error = KErrNone; sl@0: do sl@0: { sl@0: // Iterate through the array until a plugin can be created without errors sl@0: const CImplementationInformation& puInfo = *(ecomArray[index++]); sl@0: sl@0: TRAP(error, processingUnit = CMdfProcessingUnit::NewL(puInfo.ImplementationUid())); sl@0: } sl@0: while(index < noOfProcessingUnits && error != KErrNone); sl@0: sl@0: if(error) sl@0: { sl@0: ASSERT(!processingUnit && index <= noOfProcessingUnits); sl@0: User::Leave(error); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(3, customMatchData); // customMatchData, package, ecomArray sl@0: sl@0: sl@0: TInt err = processingUnit->Create(aProcessingUnitObserver); sl@0: if (err != KErrNone) sl@0: { sl@0: // delete processing unit before leaving sl@0: delete processingUnit; sl@0: User::Leave(err); sl@0: } sl@0: return processingUnit; sl@0: } sl@0: sl@0: CMdfProcessingUnit* CPuLoader::LoadProcessingUnitL( const MMdfProcessingUnitObserver& aProcessingUnitObserver, sl@0: TFourCC aSrcDataType, TFourCC aDestDataType) sl@0: { sl@0: HBufC8* packageSrcDataType = HBufC8::NewLC(KMaxDataTypeLength); sl@0: TPtr8 sourceDataType = packageSrcDataType->Des(); sl@0: aSrcDataType.FourCC(&sourceDataType); sl@0: sl@0: HBufC8* packageDestDataType = HBufC8::NewLC(KMaxDataTypeLength); sl@0: TPtr8 destinationDataType = packageDestDataType->Des(); sl@0: aDestDataType.FourCC(&destinationDataType); sl@0: sl@0: CMdfProcessingUnit* processingUnit = LoadProcessingUnitL(aProcessingUnitObserver, sourceDataType, destinationDataType, TUid::Uid(KUidAudioCodec)); sl@0: CleanupStack::PopAndDestroy(2, packageSrcDataType); sl@0: return processingUnit; sl@0: } sl@0: sl@0: sl@0: TInt CPuLoader::TunnelSetup(MMdfOutputPort& aOutputPort, MMdfInputPort& aInputPort) sl@0: { sl@0: TTunnelFlags tunnelFlags = EBufferReadOnly; sl@0: TSupplierType supplierType = EBufferSupplyUnspecified; sl@0: TUint error = KErrNone; sl@0: sl@0: if ((error = aOutputPort.MopTunnelRequest(aInputPort, tunnelFlags, supplierType)) != KErrNone) sl@0: { sl@0: return error; sl@0: } sl@0: return aInputPort.MipTunnelRequest(aOutputPort,tunnelFlags,supplierType); sl@0: } sl@0: sl@0: sl@0: void CPuLoader::UnloadProcessingUnit(CMdfProcessingUnit*& aPu) sl@0: { sl@0: delete aPu; sl@0: aPu = NULL; sl@0: } sl@0: sl@0: CPuLoader::CPuLoader() sl@0: { sl@0: } sl@0: sl@0: CPuLoader::~CPuLoader() sl@0: { sl@0: }