sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __BTGSM610_H__ sl@0: #define __BTGSM610_H__ sl@0: sl@0: #include sl@0: sl@0: // Standard EPOC32 includes required by this header file sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: const TUint KNumFramesInABuffer = 50; sl@0: const TInt KGsmFrameSize = 65; sl@0: const TUint KGsmEncodedFrameSize = KNumFramesInABuffer * KGsmFrameSize ; //50 * 65 encoded frames sl@0: const TUint KPcmEncodedFrameSize = KNumFramesInABuffer * 320; // 50 times 160*2 sl@0: const TInt KPcmDataForGsmFrame = 640; sl@0: const TUint KPcmInputFrameSize = KPcmEncodedFrameSize*2; // cache 2 frames sl@0: sl@0: /** sl@0: * sl@0: *class CMmfGsmToPcm16HwDevice sl@0: * sl@0: */ sl@0: class CMmfGsm610ToPcm16HwDevice : public CMMFSwCodecWrapper sl@0: { sl@0: public: sl@0: static CMmfGsm610ToPcm16HwDevice* NewL(); sl@0: virtual CMMFSwCodec& Codec(); sl@0: ~CMmfGsm610ToPcm16HwDevice(); sl@0: private: sl@0: void ConstructL(); sl@0: }; sl@0: sl@0: /** sl@0: * sl@0: * CMmfPcmHwDevicePcm16ToGsm610 sl@0: * sl@0: */ sl@0: class CMmfPcm16ToGsm610HwDevice : public CMMFSwCodecWrapper sl@0: { sl@0: public: sl@0: static CMmfPcm16ToGsm610HwDevice* NewL(); sl@0: virtual CMMFSwCodec& Codec(); sl@0: ~CMmfPcm16ToGsm610HwDevice(); sl@0: private: sl@0: void ConstructL(); sl@0: }; sl@0: sl@0: /** sl@0: * sl@0: * class CMMFGsm610ToPcm16Codec coverts Gsm610 to PCM16 sl@0: * sl@0: */ sl@0: class CGSM610FR_Decoder; sl@0: sl@0: class CMMFGsm610ToPcm16Codec : public CMMFSwCodec sl@0: { sl@0: public: sl@0: CMMFGsm610ToPcm16Codec(); sl@0: virtual TCodecProcessResult ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDest); sl@0: virtual TUint SourceBufferSize() {return KGsmEncodedFrameSize;}; sl@0: virtual TUint SinkBufferSize() {return KPcmInputFrameSize;}; sl@0: static CMMFGsm610ToPcm16Codec* NewL(); sl@0: void ConstructL(); sl@0: ~CMMFGsm610ToPcm16Codec(); sl@0: private: sl@0: TBool CheckInputBuffers( CMMFDataBuffer& aSrc, CMMFDataBuffer& aDest ); sl@0: TInt NumBuffersToProcess( const CMMFDataBuffer& aSrc ); sl@0: TBool ProcessPostCondition( const CMMFSwCodec::TCodecProcessResult& result ); sl@0: // do not provide an implmentation for these two methods sl@0: const CMMFGsm610ToPcm16Codec& operator=( const CMMFGsm610ToPcm16Codec& ); sl@0: CMMFGsm610ToPcm16Codec( const CMMFGsm610ToPcm16Codec& ); sl@0: private: sl@0: CGSM610FR_Decoder* iGsmDecoder; sl@0: }; sl@0: sl@0: /** sl@0: * sl@0: * class CMMFPcm16ToGsm610Codec coverts PCM16 to GSM610 sl@0: * sl@0: */ sl@0: class CGSM610FR_Encoder; sl@0: class CMMFPcm16ToGsm610Codec : public CMMFSwCodec sl@0: { sl@0: public: sl@0: CMMFPcm16ToGsm610Codec(); sl@0: virtual TCodecProcessResult ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDest); sl@0: virtual TUint SourceBufferSize() {return KPcmInputFrameSize;}; sl@0: virtual TUint SinkBufferSize() {return KGsmEncodedFrameSize;}; sl@0: static CMMFPcm16ToGsm610Codec* NewL(); sl@0: ~CMMFPcm16ToGsm610Codec(); sl@0: void ConstructL(); sl@0: private: sl@0: TBool CheckInputBuffers( CMMFDataBuffer& aSrc, CMMFDataBuffer& aDest ); sl@0: TInt NumBuffersToProcess( const CMMFDataBuffer& aSrc ); sl@0: inline TBool ProcessPostCondition( const CMMFSwCodec::TCodecProcessResult& result ); sl@0: sl@0: // do not supply implementations sl@0: const CMMFPcm16ToGsm610Codec& operator=( const CMMFPcm16ToGsm610Codec& ); sl@0: CMMFPcm16ToGsm610Codec( const CMMFPcm16ToGsm610Codec &); sl@0: private: sl@0: CGSM610FR_Encoder* iGsmEncoder; sl@0: }; sl@0: sl@0: /** sl@0: * sl@0: * class TMmfAudioAudioCodecPanics provides a name space for audio codec sl@0: * panics sl@0: * sl@0: **/ sl@0: class TMmfGsmCodecPanicsNameSpace sl@0: { sl@0: public: sl@0: /* sl@0: A list of panic codes for Codecs sl@0: @internalTechnology sl@0: EBadArgument indicates a bad argument sl@0: EBadState indicates a state viaolation sl@0: EBadInvariant indicates an invariant violation sl@0: EPostConditionViolation indicates a post condition violation sl@0: */ sl@0: enum TMmfGsmCodecPanics sl@0: { sl@0: EBadArgument, sl@0: EBadState, sl@0: EBadInvariant, sl@0: EBadReset, sl@0: EPostConditionViolation sl@0: }; sl@0: public: sl@0: inline static void Panic(const TMmfGsmCodecPanicsNameSpace::TMmfGsmCodecPanics aPanic); sl@0: }; sl@0: sl@0: /** sl@0: * sl@0: * Panic sl@0: * @param aPanic is the panic code for the codec sl@0: * sl@0: */ sl@0: inline void TMmfGsmCodecPanicsNameSpace::Panic(const TMmfGsmCodecPanicsNameSpace::TMmfGsmCodecPanics aPanic) sl@0: { sl@0: _LIT(KGsmCodecPanicCategory, "GsmCodec"); sl@0: User::Panic(KGsmCodecPanicCategory, aPanic); sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * ProcessPostCondition sl@0: * @param aResult sl@0: * @return TBool Etrue if the post condition is satisfied sl@0: * sl@0: **/ sl@0: inline TBool CMMFPcm16ToGsm610Codec::ProcessPostCondition( const CMMFSwCodec::TCodecProcessResult& aResult ) sl@0: { sl@0: TBool status = ETrue; sl@0: if( (aResult.iSrcBytesProcessed / KPcmDataForGsmFrame ) != (aResult.iDstBytesAdded / KGsmFrameSize ) ) sl@0: { sl@0: status = EFalse; sl@0: } sl@0: return status; sl@0: } sl@0: #endif //__BTGSM610_H__