sl@0: // Copyright (c) 2002-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: #include sl@0: #include sl@0: sl@0: //static const TUid KUidMmfPluginInterfaceFormatDecode = {KMmfUidPluginInterfaceFormatDecode}; sl@0: //static const TUid KUidMmfPluginInterfaceFormatEncode = {KMmfUidPluginInterfaceFormatEncode}; sl@0: sl@0: const TInt KMmfHeaderBufferSize = 512 ; //512 bytes read to parse the header sl@0: sl@0: CMMFFormatDecode* CMMFFormatDecode::CreateFormatL(TUid aUid, MDataSource* aSource) sl@0: { sl@0: CMMFFormatDecode* s = REINTERPRET_CAST( CMMFFormatDecode*, sl@0: REComSession::CreateImplementationL( aUid, _FOFF( CMMFFormatDecode, iDtor_ID_Key), sl@0: STATIC_CAST( TAny*, aSource ) ) ) ; sl@0: s->iImplementationUid = aUid; sl@0: return s; sl@0: } sl@0: sl@0: /** sl@0: Allocates and constructs an ECom format decode object. sl@0: sl@0: This is used to explicitly instantiate a format decoder where the UID is known. This method might sl@0: be used by controllers that only support one type of format such that the UID of the format is sl@0: already known. For example, if an mp3 controller has been instantiated, there is no need for any sl@0: further format recognition as this has already been performed in the controller instantiation, thus sl@0: the controller can instantiate an mp3 format directly from it’s UID. sl@0: sl@0: @param aUid sl@0: The implementation UID. This is used by Com to create the plugin. sl@0: @param aSource sl@0: The controller MDataSource and is the source of the data for the format decode plugin. The sl@0: format decode plugin is the sink of data for the MDataSource. sl@0: sl@0: @return If successful, returns the address of the format decode plugin object created. If not successful, sl@0: leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatDecode* CMMFFormatDecode::NewL( TUid aUid, MDataSource* aSource ) sl@0: { sl@0: return CreateFormatL(aUid, aSource); sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: Attempt to locate and instantiate a FormatDecode using a filename or an extension. sl@0: sl@0: Only the extension is used. If no extension is supplied (no dot is present) the whole of the sl@0: filename will be treated as the extension. sl@0: sl@0: If the file already exists, the file header is scanned to find a match in the opaque_data field of sl@0: the resource file. sl@0: sl@0: @param aFileName sl@0: The file name of target file. May be extension only or may include full path. sl@0: @param aSource sl@0: The controller's MDataSource. This is the source of the data for the format decode plugin. This must sl@0: be a CMMFFile source when instantiating a CMMFFormatDecode using a file name. sl@0: @param aPreferredSupplier sl@0: If this is provided the list of matching plugins will be further searched for the latest version of a sl@0: plugin supplied by supplier named. sl@0: sl@0: @return If successful returns an instantiated CMMFFormatDecode from a plugin. If not successful, leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatDecode* CMMFFormatDecode::NewL( const TDesC16& aFileName, MDataSource* aSource, const TDesC& aPreferredSupplier ) sl@0: { sl@0: CMMFFormatDecodePluginSelectionParameters* pluginSelector = CMMFFormatDecodePluginSelectionParameters::NewLC(); sl@0: CMMFFormatSelectionParameters* formatParams = CMMFFormatSelectionParameters::NewLC(); sl@0: formatParams->SetMatchToFileNameL(aFileName); sl@0: pluginSelector->SetRequiredFormatSupportL(*formatParams); sl@0: if (aPreferredSupplier.Length() > 0) sl@0: pluginSelector->SetPreferredSupplierL(aPreferredSupplier, CMMFPluginSelectionParameters::EOnlyPreferredSupplierPluginsReturned); sl@0: sl@0: // Instantiate this format sl@0: CMMFFormatDecode* theChosenOne = sl@0: MMFFormatEcomUtilities::SelectFormatDecodePluginL(*pluginSelector, aSource); sl@0: sl@0: // Now clean up. sl@0: CleanupStack::PopAndDestroy(2);//formatParams, pluginSelector sl@0: sl@0: return theChosenOne; sl@0: } sl@0: sl@0: /** sl@0: Attempt to locate and instantiate a FormatDecode using a filename or an extension. sl@0: sl@0: Only the extension is used. If no extension is supplied (no dot is present) the whole of the sl@0: filename will be treated as the extension. sl@0: sl@0: If the file already exists, the file header is scanned to find a match in the opaque_data field of sl@0: the resource file. sl@0: sl@0: @param aFileName sl@0: The file name of target file. May be extension only or may include full path. sl@0: @param aSource sl@0: The controller's MDataSource. This is the source of the data for the format decode plugin. This must sl@0: be a CMMFFile source when instantiating a CMMFFormatDecode using a file name. sl@0: @param aPreferredSupplier sl@0: If this is provided the list of matching plugins will be further searched for the latest version of a sl@0: plugin supplied by supplier named. sl@0: @param aSupportsCustomInterfaces sl@0: Indicates whether the instantiated FormatDecode supports custom interfaces. sl@0: sl@0: @return If successful returns an instantiated CMMFFormatDecode from a plugin. If not successful, leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatDecode* CMMFFormatDecode::NewL( const TDesC16& aFileName, MDataSource* aSource, const TDesC& aPreferredSupplier, TBool& aSupportsCustomInterfaces ) sl@0: { sl@0: CMMFFormatDecodePluginSelectionParameters* pluginSelector = CMMFFormatDecodePluginSelectionParameters::NewLC(); sl@0: CMMFFormatSelectionParameters* formatParams = CMMFFormatSelectionParameters::NewLC(); sl@0: formatParams->SetMatchToFileNameL(aFileName); sl@0: pluginSelector->SetRequiredFormatSupportL(*formatParams); sl@0: if (aPreferredSupplier.Length() > 0) sl@0: pluginSelector->SetPreferredSupplierL(aPreferredSupplier, CMMFPluginSelectionParameters::EOnlyPreferredSupplierPluginsReturned); sl@0: sl@0: // Instantiate this format sl@0: CMMFFormatDecode* theChosenOne = sl@0: MMFFormatEcomUtilities::SelectFormatDecodePluginL(*pluginSelector, aSource, aSupportsCustomInterfaces); sl@0: sl@0: // Now clean up. sl@0: CleanupStack::PopAndDestroy(2);//formatParams, pluginSelector sl@0: sl@0: return theChosenOne; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Attempts to locate and instantiate a CMMFFormatDecode using data in a buffer. The buffer is expected to contain sl@0: header data (from a file, stream or descriptor). sl@0: sl@0: Signatures (supplied by the plugin registry information) are sought in aSourceHeader. sl@0: sl@0: This function uses the match string as a resolver parameter. The format base class uses the match string sl@0: to find a match to the match string defined in the opaque_data field of the resource file. The sl@0: match string would typically be a signature for a particular format usually defined in the format header. sl@0: sl@0: @param aSourceHeader sl@0: The data which is searched for matching signatures. sl@0: @param aSource sl@0: The controller's MDataSource and the source of the data for the format decode plugin. sl@0: @param aPreferredSupplier sl@0: If this is provided the list of matching plugins will be further searched for the latest version of a sl@0: plugin supplied by the specified supplier. sl@0: sl@0: @return If successful returns an instantiated CMMFFormatDecode from a plugin. If not successful, leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatDecode* CMMFFormatDecode::NewL( const TDesC8& aSourceHeader, MDataSource* aSource, const TDesC& aPreferredSupplier ) sl@0: { sl@0: CMMFFormatDecodePluginSelectionParameters* pluginSelector = CMMFFormatDecodePluginSelectionParameters::NewLC(); sl@0: CMMFFormatSelectionParameters* formatParams = CMMFFormatSelectionParameters::NewLC(); sl@0: formatParams->SetMatchToHeaderDataL(aSourceHeader); sl@0: pluginSelector->SetRequiredFormatSupportL(*formatParams); sl@0: if (aPreferredSupplier.Length() > 0) sl@0: pluginSelector->SetPreferredSupplierL(aPreferredSupplier, CMMFPluginSelectionParameters::EOnlyPreferredSupplierPluginsReturned); sl@0: sl@0: // Instantiate this format sl@0: CMMFFormatDecode* theChosenOne = sl@0: MMFFormatEcomUtilities::SelectFormatDecodePluginL(*pluginSelector, aSource); sl@0: sl@0: // Now clean up. sl@0: CleanupStack::PopAndDestroy(2);//formatParams, pluginSelector sl@0: sl@0: return theChosenOne; sl@0: } sl@0: sl@0: /** sl@0: Attempts to locate and instantiate a CMMFFormatDecode using data in a buffer. The buffer is expected to contain sl@0: header data (from a file, stream or descriptor). sl@0: sl@0: Signatures (supplied by the plugin registry information) are sought in aSourceHeader. sl@0: sl@0: This function uses the match string as a resolver parameter. The format base class uses the match string sl@0: to find a match to the match string defined in the opaque_data field of the resource file. The sl@0: match string would typically be a signature for a particular format usually defined in the format header. sl@0: sl@0: @param aSourceHeader sl@0: The data which is searched for matching signatures. sl@0: @param aSource sl@0: The controller's MDataSource and the source of the data for the format decode plugin. sl@0: @param aPreferredSupplier sl@0: If this is provided the list of matching plugins will be further searched for the latest version of a sl@0: plugin supplied by the specified supplier. sl@0: @param aSupportsCustomInterfaces sl@0: Indicates whether the instantiated FormatDecode supports custom interfaces. sl@0: sl@0: @return If successful returns an instantiated CMMFFormatDecode from a plugin. If not successful, leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatDecode* CMMFFormatDecode::NewL( const TDesC8& aSourceHeader, MDataSource* aSource, const TDesC& aPreferredSupplier, TBool& aSupportsCustomInterfaces ) sl@0: { sl@0: CMMFFormatDecodePluginSelectionParameters* pluginSelector = CMMFFormatDecodePluginSelectionParameters::NewLC(); sl@0: CMMFFormatSelectionParameters* formatParams = CMMFFormatSelectionParameters::NewLC(); sl@0: formatParams->SetMatchToHeaderDataL(aSourceHeader); sl@0: pluginSelector->SetRequiredFormatSupportL(*formatParams); sl@0: if (aPreferredSupplier.Length() > 0) sl@0: pluginSelector->SetPreferredSupplierL(aPreferredSupplier, CMMFPluginSelectionParameters::EOnlyPreferredSupplierPluginsReturned); sl@0: sl@0: // Instantiate this format sl@0: CMMFFormatDecode* theChosenOne = sl@0: MMFFormatEcomUtilities::SelectFormatDecodePluginL(*pluginSelector, aSource, aSupportsCustomInterfaces); sl@0: sl@0: // Now clean up. sl@0: CleanupStack::PopAndDestroy(2);//formatParams, pluginSelector sl@0: sl@0: return theChosenOne; sl@0: } sl@0: sl@0: /** sl@0: Attempts to locate and instantiate a CMMFFormatDecode using data from MDataSource. sl@0: sl@0: The data is expected to contain header data (from a file, stream or descriptor). Signatures sl@0: (supplied by the plugin registry information) are sought in aSource. sl@0: sl@0: @param aSource sl@0: Header data. Must be derived from CMMFClip. sl@0: @param aPreferredSupplier sl@0: If this is provided, the list of matching plugins will be further searched for the latest version of a sl@0: plugin supplied by the specified supplier. sl@0: sl@0: @return If successful returns an instantiated CMMFFormatDecode from a plugin. If not successful, leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatDecode* CMMFFormatDecode::NewL( MDataSource* aSource, const TDesC& aPreferredSupplier ) sl@0: { sl@0: // Read header data from aSource. Call source header version sl@0: sl@0: if ( !( (aSource->DataSourceType() == KUidMmfFileSource ) || ( aSource->DataSourceType() == KUidMmfDescriptorSource) ) ) sl@0: User::Leave( KErrNotSupported ) ; sl@0: sl@0: CMMFDataBuffer* buffer = CMMFDataBuffer::NewL(KMmfHeaderBufferSize) ; sl@0: CleanupStack::PushL( buffer ) ; sl@0: sl@0: aSource->SourcePrimeL(); sl@0: TCleanupItem srcCleanupItem(DoDataSourceStop, aSource); sl@0: CleanupStack::PushL(srcCleanupItem); sl@0: sl@0: STATIC_CAST( CMMFClip*, aSource )->ReadBufferL( buffer, 0 ) ; sl@0: sl@0: CleanupStack::Pop(); sl@0: aSource->SourceStopL(); sl@0: sl@0: // attempt to instantiate the format by header data sl@0: // if this fails, try using the file extension sl@0: CMMFFormatDecode* ret = NULL; sl@0: TInt err, errFile; sl@0: TRAP(err, ret = NewL( buffer->Data(), aSource, aPreferredSupplier )); sl@0: if (err != KErrNone && aSource->DataSourceType() == KUidMmfFileSource) sl@0: { sl@0: CMMFFile* mmfFile = static_cast (aSource); sl@0: TRAP(errFile, ret = NewL( mmfFile->FullName(), aSource, aPreferredSupplier )); sl@0: if (errFile == KErrNone) sl@0: err = errFile; sl@0: } sl@0: User::LeaveIfError(err); sl@0: sl@0: CleanupStack::PopAndDestroy() ; // buffer sl@0: return ret ; sl@0: sl@0: } sl@0: sl@0: /** sl@0: Attempts to locate and instantiate a CMMFFormatDecode using data from MDataSource. sl@0: sl@0: The data is expected to contain header data (from a file, stream or descriptor). Signatures sl@0: (supplied by the plugin registry information) are sought in aSource. sl@0: sl@0: @param aSource sl@0: Header data. Must be derived from CMMFClip. sl@0: @param aPreferredSupplier sl@0: If this is provided, the list of matching plugins will be further searched for the latest version of a sl@0: plugin supplied by the specified supplier. sl@0: @param aSupportsCustomInterfaces sl@0: Indicates whether the instantiated FormatDecode supports custom interfaces. sl@0: sl@0: @return If successful returns an instantiated CMMFFormatDecode from a plugin. If not successful, leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatDecode* CMMFFormatDecode::NewL( MDataSource* aSource, const TDesC& aPreferredSupplier, TBool& aSupportsCustomInterfaces ) sl@0: { sl@0: // Read header data from aSource. Call source header version sl@0: sl@0: if ( !( (aSource->DataSourceType() == KUidMmfFileSource ) || ( aSource->DataSourceType() == KUidMmfDescriptorSource) ) ) sl@0: User::Leave( KErrNotSupported ) ; sl@0: sl@0: CMMFDataBuffer* buffer = CMMFDataBuffer::NewL(KMmfHeaderBufferSize) ; sl@0: CleanupStack::PushL( buffer ) ; sl@0: sl@0: aSource->SourcePrimeL(); sl@0: TCleanupItem srcCleanupItem(DoDataSourceStop, aSource); sl@0: CleanupStack::PushL(srcCleanupItem); sl@0: sl@0: STATIC_CAST( CMMFClip*, aSource )->ReadBufferL( buffer, 0 ) ; sl@0: sl@0: CleanupStack::Pop(); sl@0: aSource->SourceStopL(); sl@0: sl@0: // attempt to instantiate the format by header data sl@0: // if this fails, try using the file extension sl@0: CMMFFormatDecode* ret = NULL; sl@0: TInt err, errFile; sl@0: TRAP(err, ret = NewL( buffer->Data(), aSource, aPreferredSupplier, aSupportsCustomInterfaces )); sl@0: if (err != KErrNone && aSource->DataSourceType() == KUidMmfFileSource) sl@0: { sl@0: CMMFFile* mmfFile = static_cast (aSource); sl@0: TRAP(errFile, ret = NewL( mmfFile->FullName(), aSource, aPreferredSupplier, aSupportsCustomInterfaces )); sl@0: if (errFile == KErrNone) sl@0: err = errFile; sl@0: } sl@0: User::LeaveIfError(err); sl@0: sl@0: CleanupStack::PopAndDestroy() ; // buffer sl@0: return ret ; sl@0: sl@0: } sl@0: sl@0: CMMFFormatEncode* CMMFFormatEncode::CreateFormatL(TUid aUid, MDataSink* aSink) sl@0: { sl@0: CMMFFormatEncode* s = REINTERPRET_CAST( CMMFFormatEncode*, sl@0: REComSession::CreateImplementationL( aUid, _FOFF( CMMFFormatEncode, iDtor_ID_Key ), sl@0: STATIC_CAST( TAny*, aSink ) ) ) ; sl@0: s->iImplementationUid = aUid; sl@0: return s; sl@0: } sl@0: sl@0: /** sl@0: Allocates and constructs an ECom format encode object. sl@0: sl@0: @param aUid sl@0: The implementation UID. sl@0: @param aSink sl@0: The data sink. sl@0: sl@0: @return If successful, returns the address of the format decode plugin object created. If not successful, sl@0: leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatEncode* CMMFFormatEncode::NewL( TUid aUid, MDataSink* aSink ) sl@0: { sl@0: return CreateFormatL(aUid, aSink); sl@0: } sl@0: sl@0: /** sl@0: Attempts to locate and instantiate a CMMFFormatEncode using a filename or an extension. sl@0: sl@0: Only the extension of the supplied file name is used. If no extension is supplied (ie. no dot is present) sl@0: the whole of the filename will be treated as the extension. sl@0: sl@0: @param aFileName sl@0: File name of target file. May be extension only or may include the full path. sl@0: @param aSink sl@0: The data source. sl@0: @param aPreferredSupplier sl@0: If this is provided, the list of matching plugins will be further searched for the latest version of a sl@0: plugin supplied by supplier named. sl@0: sl@0: @return If successful, returns the address of the format decode plugin object created. If not successful, sl@0: leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatEncode* CMMFFormatEncode::NewL( const TDesC16& aFileName, MDataSink* aSink, const TDesC& aPreferredSupplier ) sl@0: { sl@0: CMMFFormatEncodePluginSelectionParameters* pluginSelector = CMMFFormatEncodePluginSelectionParameters::NewLC(); sl@0: CMMFFormatSelectionParameters* formatParams = CMMFFormatSelectionParameters::NewLC(); sl@0: formatParams->SetMatchToFileNameL(aFileName); sl@0: pluginSelector->SetRequiredFormatSupportL(*formatParams); sl@0: if (aPreferredSupplier.Length() > 0) sl@0: pluginSelector->SetPreferredSupplierL(aPreferredSupplier, CMMFPluginSelectionParameters::EOnlyPreferredSupplierPluginsReturned); sl@0: sl@0: TUid chosenUid = MMFFormatEcomUtilities::SelectFormatPluginL(*pluginSelector); sl@0: sl@0: // Instantiate this format sl@0: CMMFFormatEncode* theChosenOne = CreateFormatL(chosenUid, aSink); sl@0: sl@0: // Now clean up. sl@0: CleanupStack::PopAndDestroy(2);//formatParams, pluginSelector sl@0: sl@0: return theChosenOne; sl@0: } sl@0: sl@0: /** sl@0: Attempts to locate and instantiate a CMMFFormatEncode using data in the specified buffer. sl@0: sl@0: The buffer is expected to contain header data (from a file, stream or descriptor). sl@0: Signatures (supplied by the plugin registry information) are sought in aSourceHeader. sl@0: sl@0: @param aSourceHeader sl@0: The data which is searched for matching signatures. sl@0: @param aSink sl@0: The data sink. sl@0: @param aPreferredSupplier sl@0: If this is provided the list of matching plugins will be further searched for the latest version of a sl@0: plugin supplied by supplier named. sl@0: sl@0: @return If successful, returns the address of the format decode plugin object created. If not successful, sl@0: leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatEncode* CMMFFormatEncode::NewL( const TDesC8& aSourceHeader, MDataSink* aSink, const TDesC& aPreferredSupplier ) sl@0: { sl@0: CMMFFormatEncodePluginSelectionParameters* pluginSelector = CMMFFormatEncodePluginSelectionParameters::NewLC(); sl@0: CMMFFormatSelectionParameters* formatParams = CMMFFormatSelectionParameters::NewLC(); sl@0: formatParams->SetMatchToHeaderDataL(aSourceHeader); sl@0: pluginSelector->SetRequiredFormatSupportL(*formatParams); sl@0: if (aPreferredSupplier.Length() > 0) sl@0: pluginSelector->SetPreferredSupplierL(aPreferredSupplier, CMMFPluginSelectionParameters::EOnlyPreferredSupplierPluginsReturned); sl@0: sl@0: TUid chosenUid = MMFFormatEcomUtilities::SelectFormatPluginL(*pluginSelector); sl@0: sl@0: // Instantiate this format sl@0: CMMFFormatEncode* theChosenOne = CreateFormatL(chosenUid, aSink); sl@0: sl@0: // Now clean up. sl@0: CleanupStack::PopAndDestroy(2);//formatParams, pluginSelector sl@0: sl@0: return theChosenOne; sl@0: } sl@0: sl@0: /** sl@0: Attempts to locate and instantiate a CMMFFormatEncode using data from aSink. sl@0: sl@0: The data is expected to contain header data (from a file, stream or descriptor). sl@0: Signatures (supplied by the plugin registry information) are sought in the source header. sl@0: sl@0: @param aSink sl@0: The header data. Must be derived from CMMFClip. sl@0: @param aPreferredSupplier sl@0: If this is provided, the list of matching plugins will be further searched for the latest version of a sl@0: plugin supplied by supplier specified. sl@0: sl@0: @return If successful, returns the address of the format decode plugin object created. If not successful, sl@0: leaves with KErrNotFound. sl@0: */ sl@0: EXPORT_C CMMFFormatEncode* CMMFFormatEncode::NewL( MDataSink* aSink, const TDesC& aPreferredSupplier ) sl@0: { sl@0: // Read header data from aSource. Call source header version if there is header data, file name version otherwise. sl@0: sl@0: if ( !( (aSink->DataSinkType() == KUidMmfFileSink ) || ( aSink->DataSinkType() == KUidMmfDescriptorSink) ) ) sl@0: User::Leave( KErrNotSupported ) ; sl@0: sl@0: CMMFDataBuffer* buffer = CMMFDataBuffer::NewL(KMmfHeaderBufferSize) ; sl@0: CleanupStack::PushL( buffer ) ; sl@0: sl@0: aSink->SinkPrimeL(); sl@0: TCleanupItem sinkCleanupItem(DoDataSinkStop, aSink); sl@0: CleanupStack::PushL(sinkCleanupItem); sl@0: sl@0: STATIC_CAST( CMMFClip*, aSink )->ReadBufferL( buffer, 0 ) ; sl@0: sl@0: CleanupStack::Pop(); sl@0: aSink->SinkStopL(); sl@0: sl@0: CMMFFormatEncode* ret = NULL ; // set to null to avoid compiler warning. sl@0: // Check for data in the buffer sl@0: if ( buffer->BufferSize() != 0 ) sl@0: ret = NewL( buffer->Data(), aSink, aPreferredSupplier ) ; sl@0: else if ( aSink->DataSinkType() == KUidMmfFileSink ) sl@0: ret = NewL( STATIC_CAST(CMMFFile*, aSink)->Extension(), aSink, aPreferredSupplier ) ; sl@0: else sl@0: User::Leave( KErrNotSupported ) ; sl@0: sl@0: CleanupStack::PopAndDestroy() ; // buffer sl@0: return ret ; sl@0: } sl@0: sl@0: sl@0: TUid MMFFormatEcomUtilities::SelectFormatPluginL(const CMMFFormatPluginSelectionParameters& aSelectParams) sl@0: { sl@0: RMMFFormatImplInfoArray pluginArray; sl@0: CleanupResetAndDestroyPushL(pluginArray); sl@0: aSelectParams.ListImplementationsL(pluginArray); sl@0: sl@0: // Just leave if no implementations were found sl@0: if (pluginArray.Count() == 0) sl@0: User::Leave(KErrNotSupported); sl@0: sl@0: // Return the uid of the first plugin in the list sl@0: TUid ret = pluginArray[0]->Uid(); sl@0: CleanupStack::PopAndDestroy();//pluginArray sl@0: return ret; sl@0: } sl@0: sl@0: /* sl@0: * instantiate each format decode plugin in turn until we find one that works sl@0: */ sl@0: CMMFFormatDecode* MMFFormatEcomUtilities::SelectFormatDecodePluginL(const CMMFFormatPluginSelectionParameters& aSelectParams, MDataSource* aSource) sl@0: { sl@0: RMMFFormatImplInfoArray pluginArray; sl@0: CleanupResetAndDestroyPushL(pluginArray); sl@0: aSelectParams.ListImplementationsL(pluginArray); sl@0: sl@0: TInt pluginCount = pluginArray.Count(); sl@0: CMMFFormatDecode* theChosenOne = NULL; sl@0: sl@0: TInt err = KErrNotSupported; sl@0: for (TInt n=0; nUid(), aSource)); sl@0: // Ensure OOM or any unexpected error is caught immediately sl@0: // i.e. don't try the next plugin sl@0: if (err != KErrNotSupported && err != KErrCorrupt && err != KErrArgument) sl@0: break; sl@0: } sl@0: User::LeaveIfError(err); sl@0: sl@0: CleanupStack::PopAndDestroy(&pluginArray); sl@0: sl@0: return theChosenOne; sl@0: } sl@0: sl@0: /* sl@0: * instantiate each format decode plugin in turn until we find one that works sl@0: */ sl@0: CMMFFormatDecode* MMFFormatEcomUtilities::SelectFormatDecodePluginL(const CMMFFormatPluginSelectionParameters& aSelectParams, MDataSource* aSource, TBool& aSupportsCustomInterfaces) sl@0: { sl@0: RMMFFormatImplInfoArray pluginArray; sl@0: CleanupResetAndDestroyPushL(pluginArray); sl@0: aSelectParams.ListImplementationsL(pluginArray); sl@0: sl@0: TInt pluginCount = pluginArray.Count(); sl@0: CMMFFormatDecode* theChosenOne = NULL; sl@0: sl@0: TInt err = KErrNotSupported; sl@0: CMMFFormatImplementationInformation* implInfo = NULL; sl@0: for (TInt n=0; nUid(), aSource)); sl@0: // Ensure OOM or any unexpected error is caught immediately sl@0: // i.e. don't try the next plugin sl@0: if (err != KErrNotSupported && err != KErrCorrupt && err != KErrArgument) sl@0: break; sl@0: } sl@0: User::LeaveIfError(err); sl@0: aSupportsCustomInterfaces = implInfo->SupportsCustomInterfaces(); sl@0: sl@0: CleanupStack::PopAndDestroy(&pluginArray); sl@0: sl@0: return theChosenOne; sl@0: } sl@0: