Update contrib.
1 // Copyright (c) 2005-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 __MMFBTSWCODECWRAPPER_H__
17 #define __MMFBTSWCODECWRAPPER_H__
19 #include <mmfbthwdevice2.h>
20 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
21 #include <mmfbtswcodecwrapperinterface.h>
22 #include <routingsounddeviceopenhandler.h>
25 class CMMFSwCodecDataPath; //forward reference
27 class CRoutingSoundPlayDevice;
28 class CRoutingSoundRecordDevice;
34 Class for a software codec used by the CMMFSwCodecWrapper class to make the CMMFSwCodec a
35 CMMFHwDevice plugin. The CMMFSwCodec processes source data in a certain fourCC coding type and
36 converts it to a destination buffer of another fourCC coding type.
38 A CMMFSwCodec object would usually not be instantiated directly
39 but instead would be instantiated via the CMMFSwCodecWrapper class's Codec()
42 The processing of the data is handled by the codecs ProcessL() member.
43 The intention is that the source buffer for conversion is converted to the appropriate coding type
44 in the destination buffer. The size of the buffers passed in are determined by SourceBufferSize()
45 and SinkBufferSize() methods. The buffer sizes should be chosen such that
46 the ProcessL() method can be guaranteed to have enough destination buffer to
47 completely process one source buffer.
49 The ProcessL should return a TCodecProcessResult returning the number of source bytes processed
50 and the number of destination bytes processed along with a process result code defined thus:
51 - EProcessComplete: the codec processed all the source data into the sink buffer
52 - EProcessIncomplete: the codec filled sink buffer before all the source buffer was processed
53 - EDstNotFilled: the codec processed the source buffer but the sink buffer was not filled
54 - EEndOfData: the codec detected the end data - all source data in processed but sink may not be full
55 - EProcessError: the codec process error condition
57 Unlike the 7.0s CMMFCodec::ProcessL method, the CMMFSwCodec::ProcessL method
58 should not return EProcessIncomplete as this case is not handled by the
61 class CMMFSwCodec : public CBase
68 Indicates the result of processing data from the source buffer to a destination buffer
69 and provides functions to compare the result code.
70 The CMMFSwCodec buffer sizes should be set to return EProcessComplete
71 The other return codes are to keep the ProcessL method compatible with
72 the 7.0s CMMFCodec API.
74 class TCodecProcessResult
78 Flag to track the codec's processing status.
80 enum TCodecProcessResultStatus
82 /** The codec has successfully completed its processing. */
84 /** Could not empty the source buffer because the destination buffer became full. */
86 /** Codec came across an end of data. */
88 /** Could not fill the destination buffer because the source buffer has been emptied. */
90 /** An error occured. */
94 /** Overloaded operator to test equality. */
95 TBool operator==(const TCodecProcessResultStatus aStatus) const {return (iCodecProcessStatus == aStatus);}
96 /** Overloaded operator to test inequality. */
97 TBool operator!=(const TCodecProcessResultStatus aStatus) const {return (iCodecProcessStatus != aStatus);}
102 TCodecProcessResult()
103 :iCodecProcessStatus(EProcessError), iSrcBytesProcessed(0), iDstBytesAdded(0) {};
107 The codec's processing status
109 @see enum TCodecProcessResultStatus
111 TCodecProcessResultStatus iCodecProcessStatus;
113 /** The number of source bytes processed */
114 TUint iSrcBytesProcessed;
116 /** The number of bytes added to the destination buffer */
117 TUint iDstBytesAdded;
122 Processes the data in the specified source buffer and writes the processed data to
123 the specified destination buffer.
125 This function is synchronous, when the function returns the data has been processed.
126 This is a virtual function that each derived class must implement.
129 The source buffer containing data to encode or decode.
131 The destination buffer to hold the data after encoding or decoding.
133 @return The result of the processing.
135 @see TCodecProcessResult
137 virtual TCodecProcessResult ProcessL(const CMMFBuffer& aSource, CMMFBuffer& aDest) = 0;
140 Gets the max size of the source buffer passed into the
141 CMMFSwCodec::ProcessL function.
143 Note that this means that this is the Max size of each buffer passed to the codec. The actual
144 size of the data could be less than the max size. This is a virtual function that each derived
145 class must implement.
147 @return The max size of the source buffer in bytes.
149 virtual TUint SourceBufferSize() = 0;
152 Gets the max size of the sink (destination) buffer passed into the
153 CMMFSwCodec::ProcessL method.
155 Note that this means that this is the Max size of each buffer passed to the codec. The actual
156 size of the data written to this buffer could be less than the max size. This is a virtual
157 function that each derived class must implement.
159 @return The max size of the sink buffer in bytes.
161 virtual TUint SinkBufferSize() = 0;
166 Function that needs to be overriden if the codec is a 'Null' codec
167 ie. it does not perform any data type transformation. The 'Null' codec
168 should override this to return ETrue and provide a dummy
169 ProcessL. The CMMFSwCodecWrapper will then use the same buffer
170 for both the source and the sink. Null codecs should return the same
171 buffer size for both the Source and SinkBufferSize methods.
172 Since most CMMFSwCodec implementations will not be null codecs
173 this method can be ignored.
175 Would not normally expect 3rd parties to have to implement this.
177 virtual TBool IsNullCodec() {return EFalse;};
182 class CRoutingSoundDeviceOpenHandler;
188 Class to make a CMMFSwCodec into a CMMFHwDevice ECOM plugin.
190 Most of the code to make a CMMFSwCodec into a CMMFHwDevice ECOM plugin is provided
191 in CMMFSwCodecWrapper. Someone writing a plugin derrived from CMMFSwCodecWrapper
192 only needs to provide the standard ECOM implementation code, constructors
193 and destructors and implement the Codec() function which should return the
194 appropriate CMMFSwCodec.
196 Third parties using CMMFSwCodecWrapper that do not use the RMdaDevSound API
197 to talk to the sound drivers would need to port the datapaths for their own
198 sound drivers. Third parties would also need to change the custom interfaces
201 class CMMFSwCodecWrapper : public CMMFHwDevice2
204 IMPORT_C virtual ~CMMFSwCodecWrapper();
208 TInt OpenComplete(TInt aError); // Callback
210 IMPORT_C CMMFSwCodecWrapper();
211 IMPORT_C virtual TInt Init(THwDeviceInitParams &aDevInfo);
212 IMPORT_C virtual TInt Start(TDeviceFunc aFuncCmd, TDeviceFlow aFlowCmd);
213 IMPORT_C virtual TInt Stop();
214 IMPORT_C virtual TInt Pause();
215 IMPORT_C virtual TAny* CustomInterface(TUid aInterfaceId);
216 IMPORT_C virtual TInt ThisHwBufferFilled(CMMFBuffer& aFillBufferPtr);
217 IMPORT_C virtual TInt ThisHwBufferEmptied(CMMFBuffer& aBuffer);
218 IMPORT_C virtual TInt SetConfig(TTaskConfig& aConfig);
219 IMPORT_C virtual TInt StopAndDeleteCodec();
220 IMPORT_C virtual TInt DeleteCodec();
223 This method must return the CMMFSwCodec used by the derived
224 CMMFSwCodecWrapper class. The method should create the CMMFSwCodec
225 if it hasn't done so already.
227 This is a virtual function that each derived class must implement.
229 @return The CMMFSwCodec used by the derrived CMMFSwCodecWrapper
231 virtual CMMFSwCodec& Codec() = 0;
233 // from CMMFHwDevice2
234 IMPORT_C virtual void Init(THwDeviceInitParams &aDevInfo, TRequestStatus& aStatus);
241 TInt OpenPlayComplete(TInt aError);
242 TInt OpenRecordComplete(TInt aError);
245 The software codec used
250 The source buffer for the codec
252 CMMFDataBuffer* iSourceBuffer;
255 The sink buffer for the codec
257 CMMFDataBuffer* iSinkBuffer;
260 The datapath used to transfer the data
262 CMMFSwCodecDataPath* iDataPath;
265 The play custom interface
267 MPlayCustomInterface* iPlayCustomInterface;
270 The record custom interface
272 MRecordCustomInterface* iRecordCustomInterface;
275 The buffer size of the sound device
277 TUint iDeviceBufferSize;
280 The sample rate of the sound device
285 The number of channels of the sound device
296 CRoutingSoundPlayDevice* iPlayDevice;
300 CRoutingSoundRecordDevice* iRecordDevice;
304 CRoutingSoundDeviceOpenHandler* iOpenHandler;