1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsound/sounddevbt/inc/SwCodecWrapper/MmfBtSwCodecWrapper.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,308 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __MMFBTSWCODECWRAPPER_H__
1.20 +#define __MMFBTSWCODECWRAPPER_H__
1.21 +
1.22 +#include <mmfbthwdevice2.h>
1.23 +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
1.24 +#include <mmfbtswcodecwrapperinterface.h>
1.25 +#include <routingsounddeviceopenhandler.h>
1.26 +#endif
1.27 +
1.28 +class CMMFSwCodecDataPath; //forward reference
1.29 +
1.30 +class CRoutingSoundPlayDevice;
1.31 +class CRoutingSoundRecordDevice;
1.32 +
1.33 +/**
1.34 +@publishedAll
1.35 +@released
1.36 +
1.37 +Class for a software codec used by the CMMFSwCodecWrapper class to make the CMMFSwCodec a
1.38 +CMMFHwDevice plugin. The CMMFSwCodec processes source data in a certain fourCC coding type and
1.39 +converts it to a destination buffer of another fourCC coding type.
1.40 +
1.41 +A CMMFSwCodec object would usually not be instantiated directly
1.42 +but instead would be instantiated via the CMMFSwCodecWrapper class's Codec()
1.43 +method.
1.44 +
1.45 +The processing of the data is handled by the codecs ProcessL() member.
1.46 +The intention is that the source buffer for conversion is converted to the appropriate coding type
1.47 +in the destination buffer. The size of the buffers passed in are determined by SourceBufferSize()
1.48 +and SinkBufferSize() methods. The buffer sizes should be chosen such that
1.49 +the ProcessL() method can be guaranteed to have enough destination buffer to
1.50 +completely process one source buffer.
1.51 +
1.52 +The ProcessL should return a TCodecProcessResult returning the number of source bytes processed
1.53 +and the number of destination bytes processed along with a process result code defined thus:
1.54 +- EProcessComplete: the codec processed all the source data into the sink buffer
1.55 +- EProcessIncomplete: the codec filled sink buffer before all the source buffer was processed
1.56 +- EDstNotFilled: the codec processed the source buffer but the sink buffer was not filled
1.57 +- EEndOfData: the codec detected the end data - all source data in processed but sink may not be full
1.58 +- EProcessError: the codec process error condition
1.59 +
1.60 +Unlike the 7.0s CMMFCodec::ProcessL method, the CMMFSwCodec::ProcessL method
1.61 +should not return EProcessIncomplete as this case is not handled by the
1.62 +CMMFSwCodecWrapper.
1.63 +*/
1.64 +class CMMFSwCodec : public CBase
1.65 + {
1.66 +public:
1.67 + /**
1.68 + @publishedAll
1.69 + @released
1.70 +
1.71 + Indicates the result of processing data from the source buffer to a destination buffer
1.72 + and provides functions to compare the result code.
1.73 + The CMMFSwCodec buffer sizes should be set to return EProcessComplete
1.74 + The other return codes are to keep the ProcessL method compatible with
1.75 + the 7.0s CMMFCodec API.
1.76 + */
1.77 + class TCodecProcessResult
1.78 + {
1.79 + public:
1.80 + /**
1.81 + Flag to track the codec's processing status.
1.82 + */
1.83 + enum TCodecProcessResultStatus
1.84 + {
1.85 + /** The codec has successfully completed its processing. */
1.86 + EProcessComplete,
1.87 + /** Could not empty the source buffer because the destination buffer became full. */
1.88 + EProcessIncomplete,
1.89 + /** Codec came across an end of data. */
1.90 + EEndOfData,
1.91 + /** Could not fill the destination buffer because the source buffer has been emptied. */
1.92 + EDstNotFilled,
1.93 + /** An error occured. */
1.94 + EProcessError
1.95 + };
1.96 +
1.97 + /** Overloaded operator to test equality. */
1.98 + TBool operator==(const TCodecProcessResultStatus aStatus) const {return (iCodecProcessStatus == aStatus);}
1.99 + /** Overloaded operator to test inequality. */
1.100 + TBool operator!=(const TCodecProcessResultStatus aStatus) const {return (iCodecProcessStatus != aStatus);}
1.101 +
1.102 + /**
1.103 + Default constructor.
1.104 + */
1.105 + TCodecProcessResult()
1.106 + :iCodecProcessStatus(EProcessError), iSrcBytesProcessed(0), iDstBytesAdded(0) {};
1.107 +
1.108 + public:
1.109 + /**
1.110 + The codec's processing status
1.111 +
1.112 + @see enum TCodecProcessResultStatus
1.113 + */
1.114 + TCodecProcessResultStatus iCodecProcessStatus;
1.115 +
1.116 + /** The number of source bytes processed */
1.117 + TUint iSrcBytesProcessed;
1.118 +
1.119 + /** The number of bytes added to the destination buffer */
1.120 + TUint iDstBytesAdded;
1.121 + };
1.122 +public:
1.123 +
1.124 + /**
1.125 + Processes the data in the specified source buffer and writes the processed data to
1.126 + the specified destination buffer.
1.127 +
1.128 + This function is synchronous, when the function returns the data has been processed.
1.129 + This is a virtual function that each derived class must implement.
1.130 +
1.131 + @param aSource
1.132 + The source buffer containing data to encode or decode.
1.133 + @param aDest
1.134 + The destination buffer to hold the data after encoding or decoding.
1.135 +
1.136 + @return The result of the processing.
1.137 +
1.138 + @see TCodecProcessResult
1.139 + */
1.140 + virtual TCodecProcessResult ProcessL(const CMMFBuffer& aSource, CMMFBuffer& aDest) = 0;
1.141 +
1.142 + /**
1.143 + Gets the max size of the source buffer passed into the
1.144 + CMMFSwCodec::ProcessL function.
1.145 +
1.146 + Note that this means that this is the Max size of each buffer passed to the codec. The actual
1.147 + size of the data could be less than the max size. This is a virtual function that each derived
1.148 + class must implement.
1.149 +
1.150 + @return The max size of the source buffer in bytes.
1.151 + */
1.152 + virtual TUint SourceBufferSize() = 0;
1.153 +
1.154 + /**
1.155 + Gets the max size of the sink (destination) buffer passed into the
1.156 + CMMFSwCodec::ProcessL method.
1.157 +
1.158 + Note that this means that this is the Max size of each buffer passed to the codec. The actual
1.159 + size of the data written to this buffer could be less than the max size. This is a virtual
1.160 + function that each derived class must implement.
1.161 +
1.162 + @return The max size of the sink buffer in bytes.
1.163 + */
1.164 + virtual TUint SinkBufferSize() = 0;
1.165 +
1.166 + /**
1.167 + @internalAll
1.168 +
1.169 + Function that needs to be overriden if the codec is a 'Null' codec
1.170 + ie. it does not perform any data type transformation. The 'Null' codec
1.171 + should override this to return ETrue and provide a dummy
1.172 + ProcessL. The CMMFSwCodecWrapper will then use the same buffer
1.173 + for both the source and the sink. Null codecs should return the same
1.174 + buffer size for both the Source and SinkBufferSize methods.
1.175 + Since most CMMFSwCodec implementations will not be null codecs
1.176 + this method can be ignored.
1.177 +
1.178 + Would not normally expect 3rd parties to have to implement this.
1.179 + */
1.180 + virtual TBool IsNullCodec() {return EFalse;};
1.181 + };
1.182 +
1.183 +
1.184 +//fwd declaration
1.185 +class CRoutingSoundDeviceOpenHandler;
1.186 +
1.187 +/**
1.188 +@publishedAll
1.189 +@released
1.190 +
1.191 +Class to make a CMMFSwCodec into a CMMFHwDevice ECOM plugin.
1.192 +
1.193 +Most of the code to make a CMMFSwCodec into a CMMFHwDevice ECOM plugin is provided
1.194 +in CMMFSwCodecWrapper. Someone writing a plugin derrived from CMMFSwCodecWrapper
1.195 +only needs to provide the standard ECOM implementation code, constructors
1.196 +and destructors and implement the Codec() function which should return the
1.197 +appropriate CMMFSwCodec.
1.198 +
1.199 +Third parties using CMMFSwCodecWrapper that do not use the RMdaDevSound API
1.200 +to talk to the sound drivers would need to port the datapaths for their own
1.201 +sound drivers. Third parties would also need to change the custom interfaces
1.202 +where necessary.
1.203 +*/
1.204 +class CMMFSwCodecWrapper : public CMMFHwDevice2
1.205 + {
1.206 +public:
1.207 + IMPORT_C virtual ~CMMFSwCodecWrapper();
1.208 +/**
1.209 +@internalTechnology
1.210 +*/
1.211 + TInt OpenComplete(TInt aError); // Callback
1.212 +protected:
1.213 + IMPORT_C CMMFSwCodecWrapper();
1.214 + IMPORT_C virtual TInt Init(THwDeviceInitParams &aDevInfo);
1.215 + IMPORT_C virtual TInt Start(TDeviceFunc aFuncCmd, TDeviceFlow aFlowCmd);
1.216 + IMPORT_C virtual TInt Stop();
1.217 + IMPORT_C virtual TInt Pause();
1.218 + IMPORT_C virtual TAny* CustomInterface(TUid aInterfaceId);
1.219 + IMPORT_C virtual TInt ThisHwBufferFilled(CMMFBuffer& aFillBufferPtr);
1.220 + IMPORT_C virtual TInt ThisHwBufferEmptied(CMMFBuffer& aBuffer);
1.221 + IMPORT_C virtual TInt SetConfig(TTaskConfig& aConfig);
1.222 + IMPORT_C virtual TInt StopAndDeleteCodec();
1.223 + IMPORT_C virtual TInt DeleteCodec();
1.224 +
1.225 + /**
1.226 + This method must return the CMMFSwCodec used by the derived
1.227 + CMMFSwCodecWrapper class. The method should create the CMMFSwCodec
1.228 + if it hasn't done so already.
1.229 +
1.230 + This is a virtual function that each derived class must implement.
1.231 +
1.232 + @return The CMMFSwCodec used by the derrived CMMFSwCodecWrapper
1.233 + */
1.234 + virtual CMMFSwCodec& Codec() = 0;
1.235 +
1.236 + // from CMMFHwDevice2
1.237 + IMPORT_C virtual void Init(THwDeviceInitParams &aDevInfo, TRequestStatus& aStatus);
1.238 +
1.239 +private:
1.240 + TInt StartEncode();
1.241 + TInt StartDecode();
1.242 + TInt StartConvert();
1.243 + // Async handlers
1.244 + TInt OpenPlayComplete(TInt aError);
1.245 + TInt OpenRecordComplete(TInt aError);
1.246 +protected:
1.247 + /**
1.248 + The software codec used
1.249 + */
1.250 + CMMFSwCodec* iCodec;
1.251 +
1.252 + /**
1.253 + The source buffer for the codec
1.254 + */
1.255 + CMMFDataBuffer* iSourceBuffer;
1.256 +
1.257 + /**
1.258 + The sink buffer for the codec
1.259 + */
1.260 + CMMFDataBuffer* iSinkBuffer;
1.261 +
1.262 + /**
1.263 + The datapath used to transfer the data
1.264 + */
1.265 + CMMFSwCodecDataPath* iDataPath;
1.266 +
1.267 + /**
1.268 + The play custom interface
1.269 + */
1.270 + MPlayCustomInterface* iPlayCustomInterface;
1.271 +
1.272 + /**
1.273 + The record custom interface
1.274 + */
1.275 + MRecordCustomInterface* iRecordCustomInterface;
1.276 +
1.277 + /**
1.278 + The buffer size of the sound device
1.279 + */
1.280 + TUint iDeviceBufferSize;
1.281 +
1.282 + /**
1.283 + The sample rate of the sound device
1.284 + */
1.285 + TInt iSampleRate;
1.286 +
1.287 + /**
1.288 + The number of channels of the sound device
1.289 + */
1.290 + TInt iChannels;
1.291 +
1.292 + /**
1.293 + The id device
1.294 + */
1.295 + TUid iDeviceUid;
1.296 +
1.297 + /**
1.298 + */
1.299 + CRoutingSoundPlayDevice* iPlayDevice;
1.300 +
1.301 + /**
1.302 + */
1.303 + CRoutingSoundRecordDevice* iRecordDevice;
1.304 +
1.305 + /**
1.306 + */
1.307 + CRoutingSoundDeviceOpenHandler* iOpenHandler;
1.308 + };
1.309 +
1.310 +#endif
1.311 +