Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <mmf/common/mmffourcc.h>
18 #include <mmf/common/mmfpaniccodes.h>
19 #include <mmfformatimplementationuids.hrh>
21 #include "mmfclientaudioconverter.h"
23 // declared in the recorder module
24 void Panic(TInt aPanicCode);
26 //CMdaAudioConvertUtility
30 Returns the current utility state.
32 @return The state of the audio sample data. See CMdaAudioClipUtility::TState.
36 CMdaAudioClipUtility::TState CMdaAudioConvertUtility::State()
39 return iProperties->State();
43 Closes the current audio clip.
47 void CMdaAudioConvertUtility::Close()
54 This function is mapped to ConvertL(). ConvertL() should be used instead.
60 void CMdaAudioConvertUtility::PlayL()
67 This function is mapped to ConvertL. ConvertL() should be used instead.
71 void CMdaAudioConvertUtility::RecordL()
74 iProperties->RecordL();
78 Stops the current operation (playback/recording/conversion).
80 When conversion has been stopped, successfully or otherwise, the client is notified by
81 MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
82 providing it with state change information and error codes.
86 void CMdaAudioConvertUtility::Stop()
93 Crops the current clip from the current position. The remainder of the clip is discarded.
95 The effects of the function cannot be undone. The function is synchronous and can leave if there is
96 a problem. The leave code depends on the configuration.
100 void CMdaAudioConvertUtility::CropL()
103 iProperties->CropL(ETrue);
107 Sets the current position in the audio clip.
109 A subsequent call to ConvertL() starts conversion from this new position.
112 The position in the audio clip, in microseconds.
116 void CMdaAudioConvertUtility::SetPosition(const TTimeIntervalMicroSeconds& aPosition)
119 iProperties->SetPosition(aPosition);
123 Returns the current position in the audio clip. The position is defined in terms of a time interval
124 measured from the beginning of the audio sample data.
126 @return The current position in the audio clip, in microseconds.
130 const TTimeIntervalMicroSeconds& CMdaAudioConvertUtility::Position()
133 return iProperties->Position();
137 Returns the amount of recording time available to the current clip.
139 @return The recording time available measured in microseconds.
143 const TTimeIntervalMicroSeconds& CMdaAudioConvertUtility::RecordTimeAvailable()
146 return iProperties->RecordTimeAvailable();
150 Returns the duration of the audio clip.
152 @return The duration in microseconds.
156 const TTimeIntervalMicroSeconds& CMdaAudioConvertUtility::Duration()
159 return iProperties->Duration();
163 Sets a window for playback.
165 The window is defined in terms of a start and end time. A subsequent call to ConvertL() results
166 in just the data within the window being converted.
169 The position in the clip to start playback, in microseconds. This must be any value from zero
170 to aEnd. If this value is less than zero or greater than aEnd, this function raises
171 EMMFMediaClientPanicServerCommunicationProblem panic in debug version.
173 The position in the clip to end playback, in microseconds. This must be any value from aStart
174 to the value returned by Duration(). If this value is greater than the value returned by
175 Duration() or less than aStart, this function raises EMMFMediaClientPanicServerCommunicationProblem panic in debug version.
179 void CMdaAudioConvertUtility::SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd)
182 iProperties->SetPlayWindow(aStart, aEnd);
186 Clears the playback window.
188 Playback returns to playing the entire clip. A subsequent call to ConvertL() results in the entire
189 source audio being converted.
193 void CMdaAudioConvertUtility::ClearPlayWindow()
196 iProperties->ClearPlayWindow();
200 Sets the number of repetitions for playback. This is unsupported for CMdaConvertUtility as there is
201 no playback facility. It is provided only for binary compatibility.
203 @param aRepeatNumberOfTimes
204 The number of times to repeat the audio clip, after the first playback. If this is set to
205 KMdaRepeatForever, then the audio sample, together with the trailing silence, is repeated
206 indefinitely. If this is set to zero, then the audio sample is not repeated.
207 @param aTrailingSilence
208 A delay to wait before each repetition.
212 void CMdaAudioConvertUtility::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence)
215 iProperties->SetRepeats(aRepeatNumberOfTimes, aTrailingSilence);
219 Sets the maximum size of an audio clip.
221 This function is provided so that applications such as recorders and converters can limit the amount
222 of file storage/memory that should be allocated.
224 @param aMaxWriteLength
225 The maximum size of the audio clip, in bytes. If the default value is used, there is no
230 void CMdaAudioConvertUtility::SetMaxWriteLength(TInt aMaxWriteLength /* = KMdaClipLocationMaxWriteLengthNone*/)
233 iProperties->SetMaxWriteLength(aMaxWriteLength);
237 Crops the audio clip from the start of the file to the current position. The audio data
238 prior to the current position is discarded.
240 The effects of the function cannot be undone.
242 The function is synchronous and can leave if there is a problem. The leave code depends on the
247 void CMdaAudioConvertUtility::CropFromBeginningL()
250 iProperties->CropL(EFalse);
254 Constructs and initialises a new instance of the audio converter for converting audio sample data
255 from one format to another.
257 The function leaves if the audio converter object cannot be created.
260 The class to receive state change events from converter.
262 No longer used, should be NULL.
264 The Priority Value - this client's relative priority. This is a value between EMdaPriorityMin and
265 EMdaPriorityMax and represents a relative priority. A higher value indicates a more important request.
267 The Priority Preference - an additional audio policy parameter. The suggested default is
268 EMdaPriorityPreferenceNone. Further values are given by TMdaPriorityPreference, and additional
269 values may be supported by given phones and/or platforms, but should not be depended upon by
272 @return A pointer to a new instance of CMdaAudioConvertUtility.
276 Note: The Priority Value and Priority Preference are used primarily when deciding what to do when
277 several audio clients attempt to play or record simultaneously. In addition to the Priority Value and Preference,
278 the adaptation may consider other parameters such as the SecureId and Capabilities of the client process.
279 Whatever, the decision as to what to do in such situations is up to the audio adaptation, and may
280 vary between different phones. Portable applications are advised not to assume any specific behaviour.
282 EXPORT_C CMdaAudioConvertUtility* CMdaAudioConvertUtility::NewL(MMdaObjectStateChangeObserver& aObserver,
283 CMdaServer* /*aServer*/,
287 CMdaAudioConvertUtility* self = new(ELeave) CMdaAudioConvertUtility();
288 CleanupStack::PushL(self);
289 self->iProperties = new(ELeave) CMMFMdaAudioConvertUtility(self, aObserver);
290 self->iProperties->ConstructL(aPriority, aPref);
291 CleanupStack::Pop(self);
298 Closes the audio clip and frees resources.
302 CMdaAudioConvertUtility::~CMdaAudioConvertUtility()
308 Ensures that any subsequent calls to OpenXYZ() will create controllers that
311 The default behaviour is that for each converter utility a controller with its own heap
312 is created. Each heap uses a chunk, so using this function avoids situations where
313 the number of chunks per process is limited.
314 The default behaviour is generally to be preferred, and should give lower overall
315 memory usage. However, if many controllers are to be created for a particular thread,
316 then this function should be used to prevent running out of heaps or chunks.
320 EXPORT_C void CMdaAudioConvertUtility::UseSharedHeap()
323 iProperties->UseSharedHeap();
327 Opens source and target files (both of which must already exist) so that audio sample data can be
328 extracted from the source file, converted and appended to the target file.
330 When opening is complete, successfully or otherwise, the client is notified by
331 MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
332 providing it with state change information and error codes.
335 The full path and filename of a file containing audio sample data to be converted.
336 @param aSecondaryFile
337 The full path and filename of a file to which converted data is appended.
341 void CMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, const TDesC& aSecondaryFile)
344 iProperties->OpenL(aPrimaryFile, aSecondaryFile);
348 Opens an existing audio file so that audio sample data can be extracted from it, converted and
349 placed into the target audio object.
351 When opening is complete, successfully or otherwise, the client is notified by
352 MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
353 providing it with state change information and error codes.
356 The full path and filename of a file containing audio sample data to be converted.
358 The target location for the audio data. This is normally a file (TMdaFileClipLocation) or a
359 descriptor (TMdaDesClipLocation).
361 The audio format for the target audio object.
363 The codec to use for the target audio object.
365 The audio settings for the target audio object.
369 void CMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, TMdaClipLocation* aLocation, TMdaClipFormat* aFormat,
370 TMdaPackage* aArg1 /*= NULL*/, TMdaPackage* aArg2 /*= NULL*/)
373 iProperties->OpenL(aPrimaryFile, aLocation, aFormat, aArg1, aArg2);
377 Opens an audio clip for conversion.
380 The source location for audio data. This is normally a file (TMdaFileClipLocation) or a
381 descriptor (TMdaDesClipLocation).
383 The target location for audio data. This is normally a file (TMdaFileClipLocation) or a
384 descriptor (TMdaDesClipLocation).
386 The audio format of the source audio object.
388 The audio format for the target audio object.
390 The codec used by the source audio object.
392 The audio settings of the source audio object.
394 The codec to be used for the target audio object.
396 The audio settings for the target audio object.
400 void CMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation,
401 TMdaClipFormat* aPriFormat, TMdaClipFormat* aSecFormat,
402 TMdaPackage* aPriArg1 /*= NULL*/, TMdaPackage* aPriArg2 /*= NULL*/,
403 TMdaPackage* aSecArg1 /*= NULL*/, TMdaPackage* aSecArg2 /*= NULL*/)
406 iProperties->OpenL(aPriLocation, aSecLocation, aPriFormat, aSecFormat, aPriArg1, aPriArg2, aSecArg1, aSecArg2);
409 // New functions for 7.0s
411 Opens source and target audio objects and specifies controller and audio format and codec
414 When opening is complete, successfully or otherwise, the client is notified by
415 MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
416 providing it with state change information and error codes.
419 The source location for audio data. This is normally a file (TMdaFileClipLocation) or a
420 descriptor (TMdaDesClipLocation).
422 The destination location for the converted audio data. This is normally a file
423 (TMdaFileClipLocation) or a descriptor (TMdaDesClipLocation).
424 @param aControllerUid
425 The UID of the controller to used for conversion.
426 @param aDestFormatUid
427 The UID of the destination format.
429 The audio codec to use for the destination data sink.
433 EXPORT_C void CMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation, TUid aControllerUid,
434 TUid aDestFormatUid, TFourCC aDestDataType)
437 iProperties->OpenL(aPriLocation, aSecLocation, aControllerUid, aDestFormatUid, aDestDataType);
441 Returns a list of the supported data types for the conversion destination.
443 @param aSupportedDestinationDataTypes
444 A list of four character codes, representing the supported data
445 encodings for the conversion destination.
449 EXPORT_C void CMdaAudioConvertUtility::GetSupportedDestinationDataTypesL(RArray<TFourCC>& aSupportedDestinationDataTypes)
452 iProperties->GetSupportedDestinationDataTypesL(aSupportedDestinationDataTypes);
456 Sets the data type of the destination audio clip.
459 The four character code, representing the encoding of the destination audio clip
463 EXPORT_C void CMdaAudioConvertUtility::SetDestinationDataTypeL(TFourCC aCodec)
466 iProperties->SetDestinationDataTypeL(aCodec);
470 Returns the data type of the destination audio clip.
472 @return The four character code, representing the encoding of the destination audio clip.
476 EXPORT_C TFourCC CMdaAudioConvertUtility::DestinationDataTypeL()
479 return iProperties->DestinationDataTypeL();
483 Returns the data type of the source audio clip.
485 @return The four character code, representing the encoding of the source audio clip.
489 EXPORT_C TFourCC CMdaAudioConvertUtility::SourceDataTypeL()
492 return iProperties->SourceDataTypeL();
496 Sets the bit rate of the destination audio clip.
498 The bit rate must be one of the supported bit rates of the audio target. Use
499 GetSupportedConversionBitRatesL() to retrieve a list of supported bit rates.
502 The destination bit rate in bits/second.
506 EXPORT_C void CMdaAudioConvertUtility::SetDestinationBitRateL(TUint aBitRate)
509 iProperties->SetDestinationBitRateL(aBitRate);
513 Returns the bit rate of the destination audio clip.
515 @return The destination bit rate in bits/second.
519 EXPORT_C TUint CMdaAudioConvertUtility::DestinationBitRateL()
522 return iProperties->DestinationBitRateL();
526 Gets a list of the supported bit rates for the conversion destination.
528 @param aSupportedBitRates
529 The list of bit rates supported for the conversion destination.
533 EXPORT_C void CMdaAudioConvertUtility::GetSupportedConversionBitRatesL(RArray<TUint>& aSupportedBitRates)
536 iProperties->GetSupportedConversionBitRatesL(aSupportedBitRates);
540 Returns the bit rate of the source audio clip.
542 @return The source bit rate in bits/second.
546 EXPORT_C TInt CMdaAudioConvertUtility::SourceBitRateL()
549 return iProperties->SourceBitRateL();
553 Sets the sample rate for the conversion destination.
555 The sample rate must be one of the supported sample rates of the audio target. Use
556 GetSupportedConversionSampleRatesL() to retrieve a list of supported sample rates.
557 This function should not be used if the audio clip already exists; that is, in the
558 "Open and Append" scenario, when the function's behaviour is undefined.
561 The sample rate of the conversion destination in samples per second.
565 EXPORT_C void CMdaAudioConvertUtility::SetDestinationSampleRateL(TUint aSampleRate)
568 iProperties->SetDestinationSampleRateL(aSampleRate);
572 Returns the sample rate of the conversion destination.
574 @return The sample rate of the conversion destination in samples per second.
578 EXPORT_C TUint CMdaAudioConvertUtility::DestinationSampleRateL()
581 return iProperties->DestinationSampleRateL();
585 Gets a list of supported conversion sample rates. This is a list of the sample rates that
586 the conversion destination can take.
588 @param aSupportedSampleRates
589 A list of the sample rates that are supported for the conversion.
593 EXPORT_C void CMdaAudioConvertUtility::GetSupportedConversionSampleRatesL(RArray<TUint>& aSupportedSampleRates)
596 iProperties->GetSupportedConversionSampleRatesL(aSupportedSampleRates);
600 Returns the sample rate of the source audio clip.
602 @return The source sample rate in samples/second.
606 EXPORT_C TUint CMdaAudioConvertUtility::SourceSampleRateL()
609 return iProperties->SourceSampleRateL();
613 Sets the format of the destination audio clip.
615 The UID (aFormatUid) corresponds to the UID of the destination format to use.
618 The UID of the destination format.
622 EXPORT_C void CMdaAudioConvertUtility::SetDestinationFormatL(TUid aFormatUid)
625 iProperties->SetDestinationFormatL(aFormatUid);
629 Returns the format of the destination audio clip.
631 @return The UID of the destination format.
635 EXPORT_C TUid CMdaAudioConvertUtility::DestinationFormatL()
638 return iProperties->DestinationFormatL();
642 Returns the format of the source audio clip.
644 @return The UID of the source format.
648 EXPORT_C TUid CMdaAudioConvertUtility::SourceFormatL()
651 return iProperties->SourceFormatL();
655 Sets the number of channels the destination audio clip contains.
657 The number of channels must be one of the values returned by
658 GetSupportedConversionNumberOfChannelsL().
660 @param aNumberOfChannels
661 The number of channels.
665 EXPORT_C void CMdaAudioConvertUtility::SetDestinationNumberOfChannelsL(TUint aNumberOfChannels)
668 iProperties->SetDestinationNumberOfChannelsL(aNumberOfChannels);
672 Returns the number of channels the destination audio clip contains.
674 @return The number of channels.
678 EXPORT_C TUint CMdaAudioConvertUtility::DestinationNumberOfChannelsL()
681 return iProperties->DestinationNumberOfChannelsL();
685 Returns a list of the supported number of channels for conversion.
687 For example, 1 for mono, 2 for stereo and so on.
689 @param aSupportedNumChannels
690 A list of the number of channels supported for the conversion destination.
694 EXPORT_C void CMdaAudioConvertUtility::GetSupportedConversionNumberOfChannelsL(RArray<TUint>& aSupportedNumChannels)
697 iProperties->GetSupportedConversionNumberOfChannelsL(aSupportedNumChannels);
701 Returns the number of channels used by the conversion source.
703 @return The number of channels.
707 EXPORT_C TUint CMdaAudioConvertUtility::SourceNumberOfChannelsL()
710 return iProperties->SourceNumberOfChannelsL();
713 Performs the conversion from the source audio format to the destination.
715 When conversion is complete, successfully or otherwise, the client is notified by
716 MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
717 providing it with state change information and error codes.
721 EXPORT_C void CMdaAudioConvertUtility::ConvertL()
724 iProperties->ConvertL();
728 Returns the controller implementation information associated with the current controller.
730 @return The controller implementation structure associated with the controller
734 EXPORT_C const CMMFControllerImplementationInformation& CMdaAudioConvertUtility::ControllerImplementationInformationL()
737 return iProperties->ControllerImplementationInformationL();
741 Sends a synchronous custom command to the controller.
744 The destination of the message, consisting of the UID of the interface of this message.
746 The function number to indicate which function is to be called
747 on the interface defined in the aDestination parameter.
749 A reference to the first chunk of data to be copied to the controller
750 framework. The exact contents of the data are dependent on the
751 interface being called. Can be KNullDesC8.
753 A reference to the second chunk of data to be copied to the controller
754 framework. The exact contents of the data are dependent on the
755 interface being called. Can be KNullDesC8.
757 A reference to an area of memory to which the controller framework will
758 write any data to be passed back to the client. Can't be KNullDesC8.
760 @return The result of the request. Exact range of values is dependent on the interface.
764 EXPORT_C TInt CMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom)
767 return iProperties->CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom);
771 Sends a synchronous custom command to the controller.
774 The destination of the message, consisting of the UID of the interface of this message.
776 The function number to indicate which function is to be called on the interface defined in
777 the aDestination parameter.
779 A reference to the first chunk of data to be copied to the controllert framework. The exact
780 contents of the data are dependent on the interface being called. Can be KNullDesC8.
782 A reference to the second chunk of data to be copied to the controller framework. The exact
783 contents of the data are dependent on the interface being called. Can be KNullDesC8.
785 @return The result of the request. The exact range of values is dependent on the interface.
789 EXPORT_C TInt CMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2)
792 return iProperties->CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2);
796 Send a asynchronous custom command to the controller.
798 Note: This method will return immediately. The RunL of the active object owning the
799 aStatus parameter will be called when the command is completed by the controller framework.
802 The destination of the message, consisting of the UID of the interface of this message.
804 The function number to indicate which function is to be called on the interface defined in
805 the aDestination parameter.
807 A reference to the first chunk of data to be copied to the controller framework. The exact
808 contents of the data are dependent on the interface being called. Can be KNullDesC8.
810 A reference to the second chunk of data to be copied to the controller framework. The exact
811 contents of the data are dependent on the interface being called. Can be KNullDesC8.
813 A reference to an area of memory to which the controller framework will write any data to be
814 passed back to the client. Can't be KNullDesC8.
816 The TRequestStatus of an active object. This will contain the result of the request on
817 completion. The exact range of result values is dependent on the interface.
820 EXPORT_C void CMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus)
823 iProperties->CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom, aStatus);
827 Send a asynchronous custom command to the controller.
829 Note: This method will return immediately. The RunL of the active object owning the
830 aStatus parameter will be called when the command is completed by the controller framework.
833 The destination of the message, consisting of the UID of the interface of this message.
835 The function number to indicate which function is to be called on the interface defined in
836 the aDestination parameter.
838 A reference to the first chunk of data to be copied to the controller framework. The exact
839 contents of the data are dependent on the interface being called. Can be KNullDesC8.
841 A reference to the second chunk of data to be copied to the controller framework. The exact
842 contents of the data are dependent on the interface being called. Can be KNullDesC8.
844 The TRequestStatus of an active object. This will contain the result of the request on
845 completion. The exact range of result values is dependent on the interface.
849 EXPORT_C void CMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus)
852 iProperties->CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aStatus);
856 Set the priority of the controller's sub thread.
858 This can be used to increase the responsiveness of the audio plugin to minimise
859 any lag in processing. This function should be used with care as it may have knock-on
860 effects elsewhere in the system.
863 The TThreadPriority that the thread should run under. The default is EPriorityNormal.
865 A standard error code: KErrNone if successful, KErrNotReady if the thread does not have a
868 EXPORT_C TInt CMdaAudioConvertUtility::SetThreadPriority(const TThreadPriority& aThreadPriority) const
871 return iProperties->SetThreadPriority(aThreadPriority);
875 /******************************************************************************/
878 CMMFMdaAudioConvertUtility::CMMFMdaAudioConvertUtility(CMdaAudioConvertUtility* aParent,
879 MMdaObjectStateChangeObserver& aCallback) :
880 iCallback(aCallback),
881 iAudioControllerCustomCommands(iController),
882 iAudioPlayControllerCustomCommands(iController),
883 iAudioRecordControllerCustomCommands(iController),
888 iConvertStart = TTimeIntervalMicroSeconds(0);
889 iConvertEnd = TTimeIntervalMicroSeconds(0);
890 iConvertWindowSet = EFalse;
893 void CMMFMdaAudioConvertUtility::ConstructL(TInt /*aPriority*/, TInt /*aPref*/)
895 iControllerEventMonitor = CMMFControllerEventMonitor::NewL(*this, iController);
896 iAsyncCallback = CMMFMdaObjectStateChangeObserverCallback::NewL(iCallback);
897 User::LeaveIfError(iMediaIds.Append(KUidMediaTypeAudio));
898 iFindAndOpenController = CMMFFindAndOpenController::NewL(*this);
899 iFindAndOpenController->Configure(iMediaIds[0], iPrioritySettings);
900 iFindAndOpenController->ConfigureController(iController, *iControllerEventMonitor, CMMFFindAndOpenController::EConvert);
903 CMMFMdaAudioConvertUtility::~CMMFMdaAudioConvertUtility()
905 delete iControllerImplementationInformation;
906 delete iAsyncCallback;
907 delete iFindAndOpenController;
908 delete iControllerEventMonitor;
913 void CMMFMdaAudioConvertUtility::UseSharedHeap()
915 iFindAndOpenController->UseSharedHeap();
918 void CMMFMdaAudioConvertUtility::MfaocComplete(
920 RMMFController* /*aController*/,
922 TMMFMessageDestination* /*aSourceHandle*/,
923 TMMFMessageDestination* /*aSinkHandle*/)
925 TInt oldState = iState;
927 if (aError == KErrNone)
929 iControllerUid = aControllerUid;
930 aError = ControllerOpen();
931 if (iFindAndOpenController)
933 iFindAndOpenController->Close();
937 iAsyncCallback->CallBack(iParent, oldState, iState, aError);
940 void CMMFMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation,
941 TMdaClipLocation* aSecLocation,
942 TMdaClipFormat* aPriFormat,
943 TMdaClipFormat* aSecFormat,
944 TMdaPackage* aPriArg1 /*= NULL*/,
945 TMdaPackage* aPriArg2 /*= NULL*/,
946 TMdaPackage* aSecArg1 /*= NULL*/,
947 TMdaPackage* aSecArg2 /*= NULL*/)
949 __ASSERT_ALWAYS((aPriLocation && aSecLocation && aPriFormat && aSecFormat), User::Leave(KErrArgument));
951 __ASSERT_ALWAYS((((aPriLocation->Uid() == KUidMdaFileResLoc) || (aPriLocation->Uid() == KUidMdaDesResLoc) || (aPriLocation->Uid() == KUidMdaUrlResLoc)) &&
952 ((aSecLocation->Uid() == KUidMdaFileResLoc) || (aSecLocation->Uid() == KUidMdaDesResLoc) || (aSecLocation->Uid() == KUidMdaUrlResLoc))),
953 User::Leave(KErrNotSupported));
955 __ASSERT_ALWAYS(((aPriFormat->Uid() != KNullUid) && (aSecFormat->Uid() != KNullUid)), User::Leave(KErrNotSupported));
959 //Do aPriArg2 & aSecArg2 contain the correct package type
962 TMdaPackage* pckg = aPriArg2;
963 if(pckg->Uid() != KUidMdaMediaTypeAudio)
964 User::Leave(KErrNotSupported);
966 TMdaAudioDataSettings audioSettings = *(TMdaAudioDataSettings*)aPriArg2;
967 iSourceSampleRate = audioSettings.iSampleRate;
968 iSourceChannels = audioSettings.iChannels;
973 TMdaPackage* pckg = aSecArg2;
974 if(pckg->Uid() != KUidMdaMediaTypeAudio)
975 User::Leave(KErrNotSupported);
976 TMdaAudioDataSettings audioSettings = *(TMdaAudioDataSettings*)aSecArg2;
977 iSinkSampleRate = audioSettings.iSampleRate;
978 iSinkChannels = audioSettings.iChannels;
982 //Do aPriArg1 & aSecArg1 contain supported FourCC types
983 iSourceDataType = KMMFFourCCCodeNULL;
986 iSourceDataType = CMMFClientUtility::ConvertMdaCodecToFourCC(*aPriArg1);
987 if(iSourceDataType == KMMFFourCCCodeNULL)
988 User::Leave(KErrNotSupported);
991 iSinkDataType = KMMFFourCCCodeNULL;
994 iSinkDataType = CMMFClientUtility::ConvertMdaCodecToFourCC(*aSecArg1);
995 if(iSinkDataType == KMMFFourCCCodeNULL)
996 User::Leave(KErrNotSupported);
1001 TInt err = KErrNone;
1003 iSourceFormatUid = CMMFClientUtility::ConvertMdaFormatUidToECOMRead(aPriFormat->Uid());
1004 //If a new formatter plugin has been added, use the supplied read format implementation ID
1005 if (iSourceFormatUid == KNullUid)
1006 iSourceFormatUid = aPriFormat->Uid();
1008 iSinkFormatUid = CMMFClientUtility::ConvertMdaFormatUidToECOMWrite(aSecFormat->Uid());
1009 //If a new formatter plugin has been added, use the supplied write format implementation ID
1010 if (iSinkFormatUid == KNullUid)
1011 iSinkFormatUid = aSecFormat->Uid();
1013 TRAP(err, ConfigureSourceSinkL(aPriLocation, aSecLocation));
1016 iFindAndOpenController->OpenByFormatUid(iSourceFormatUid, iSinkFormatUid);
1020 TInt oldState = State();
1021 iAsyncCallback->CallBack(iParent, oldState, oldState, err);
1029 void CMMFMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, const TDesC& aSecondaryFile)
1033 iFindAndOpenController->ConfigureSourceSink(
1034 CMMFFindAndOpenController::TSourceSink(KUidMmfFileSource, CMMFFindAndOpenController::GetConfigFile(aPrimaryFile)),
1035 CMMFFindAndOpenController::TSourceSink(KUidMmfFileSink, CMMFFindAndOpenController::GetConfigFile(aSecondaryFile)));
1037 TMMFileSource tfs(aPrimaryFile);
1038 iFindAndOpenController->OpenByFileSource(tfs, aSecondaryFile);
1041 void CMMFMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile,
1042 TMdaClipLocation* aLocation, // Normally file or descriptor
1043 TMdaClipFormat* aFormat, // Data format
1044 TMdaPackage* aArg1, // Normally codec to use
1045 TMdaPackage* aArg2) // Normally audio settings
1047 __ASSERT_ALWAYS(aLocation && aFormat, User::Leave(KErrArgument));
1051 // convert from the old parameters
1054 iSinkFormatUid = CMMFClientUtility::ConvertMdaFormatUidToECOMWrite(aFormat->Uid());
1056 //If a new formatter plugin has been added, use the supplied format ID
1057 if (iSinkFormatUid == KNullUid)
1058 iSinkFormatUid = aFormat->Uid();
1062 iSinkDataType = CMMFClientUtility::ConvertMdaCodecToFourCC(*aArg1);
1065 {//have audio settings
1066 TMdaAudioDataSettings audioSettings = *(TMdaAudioDataSettings*)aArg2; //shoud check arg2 are data settings
1067 iSinkSampleRate = audioSettings.iSampleRate;
1068 iSinkChannels = audioSettings.iChannels;
1073 TMMFFileConfig sourceCfg;
1074 sourceCfg().iPath = aPrimaryFile;
1076 TMMFDescriptorConfig dstDesCfg;
1077 TMMFFileConfig dstFileCfg;
1078 CBufFlat* dstCfgBuffer = NULL;
1079 CMMFUrlParams* dstURLCfg = NULL;
1080 TUid dstUid = KNullUid;
1081 TPtrC8 dstCfg(NULL, 0);
1083 TInt err = KErrNone;
1085 if (aLocation->Uid() == KUidMdaFileResLoc)
1086 {//sink clip location is a file
1087 TDesC& fileName = ((TMdaFileClipLocation*)aLocation)->iName;
1088 dstFileCfg().iPath = fileName;
1089 dstCfg.Set(dstFileCfg);
1090 dstUid = KUidMmfFileSink;
1092 else if (aLocation->Uid() == KUidMdaDesResLoc)
1093 {//sink clip is a descriptor - pass down descriptor & thread id
1094 TMdaDesClipLocation* desLoc = (TMdaDesClipLocation*)aLocation;
1095 dstDesCfg().iDes = desLoc->iDes;
1096 dstDesCfg().iDesThreadId = desLoc->iThreadId;
1097 dstCfg.Set(dstDesCfg);
1098 dstUid = KUidMmfDescriptorSink;
1100 else if (aLocation->Uid() == KUidMdaUrlResLoc)
1102 TMdaUrlClipLocation* desLoc = (TMdaUrlClipLocation*)aLocation;
1103 dstURLCfg = CMMFUrlParams::NewLC(desLoc->iUrl, desLoc->iIapId);
1104 dstCfgBuffer = dstURLCfg->ExternalizeToCBufFlatLC();
1105 dstCfg.Set(dstCfgBuffer->Ptr(0));
1106 dstUid = KUidMmfUrlSink;
1109 err = KErrNotSupported;
1113 iFindAndOpenController->ConfigureSourceSink(
1114 CMMFFindAndOpenController::TSourceSink(KUidMmfFileSource, sourceCfg),
1115 CMMFFindAndOpenController::TSourceSink(dstUid, dstCfg));
1117 TMMFileSource tfs(aPrimaryFile);
1118 iFindAndOpenController->OpenByFileSource(tfs);
1124 CleanupStack::PopAndDestroy(dstCfgBuffer);
1126 CleanupStack::PopAndDestroy(dstURLCfg);
1131 TInt oldState = State();
1132 iAsyncCallback->CallBack(iParent, oldState, oldState, err);
1137 void CMMFMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation,
1138 TMdaClipLocation* aSecLocation,
1139 TUid aControllerUid, // the controller to use
1140 TUid aDestFormatUid,
1141 TFourCC aDestDataType)
1143 __ASSERT_ALWAYS(aPriLocation && aSecLocation, User::Leave(KErrArgument));
1148 // Configure the destination format and data type
1149 if (aDestFormatUid != KNullUid)
1150 iSinkFormatUid = aDestFormatUid;
1152 if (aDestDataType != KMMFFourCCCodeNULL)
1153 iSinkDataType = aDestDataType;
1155 TRAPD(err, ConfigureSourceSinkL(aPriLocation, aSecLocation));
1157 iFindAndOpenController->OpenByControllerUid(aControllerUid);
1162 TInt oldState = State();
1163 iAsyncCallback->CallBack(iParent, oldState, oldState, err);
1169 void CMMFMdaAudioConvertUtility::HandleEvent(const TMMFEvent& aEvent)
1171 //When converting, state is EPlaying, ERecording is never used
1172 if (aEvent.iEventType==KMMFEventCategoryPlaybackComplete || aEvent.iEventType==KMMFErrorCategoryControllerGeneralError)
1174 TInt oldState = iState;
1175 iState = CMdaAudioClipUtility::EOpen;
1177 //if we weren't converting, don't advise Client.
1178 if(oldState == CMdaAudioClipUtility::EPlaying)
1179 iCallback.MoscoStateChangeEvent(iParent, CMdaAudioClipUtility::EPlaying, iState, aEvent.iErrorCode);
1183 void CMMFMdaAudioConvertUtility::PlayL()
1185 // N.B. ConvertL should be used in preference to PlayL
1189 void CMMFMdaAudioConvertUtility::RecordL()
1191 // N.B. ConvertL should be used in preference to RecordL
1195 void CMMFMdaAudioConvertUtility::ConvertL()
1197 if (iState == CMdaAudioClipUtility::EOpen)
1200 err = iController.Prime();
1203 err=iController.SetPosition(iPosition);
1204 if (!err && iConvertWindowSet)
1205 err = iAudioPlayControllerCustomCommands.SetPlaybackWindow(iConvertStart, iConvertEnd);
1207 err = iController.Play();
1210 TInt oldState = iState;
1212 iState = CMdaAudioClipUtility::EPlaying;
1214 iAsyncCallback->CallBack(iParent, oldState, iState, err);
1217 iAsyncCallback->CallBack(iParent, iState, iState, KErrNotReady);
1220 void CMMFMdaAudioConvertUtility::Stop()
1222 TInt err = iController.Pause();
1223 TInt oldState = iState;
1225 iState = CMdaAudioClipUtility::EOpen;
1226 iAsyncCallback->CallBack(iParent, oldState, iState, err);
1229 void CMMFMdaAudioConvertUtility::CropL(TBool aCropToEnd)
1231 // if we are busy converting, or we have not opened the file, return KErrNotReady
1232 if (iState!=CMdaAudioClipUtility::EOpen)
1233 User::Leave(KErrNotReady);
1235 // check that cropping position is valid if clip has been cropped before
1236 if (iHasCropped && iPosition > iCroppedDuration)
1238 User::Leave(KErrArgument);
1241 TInt err = iController.Prime();
1246 err = iController.SetPosition(iPosition);
1248 err = iAudioRecordControllerCustomCommands.Crop(aCropToEnd);
1249 // try to stop controller regardless of whether any of the above commands failed
1251 // save the duration of the cropped clip because
1252 // Duration() returns length of the original clip only
1253 // this is used to prevent a subsequent crop, beyond the end of the
1254 // already cropped clip.
1255 if (err == KErrNone)
1257 iHasCropped = ETrue;
1259 iCroppedDuration = iPosition;
1261 iCroppedDuration = TTimeIntervalMicroSeconds(iDuration.Int64() - iPosition.Int64());
1264 User::LeaveIfError(err);
1267 void CMMFMdaAudioConvertUtility::SetPosition(const TTimeIntervalMicroSeconds& aPosition)
1269 iPosition = aPosition;
1271 // Clip the position if aPosition is greater than the duration, or less then 0
1272 const TTimeIntervalMicroSeconds duration = Duration();
1273 if (iPosition > duration)
1274 iPosition = duration;
1275 else if (iPosition < TTimeIntervalMicroSeconds(0))
1278 if (iState==CMdaAudioClipUtility::EPlaying)
1279 iController.SetPosition(iPosition);
1282 const TTimeIntervalMicroSeconds& CMMFMdaAudioConvertUtility::Position()
1284 if (iState==CMdaAudioClipUtility::EPlaying)
1286 TInt err = iController.GetPosition(iPositionTemp);
1288 return iPositionTemp;
1293 const TTimeIntervalMicroSeconds& CMMFMdaAudioConvertUtility::RecordTimeAvailable()
1298 iAudioRecordControllerCustomCommands.GetRecordTimeAvailable(iRecordTimeAvailable);
1299 __ASSERT_DEBUG(error==KErrNone, Panic(EMMFMediaClientPanicServerCommunicationProblem));
1300 return iRecordTimeAvailable;
1303 const TTimeIntervalMicroSeconds& CMMFMdaAudioConvertUtility::Duration()
1305 TInt err = iController.GetDuration(iDuration);
1311 void CMMFMdaAudioConvertUtility::SetMaxWriteLength(TInt aMaxWriteLength)
1313 iAudioRecordControllerCustomCommands.SetMaxFileSize(aMaxWriteLength);
1317 void CMMFMdaAudioConvertUtility::SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd)
1319 if (aStart >= TTimeIntervalMicroSeconds(0) &&
1320 aStart < iDuration &&
1324 iConvertStart = aStart;
1326 iConvertWindowSet = ETrue;
1328 if (iState==CMdaAudioClipUtility::EPlaying)
1333 iAudioPlayControllerCustomCommands.SetPlaybackWindow(aStart, aEnd);
1334 __ASSERT_DEBUG(error==KErrNone, Panic(EMMFMediaClientPanicServerCommunicationProblem));
1339 __ASSERT_DEBUG(EFalse, Panic(EMMFMediaClientPanicServerCommunicationProblem));
1343 void CMMFMdaAudioConvertUtility::ClearPlayWindow()
1345 iConvertWindowSet = EFalse;
1349 iAudioPlayControllerCustomCommands.DeletePlaybackWindow();
1350 __ASSERT_DEBUG(err==KErrNone, Panic(EMMFMediaClientPanicServerCommunicationProblem));
1353 void CMMFMdaAudioConvertUtility::SetRepeats(TInt /*aRepeatNumberOfTimes*/, const TTimeIntervalMicroSeconds& /*aTrailingSilence*/)
1355 // This doesn't really make sense for the converter.
1358 void CMMFMdaAudioConvertUtility::SetPriority(TInt aPriority, TInt aPref)
1360 iPrioritySettings.iPref = aPref;
1361 iPrioritySettings.iPriority = aPriority;
1362 iFindAndOpenController->Configure(iMediaIds[0], iPrioritySettings);
1363 iController.SetPrioritySettings(iPrioritySettings);
1367 void CMMFMdaAudioConvertUtility::Close()
1369 iControllerEventMonitor->Cancel();
1370 iController.Close();
1372 if (iFindAndOpenController)
1373 iFindAndOpenController->Close();
1375 iHasCropped = EFalse;
1376 iCroppedDuration = 0;
1377 iState = CMdaAudioClipUtility::ENotReady;
1378 if(iControllerImplementationInformation)
1380 delete iControllerImplementationInformation;
1381 iControllerImplementationInformation = NULL;
1383 iControllerUid = KNullUid;
1386 void CMMFMdaAudioConvertUtility::CropL(const TTimeIntervalMicroSeconds &aCropBegin,
1387 const TTimeIntervalMicroSeconds &aCropEnd)
1389 // if we are busy converting, or we have not opened the file, return KErrNotReady
1390 if (iState!=CMdaAudioClipUtility::EOpen)
1391 User::Leave(KErrNotReady);
1393 // check that cropping positions are valid if clip has been cropped before
1394 if (iHasCropped && aCropEnd > iCroppedDuration)
1396 User::Leave(KErrArgument);
1399 TInt err = iController.Prime();
1402 err =iController.SetPosition(aCropEnd);
1404 err = iAudioRecordControllerCustomCommands.Crop(ETrue);
1407 //remember the cropping, store the cropped length
1408 iHasCropped = ETrue;
1409 iCroppedDuration = aCropEnd;
1410 err = iController.SetPosition(aCropBegin);
1413 err = iAudioRecordControllerCustomCommands.Crop(EFalse);
1414 if (!err) // store the new cropped length
1415 iCroppedDuration = TTimeIntervalMicroSeconds(aCropEnd.Int64() - aCropBegin.Int64());
1417 // try to stop controller regardless of whether any of the above commands failed
1420 User::LeaveIfError(err);
1423 CMdaAudioClipUtility::TState CMMFMdaAudioConvertUtility::State()
1428 void CMMFMdaAudioConvertUtility::GetSupportedDestinationDataTypesL(RArray<TFourCC>& aSupportedDataTypes)
1430 iAudioControllerCustomCommands.GetSupportedSinkDataTypesL(aSupportedDataTypes);
1433 void CMMFMdaAudioConvertUtility::SetSourceDataTypeL(TFourCC aDataType)
1435 User::LeaveIfError(iAudioControllerCustomCommands.SetSourceDataType(aDataType));
1438 void CMMFMdaAudioConvertUtility::SetDestinationDataTypeL(TFourCC aDataType)
1440 User::LeaveIfError(iAudioControllerCustomCommands.SetSinkDataType(aDataType));
1443 TFourCC CMMFMdaAudioConvertUtility::DestinationDataTypeL()
1446 User::LeaveIfError(iAudioControllerCustomCommands.GetSinkDataType(dataType));
1450 TFourCC CMMFMdaAudioConvertUtility::SourceDataTypeL()
1453 User::LeaveIfError(iAudioControllerCustomCommands.GetSourceDataType(dataType));
1458 void CMMFMdaAudioConvertUtility::SetDestinationBitRateL(TUint aBitRate)
1460 User::LeaveIfError(iAudioControllerCustomCommands.SetSinkBitRate(aBitRate));
1463 void CMMFMdaAudioConvertUtility::SetSourceSampleRateL(TUint aSampleRate)
1465 User::LeaveIfError(iController.Stop());
1466 User::LeaveIfError(iAudioControllerCustomCommands.SetSourceSampleRate(aSampleRate));
1469 void CMMFMdaAudioConvertUtility::SetDestinationSampleRateL(TUint aSampleRate)
1471 User::LeaveIfError(iController.Stop());
1472 User::LeaveIfError(iAudioControllerCustomCommands.SetSinkSampleRate(aSampleRate));
1475 void CMMFMdaAudioConvertUtility::SetSourceFormatL(TUid aRecordFormat)
1477 User::LeaveIfError(iAudioControllerCustomCommands.SetSourceFormat(aRecordFormat));
1480 void CMMFMdaAudioConvertUtility::SetDestinationFormatL(TUid aRecordFormat)
1482 User::LeaveIfError(iAudioControllerCustomCommands.SetSinkFormat(aRecordFormat));
1485 void CMMFMdaAudioConvertUtility::SetSourceNumberOfChannelsL(TUint aNumberOfChannels)
1487 User::LeaveIfError(iAudioControllerCustomCommands.SetSourceNumChannels(aNumberOfChannels));
1490 void CMMFMdaAudioConvertUtility::SetDestinationNumberOfChannelsL(TUint aNumberOfChannels)
1492 User::LeaveIfError(iAudioControllerCustomCommands.SetSinkNumChannels(aNumberOfChannels));
1495 TUint CMMFMdaAudioConvertUtility::DestinationBitRateL()
1498 User::LeaveIfError(iAudioControllerCustomCommands.GetSinkBitRate(bitRate));
1502 TUint CMMFMdaAudioConvertUtility::DestinationSampleRateL()
1505 User::LeaveIfError(iAudioControllerCustomCommands.GetSinkSampleRate(sampleRate));
1509 TUid CMMFMdaAudioConvertUtility::DestinationFormatL()
1512 User::LeaveIfError(iAudioControllerCustomCommands.GetSinkFormat(format));
1516 TUint CMMFMdaAudioConvertUtility::DestinationNumberOfChannelsL()
1519 User::LeaveIfError(iAudioControllerCustomCommands.GetSinkNumChannels(numChannels));
1523 TUint CMMFMdaAudioConvertUtility::SourceBitRateL()
1526 User::LeaveIfError(iAudioControllerCustomCommands.GetSourceBitRate(bitRate));
1530 TUint CMMFMdaAudioConvertUtility::SourceSampleRateL()
1533 User::LeaveIfError(iAudioControllerCustomCommands.GetSourceSampleRate(sampleRate));
1537 TUid CMMFMdaAudioConvertUtility::SourceFormatL()
1540 User::LeaveIfError(iAudioControllerCustomCommands.GetSourceFormat(format));
1544 TUint CMMFMdaAudioConvertUtility::SourceNumberOfChannelsL()
1547 User::LeaveIfError(iAudioControllerCustomCommands.GetSourceNumChannels(numChannels));
1552 void CMMFMdaAudioConvertUtility::GetSupportedConversionBitRatesL(RArray<TUint>& aSupportedBitRates)
1554 iAudioControllerCustomCommands.GetSupportedSinkBitRatesL(aSupportedBitRates);
1557 void CMMFMdaAudioConvertUtility::GetSupportedConversionSampleRatesL(RArray<TUint>& aSupportedSampleRates)
1559 User::LeaveIfError(iController.Prime());
1560 iAudioControllerCustomCommands.GetSupportedSinkSampleRatesL(aSupportedSampleRates);
1561 User::LeaveIfError(iController.Stop());
1564 void CMMFMdaAudioConvertUtility::GetSupportedConversionNumberOfChannelsL(RArray<TUint>& aSupportedNumChannels)
1566 iAudioControllerCustomCommands.GetSupportedSinkNumChannelsL(aSupportedNumChannels);
1569 CMdaAudioConvertUtility* CMMFMdaAudioConvertUtility::Parent() const
1572 return static_cast<CMdaAudioConvertUtility*>(iParent);
1575 TInt CMMFMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom)
1577 return iController.CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom);
1580 TInt CMMFMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2)
1582 return iController.CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2);
1585 void CMMFMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus)
1587 iController.CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom, aStatus);
1590 void CMMFMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus)
1592 iController.CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aStatus);
1595 const CMMFControllerImplementationInformation& CMMFMdaAudioConvertUtility::ControllerImplementationInformationL()
1597 if (!iControllerImplementationInformation)
1599 if (iControllerUid==KNullUid)
1600 User::Leave(KErrNotReady);
1601 iControllerImplementationInformation = CMMFControllerImplementationInformation::NewL(iControllerUid);
1603 return *iControllerImplementationInformation;
1607 void CMMFMdaAudioConvertUtility::Reset()
1609 // Make sure any existing controller is closed.
1612 iSourceFormatUid = KNullUid;
1613 iSinkFormatUid = KNullUid;
1614 iSourceDataType = KMMFFourCCCodeNULL;
1615 iSinkDataType = KMMFFourCCCodeNULL;
1616 iSourceSampleRate = 0;
1617 iSinkSampleRate = 0;
1618 iSourceChannels = 0;
1623 TInt CMMFMdaAudioConvertUtility::ControllerOpen()
1625 TInt err = KErrNone;
1627 if(iSourceFormatUid != KNullUid)
1628 TRAP(err, SetSourceFormatL(iSourceFormatUid));
1630 if(!err && iSinkFormatUid != KNullUid)
1631 TRAP(err, SetDestinationFormatL(iSinkFormatUid));
1633 if(!err && iSourceDataType != KMMFFourCCCodeNULL)
1635 TRAP(err, SetSourceDataTypeL(iSourceDataType));
1638 if(!err && iSinkDataType != KMMFFourCCCodeNULL)
1640 TRAP(err, SetDestinationDataTypeL(iSinkDataType));
1643 // set the audio data settings ie sample rate & channels
1644 if (!err && iSourceSampleRate != 0)
1646 TRAP(err, SetSourceSampleRateL(iSourceSampleRate));
1649 if (!err && iSourceChannels != 0)
1651 TRAP(err, SetSourceNumberOfChannelsL(iSourceChannels));
1654 if (!err && iSinkSampleRate != 0)
1656 TRAP(err, SetDestinationSampleRateL(iSinkSampleRate));
1659 if (!err && iSinkChannels != 0)
1661 TRAP(err, SetDestinationNumberOfChannelsL(iSinkChannels));
1664 //get the clip duration
1667 iDuration = TTimeIntervalMicroSeconds(0);
1668 err = iController.GetDuration(iDuration);
1674 iState = CMdaAudioClipUtility::EOpen;
1680 void CMMFMdaAudioConvertUtility::ConfigureSourceSinkL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation)
1682 TMMFDescriptorConfig srcDesCfg;
1683 TMMFFileConfig srcFileCfg;
1684 CBufFlat* srcCfgBuffer = NULL;
1685 CMMFUrlParams* srcURLCfg = NULL;
1687 TUid sourceUid = KNullUid;
1689 TMMFDescriptorConfig dstDesCfg;
1690 TMMFFileConfig dstFileCfg;
1691 CBufFlat* dstCfgBuffer = NULL;
1692 CMMFUrlParams* dstURLCfg = NULL;
1694 TUid dstUid = KNullUid;
1696 TInt err = KErrNone;
1698 // setup the source config info
1699 if (aPriLocation->Uid() == KUidMdaFileResLoc)
1700 {//sink clip location is a file
1701 TDesC& fileName = ((TMdaFileClipLocation*)aPriLocation)->iName;
1702 srcFileCfg().iPath = fileName;
1703 sourceCfg.Set(srcFileCfg);
1704 sourceUid = KUidMmfFileSource;
1706 else if (aPriLocation->Uid() == KUidMdaDesResLoc)
1707 {//sink clip is a descriptor - pass down descriptor & thread id
1708 TMdaDesClipLocation* srcLoc = (TMdaDesClipLocation*)aPriLocation;
1709 srcDesCfg().iDes = srcLoc->iDes;
1710 srcDesCfg().iDesThreadId = srcLoc->iThreadId;
1711 sourceCfg.Set(srcDesCfg);
1712 sourceUid = KUidMmfDescriptorSource;
1714 else if (aPriLocation->Uid() == KUidMdaUrlResLoc)
1716 TMdaUrlClipLocation* srcLoc = (TMdaUrlClipLocation*)aPriLocation;
1717 srcURLCfg = CMMFUrlParams::NewLC(srcLoc->iUrl, srcLoc->iIapId);
1718 srcCfgBuffer = srcURLCfg->ExternalizeToCBufFlatLC();
1719 sourceCfg.Set(srcCfgBuffer->Ptr(0));
1720 sourceUid = KUidMmfUrlSource;
1724 err = KErrNotSupported;
1729 if (aSecLocation->Uid() == KUidMdaFileResLoc)
1730 {//sink clip location is a file
1731 TDesC& fileName = ((TMdaFileClipLocation*)aSecLocation)->iName;
1732 dstFileCfg().iPath = fileName;
1733 dstCfg.Set(dstFileCfg);
1734 dstUid = KUidMmfFileSink;
1736 else if (aSecLocation->Uid() == KUidMdaDesResLoc)
1737 {//sink clip is a descriptor - pass down descriptor & thread id
1738 TMdaDesClipLocation* desLoc = (TMdaDesClipLocation*)aSecLocation;
1739 dstDesCfg().iDes = desLoc->iDes;
1740 dstDesCfg().iDesThreadId = desLoc->iThreadId;
1741 dstCfg.Set(dstDesCfg);
1742 dstUid = KUidMmfDescriptorSink;
1744 else if (aSecLocation->Uid() == KUidMdaUrlResLoc)
1746 TMdaUrlClipLocation* desLoc = (TMdaUrlClipLocation*)aSecLocation;
1747 dstURLCfg = CMMFUrlParams::NewLC(desLoc->iUrl, desLoc->iIapId);
1748 dstCfgBuffer = dstURLCfg->ExternalizeToCBufFlatLC();
1749 dstCfg.Set(dstCfgBuffer->Ptr(0));
1750 dstUid = KUidMmfUrlSink;
1754 err = KErrNotSupported;
1760 iFindAndOpenController->ConfigureSourceSink(
1761 CMMFFindAndOpenController::TSourceSink(sourceUid, sourceCfg),
1762 CMMFFindAndOpenController::TSourceSink(dstUid, dstCfg));
1766 CleanupStack::PopAndDestroy(2); //dstCfgBuffer, dstURLCfg
1768 CleanupStack::PopAndDestroy(2); //srcCfgBuffer, srcURLCfg
1770 User::LeaveIfError(err);
1774 TInt CMMFMdaAudioConvertUtility::SetThreadPriority(const TThreadPriority& aThreadPriority) const
1776 return iController.SetThreadPriority(aThreadPriority);