1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsound/devsoundrefplugin/src/plugin/audio/Gsm610/GSM610.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,181 @@
1.4 +// Copyright (c) 2002-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 __GSM610_H__
1.20 +#define __GSM610_H__
1.21 +
1.22 +#include <mmf/server/mmfswcodecwrapper.h>
1.23 +
1.24 +// Standard EPOC32 includes required by this header file
1.25 +#include <e32base.h>
1.26 +#include <mmf/server/mmfdatabuffer.h>
1.27 +#include <e32std.h>
1.28 +
1.29 +
1.30 +#ifdef EABI
1.31 +const TUint KNumFramesInABuffer = 50;
1.32 +#else
1.33 +const TUint KNumFramesInABuffer = 6;
1.34 +#endif
1.35 +const TInt KGsmFrameSize = 65;
1.36 +const TUint KGsmEncodedFrameSize = KNumFramesInABuffer * KGsmFrameSize ; //50 * 65 encoded frames
1.37 +const TUint KPcmEncodedFrameSize = KNumFramesInABuffer * 320; // 50 times 160*2
1.38 +const TInt KPcmDataForGsmFrame = 640;
1.39 +const TUint KPcmInputFrameSize = KPcmEncodedFrameSize*2; // cache 2 frames
1.40 +
1.41 +/**
1.42 +*
1.43 +*class CMmfGsmToPcm16HwDevice
1.44 +*
1.45 +*/
1.46 +class CMmfGsm610ToPcm16HwDevice : public CMMFSwCodecWrapper
1.47 + {
1.48 +public:
1.49 + static CMmfGsm610ToPcm16HwDevice* NewL();
1.50 + virtual CMMFSwCodec& Codec();
1.51 + ~CMmfGsm610ToPcm16HwDevice();
1.52 +private:
1.53 + void ConstructL();
1.54 + };
1.55 +
1.56 +/**
1.57 +*
1.58 +* CMmfPcmHwDevicePcm16ToGsm610
1.59 +*
1.60 +*/
1.61 +class CMmfPcm16ToGsm610HwDevice : public CMMFSwCodecWrapper
1.62 + {
1.63 +public:
1.64 + static CMmfPcm16ToGsm610HwDevice* NewL();
1.65 + virtual CMMFSwCodec& Codec();
1.66 + ~CMmfPcm16ToGsm610HwDevice();
1.67 +private:
1.68 + void ConstructL();
1.69 + };
1.70 +
1.71 +/**
1.72 +*
1.73 +* class CMMFGsm610ToPcm16Codec coverts Gsm610 to PCM16
1.74 +*
1.75 +*/
1.76 +class CGSM610FR_Decoder;
1.77 +
1.78 +class CMMFGsm610ToPcm16Codec : public CMMFSwCodec
1.79 + {
1.80 +public:
1.81 + CMMFGsm610ToPcm16Codec();
1.82 + virtual TCodecProcessResult ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDest);
1.83 + virtual TUint SourceBufferSize() {return KGsmEncodedFrameSize;};
1.84 + virtual TUint SinkBufferSize() {return KPcmInputFrameSize;};
1.85 + static CMMFGsm610ToPcm16Codec* NewL();
1.86 + void ConstructL();
1.87 + ~CMMFGsm610ToPcm16Codec();
1.88 +private:
1.89 + TBool CheckInputBuffers( CMMFDataBuffer& aSrc, CMMFDataBuffer& aDest );
1.90 + TInt NumBuffersToProcess( const CMMFDataBuffer& aSrc );
1.91 + TBool ProcessPostCondition( const CMMFSwCodec::TCodecProcessResult& result );
1.92 + // do not provide an implmentation for these two methods
1.93 + const CMMFGsm610ToPcm16Codec& operator=( const CMMFGsm610ToPcm16Codec& );
1.94 + CMMFGsm610ToPcm16Codec( const CMMFGsm610ToPcm16Codec& );
1.95 +private:
1.96 + CGSM610FR_Decoder* iGsmDecoder;
1.97 + };
1.98 +
1.99 +/**
1.100 +*
1.101 +* class CMMFPcm16ToGsm610Codec coverts PCM16 to GSM610
1.102 +*
1.103 +*/
1.104 +class CGSM610FR_Encoder;
1.105 +class CMMFPcm16ToGsm610Codec : public CMMFSwCodec
1.106 + {
1.107 +public:
1.108 + CMMFPcm16ToGsm610Codec();
1.109 + virtual TCodecProcessResult ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDest);
1.110 + virtual TUint SourceBufferSize() {return KPcmInputFrameSize;};
1.111 + virtual TUint SinkBufferSize() {return KGsmEncodedFrameSize;};
1.112 + static CMMFPcm16ToGsm610Codec* NewL();
1.113 + ~CMMFPcm16ToGsm610Codec();
1.114 + void ConstructL();
1.115 +private:
1.116 + TBool CheckInputBuffers( CMMFDataBuffer& aSrc, CMMFDataBuffer& aDest );
1.117 + TInt NumBuffersToProcess( const CMMFDataBuffer& aSrc );
1.118 + inline TBool ProcessPostCondition( const CMMFSwCodec::TCodecProcessResult& result );
1.119 +
1.120 + // do not supply implementations
1.121 + const CMMFPcm16ToGsm610Codec& operator=( const CMMFPcm16ToGsm610Codec& );
1.122 + CMMFPcm16ToGsm610Codec( const CMMFPcm16ToGsm610Codec &);
1.123 +private:
1.124 + CGSM610FR_Encoder* iGsmEncoder;
1.125 + };
1.126 +
1.127 +/**
1.128 +*
1.129 +* class TMmfAudioAudioCodecPanics provides a name space for audio codec
1.130 +* panics
1.131 +*
1.132 +**/
1.133 +class TMmfGsmCodecPanicsNameSpace
1.134 + {
1.135 +public:
1.136 + /*
1.137 + A list of panic codes for Codecs
1.138 + @internalTechnology
1.139 + EBadArgument indicates a bad argument
1.140 + EBadState indicates a state viaolation
1.141 + EBadInvariant indicates an invariant violation
1.142 + EPostConditionViolation indicates a post condition violation
1.143 + */
1.144 + enum TMmfGsmCodecPanics
1.145 + {
1.146 + EBadArgument,
1.147 + EBadState,
1.148 + EBadInvariant,
1.149 + EBadReset,
1.150 + EPostConditionViolation
1.151 + };
1.152 +public:
1.153 + inline static void Panic(const TMmfGsmCodecPanicsNameSpace::TMmfGsmCodecPanics aPanic);
1.154 + };
1.155 +
1.156 +/**
1.157 +*
1.158 +* Panic
1.159 +* @argument aPanic is the panic code for the codec
1.160 +*
1.161 +*/
1.162 +inline void TMmfGsmCodecPanicsNameSpace::Panic(const TMmfGsmCodecPanicsNameSpace::TMmfGsmCodecPanics aPanic)
1.163 + {
1.164 + _LIT(KGsmCodecPanicCategory, "GsmCodec");
1.165 + User::Panic(KGsmCodecPanicCategory, aPanic);
1.166 + }
1.167 +
1.168 +/**
1.169 +*
1.170 +* ProcessPostCondition
1.171 +* @param aResult
1.172 +* @result TBool Etrue if the post condition is satisfied
1.173 +*
1.174 +**/
1.175 +inline TBool CMMFPcm16ToGsm610Codec::ProcessPostCondition( const CMMFSwCodec::TCodecProcessResult& aResult )
1.176 + {
1.177 + TBool status = ETrue;
1.178 + if( (aResult.iSrcBytesProcessed / KPcmDataForGsmFrame ) != (aResult.iDstBytesAdded / KGsmFrameSize ) )
1.179 + {
1.180 + status = EFalse;
1.181 + }
1.182 + return status;
1.183 + }
1.184 +#endif //__GSM610_H__