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