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: sl@0: #include "mmfclientaudioconverter.h" sl@0: sl@0: // declared in the recorder module sl@0: void Panic(TInt aPanicCode); sl@0: sl@0: //CMdaAudioConvertUtility sl@0: sl@0: sl@0: /** sl@0: Returns the current utility state. sl@0: sl@0: @return The state of the audio sample data. See CMdaAudioClipUtility::TState. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: CMdaAudioClipUtility::TState CMdaAudioConvertUtility::State() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->State(); sl@0: } sl@0: sl@0: /** sl@0: Closes the current audio clip. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::Close() sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->Close(); sl@0: } sl@0: sl@0: /** sl@0: This function is mapped to ConvertL(). ConvertL() should be used instead. sl@0: sl@0: @see ConvertL() sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::PlayL() sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->PlayL(); sl@0: } sl@0: sl@0: /** sl@0: This function is mapped to ConvertL. ConvertL() should be used instead. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::RecordL() sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->RecordL(); sl@0: } sl@0: sl@0: /** sl@0: Stops the current operation (playback/recording/conversion). sl@0: sl@0: When conversion has been stopped, successfully or otherwise, the client is notified by sl@0: MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function sl@0: providing it with state change information and error codes. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::Stop() sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->Stop(); sl@0: } sl@0: sl@0: /** sl@0: Crops the current clip from the current position. The remainder of the clip is discarded. sl@0: sl@0: The effects of the function cannot be undone. The function is synchronous and can leave if there is sl@0: a problem. The leave code depends on the configuration. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::CropL() sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->CropL(ETrue); sl@0: } sl@0: sl@0: /** sl@0: Sets the current position in the audio clip. sl@0: sl@0: A subsequent call to ConvertL() starts conversion from this new position. sl@0: sl@0: @param aPosition sl@0: The position in the audio clip, in microseconds. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::SetPosition(const TTimeIntervalMicroSeconds& aPosition) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->SetPosition(aPosition); sl@0: } sl@0: sl@0: /** sl@0: Returns the current position in the audio clip. The position is defined in terms of a time interval sl@0: measured from the beginning of the audio sample data. sl@0: sl@0: @return The current position in the audio clip, in microseconds. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: const TTimeIntervalMicroSeconds& CMdaAudioConvertUtility::Position() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->Position(); sl@0: } sl@0: sl@0: /** sl@0: Returns the amount of recording time available to the current clip. sl@0: sl@0: @return The recording time available measured in microseconds. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: const TTimeIntervalMicroSeconds& CMdaAudioConvertUtility::RecordTimeAvailable() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->RecordTimeAvailable(); sl@0: } sl@0: sl@0: /** sl@0: Returns the duration of the audio clip. sl@0: sl@0: @return The duration in microseconds. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: const TTimeIntervalMicroSeconds& CMdaAudioConvertUtility::Duration() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->Duration(); sl@0: } sl@0: sl@0: /** sl@0: Sets a window for playback. sl@0: sl@0: The window is defined in terms of a start and end time. A subsequent call to ConvertL() results sl@0: in just the data within the window being converted. sl@0: sl@0: @param aStart sl@0: The position in the clip to start playback, in microseconds. This must be any value from zero sl@0: to aEnd. If this value is less than zero or greater than aEnd, this function raises sl@0: EMMFMediaClientPanicServerCommunicationProblem panic in debug version. sl@0: @param aEnd sl@0: The position in the clip to end playback, in microseconds. This must be any value from aStart sl@0: to the value returned by Duration(). If this value is greater than the value returned by sl@0: Duration() or less than aStart, this function raises EMMFMediaClientPanicServerCommunicationProblem panic in debug version. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->SetPlayWindow(aStart, aEnd); sl@0: } sl@0: sl@0: /** sl@0: Clears the playback window. sl@0: sl@0: Playback returns to playing the entire clip. A subsequent call to ConvertL() results in the entire sl@0: source audio being converted. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::ClearPlayWindow() sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->ClearPlayWindow(); sl@0: } sl@0: sl@0: /** sl@0: Sets the number of repetitions for playback. This is unsupported for CMdaConvertUtility as there is sl@0: no playback facility. It is provided only for binary compatibility. sl@0: sl@0: @param aRepeatNumberOfTimes sl@0: The number of times to repeat the audio clip, after the first playback. If this is set to sl@0: KMdaRepeatForever, then the audio sample, together with the trailing silence, is repeated sl@0: indefinitely. If this is set to zero, then the audio sample is not repeated. sl@0: @param aTrailingSilence sl@0: A delay to wait before each repetition. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->SetRepeats(aRepeatNumberOfTimes, aTrailingSilence); sl@0: } sl@0: sl@0: /** sl@0: Sets the maximum size of an audio clip. sl@0: sl@0: This function is provided so that applications such as recorders and converters can limit the amount sl@0: of file storage/memory that should be allocated. sl@0: sl@0: @param aMaxWriteLength sl@0: The maximum size of the audio clip, in bytes. If the default value is used, there is no sl@0: maximum file size. sl@0: sl@0: @since 7.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::SetMaxWriteLength(TInt aMaxWriteLength /* = KMdaClipLocationMaxWriteLengthNone*/) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->SetMaxWriteLength(aMaxWriteLength); sl@0: } sl@0: sl@0: /** sl@0: Crops the audio clip from the start of the file to the current position. The audio data sl@0: prior to the current position is discarded. sl@0: sl@0: The effects of the function cannot be undone. sl@0: sl@0: The function is synchronous and can leave if there is a problem. The leave code depends on the sl@0: configuration. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: void CMdaAudioConvertUtility::CropFromBeginningL() sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->CropL(EFalse); sl@0: } sl@0: sl@0: /** sl@0: Constructs and initialises a new instance of the audio converter for converting audio sample data sl@0: from one format to another. sl@0: sl@0: The function leaves if the audio converter object cannot be created. sl@0: sl@0: @param aObserver sl@0: The class to receive state change events from converter. sl@0: @param aServer sl@0: No longer used, should be NULL. sl@0: @param aPriority sl@0: The Priority Value - this client's relative priority. This is a value between EMdaPriorityMin and sl@0: EMdaPriorityMax and represents a relative priority. A higher value indicates a more important request. sl@0: @param aPref sl@0: The Priority Preference - an additional audio policy parameter. The suggested default is sl@0: EMdaPriorityPreferenceNone. Further values are given by TMdaPriorityPreference, and additional sl@0: values may be supported by given phones and/or platforms, but should not be depended upon by sl@0: portable code. sl@0: sl@0: @return A pointer to a new instance of CMdaAudioConvertUtility. sl@0: sl@0: @since 5.0 sl@0: sl@0: Note: The Priority Value and Priority Preference are used primarily when deciding what to do when sl@0: several audio clients attempt to play or record simultaneously. In addition to the Priority Value and Preference, sl@0: the adaptation may consider other parameters such as the SecureId and Capabilities of the client process. sl@0: Whatever, the decision as to what to do in such situations is up to the audio adaptation, and may sl@0: vary between different phones. Portable applications are advised not to assume any specific behaviour. sl@0: */ sl@0: EXPORT_C CMdaAudioConvertUtility* CMdaAudioConvertUtility::NewL(MMdaObjectStateChangeObserver& aObserver, sl@0: CMdaServer* /*aServer*/, sl@0: TInt aPriority, sl@0: TInt aPref) sl@0: { sl@0: CMdaAudioConvertUtility* self = new(ELeave) CMdaAudioConvertUtility(); sl@0: CleanupStack::PushL(self); sl@0: self->iProperties = new(ELeave) CMMFMdaAudioConvertUtility(self, aObserver); sl@0: self->iProperties->ConstructL(aPriority, aPref); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: /** sl@0: Destructor. sl@0: sl@0: Closes the audio clip and frees resources. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: CMdaAudioConvertUtility::~CMdaAudioConvertUtility() sl@0: { sl@0: delete iProperties; sl@0: } sl@0: sl@0: /** sl@0: Ensures that any subsequent calls to OpenXYZ() will create controllers that sl@0: share a heap. sl@0: sl@0: The default behaviour is that for each converter utility a controller with its own heap sl@0: is created. Each heap uses a chunk, so using this function avoids situations where sl@0: the number of chunks per process is limited. sl@0: The default behaviour is generally to be preferred, and should give lower overall sl@0: memory usage. However, if many controllers are to be created for a particular thread, sl@0: then this function should be used to prevent running out of heaps or chunks. sl@0: sl@0: @since 9.2 sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::UseSharedHeap() sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->UseSharedHeap(); sl@0: } sl@0: sl@0: /** sl@0: Opens source and target files (both of which must already exist) so that audio sample data can be sl@0: extracted from the source file, converted and appended to the target file. sl@0: sl@0: When opening is complete, successfully or otherwise, the client is notified by sl@0: MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function sl@0: providing it with state change information and error codes. sl@0: sl@0: @param aPrimaryFile sl@0: The full path and filename of a file containing audio sample data to be converted. sl@0: @param aSecondaryFile sl@0: The full path and filename of a file to which converted data is appended. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, const TDesC& aSecondaryFile) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->OpenL(aPrimaryFile, aSecondaryFile); sl@0: } sl@0: sl@0: /** sl@0: Opens an existing audio file so that audio sample data can be extracted from it, converted and sl@0: placed into the target audio object. sl@0: sl@0: When opening is complete, successfully or otherwise, the client is notified by sl@0: MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function sl@0: providing it with state change information and error codes. sl@0: sl@0: @param aPrimaryFile sl@0: The full path and filename of a file containing audio sample data to be converted. sl@0: @param aLocation sl@0: The target location for the audio data. This is normally a file (TMdaFileClipLocation) or a sl@0: descriptor (TMdaDesClipLocation). sl@0: @param aFormat sl@0: The audio format for the target audio object. sl@0: @param aArg1 sl@0: The codec to use for the target audio object. sl@0: @param aArg2 sl@0: The audio settings for the target audio object. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, TMdaClipLocation* aLocation, TMdaClipFormat* aFormat, sl@0: TMdaPackage* aArg1 /*= NULL*/, TMdaPackage* aArg2 /*= NULL*/) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->OpenL(aPrimaryFile, aLocation, aFormat, aArg1, aArg2); sl@0: } sl@0: sl@0: /** sl@0: Opens an audio clip for conversion. sl@0: sl@0: @param aPriLocation sl@0: The source location for audio data. This is normally a file (TMdaFileClipLocation) or a sl@0: descriptor (TMdaDesClipLocation). sl@0: @param aSecLocation sl@0: The target location for audio data. This is normally a file (TMdaFileClipLocation) or a sl@0: descriptor (TMdaDesClipLocation). sl@0: @param aPriFormat sl@0: The audio format of the source audio object. sl@0: @param aSecFormat sl@0: The audio format for the target audio object. sl@0: @param aPriArg1 sl@0: The codec used by the source audio object. sl@0: @param aPriArg2 sl@0: The audio settings of the source audio object. sl@0: @param aSecArg1 sl@0: The codec to be used for the target audio object. sl@0: @param aSecArg2 sl@0: The audio settings for the target audio object. sl@0: sl@0: @since 5.0 sl@0: */ sl@0: void CMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation, sl@0: TMdaClipFormat* aPriFormat, TMdaClipFormat* aSecFormat, sl@0: TMdaPackage* aPriArg1 /*= NULL*/, TMdaPackage* aPriArg2 /*= NULL*/, sl@0: TMdaPackage* aSecArg1 /*= NULL*/, TMdaPackage* aSecArg2 /*= NULL*/) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->OpenL(aPriLocation, aSecLocation, aPriFormat, aSecFormat, aPriArg1, aPriArg2, aSecArg1, aSecArg2); sl@0: } sl@0: sl@0: // New functions for 7.0s sl@0: /** sl@0: Opens source and target audio objects and specifies controller and audio format and codec sl@0: information. sl@0: sl@0: When opening is complete, successfully or otherwise, the client is notified by sl@0: MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function sl@0: providing it with state change information and error codes. sl@0: sl@0: @param aPriLocation sl@0: The source location for audio data. This is normally a file (TMdaFileClipLocation) or a sl@0: descriptor (TMdaDesClipLocation). sl@0: @param aSecLocation sl@0: The destination location for the converted audio data. This is normally a file sl@0: (TMdaFileClipLocation) or a descriptor (TMdaDesClipLocation). sl@0: @param aControllerUid sl@0: The UID of the controller to used for conversion. sl@0: @param aDestFormatUid sl@0: The UID of the destination format. sl@0: @param aDestDataType sl@0: The audio codec to use for the destination data sink. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation, TUid aControllerUid, sl@0: TUid aDestFormatUid, TFourCC aDestDataType) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->OpenL(aPriLocation, aSecLocation, aControllerUid, aDestFormatUid, aDestDataType); sl@0: } sl@0: sl@0: /** sl@0: Returns a list of the supported data types for the conversion destination. sl@0: sl@0: @param aSupportedDestinationDataTypes sl@0: A list of four character codes, representing the supported data sl@0: encodings for the conversion destination. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::GetSupportedDestinationDataTypesL(RArray& aSupportedDestinationDataTypes) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->GetSupportedDestinationDataTypesL(aSupportedDestinationDataTypes); sl@0: } sl@0: sl@0: /** sl@0: Sets the data type of the destination audio clip. sl@0: sl@0: @param aCodec sl@0: The four character code, representing the encoding of the destination audio clip sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::SetDestinationDataTypeL(TFourCC aCodec) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->SetDestinationDataTypeL(aCodec); sl@0: } sl@0: sl@0: /** sl@0: Returns the data type of the destination audio clip. sl@0: sl@0: @return The four character code, representing the encoding of the destination audio clip. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TFourCC CMdaAudioConvertUtility::DestinationDataTypeL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->DestinationDataTypeL(); sl@0: } sl@0: sl@0: /** sl@0: Returns the data type of the source audio clip. sl@0: sl@0: @return The four character code, representing the encoding of the source audio clip. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TFourCC CMdaAudioConvertUtility::SourceDataTypeL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->SourceDataTypeL(); sl@0: } sl@0: sl@0: /** sl@0: Sets the bit rate of the destination audio clip. sl@0: sl@0: The bit rate must be one of the supported bit rates of the audio target. Use sl@0: GetSupportedConversionBitRatesL() to retrieve a list of supported bit rates. sl@0: sl@0: @param aBitRate sl@0: The destination bit rate in bits/second. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::SetDestinationBitRateL(TUint aBitRate) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->SetDestinationBitRateL(aBitRate); sl@0: } sl@0: sl@0: /** sl@0: Returns the bit rate of the destination audio clip. sl@0: sl@0: @return The destination bit rate in bits/second. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TUint CMdaAudioConvertUtility::DestinationBitRateL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->DestinationBitRateL(); sl@0: } sl@0: sl@0: /** sl@0: Gets a list of the supported bit rates for the conversion destination. sl@0: sl@0: @param aSupportedBitRates sl@0: The list of bit rates supported for the conversion destination. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::GetSupportedConversionBitRatesL(RArray& aSupportedBitRates) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->GetSupportedConversionBitRatesL(aSupportedBitRates); sl@0: } sl@0: sl@0: /** sl@0: Returns the bit rate of the source audio clip. sl@0: sl@0: @return The source bit rate in bits/second. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TInt CMdaAudioConvertUtility::SourceBitRateL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->SourceBitRateL(); sl@0: } sl@0: sl@0: /** sl@0: Sets the sample rate for the conversion destination. sl@0: sl@0: The sample rate must be one of the supported sample rates of the audio target. Use sl@0: GetSupportedConversionSampleRatesL() to retrieve a list of supported sample rates. sl@0: This function should not be used if the audio clip already exists; that is, in the sl@0: "Open and Append" scenario, when the function's behaviour is undefined. sl@0: sl@0: @param aSampleRate sl@0: The sample rate of the conversion destination in samples per second. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::SetDestinationSampleRateL(TUint aSampleRate) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->SetDestinationSampleRateL(aSampleRate); sl@0: } sl@0: sl@0: /** sl@0: Returns the sample rate of the conversion destination. sl@0: sl@0: @return The sample rate of the conversion destination in samples per second. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TUint CMdaAudioConvertUtility::DestinationSampleRateL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->DestinationSampleRateL(); sl@0: } sl@0: sl@0: /** sl@0: Gets a list of supported conversion sample rates. This is a list of the sample rates that sl@0: the conversion destination can take. sl@0: sl@0: @param aSupportedSampleRates sl@0: A list of the sample rates that are supported for the conversion. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::GetSupportedConversionSampleRatesL(RArray& aSupportedSampleRates) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->GetSupportedConversionSampleRatesL(aSupportedSampleRates); sl@0: } sl@0: sl@0: /** sl@0: Returns the sample rate of the source audio clip. sl@0: sl@0: @return The source sample rate in samples/second. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TUint CMdaAudioConvertUtility::SourceSampleRateL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->SourceSampleRateL(); sl@0: } sl@0: sl@0: /** sl@0: Sets the format of the destination audio clip. sl@0: sl@0: The UID (aFormatUid) corresponds to the UID of the destination format to use. sl@0: sl@0: @param aFormatUid sl@0: The UID of the destination format. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::SetDestinationFormatL(TUid aFormatUid) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->SetDestinationFormatL(aFormatUid); sl@0: } sl@0: sl@0: /** sl@0: Returns the format of the destination audio clip. sl@0: sl@0: @return The UID of the destination format. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TUid CMdaAudioConvertUtility::DestinationFormatL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->DestinationFormatL(); sl@0: } sl@0: sl@0: /** sl@0: Returns the format of the source audio clip. sl@0: sl@0: @return The UID of the source format. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TUid CMdaAudioConvertUtility::SourceFormatL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->SourceFormatL(); sl@0: } sl@0: sl@0: /** sl@0: Sets the number of channels the destination audio clip contains. sl@0: sl@0: The number of channels must be one of the values returned by sl@0: GetSupportedConversionNumberOfChannelsL(). sl@0: sl@0: @param aNumberOfChannels sl@0: The number of channels. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::SetDestinationNumberOfChannelsL(TUint aNumberOfChannels) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->SetDestinationNumberOfChannelsL(aNumberOfChannels); sl@0: } sl@0: sl@0: /** sl@0: Returns the number of channels the destination audio clip contains. sl@0: sl@0: @return The number of channels. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TUint CMdaAudioConvertUtility::DestinationNumberOfChannelsL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->DestinationNumberOfChannelsL(); sl@0: } sl@0: sl@0: /** sl@0: Returns a list of the supported number of channels for conversion. sl@0: sl@0: For example, 1 for mono, 2 for stereo and so on. sl@0: sl@0: @param aSupportedNumChannels sl@0: A list of the number of channels supported for the conversion destination. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::GetSupportedConversionNumberOfChannelsL(RArray& aSupportedNumChannels) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->GetSupportedConversionNumberOfChannelsL(aSupportedNumChannels); sl@0: } sl@0: sl@0: /** sl@0: Returns the number of channels used by the conversion source. sl@0: sl@0: @return The number of channels. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TUint CMdaAudioConvertUtility::SourceNumberOfChannelsL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->SourceNumberOfChannelsL(); sl@0: } sl@0: /** sl@0: Performs the conversion from the source audio format to the destination. sl@0: sl@0: When conversion is complete, successfully or otherwise, the client is notified by sl@0: MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function sl@0: providing it with state change information and error codes. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::ConvertL() sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->ConvertL(); sl@0: } sl@0: sl@0: /** sl@0: Returns the controller implementation information associated with the current controller. sl@0: sl@0: @return The controller implementation structure associated with the controller sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C const CMMFControllerImplementationInformation& CMdaAudioConvertUtility::ControllerImplementationInformationL() sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->ControllerImplementationInformationL(); sl@0: } sl@0: sl@0: /** sl@0: Sends a synchronous custom command to the controller. sl@0: sl@0: @param aDestination sl@0: The destination of the message, consisting of the UID of the interface of this message. sl@0: @param aFunction sl@0: The function number to indicate which function is to be called sl@0: on the interface defined in the aDestination parameter. sl@0: @param aDataTo1 sl@0: A reference to the first chunk of data to be copied to the controller sl@0: framework. The exact contents of the data are dependent on the sl@0: interface being called. Can be KNullDesC8. sl@0: @param aDataTo2 sl@0: A reference to the second chunk of data to be copied to the controller sl@0: framework. The exact contents of the data are dependent on the sl@0: interface being called. Can be KNullDesC8. sl@0: @param aDataFrom sl@0: A reference to an area of memory to which the controller framework will sl@0: write any data to be passed back to the client. Can't be KNullDesC8. sl@0: sl@0: @return The result of the request. Exact range of values is dependent on the interface. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TInt CMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom) sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom); sl@0: } sl@0: sl@0: /** sl@0: Sends a synchronous custom command to the controller. sl@0: sl@0: @param aDestination sl@0: The destination of the message, consisting of the UID of the interface of this message. sl@0: @param aFunction sl@0: The function number to indicate which function is to be called on the interface defined in sl@0: the aDestination parameter. sl@0: @param aDataTo1 sl@0: A reference to the first chunk of data to be copied to the controllert framework. The exact sl@0: contents of the data are dependent on the interface being called. Can be KNullDesC8. sl@0: @param aDataTo2 sl@0: A reference to the second chunk of data to be copied to the controller framework. The exact sl@0: contents of the data are dependent on the interface being called. Can be KNullDesC8. sl@0: sl@0: @return The result of the request. The exact range of values is dependent on the interface. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C TInt CMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2) sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2); sl@0: } sl@0: sl@0: /** sl@0: Send a asynchronous custom command to the controller. sl@0: sl@0: Note: This method will return immediately. The RunL of the active object owning the sl@0: aStatus parameter will be called when the command is completed by the controller framework. sl@0: sl@0: @param aDestination sl@0: The destination of the message, consisting of the UID of the interface of this message. sl@0: @param aFunction sl@0: The function number to indicate which function is to be called on the interface defined in sl@0: the aDestination parameter. sl@0: @param aDataTo1 sl@0: A reference to the first chunk of data to be copied to the controller framework. The exact sl@0: contents of the data are dependent on the interface being called. Can be KNullDesC8. sl@0: @param aDataTo2 sl@0: A reference to the second chunk of data to be copied to the controller framework. The exact sl@0: contents of the data are dependent on the interface being called. Can be KNullDesC8. sl@0: @param aDataFrom sl@0: A reference to an area of memory to which the controller framework will write any data to be sl@0: passed back to the client. Can't be KNullDesC8. sl@0: @param aStatus sl@0: The TRequestStatus of an active object. This will contain the result of the request on sl@0: completion. The exact range of result values is dependent on the interface. sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom, aStatus); sl@0: } sl@0: sl@0: /** sl@0: Send a asynchronous custom command to the controller. sl@0: sl@0: Note: This method will return immediately. The RunL of the active object owning the sl@0: aStatus parameter will be called when the command is completed by the controller framework. sl@0: sl@0: @param aDestination sl@0: The destination of the message, consisting of the UID of the interface of this message. sl@0: @param aFunction sl@0: The function number to indicate which function is to be called on the interface defined in sl@0: the aDestination parameter. sl@0: @param aDataTo1 sl@0: A reference to the first chunk of data to be copied to the controller framework. The exact sl@0: contents of the data are dependent on the interface being called. Can be KNullDesC8. sl@0: @param aDataTo2 sl@0: A reference to the second chunk of data to be copied to the controller framework. The exact sl@0: contents of the data are dependent on the interface being called. Can be KNullDesC8. sl@0: @param aStatus sl@0: The TRequestStatus of an active object. This will contain the result of the request on sl@0: completion. The exact range of result values is dependent on the interface. sl@0: sl@0: @since 7.0s sl@0: */ sl@0: EXPORT_C void CMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus) sl@0: { sl@0: ASSERT(iProperties); sl@0: iProperties->CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aStatus); sl@0: } sl@0: sl@0: /** sl@0: Set the priority of the controller's sub thread. sl@0: sl@0: This can be used to increase the responsiveness of the audio plugin to minimise sl@0: any lag in processing. This function should be used with care as it may have knock-on sl@0: effects elsewhere in the system. sl@0: sl@0: @param aPriority sl@0: The TThreadPriority that the thread should run under. The default is EPriorityNormal. sl@0: @return TInt sl@0: A standard error code: KErrNone if successful, KErrNotReady if the thread does not have a sl@0: valid handle. sl@0: */ sl@0: EXPORT_C TInt CMdaAudioConvertUtility::SetThreadPriority(const TThreadPriority& aThreadPriority) const sl@0: { sl@0: ASSERT(iProperties); sl@0: return iProperties->SetThreadPriority(aThreadPriority); sl@0: } sl@0: sl@0: sl@0: /******************************************************************************/ sl@0: sl@0: sl@0: CMMFMdaAudioConvertUtility::CMMFMdaAudioConvertUtility(CMdaAudioConvertUtility* aParent, sl@0: MMdaObjectStateChangeObserver& aCallback) : sl@0: iCallback(aCallback), sl@0: iAudioControllerCustomCommands(iController), sl@0: iAudioPlayControllerCustomCommands(iController), sl@0: iAudioRecordControllerCustomCommands(iController), sl@0: iParent(aParent), sl@0: iHasCropped(EFalse), sl@0: iCroppedDuration(0) sl@0: { sl@0: iConvertStart = TTimeIntervalMicroSeconds(0); sl@0: iConvertEnd = TTimeIntervalMicroSeconds(0); sl@0: iConvertWindowSet = EFalse; sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::ConstructL(TInt /*aPriority*/, TInt /*aPref*/) sl@0: { sl@0: iControllerEventMonitor = CMMFControllerEventMonitor::NewL(*this, iController); sl@0: iAsyncCallback = CMMFMdaObjectStateChangeObserverCallback::NewL(iCallback); sl@0: User::LeaveIfError(iMediaIds.Append(KUidMediaTypeAudio)); sl@0: iFindAndOpenController = CMMFFindAndOpenController::NewL(*this); sl@0: iFindAndOpenController->Configure(iMediaIds[0], iPrioritySettings); sl@0: iFindAndOpenController->ConfigureController(iController, *iControllerEventMonitor, CMMFFindAndOpenController::EConvert); sl@0: } sl@0: sl@0: CMMFMdaAudioConvertUtility::~CMMFMdaAudioConvertUtility() sl@0: { sl@0: delete iControllerImplementationInformation; sl@0: delete iAsyncCallback; sl@0: delete iFindAndOpenController; sl@0: delete iControllerEventMonitor; sl@0: iMediaIds.Close(); sl@0: iController.Close(); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::UseSharedHeap() sl@0: { sl@0: iFindAndOpenController->UseSharedHeap(); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::MfaocComplete( sl@0: TInt& aError, sl@0: RMMFController* /*aController*/, sl@0: TUid aControllerUid, sl@0: TMMFMessageDestination* /*aSourceHandle*/, sl@0: TMMFMessageDestination* /*aSinkHandle*/) sl@0: { sl@0: TInt oldState = iState; sl@0: sl@0: if (aError == KErrNone) sl@0: { sl@0: iControllerUid = aControllerUid; sl@0: aError = ControllerOpen(); sl@0: if (iFindAndOpenController) sl@0: { sl@0: iFindAndOpenController->Close(); sl@0: } sl@0: } sl@0: sl@0: iAsyncCallback->CallBack(iParent, oldState, iState, aError); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation, sl@0: TMdaClipLocation* aSecLocation, sl@0: TMdaClipFormat* aPriFormat, sl@0: TMdaClipFormat* aSecFormat, sl@0: TMdaPackage* aPriArg1 /*= NULL*/, sl@0: TMdaPackage* aPriArg2 /*= NULL*/, sl@0: TMdaPackage* aSecArg1 /*= NULL*/, sl@0: TMdaPackage* aSecArg2 /*= NULL*/) sl@0: { sl@0: __ASSERT_ALWAYS((aPriLocation && aSecLocation && aPriFormat && aSecFormat), User::Leave(KErrArgument)); sl@0: sl@0: __ASSERT_ALWAYS((((aPriLocation->Uid() == KUidMdaFileResLoc) || (aPriLocation->Uid() == KUidMdaDesResLoc) || (aPriLocation->Uid() == KUidMdaUrlResLoc)) && sl@0: ((aSecLocation->Uid() == KUidMdaFileResLoc) || (aSecLocation->Uid() == KUidMdaDesResLoc) || (aSecLocation->Uid() == KUidMdaUrlResLoc))), sl@0: User::Leave(KErrNotSupported)); sl@0: sl@0: __ASSERT_ALWAYS(((aPriFormat->Uid() != KNullUid) && (aSecFormat->Uid() != KNullUid)), User::Leave(KErrNotSupported)); sl@0: sl@0: Reset(); sl@0: sl@0: //Do aPriArg2 & aSecArg2 contain the correct package type sl@0: if(aPriArg2) sl@0: { sl@0: TMdaPackage* pckg = aPriArg2; sl@0: if(pckg->Uid() != KUidMdaMediaTypeAudio) sl@0: User::Leave(KErrNotSupported); sl@0: sl@0: TMdaAudioDataSettings audioSettings = *(TMdaAudioDataSettings*)aPriArg2; sl@0: iSourceSampleRate = audioSettings.iSampleRate; sl@0: iSourceChannels = audioSettings.iChannels; sl@0: } sl@0: sl@0: if(aSecArg2) sl@0: { sl@0: TMdaPackage* pckg = aSecArg2; sl@0: if(pckg->Uid() != KUidMdaMediaTypeAudio) sl@0: User::Leave(KErrNotSupported); sl@0: TMdaAudioDataSettings audioSettings = *(TMdaAudioDataSettings*)aSecArg2; sl@0: iSinkSampleRate = audioSettings.iSampleRate; sl@0: iSinkChannels = audioSettings.iChannels; sl@0: } sl@0: sl@0: sl@0: //Do aPriArg1 & aSecArg1 contain supported FourCC types sl@0: iSourceDataType = KMMFFourCCCodeNULL; sl@0: if (aPriArg1) sl@0: { sl@0: iSourceDataType = CMMFClientUtility::ConvertMdaCodecToFourCC(*aPriArg1); sl@0: if(iSourceDataType == KMMFFourCCCodeNULL) sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: iSinkDataType = KMMFFourCCCodeNULL; sl@0: if (aSecArg1) sl@0: { sl@0: iSinkDataType = CMMFClientUtility::ConvertMdaCodecToFourCC(*aSecArg1); sl@0: if(iSinkDataType == KMMFFourCCCodeNULL) sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: sl@0: sl@0: TInt err = KErrNone; sl@0: sl@0: iSourceFormatUid = CMMFClientUtility::ConvertMdaFormatUidToECOMRead(aPriFormat->Uid()); sl@0: //If a new formatter plugin has been added, use the supplied read format implementation ID sl@0: if (iSourceFormatUid == KNullUid) sl@0: iSourceFormatUid = aPriFormat->Uid(); sl@0: sl@0: iSinkFormatUid = CMMFClientUtility::ConvertMdaFormatUidToECOMWrite(aSecFormat->Uid()); sl@0: //If a new formatter plugin has been added, use the supplied write format implementation ID sl@0: if (iSinkFormatUid == KNullUid) sl@0: iSinkFormatUid = aSecFormat->Uid(); sl@0: sl@0: TRAP(err, ConfigureSourceSinkL(aPriLocation, aSecLocation)); sl@0: sl@0: if (!err) sl@0: iFindAndOpenController->OpenByFormatUid(iSourceFormatUid, iSinkFormatUid); sl@0: sl@0: if (err) sl@0: { sl@0: TInt oldState = State(); sl@0: iAsyncCallback->CallBack(iParent, oldState, oldState, err); sl@0: return; sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: void CMMFMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, const TDesC& aSecondaryFile) sl@0: { sl@0: Reset(); sl@0: sl@0: iFindAndOpenController->ConfigureSourceSink( sl@0: CMMFFindAndOpenController::TSourceSink(KUidMmfFileSource, CMMFFindAndOpenController::GetConfigFile(aPrimaryFile)), sl@0: CMMFFindAndOpenController::TSourceSink(KUidMmfFileSink, CMMFFindAndOpenController::GetConfigFile(aSecondaryFile))); sl@0: sl@0: TMMFileSource tfs(aPrimaryFile); sl@0: iFindAndOpenController->OpenByFileSource(tfs, aSecondaryFile); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, sl@0: TMdaClipLocation* aLocation, // Normally file or descriptor sl@0: TMdaClipFormat* aFormat, // Data format sl@0: TMdaPackage* aArg1, // Normally codec to use sl@0: TMdaPackage* aArg2) // Normally audio settings sl@0: { sl@0: __ASSERT_ALWAYS(aLocation && aFormat, User::Leave(KErrArgument)); sl@0: sl@0: Reset(); sl@0: sl@0: // convert from the old parameters sl@0: if (aFormat) sl@0: { sl@0: iSinkFormatUid = CMMFClientUtility::ConvertMdaFormatUidToECOMWrite(aFormat->Uid()); sl@0: sl@0: //If a new formatter plugin has been added, use the supplied format ID sl@0: if (iSinkFormatUid == KNullUid) sl@0: iSinkFormatUid = aFormat->Uid(); sl@0: } sl@0: sl@0: if (aArg1) sl@0: iSinkDataType = CMMFClientUtility::ConvertMdaCodecToFourCC(*aArg1); sl@0: sl@0: if (aArg2) sl@0: {//have audio settings sl@0: TMdaAudioDataSettings audioSettings = *(TMdaAudioDataSettings*)aArg2; //shoud check arg2 are data settings sl@0: iSinkSampleRate = audioSettings.iSampleRate; sl@0: iSinkChannels = audioSettings.iChannels; sl@0: } sl@0: sl@0: sl@0: sl@0: TMMFFileConfig sourceCfg; sl@0: sourceCfg().iPath = aPrimaryFile; sl@0: sl@0: TMMFDescriptorConfig dstDesCfg; sl@0: TMMFFileConfig dstFileCfg; sl@0: CBufFlat* dstCfgBuffer = NULL; sl@0: CMMFUrlParams* dstURLCfg = NULL; sl@0: TUid dstUid = KNullUid; sl@0: TPtrC8 dstCfg(NULL, 0); sl@0: sl@0: TInt err = KErrNone; sl@0: sl@0: if (aLocation->Uid() == KUidMdaFileResLoc) sl@0: {//sink clip location is a file sl@0: TDesC& fileName = ((TMdaFileClipLocation*)aLocation)->iName; sl@0: dstFileCfg().iPath = fileName; sl@0: dstCfg.Set(dstFileCfg); sl@0: dstUid = KUidMmfFileSink; sl@0: } sl@0: else if (aLocation->Uid() == KUidMdaDesResLoc) sl@0: {//sink clip is a descriptor - pass down descriptor & thread id sl@0: TMdaDesClipLocation* desLoc = (TMdaDesClipLocation*)aLocation; sl@0: dstDesCfg().iDes = desLoc->iDes; sl@0: dstDesCfg().iDesThreadId = desLoc->iThreadId; sl@0: dstCfg.Set(dstDesCfg); sl@0: dstUid = KUidMmfDescriptorSink; sl@0: } sl@0: else if (aLocation->Uid() == KUidMdaUrlResLoc) sl@0: { sl@0: TMdaUrlClipLocation* desLoc = (TMdaUrlClipLocation*)aLocation; sl@0: dstURLCfg = CMMFUrlParams::NewLC(desLoc->iUrl, desLoc->iIapId); sl@0: dstCfgBuffer = dstURLCfg->ExternalizeToCBufFlatLC(); sl@0: dstCfg.Set(dstCfgBuffer->Ptr(0)); sl@0: dstUid = KUidMmfUrlSink; sl@0: } sl@0: else sl@0: err = KErrNotSupported; sl@0: sl@0: if (!err) sl@0: { sl@0: iFindAndOpenController->ConfigureSourceSink( sl@0: CMMFFindAndOpenController::TSourceSink(KUidMmfFileSource, sourceCfg), sl@0: CMMFFindAndOpenController::TSourceSink(dstUid, dstCfg)); sl@0: sl@0: TMMFileSource tfs(aPrimaryFile); sl@0: iFindAndOpenController->OpenByFileSource(tfs); sl@0: } sl@0: sl@0: sl@0: sl@0: if (dstCfgBuffer) sl@0: CleanupStack::PopAndDestroy(dstCfgBuffer); sl@0: if (dstURLCfg) sl@0: CleanupStack::PopAndDestroy(dstURLCfg); sl@0: sl@0: sl@0: if (err) sl@0: { sl@0: TInt oldState = State(); sl@0: iAsyncCallback->CallBack(iParent, oldState, oldState, err); sl@0: return; sl@0: } sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation, sl@0: TMdaClipLocation* aSecLocation, sl@0: TUid aControllerUid, // the controller to use sl@0: TUid aDestFormatUid, sl@0: TFourCC aDestDataType) sl@0: { sl@0: __ASSERT_ALWAYS(aPriLocation && aSecLocation, User::Leave(KErrArgument)); sl@0: sl@0: Reset(); sl@0: sl@0: sl@0: // Configure the destination format and data type sl@0: if (aDestFormatUid != KNullUid) sl@0: iSinkFormatUid = aDestFormatUid; sl@0: sl@0: if (aDestDataType != KMMFFourCCCodeNULL) sl@0: iSinkDataType = aDestDataType; sl@0: sl@0: TRAPD(err, ConfigureSourceSinkL(aPriLocation, aSecLocation)); sl@0: if (!err) sl@0: iFindAndOpenController->OpenByControllerUid(aControllerUid); sl@0: sl@0: sl@0: if (err) sl@0: { sl@0: TInt oldState = State(); sl@0: iAsyncCallback->CallBack(iParent, oldState, oldState, err); sl@0: return; sl@0: } sl@0: } sl@0: sl@0: sl@0: void CMMFMdaAudioConvertUtility::HandleEvent(const TMMFEvent& aEvent) sl@0: { sl@0: //When converting, state is EPlaying, ERecording is never used sl@0: if (aEvent.iEventType==KMMFEventCategoryPlaybackComplete || aEvent.iEventType==KMMFErrorCategoryControllerGeneralError) sl@0: { sl@0: TInt oldState = iState; sl@0: iState = CMdaAudioClipUtility::EOpen; sl@0: sl@0: //if we weren't converting, don't advise Client. sl@0: if(oldState == CMdaAudioClipUtility::EPlaying) sl@0: iCallback.MoscoStateChangeEvent(iParent, CMdaAudioClipUtility::EPlaying, iState, aEvent.iErrorCode); sl@0: } sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::PlayL() sl@0: { sl@0: // N.B. ConvertL should be used in preference to PlayL sl@0: ConvertL(); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::RecordL() sl@0: { sl@0: // N.B. ConvertL should be used in preference to RecordL sl@0: ConvertL(); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::ConvertL() sl@0: { sl@0: if (iState == CMdaAudioClipUtility::EOpen) sl@0: { sl@0: TInt err; sl@0: err = iController.Prime(); sl@0: if (err==KErrNone) sl@0: { sl@0: err=iController.SetPosition(iPosition); sl@0: if (!err && iConvertWindowSet) sl@0: err = iAudioPlayControllerCustomCommands.SetPlaybackWindow(iConvertStart, iConvertEnd); sl@0: if (err==KErrNone) sl@0: err = iController.Play(); sl@0: } sl@0: sl@0: TInt oldState = iState; sl@0: if (!err) sl@0: iState = CMdaAudioClipUtility::EPlaying; sl@0: sl@0: iAsyncCallback->CallBack(iParent, oldState, iState, err); sl@0: } sl@0: else sl@0: iAsyncCallback->CallBack(iParent, iState, iState, KErrNotReady); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::Stop() sl@0: { sl@0: TInt err = iController.Pause(); sl@0: TInt oldState = iState; sl@0: if (!err) sl@0: iState = CMdaAudioClipUtility::EOpen; sl@0: iAsyncCallback->CallBack(iParent, oldState, iState, err); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::CropL(TBool aCropToEnd) sl@0: { sl@0: // if we are busy converting, or we have not opened the file, return KErrNotReady sl@0: if (iState!=CMdaAudioClipUtility::EOpen) sl@0: User::Leave(KErrNotReady); sl@0: sl@0: // check that cropping position is valid if clip has been cropped before sl@0: if (iHasCropped && iPosition > iCroppedDuration) sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: sl@0: TInt err = iController.Prime(); sl@0: if (!err) sl@0: { sl@0: sl@0: if (!err) sl@0: err = iController.SetPosition(iPosition); sl@0: sl@0: err = iAudioRecordControllerCustomCommands.Crop(aCropToEnd); sl@0: // try to stop controller regardless of whether any of the above commands failed sl@0: iController.Stop(); sl@0: // save the duration of the cropped clip because sl@0: // Duration() returns length of the original clip only sl@0: // this is used to prevent a subsequent crop, beyond the end of the sl@0: // already cropped clip. sl@0: if (err == KErrNone) sl@0: { sl@0: iHasCropped = ETrue; sl@0: if (aCropToEnd) sl@0: iCroppedDuration = iPosition; sl@0: else sl@0: iCroppedDuration = TTimeIntervalMicroSeconds(iDuration.Int64() - iPosition.Int64()); sl@0: } sl@0: } sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetPosition(const TTimeIntervalMicroSeconds& aPosition) sl@0: { sl@0: iPosition = aPosition; sl@0: sl@0: // Clip the position if aPosition is greater than the duration, or less then 0 sl@0: const TTimeIntervalMicroSeconds duration = Duration(); sl@0: if (iPosition > duration) sl@0: iPosition = duration; sl@0: else if (iPosition < TTimeIntervalMicroSeconds(0)) sl@0: iPosition = 0; sl@0: sl@0: if (iState==CMdaAudioClipUtility::EPlaying) sl@0: iController.SetPosition(iPosition); sl@0: } sl@0: sl@0: const TTimeIntervalMicroSeconds& CMMFMdaAudioConvertUtility::Position() sl@0: { sl@0: if (iState==CMdaAudioClipUtility::EPlaying) sl@0: { sl@0: TInt err = iController.GetPosition(iPositionTemp); sl@0: if (err==KErrNone) sl@0: return iPositionTemp; sl@0: } sl@0: return iPosition; sl@0: } sl@0: sl@0: const TTimeIntervalMicroSeconds& CMMFMdaAudioConvertUtility::RecordTimeAvailable() sl@0: { sl@0: #ifdef _DEBUG sl@0: TInt error = sl@0: #endif sl@0: iAudioRecordControllerCustomCommands.GetRecordTimeAvailable(iRecordTimeAvailable); sl@0: __ASSERT_DEBUG(error==KErrNone, Panic(EMMFMediaClientPanicServerCommunicationProblem)); sl@0: return iRecordTimeAvailable; sl@0: } sl@0: sl@0: const TTimeIntervalMicroSeconds& CMMFMdaAudioConvertUtility::Duration() sl@0: { sl@0: TInt err = iController.GetDuration(iDuration); sl@0: if (err) sl@0: iDuration = 0; sl@0: return iDuration; sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetMaxWriteLength(TInt aMaxWriteLength) sl@0: { sl@0: iAudioRecordControllerCustomCommands.SetMaxFileSize(aMaxWriteLength); sl@0: } sl@0: sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd) sl@0: { sl@0: if (aStart >= TTimeIntervalMicroSeconds(0) && sl@0: aStart < iDuration && sl@0: aStart <= aEnd && sl@0: aEnd <= iDuration ) sl@0: { sl@0: iConvertStart = aStart; sl@0: iConvertEnd = aEnd; sl@0: iConvertWindowSet = ETrue; sl@0: sl@0: if (iState==CMdaAudioClipUtility::EPlaying) sl@0: { sl@0: #ifdef _DEBUG sl@0: TInt error = sl@0: #endif sl@0: iAudioPlayControllerCustomCommands.SetPlaybackWindow(aStart, aEnd); sl@0: __ASSERT_DEBUG(error==KErrNone, Panic(EMMFMediaClientPanicServerCommunicationProblem)); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: __ASSERT_DEBUG(EFalse, Panic(EMMFMediaClientPanicServerCommunicationProblem)); sl@0: } sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::ClearPlayWindow() sl@0: { sl@0: iConvertWindowSet = EFalse; sl@0: #ifdef _DEBUG sl@0: TInt err = sl@0: #endif //_DEBUG sl@0: iAudioPlayControllerCustomCommands.DeletePlaybackWindow(); sl@0: __ASSERT_DEBUG(err==KErrNone, Panic(EMMFMediaClientPanicServerCommunicationProblem)); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetRepeats(TInt /*aRepeatNumberOfTimes*/, const TTimeIntervalMicroSeconds& /*aTrailingSilence*/) sl@0: { sl@0: // This doesn't really make sense for the converter. sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetPriority(TInt aPriority, TInt aPref) sl@0: { sl@0: iPrioritySettings.iPref = aPref; sl@0: iPrioritySettings.iPriority = aPriority; sl@0: iFindAndOpenController->Configure(iMediaIds[0], iPrioritySettings); sl@0: iController.SetPrioritySettings(iPrioritySettings); sl@0: } sl@0: sl@0: sl@0: void CMMFMdaAudioConvertUtility::Close() sl@0: { sl@0: iControllerEventMonitor->Cancel(); sl@0: iController.Close(); sl@0: sl@0: if (iFindAndOpenController) sl@0: iFindAndOpenController->Close(); sl@0: sl@0: iHasCropped = EFalse; sl@0: iCroppedDuration = 0; sl@0: iState = CMdaAudioClipUtility::ENotReady; sl@0: if(iControllerImplementationInformation) sl@0: { sl@0: delete iControllerImplementationInformation; sl@0: iControllerImplementationInformation = NULL; sl@0: } sl@0: iControllerUid = KNullUid; sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::CropL(const TTimeIntervalMicroSeconds &aCropBegin, sl@0: const TTimeIntervalMicroSeconds &aCropEnd) sl@0: { sl@0: // if we are busy converting, or we have not opened the file, return KErrNotReady sl@0: if (iState!=CMdaAudioClipUtility::EOpen) sl@0: User::Leave(KErrNotReady); sl@0: sl@0: // check that cropping positions are valid if clip has been cropped before sl@0: if (iHasCropped && aCropEnd > iCroppedDuration) sl@0: { sl@0: User::Leave(KErrArgument); sl@0: } sl@0: sl@0: TInt err = iController.Prime(); sl@0: if (!err) sl@0: { sl@0: err =iController.SetPosition(aCropEnd); sl@0: if (!err) sl@0: err = iAudioRecordControllerCustomCommands.Crop(ETrue); sl@0: if (!err) sl@0: { sl@0: //remember the cropping, store the cropped length sl@0: iHasCropped = ETrue; sl@0: iCroppedDuration = aCropEnd; sl@0: err = iController.SetPosition(aCropBegin); sl@0: } sl@0: if (!err) sl@0: err = iAudioRecordControllerCustomCommands.Crop(EFalse); sl@0: if (!err) // store the new cropped length sl@0: iCroppedDuration = TTimeIntervalMicroSeconds(aCropEnd.Int64() - aCropBegin.Int64()); sl@0: sl@0: // try to stop controller regardless of whether any of the above commands failed sl@0: iController.Stop(); sl@0: } sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: CMdaAudioClipUtility::TState CMMFMdaAudioConvertUtility::State() sl@0: { sl@0: return iState; sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::GetSupportedDestinationDataTypesL(RArray& aSupportedDataTypes) sl@0: { sl@0: iAudioControllerCustomCommands.GetSupportedSinkDataTypesL(aSupportedDataTypes); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetSourceDataTypeL(TFourCC aDataType) sl@0: { sl@0: User::LeaveIfError(iAudioControllerCustomCommands.SetSourceDataType(aDataType)); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetDestinationDataTypeL(TFourCC aDataType) sl@0: { sl@0: User::LeaveIfError(iAudioControllerCustomCommands.SetSinkDataType(aDataType)); sl@0: } sl@0: sl@0: TFourCC CMMFMdaAudioConvertUtility::DestinationDataTypeL() sl@0: { sl@0: TFourCC dataType; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSinkDataType(dataType)); sl@0: return dataType; sl@0: } sl@0: sl@0: TFourCC CMMFMdaAudioConvertUtility::SourceDataTypeL() sl@0: { sl@0: TFourCC dataType; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSourceDataType(dataType)); sl@0: return dataType; sl@0: } sl@0: sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetDestinationBitRateL(TUint aBitRate) sl@0: { sl@0: User::LeaveIfError(iAudioControllerCustomCommands.SetSinkBitRate(aBitRate)); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetSourceSampleRateL(TUint aSampleRate) sl@0: { sl@0: User::LeaveIfError(iController.Stop()); sl@0: User::LeaveIfError(iAudioControllerCustomCommands.SetSourceSampleRate(aSampleRate)); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetDestinationSampleRateL(TUint aSampleRate) sl@0: { sl@0: User::LeaveIfError(iController.Stop()); sl@0: User::LeaveIfError(iAudioControllerCustomCommands.SetSinkSampleRate(aSampleRate)); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetSourceFormatL(TUid aRecordFormat) sl@0: { sl@0: User::LeaveIfError(iAudioControllerCustomCommands.SetSourceFormat(aRecordFormat)); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetDestinationFormatL(TUid aRecordFormat) sl@0: { sl@0: User::LeaveIfError(iAudioControllerCustomCommands.SetSinkFormat(aRecordFormat)); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetSourceNumberOfChannelsL(TUint aNumberOfChannels) sl@0: { sl@0: User::LeaveIfError(iAudioControllerCustomCommands.SetSourceNumChannels(aNumberOfChannels)); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::SetDestinationNumberOfChannelsL(TUint aNumberOfChannels) sl@0: { sl@0: User::LeaveIfError(iAudioControllerCustomCommands.SetSinkNumChannels(aNumberOfChannels)); sl@0: } sl@0: sl@0: TUint CMMFMdaAudioConvertUtility::DestinationBitRateL() sl@0: { sl@0: TUint bitRate; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSinkBitRate(bitRate)); sl@0: return bitRate; sl@0: } sl@0: sl@0: TUint CMMFMdaAudioConvertUtility::DestinationSampleRateL() sl@0: { sl@0: TUint sampleRate; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSinkSampleRate(sampleRate)); sl@0: return sampleRate; sl@0: } sl@0: sl@0: TUid CMMFMdaAudioConvertUtility::DestinationFormatL() sl@0: { sl@0: TUid format; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSinkFormat(format)); sl@0: return format; sl@0: } sl@0: sl@0: TUint CMMFMdaAudioConvertUtility::DestinationNumberOfChannelsL() sl@0: { sl@0: TUint numChannels; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSinkNumChannels(numChannels)); sl@0: return numChannels; sl@0: } sl@0: sl@0: TUint CMMFMdaAudioConvertUtility::SourceBitRateL() sl@0: { sl@0: TUint bitRate; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSourceBitRate(bitRate)); sl@0: return bitRate; sl@0: } sl@0: sl@0: TUint CMMFMdaAudioConvertUtility::SourceSampleRateL() sl@0: { sl@0: TUint sampleRate; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSourceSampleRate(sampleRate)); sl@0: return sampleRate; sl@0: } sl@0: sl@0: TUid CMMFMdaAudioConvertUtility::SourceFormatL() sl@0: { sl@0: TUid format; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSourceFormat(format)); sl@0: return format; sl@0: } sl@0: sl@0: TUint CMMFMdaAudioConvertUtility::SourceNumberOfChannelsL() sl@0: { sl@0: TUint numChannels; sl@0: User::LeaveIfError(iAudioControllerCustomCommands.GetSourceNumChannels(numChannels)); sl@0: return numChannels; sl@0: } sl@0: sl@0: sl@0: void CMMFMdaAudioConvertUtility::GetSupportedConversionBitRatesL(RArray& aSupportedBitRates) sl@0: { sl@0: iAudioControllerCustomCommands.GetSupportedSinkBitRatesL(aSupportedBitRates); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::GetSupportedConversionSampleRatesL(RArray& aSupportedSampleRates) sl@0: { sl@0: User::LeaveIfError(iController.Prime()); sl@0: iAudioControllerCustomCommands.GetSupportedSinkSampleRatesL(aSupportedSampleRates); sl@0: User::LeaveIfError(iController.Stop()); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::GetSupportedConversionNumberOfChannelsL(RArray& aSupportedNumChannels) sl@0: { sl@0: iAudioControllerCustomCommands.GetSupportedSinkNumChannelsL(aSupportedNumChannels); sl@0: } sl@0: sl@0: CMdaAudioConvertUtility* CMMFMdaAudioConvertUtility::Parent() const sl@0: { sl@0: ASSERT(iParent); sl@0: return static_cast(iParent); sl@0: } sl@0: sl@0: TInt CMMFMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom) sl@0: { sl@0: return iController.CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom); sl@0: } sl@0: sl@0: TInt CMMFMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2) sl@0: { sl@0: return iController.CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus) sl@0: { sl@0: iController.CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom, aStatus); sl@0: } sl@0: sl@0: void CMMFMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus) sl@0: { sl@0: iController.CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aStatus); sl@0: } sl@0: sl@0: const CMMFControllerImplementationInformation& CMMFMdaAudioConvertUtility::ControllerImplementationInformationL() sl@0: { sl@0: if (!iControllerImplementationInformation) sl@0: { sl@0: if (iControllerUid==KNullUid) sl@0: User::Leave(KErrNotReady); sl@0: iControllerImplementationInformation = CMMFControllerImplementationInformation::NewL(iControllerUid); sl@0: } sl@0: return *iControllerImplementationInformation; sl@0: } sl@0: sl@0: sl@0: void CMMFMdaAudioConvertUtility::Reset() sl@0: { sl@0: // Make sure any existing controller is closed. sl@0: Close(); sl@0: sl@0: iSourceFormatUid = KNullUid; sl@0: iSinkFormatUid = KNullUid; sl@0: iSourceDataType = KMMFFourCCCodeNULL; sl@0: iSinkDataType = KMMFFourCCCodeNULL; sl@0: iSourceSampleRate = 0; sl@0: iSinkSampleRate = 0; sl@0: iSourceChannels = 0; sl@0: iSinkChannels = 0; sl@0: } sl@0: sl@0: sl@0: TInt CMMFMdaAudioConvertUtility::ControllerOpen() sl@0: { sl@0: TInt err = KErrNone; sl@0: sl@0: if(iSourceFormatUid != KNullUid) sl@0: TRAP(err, SetSourceFormatL(iSourceFormatUid)); sl@0: sl@0: if(!err && iSinkFormatUid != KNullUid) sl@0: TRAP(err, SetDestinationFormatL(iSinkFormatUid)); sl@0: sl@0: if(!err && iSourceDataType != KMMFFourCCCodeNULL) sl@0: { sl@0: TRAP(err, SetSourceDataTypeL(iSourceDataType)); sl@0: } sl@0: sl@0: if(!err && iSinkDataType != KMMFFourCCCodeNULL) sl@0: { sl@0: TRAP(err, SetDestinationDataTypeL(iSinkDataType)); sl@0: } sl@0: sl@0: // set the audio data settings ie sample rate & channels sl@0: if (!err && iSourceSampleRate != 0) sl@0: { sl@0: TRAP(err, SetSourceSampleRateL(iSourceSampleRate)); sl@0: } sl@0: sl@0: if (!err && iSourceChannels != 0) sl@0: { sl@0: TRAP(err, SetSourceNumberOfChannelsL(iSourceChannels)); sl@0: } sl@0: sl@0: if (!err && iSinkSampleRate != 0) sl@0: { sl@0: TRAP(err, SetDestinationSampleRateL(iSinkSampleRate)); sl@0: } sl@0: sl@0: if (!err && iSinkChannels != 0) sl@0: { sl@0: TRAP(err, SetDestinationNumberOfChannelsL(iSinkChannels)); sl@0: } sl@0: sl@0: //get the clip duration sl@0: if (!err) sl@0: { sl@0: iDuration = TTimeIntervalMicroSeconds(0); sl@0: err = iController.GetDuration(iDuration); sl@0: } sl@0: sl@0: if (err) sl@0: Close(); sl@0: else sl@0: iState = CMdaAudioClipUtility::EOpen; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: sl@0: void CMMFMdaAudioConvertUtility::ConfigureSourceSinkL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation) sl@0: { sl@0: TMMFDescriptorConfig srcDesCfg; sl@0: TMMFFileConfig srcFileCfg; sl@0: CBufFlat* srcCfgBuffer = NULL; sl@0: CMMFUrlParams* srcURLCfg = NULL; sl@0: TPtrC8 sourceCfg; sl@0: TUid sourceUid = KNullUid; sl@0: sl@0: TMMFDescriptorConfig dstDesCfg; sl@0: TMMFFileConfig dstFileCfg; sl@0: CBufFlat* dstCfgBuffer = NULL; sl@0: CMMFUrlParams* dstURLCfg = NULL; sl@0: TPtrC8 dstCfg; sl@0: TUid dstUid = KNullUid; sl@0: sl@0: TInt err = KErrNone; sl@0: sl@0: // setup the source config info sl@0: if (aPriLocation->Uid() == KUidMdaFileResLoc) sl@0: {//sink clip location is a file sl@0: TDesC& fileName = ((TMdaFileClipLocation*)aPriLocation)->iName; sl@0: srcFileCfg().iPath = fileName; sl@0: sourceCfg.Set(srcFileCfg); sl@0: sourceUid = KUidMmfFileSource; sl@0: } sl@0: else if (aPriLocation->Uid() == KUidMdaDesResLoc) sl@0: {//sink clip is a descriptor - pass down descriptor & thread id sl@0: TMdaDesClipLocation* srcLoc = (TMdaDesClipLocation*)aPriLocation; sl@0: srcDesCfg().iDes = srcLoc->iDes; sl@0: srcDesCfg().iDesThreadId = srcLoc->iThreadId; sl@0: sourceCfg.Set(srcDesCfg); sl@0: sourceUid = KUidMmfDescriptorSource; sl@0: } sl@0: else if (aPriLocation->Uid() == KUidMdaUrlResLoc) sl@0: { sl@0: TMdaUrlClipLocation* srcLoc = (TMdaUrlClipLocation*)aPriLocation; sl@0: srcURLCfg = CMMFUrlParams::NewLC(srcLoc->iUrl, srcLoc->iIapId); sl@0: srcCfgBuffer = srcURLCfg->ExternalizeToCBufFlatLC(); sl@0: sourceCfg.Set(srcCfgBuffer->Ptr(0)); sl@0: sourceUid = KUidMmfUrlSource; sl@0: } sl@0: else sl@0: { sl@0: err = KErrNotSupported; sl@0: } sl@0: sl@0: if (!err) sl@0: { sl@0: if (aSecLocation->Uid() == KUidMdaFileResLoc) sl@0: {//sink clip location is a file sl@0: TDesC& fileName = ((TMdaFileClipLocation*)aSecLocation)->iName; sl@0: dstFileCfg().iPath = fileName; sl@0: dstCfg.Set(dstFileCfg); sl@0: dstUid = KUidMmfFileSink; sl@0: } sl@0: else if (aSecLocation->Uid() == KUidMdaDesResLoc) sl@0: {//sink clip is a descriptor - pass down descriptor & thread id sl@0: TMdaDesClipLocation* desLoc = (TMdaDesClipLocation*)aSecLocation; sl@0: dstDesCfg().iDes = desLoc->iDes; sl@0: dstDesCfg().iDesThreadId = desLoc->iThreadId; sl@0: dstCfg.Set(dstDesCfg); sl@0: dstUid = KUidMmfDescriptorSink; sl@0: } sl@0: else if (aSecLocation->Uid() == KUidMdaUrlResLoc) sl@0: { sl@0: TMdaUrlClipLocation* desLoc = (TMdaUrlClipLocation*)aSecLocation; sl@0: dstURLCfg = CMMFUrlParams::NewLC(desLoc->iUrl, desLoc->iIapId); sl@0: dstCfgBuffer = dstURLCfg->ExternalizeToCBufFlatLC(); sl@0: dstCfg.Set(dstCfgBuffer->Ptr(0)); sl@0: dstUid = KUidMmfUrlSink; sl@0: } sl@0: else sl@0: { sl@0: err = KErrNotSupported; sl@0: } sl@0: } sl@0: sl@0: if (!err) sl@0: { sl@0: iFindAndOpenController->ConfigureSourceSink( sl@0: CMMFFindAndOpenController::TSourceSink(sourceUid, sourceCfg), sl@0: CMMFFindAndOpenController::TSourceSink(dstUid, dstCfg)); sl@0: } sl@0: sl@0: if (dstCfgBuffer) sl@0: CleanupStack::PopAndDestroy(2); //dstCfgBuffer, dstURLCfg sl@0: if (srcCfgBuffer) sl@0: CleanupStack::PopAndDestroy(2); //srcCfgBuffer, srcURLCfg sl@0: sl@0: User::LeaveIfError(err); sl@0: } sl@0: sl@0: sl@0: TInt CMMFMdaAudioConvertUtility::SetThreadPriority(const TThreadPriority& aThreadPriority) const sl@0: { sl@0: return iController.SetThreadPriority(aThreadPriority); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: