os/mm/mmlibs/mmfw/src/Client/Audio/mmfclientaudioconverter.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __MMFCLIENTAUDIOCONVERTER_H
    17 #define __MMFCLIENTAUDIOCONVERTER_H
    18 
    19 #include <e32std.h>
    20 #include <e32base.h>
    21 #include <mdaaudiosampleeditor.h>
    22 #include <mmf/server/mmffile.h>
    23 #include <mmf/server/mmfdes.h>
    24 #include <mmf/server/mmfurl.h>
    25 #include <mmf/common/mmfcontroller.h>
    26 #include "mmfclientutility.h"
    27 
    28 /**
    29 Concrete implementation of the CMdaAudioConvertUtility API.
    30 @see CMdaAudioConvertUtility
    31 */
    32 class CMMFMdaAudioConvertUtility;
    33 NONSHARABLE_CLASS( CMMFMdaAudioConvertUtility ): public CBase,
    34 								   				 public MMMFControllerEventMonitorObserver,
    35 								   				 public MMMFFindAndOpenControllerObserver
    36 	{
    37 friend class CMdaAudioConvertUtility;
    38 // for testing only
    39 friend class CTestStepUnitMMFAudClient;
    40 
    41 public:
    42 	~CMMFMdaAudioConvertUtility();
    43 
    44 	void OpenL(const TDesC& aPrimaryFile, const TDesC& aSecondaryFile);
    45 	// Open existing file and new/existing secondary
    46 	void OpenL(const TDesC& aPrimaryFile,
    47 			   TMdaClipLocation* aLocation,	// Normally file or descriptor
    48 			   TMdaClipFormat* aFormat,		// Data format
    49 			   TMdaPackage* aArg1 = NULL,	// Normally codec to use
    50 			   TMdaPackage* aArg2 = NULL);	// Normally audio settings
    51 
    52 	void OpenL(TMdaClipLocation* aPriLocation, 
    53 			   TMdaClipLocation* aSecLocation, 
    54 			   TMdaClipFormat* aPriFormat, 
    55 			   TMdaClipFormat* aSecFormat, 
    56 			   TMdaPackage* aPriArg1 = NULL, // Normally source codec to use
    57 			   TMdaPackage* aPriArg2 = NULL, // Normally source audio settings
    58 			   TMdaPackage* aSecArg1 = NULL, // Normally sink codec to use
    59 			   TMdaPackage* aSecArg2 = NULL);// Normally sink audio settings
    60 
    61 	// new controller based open
    62 	void OpenL(TMdaClipLocation* aPriLocation, 
    63 			   TMdaClipLocation* aSecLocation, 
    64 			   TUid aControllerUid, // the controller to use
    65 			   TUid aDestFormatUid,
    66 			   TFourCC aDestDataType);	
    67 	//from MMMFControllerEventMonitorObserver
    68 	void HandleEvent(const TMMFEvent& aEvent);
    69 
    70 	// from MMMFFindAndOpenControllerObserver 
    71 	virtual void MfaocComplete(
    72 		TInt& aError, 
    73 		RMMFController* aController, 
    74 		TUid aControllerUid, 
    75 		TMMFMessageDestination* aSourceHandle, 
    76 		TMMFMessageDestination* aSinkHandle);
    77 	
    78 	void UseSharedHeap();
    79 
    80 protected:
    81 	CMMFMdaAudioConvertUtility(CMdaAudioConvertUtility* aParent, MMdaObjectStateChangeObserver& aCallback);
    82 	void ConstructL(TInt aPriority, TInt aPref);
    83 private:
    84 
    85 	CMdaAudioClipUtility::TState State();
    86 	void Close();
    87 	void PlayL();		// N.B. ConvertL should be used in preference to PlayL
    88 	void RecordL();		// N.B. ConvertL should be used in preference to RecordL
    89 	void ConvertL();
    90 	void Stop();
    91 	void CropL(TBool aCropToEnd = ETrue);
    92 	void SetPosition(const TTimeIntervalMicroSeconds& aPosition);
    93 	const TTimeIntervalMicroSeconds& Position();
    94 	const TTimeIntervalMicroSeconds& RecordTimeAvailable();
    95 	const TTimeIntervalMicroSeconds& Duration();
    96 	void SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd);
    97 	void ClearPlayWindow();
    98 	void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
    99 	void SetMaxWriteLength(TInt aMaxWriteLength /*= KMdaClipLocationMaxWriteLengthNone*/);
   100 	void SetPriority(TInt aPriority, TInt aPref);  
   101 	void CropL(const TTimeIntervalMicroSeconds & aCropBegin, 
   102 			   const TTimeIntervalMicroSeconds & aCropEnd);
   103 
   104 	// Codec support
   105 	void GetSupportedDestinationDataTypesL(RArray<TFourCC>& aSupportedDestinationDataTypes);
   106 	void SetSourceDataTypeL(TFourCC aDataType)	;
   107 	void SetDestinationDataTypeL(TFourCC aCodec);
   108 	TFourCC DestinationDataTypeL();
   109 	TFourCC SourceDataTypeL();
   110 
   111 	// Bit rate support	
   112 	void SetDestinationBitRateL(TUint aBitRate);
   113 	TUint DestinationBitRateL();
   114 	void GetSupportedConversionBitRatesL(RArray<TUint>& aSupportedBitRates);
   115 	TUint SourceBitRateL();
   116 
   117 	// Sample rate support
   118 	void SetSourceSampleRateL(TUint aSampleRate);
   119 	void SetDestinationSampleRateL(TUint aSampleRate);
   120 	TUint DestinationSampleRateL();
   121 	void GetSupportedConversionSampleRatesL(RArray<TUint>& aSupportedSampleRates);
   122 	TUint SourceSampleRateL();
   123 	
   124 	// Format support
   125 	void SetSourceFormatL(TUid aRecordFormat);
   126 	void SetDestinationFormatL(TUid aFormatUid);
   127 	TUid DestinationFormatL();
   128 	TUid SourceFormatL();
   129 
   130 	// Number of channels
   131 	void SetSourceNumberOfChannelsL(TUint aNumberOfChannels);
   132 	void SetDestinationNumberOfChannelsL(TUint aNumberOfChannels);
   133 	TUint DestinationNumberOfChannelsL();
   134 	void GetSupportedConversionNumberOfChannelsL(RArray<TUint>& aSupportedNumChannels);
   135 	TUint SourceNumberOfChannelsL();
   136 	
   137 	const CMMFControllerImplementationInformation& ControllerImplementationInformationL();
   138 	TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
   139 	TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
   140 	void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
   141 	void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
   142 
   143 	CMdaAudioConvertUtility* Parent() const;
   144 
   145 	void Reset();
   146 	TInt ControllerOpen();
   147 	void ConfigureSourceSinkL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation);
   148 
   149 	TInt SetThreadPriority(const TThreadPriority& aThreadPriority) const;
   150 private:
   151 	MMdaObjectStateChangeObserver& iCallback;
   152 	CMMFMdaObjectStateChangeObserverCallback* iAsyncCallback;
   153 
   154 	RMMFController iController;
   155 	CMMFControllerEventMonitor* iControllerEventMonitor;
   156 
   157 	// Source and sink handle info
   158 	TMMFMessageDestination iSourceHandle;
   159 	TMMFMessageDestination iSinkHandle;
   160 	// Custom commands
   161 	RMMFAudioControllerCustomCommands iAudioControllerCustomCommands;
   162 	RMMFAudioPlayControllerCustomCommands iAudioPlayControllerCustomCommands;
   163 	RMMFAudioRecordControllerCustomCommands iAudioRecordControllerCustomCommands;
   164 
   165 	TMMFPrioritySettings iPrioritySettings;
   166 
   167 	TTimeIntervalMicroSeconds iPosition;
   168 	TTimeIntervalMicroSeconds iPositionTemp;
   169 	TTimeIntervalMicroSeconds iDuration;
   170 	TTimeIntervalMicroSeconds iRecordTimeAvailable;
   171 
   172 	CMdaAudioClipUtility::TState iState;
   173 
   174 	// Convert window start and end times and whether it has been set
   175 	TTimeIntervalMicroSeconds iConvertStart;
   176 	TTimeIntervalMicroSeconds iConvertEnd;
   177 	TBool iConvertWindowSet;
   178 
   179 	// parent class for callback
   180 	CMdaAudioConvertUtility* iParent;
   181 	RArray<TUid> iMediaIds;
   182 
   183 	// keeping track of cropped clip duration
   184 	TBool iHasCropped;
   185 	TTimeIntervalMicroSeconds iCroppedDuration;
   186 	CMMFControllerImplementationInformation* iControllerImplementationInformation;
   187 	TUid iControllerUid;
   188 
   189 	// utility class to find and open a suitable controller asynchronously
   190 	CMMFFindAndOpenController* iFindAndOpenController;
   191 
   192 	TUid iSourceFormatUid;		// for SetSourceFormat()
   193 	TUid iSinkFormatUid;		// for SetSinkFormat()
   194 
   195 	TFourCC iSourceDataType;	// for SetSourceDataType()
   196 	TFourCC iSinkDataType;		// for SetSinkDataType()
   197 
   198 	TInt iSourceSampleRate;		// for SetSourceSampleRateL()
   199 	TInt iSinkSampleRate;		// for SetDestinationSampleRateL()
   200 
   201 	TInt iSourceChannels;		// for SetSourceNumberOfChannelsL()
   202 	TInt iSinkChannels;			// for SetDestinationNumberOfChannelsL()
   203 	};
   204 
   205 #endif