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