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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MMFCLIENTAUDIOCONVERTER_H
17 #define __MMFCLIENTAUDIOCONVERTER_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"
29 Concrete implementation of the CMdaAudioConvertUtility API.
30 @see CMdaAudioConvertUtility
32 class CMMFMdaAudioConvertUtility;
33 NONSHARABLE_CLASS( CMMFMdaAudioConvertUtility ): public CBase,
34 public MMMFControllerEventMonitorObserver,
35 public MMMFFindAndOpenControllerObserver
37 friend class CMdaAudioConvertUtility;
39 friend class CTestStepUnitMMFAudClient;
42 ~CMMFMdaAudioConvertUtility();
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
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
61 // new controller based open
62 void OpenL(TMdaClipLocation* aPriLocation,
63 TMdaClipLocation* aSecLocation,
64 TUid aControllerUid, // the controller to use
66 TFourCC aDestDataType);
67 //from MMMFControllerEventMonitorObserver
68 void HandleEvent(const TMMFEvent& aEvent);
70 // from MMMFFindAndOpenControllerObserver
71 virtual void MfaocComplete(
73 RMMFController* aController,
75 TMMFMessageDestination* aSourceHandle,
76 TMMFMessageDestination* aSinkHandle);
81 CMMFMdaAudioConvertUtility(CMdaAudioConvertUtility* aParent, MMdaObjectStateChangeObserver& aCallback);
82 void ConstructL(TInt aPriority, TInt aPref);
85 CMdaAudioClipUtility::TState State();
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
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);
105 void GetSupportedDestinationDataTypesL(RArray<TFourCC>& aSupportedDestinationDataTypes);
106 void SetSourceDataTypeL(TFourCC aDataType) ;
107 void SetDestinationDataTypeL(TFourCC aCodec);
108 TFourCC DestinationDataTypeL();
109 TFourCC SourceDataTypeL();
112 void SetDestinationBitRateL(TUint aBitRate);
113 TUint DestinationBitRateL();
114 void GetSupportedConversionBitRatesL(RArray<TUint>& aSupportedBitRates);
115 TUint SourceBitRateL();
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();
125 void SetSourceFormatL(TUid aRecordFormat);
126 void SetDestinationFormatL(TUid aFormatUid);
127 TUid DestinationFormatL();
128 TUid SourceFormatL();
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();
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);
143 CMdaAudioConvertUtility* Parent() const;
146 TInt ControllerOpen();
147 void ConfigureSourceSinkL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation);
149 TInt SetThreadPriority(const TThreadPriority& aThreadPriority) const;
151 MMdaObjectStateChangeObserver& iCallback;
152 CMMFMdaObjectStateChangeObserverCallback* iAsyncCallback;
154 RMMFController iController;
155 CMMFControllerEventMonitor* iControllerEventMonitor;
157 // Source and sink handle info
158 TMMFMessageDestination iSourceHandle;
159 TMMFMessageDestination iSinkHandle;
161 RMMFAudioControllerCustomCommands iAudioControllerCustomCommands;
162 RMMFAudioPlayControllerCustomCommands iAudioPlayControllerCustomCommands;
163 RMMFAudioRecordControllerCustomCommands iAudioRecordControllerCustomCommands;
165 TMMFPrioritySettings iPrioritySettings;
167 TTimeIntervalMicroSeconds iPosition;
168 TTimeIntervalMicroSeconds iPositionTemp;
169 TTimeIntervalMicroSeconds iDuration;
170 TTimeIntervalMicroSeconds iRecordTimeAvailable;
172 CMdaAudioClipUtility::TState iState;
174 // Convert window start and end times and whether it has been set
175 TTimeIntervalMicroSeconds iConvertStart;
176 TTimeIntervalMicroSeconds iConvertEnd;
177 TBool iConvertWindowSet;
179 // parent class for callback
180 CMdaAudioConvertUtility* iParent;
181 RArray<TUid> iMediaIds;
183 // keeping track of cropped clip duration
185 TTimeIntervalMicroSeconds iCroppedDuration;
186 CMMFControllerImplementationInformation* iControllerImplementationInformation;
189 // utility class to find and open a suitable controller asynchronously
190 CMMFFindAndOpenController* iFindAndOpenController;
192 TUid iSourceFormatUid; // for SetSourceFormat()
193 TUid iSinkFormatUid; // for SetSinkFormat()
195 TFourCC iSourceDataType; // for SetSourceDataType()
196 TFourCC iSinkDataType; // for SetSinkDataType()
198 TInt iSourceSampleRate; // for SetSourceSampleRateL()
199 TInt iSinkSampleRate; // for SetDestinationSampleRateL()
201 TInt iSourceChannels; // for SetSourceNumberOfChannelsL()
202 TInt iSinkChannels; // for SetDestinationNumberOfChannelsL()