os/mm/mmdevicefw/mdf/src/codecapi/codecapiresolver.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmdevicefw/mdf/src/codecapi/codecapiresolver.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,194 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <ecom/ecom.h>
    1.20 +#include <ecom/ecomerrorcodes.h>
    1.21 +#include <ecom/ecomresolverparams.h>
    1.22 +#include <ecom/implementationinformation.h>
    1.23 +#include <ecom/publicregistry.h>
    1.24 +#include <mdf/codecapiresolverdata.h>
    1.25 +#include <mdf/codecapiresolverutils.h>
    1.26 +#include <mdf/codecapivideoresolverutils.h>
    1.27 +#include <mdf/codecapiuids.hrh>
    1.28 +#include "codecapiresolver.h"
    1.29 +
    1.30 +/**
    1.31 +Constructs a CCodecApiResolver object.
    1.32 +@param  aRegistry
    1.33 +		A reference to the instantiated registry information 
    1.34 +@return An instance of the class or NULL.
    1.35 +*/
    1.36 +CCodecApiResolver* CCodecApiResolver::NewL (MPublicRegistry& aRegistry)
    1.37 +	{
    1.38 +	return new(ELeave) CCodecApiResolver (aRegistry);
    1.39 +	}
    1.40 +
    1.41 +
    1.42 +/**
    1.43 +Class destructor.
    1.44 +*/
    1.45 +CCodecApiResolver::~CCodecApiResolver()
    1.46 +	{
    1.47 +	}
    1.48 +
    1.49 +/**
    1.50 +Class constructor.
    1.51 +*/
    1.52 +CCodecApiResolver::CCodecApiResolver (MPublicRegistry& aRegistry) :
    1.53 +	CResolver (aRegistry)
    1.54 +	{
    1.55 +	}
    1.56 +
    1.57 +/**
    1.58 +Requests the resolver to identify the most appropriate interface implementation.
    1.59 +@param  aInterfaceUid
    1.60 +		The interface for which an implementation is requested.
    1.61 +@param  aAdditionalParameters
    1.62 +	    The parameters which must match for an implementation to be suitable. 
    1.63 +@return The unique id of the implementation which satisfies the specified parameters. 
    1.64 + 		KNullUid if not implementation is found.
    1.65 +*/ 
    1.66 +TUid CCodecApiResolver::IdentifyImplementationL(TUid /*aInterfaceUid*/,
    1.67 +	const TEComResolverParams& /*aAdditionalParameters*/) const
    1.68 +	{
    1.69 +	return KNullUid;
    1.70 +	}
    1.71 +
    1.72 +
    1.73 +/**
    1.74 +Lists all the implementations which satisfy the specified interface definition and the 
    1.75 +resolve parameters supplied.
    1.76 +@param  aInterfaceUid
    1.77 +		The interface for which an implementation is requested.
    1.78 +@param  aAdditionalParameters	  	
    1.79 +		The parameters which must match for an implementation to be suitable.
    1.80 +@return Pointer to an array of suitable implementations. Ownership of this array is passed
    1.81 +	    to the calling function. 
    1.82 +*/
    1.83 +RImplInfoArray* CCodecApiResolver::ListAllL(TUid aInterfaceUid,
    1.84 +	const TEComResolverParams& aAdditionalParameters) const
    1.85 +	{
    1.86 +	RImplInfoArray* retList = new (ELeave) RImplInfoArray;
    1.87 +	// coverity[double_push]
    1.88 +	CleanupStack::PushL(retList);
    1.89 +	CleanupClosePushL(*retList);
    1.90 +	
    1.91 +	CCodecApiResolverData* customMatch = CCodecApiResolverData::NewLC(aAdditionalParameters.DataType());
    1.92 +	
    1.93 +	TCodecApiResolverMatchType matchType = customMatch->MatchType();
    1.94 +	TUid implementationTypeUid 			 = customMatch->ImplementationType();
    1.95 +	
    1.96 +	// create a list with all 
    1.97 +	RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);
    1.98 +	const TInt count = fullList.Count();
    1.99 +	
   1.100 +	for(TInt index = 0; index < count; index++)
   1.101 +		{
   1.102 +		TBool matchFound = EFalse;
   1.103 +		const CImplementationInformation& impData = *(fullList[index]);
   1.104 +		CCodecApiOpaqueData* parse = NULL;
   1.105 +		const TDesC8* opaqueData = &impData.OpaqueData();
   1.106 +		// if opaque data is empty, move to the next element in the list
   1.107 +		if (opaqueData->Length() == 0)
   1.108 +			{
   1.109 +			continue;
   1.110 +			}
   1.111 +		// create an instance of the class which holds the opaque data	
   1.112 +		TInt error = KErrNotFound;
   1.113 +		
   1.114 +		if (implementationTypeUid == TUid::Uid(KUidAudioCodec)) 
   1.115 +			{
   1.116 +			TRAP(error, parse = CCodecApiOpaqueData::NewL(impData.OpaqueData()));	
   1.117 +			}
   1.118 +		else
   1.119 +			{
   1.120 +			if ((implementationTypeUid == TUid::Uid(KUidVideoEncoder)) 
   1.121 +				|| implementationTypeUid == TUid::Uid(KUidVideoDecoder)) 
   1.122 +				{
   1.123 +				TRAP(error, parse = CCodecApiVideoOpaqueData::NewL(impData.OpaqueData()));
   1.124 +				}	
   1.125 +			else
   1.126 +				{
   1.127 +				error = KErrNotSupported;	
   1.128 +				}
   1.129 +			} 
   1.130 +			
   1.131 +		CleanupStack::PushL(parse);	
   1.132 +		
   1.133 +		if (error)
   1.134 +			{
   1.135 +			if ((error == KErrNotSupported) || (error == KErrCorrupt))
   1.136 +				{
   1.137 +				// means that the resource entry was not valid
   1.138 +				// we ignore this plugin and try the next one
   1.139 +				CleanupStack::PopAndDestroy(parse);
   1.140 +				continue;
   1.141 +				}
   1.142 +			else
   1.143 +				{
   1.144 +				User::Leave(error);
   1.145 +				}				
   1.146 +			} //end of 	if (error!=KErrNone)
   1.147 +			
   1.148 +		// check if the uids are different. If they are, move to the next element
   1.149 +		// in the list		
   1.150 +		if (implementationTypeUid != parse->TypeUid())
   1.151 +			{
   1.152 +			CleanupStack::PopAndDestroy(parse);
   1.153 +			continue;
   1.154 +			}
   1.155 +		switch(matchType)
   1.156 +			{	
   1.157 +			// check that the input data type is what we are looking for
   1.158 +			case EMatchInputDataFormat:
   1.159 +				if (parse->CompareInputDataType(customMatch->InputDataFormat()))
   1.160 +					{
   1.161 +					matchFound = ETrue;
   1.162 +					}
   1.163 +				break;
   1.164 +			// check that the output data type is what we are looking for	
   1.165 +			case EMatchOutputDataFormat:
   1.166 +				if (parse->CompareOutputDataType(customMatch->OutputDataFormat()))
   1.167 +					{
   1.168 +					matchFound = ETrue;
   1.169 +					}
   1.170 +				break;
   1.171 +			// check that the input and output data type is what we are looking for	
   1.172 +			case EMatchInputAndOutputDataFormat:
   1.173 +				if (parse->CompareInputDataType(customMatch->InputDataFormat()) 
   1.174 +					&& parse->CompareOutputDataType(customMatch->OutputDataFormat()))
   1.175 +					{
   1.176 +					matchFound = ETrue;
   1.177 +					}
   1.178 +				break;
   1.179 +			default:
   1.180 +				{
   1.181 +				//matchFound was initialised to EFalse, so fall through				
   1.182 +				}				
   1.183 +			}
   1.184 +		// if a match was found, it will be appended to the list returned by this method
   1.185 +		if (matchFound)
   1.186 +			{
   1.187 +			User::LeaveIfError(retList->Append(fullList[index]));	
   1.188 +			}
   1.189 +		CleanupStack::PopAndDestroy(parse);
   1.190 +		} // end of for
   1.191 +	
   1.192 +	CleanupStack::PopAndDestroy(customMatch);
   1.193 +	CleanupStack::Pop(2, retList);
   1.194 +	return retList;	
   1.195 +	}
   1.196 +
   1.197 +