1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmhais/videohai/devvideo/src/DevVideo/devvideointernal.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,213 @@
1.4 +// Copyright (c) 2003-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 "devvideointernal.h"
1.20 +#ifdef SYMBIAN_MULTIMEDIA_CODEC_API
1.21 +#include <mdf/codecapiresolverdata.h>
1.22 +#include <mdf/codecapiuids.hrh>
1.23 +#include <mdf/codecapiresolver.hrh>
1.24 +#include <mm/mmpluginutils.h>
1.25 +
1.26 +#include "videoplayhwdevice.h"
1.27 +
1.28 +void DevVideoUtilities::FindVideoDecoderPluginsL(const TDesC8& aMimeType, RImplInfoPtrArray& aImplInfoArray)
1.29 + {
1.30 + CCodecApiResolverData* customMatchData = CCodecApiResolverData::NewLC();
1.31 + customMatchData->SetMatchType(EMatchInputDataFormat);
1.32 + customMatchData->SetImplementationType(TUid::Uid(KUidVideoDecoder));
1.33 + // string value of the input source data
1.34 + customMatchData->SetInputDataL(aMimeType);
1.35 +
1.36 + HBufC8* package = customMatchData->NewPackLC(); // parameters to match sent as "default data"
1.37 + MmPluginUtils::FindImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray, *package, TUid::Uid(KUidCodecApiResolverImplementation));
1.38 + CleanupStack::PopAndDestroy(2, customMatchData); // package, customMatchData
1.39 + }
1.40 +
1.41 +
1.42 +void DevVideoUtilities::FindVideoEncoderPluginsL(const TDesC8& aMimeType, RImplInfoPtrArray& aImplInfoArray)
1.43 + {
1.44 + CCodecApiResolverData* customMatchData = CCodecApiResolverData::NewLC();
1.45 + customMatchData->SetMatchType(EMatchOutputDataFormat);
1.46 + customMatchData->SetImplementationType(TUid::Uid(KUidVideoEncoder));
1.47 + // string value of the input source data
1.48 + customMatchData->SetOutputDataL(aMimeType);
1.49 +
1.50 + HBufC8* package = customMatchData->NewPackLC(); // parameters to match sent as "default data"
1.51 + MmPluginUtils::FindImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray, *package, TUid::Uid(KUidCodecApiResolverImplementation));
1.52 + CleanupStack::PopAndDestroy(2, customMatchData); // package, customMatchData
1.53 + }
1.54 +
1.55 +void DevVideoUtilities::CreatePuListL(RImplInfoPtrArray& aImplInfoArray)
1.56 + {
1.57 + // we can use REComSession::ListImplementationsL() straight, and skip the sort step of MmPluginUtils
1.58 + // as this list is used purely to feedback into FindPu below, and see if the plugin is a PU and not a HwDevice
1.59 + aImplInfoArray.Reset();
1.60 + REComSession::ListImplementationsL(TUid::Uid(KUidMdfProcessingUnit), aImplInfoArray);
1.61 + }
1.62 +
1.63 +
1.64 +const CImplementationInformation* DevVideoUtilities::FindPu(const RImplInfoPtrArray& aImplInfoArray, TUid aPuUid)
1.65 + {
1.66 + CImplementationInformation* info = NULL;
1.67 + for (TInt i=0;i<aImplInfoArray.Count() && info == NULL;i++)
1.68 + {
1.69 + if (aImplInfoArray[i]->ImplementationUid() == aPuUid)
1.70 + {
1.71 + info = aImplInfoArray[i];
1.72 + }
1.73 + }
1.74 + return info;
1.75 + }
1.76 +
1.77 +#endif // SYMBIAN_MULTIMEDIA_CODEC_API
1.78 +
1.79 +TInt DevVideoUtilities::ConvertTextToTUint32(const TDesC8& aData, TUint32& aNumber)
1.80 + {
1.81 + // Work out whether aData is in hex or not by looking for an 0x at the beginning
1.82 + TInt error = KErrNone;
1.83 +
1.84 + _LIT8(K0x, "0x");
1.85 + if (aData.FindF(K0x) == 0)
1.86 + {
1.87 + // Data is in hex
1.88 + // Discard the '0x'
1.89 + TLex8 lex(aData.Right(aData.Length() - K0x().Length()));
1.90 + error = lex.Val(aNumber, EHex);
1.91 + }
1.92 + else
1.93 + {
1.94 + // Assume aData is in decimal
1.95 + TLex8 lex(aData);
1.96 + error = lex.Val(aNumber, EDecimal);
1.97 + }
1.98 +
1.99 + return error;
1.100 + }
1.101 +
1.102 +void DevVideoUtilities::MatchPrePostProcessorCapabilitiesL(const RImplInfoPtrArray& aPlugins, TUint32 aReqPrePostProcType, RArray<TUid>& aMatchingPlugins)
1.103 + {
1.104 + aMatchingPlugins.Reset();
1.105 +
1.106 + TInt count = aPlugins.Count();
1.107 + for (TInt i=0; i<count; i++)
1.108 + {
1.109 + const CImplementationInformation* plugin = aPlugins[i];
1.110 + TUint32 pluginPostProcType = 0;
1.111 + TInt error = ConvertTextToTUint32(plugin->OpaqueData(), pluginPostProcType);
1.112 + if (error == KErrNone)
1.113 + {
1.114 + // Check the plugin has at least the pre/post processing capabilities demanded by the client
1.115 + if ((pluginPostProcType & aReqPrePostProcType) == aReqPrePostProcType)
1.116 + {
1.117 + User::LeaveIfError(aMatchingPlugins.Append(plugin->ImplementationUid()));
1.118 + }
1.119 + }
1.120 + else if (error == KErrCorrupt)
1.121 + {
1.122 + // In debug mode leave, in release mode just swallow the error since we
1.123 + // don't want to allow broken plugins to prevent other plugins being recognised.
1.124 +#ifdef _DEBUG
1.125 + User::Leave(error);
1.126 +#endif //_DEBUG
1.127 + }
1.128 + else
1.129 + {
1.130 + User::Leave(error);
1.131 + }
1.132 + }
1.133 + }
1.134 +
1.135 +void DevVideoUtilities::SelectPluginBasedOnMatchType(const TDesC8& aMatchType, RImplInfoPtrArray& aImplInfoArray)
1.136 + {
1.137 + // In this function if allowing wildcards then TDesC8::Match is used which returns
1.138 + // the position of the match or KErrNotFound
1.139 + // If not allowing wildcards then TDesC8::Compare is used which returns a TInt which
1.140 + // indicates if one descriptor is bigger than the other (0 if they are identical)
1.141 + TBool matchResult = ETrue;
1.142 +
1.143 + if(aMatchType.Length() == 0)
1.144 + {
1.145 + return;
1.146 + }
1.147 + else
1.148 + {
1.149 + TInt count = aImplInfoArray.Count();
1.150 +
1.151 + _LIT8(KdataSeparator, "||");
1.152 + const TInt separatorLength = KdataSeparator().Length();
1.153 +
1.154 + for (TInt index = 0; index < count;)
1.155 + {
1.156 + CImplementationInformation* plugin = aImplInfoArray[index];
1.157 + const TDesC8& mimeType = plugin->DataType();
1.158 +
1.159 + // Look for the section separator marker '||'
1.160 + TInt separatorPos = mimeType.Find(KdataSeparator);
1.161 +
1.162 + if(separatorPos == KErrNotFound)
1.163 + {
1.164 + matchResult = aMatchType.MatchF(mimeType) != KErrNotFound;
1.165 + }
1.166 + else
1.167 + {
1.168 + // Find the first section, up to the separator
1.169 + TPtrC8 dataSection = mimeType.Left(separatorPos);
1.170 + TPtrC8 remainingData = mimeType.Mid(separatorPos + separatorLength);
1.171 +
1.172 + // Match against each section in turn
1.173 + while(separatorPos != KErrNotFound)
1.174 + {
1.175 + matchResult = aMatchType.MatchF(dataSection) != KErrNotFound;
1.176 +
1.177 + // If we found it then no need to continue, so return
1.178 + if(matchResult)
1.179 + break;
1.180 +
1.181 + // Move on to the next section
1.182 + separatorPos = remainingData.Find(KdataSeparator);
1.183 + if(separatorPos != KErrNotFound)
1.184 + {
1.185 + dataSection.Set(remainingData.Left(separatorPos));
1.186 + remainingData.Set(remainingData.Mid(separatorPos + separatorLength));
1.187 + }
1.188 + else
1.189 + {
1.190 + dataSection.Set(remainingData);
1.191 + }
1.192 + } // end of while
1.193 +
1.194 + // Check the final part
1.195 + matchResult = aMatchType.MatchF(dataSection) != KErrNotFound;
1.196 +
1.197 + } //end of else
1.198 +
1.199 + // if a match was found increment the array,
1.200 + // otherwise remove the element from the array
1.201 + if (matchResult)
1.202 + {
1.203 + index++;
1.204 + }
1.205 + else
1.206 + {
1.207 + delete aImplInfoArray[index];
1.208 + aImplInfoArray.Remove(index);
1.209 + count--;
1.210 + }
1.211 +
1.212 + } //end of for
1.213 + }
1.214 + }
1.215 +
1.216 +