sl@0: // Copyright (c) 2000-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 __GSM610_H__
sl@0: #define __GSM610_H__
sl@0: 
sl@0: 
sl@0: //*******************************************************************
sl@0: //* INCLUDE FILES:
sl@0: //*******************************************************************
sl@0: 
sl@0: // Standard EPOC32 includes required by this header file
sl@0: #include <e32base.h>
sl@0: #include <mmf/server/mmfcodec.h>
sl@0: #include <mmf/server/mmfdatabuffer.h>
sl@0: #include <e32std.h>
sl@0: 
sl@0: #include "gsm610fr.h"
sl@0: 
sl@0: const TUint	KGsmEncodedFrameSize = 65;
sl@0: 
sl@0: const TUint	KPcmEncodedFrameSize = 160*2;
sl@0: const TUint	KPcmInputFrameSize   = KPcmEncodedFrameSize*2;	// cache 2 frames
sl@0: 
sl@0: 
sl@0: // Internal to Symbian
sl@0: // Used to be TMMFPtr8 - useful aid to porting
sl@0: class TMMFPtr8 : public TPtr8
sl@0: 	{
sl@0: public:
sl@0: 	TMMFPtr8()
sl@0: 		: TPtr8(0,0,0) {};
sl@0: 	inline void Set(const TDes8& aDes)
sl@0: 		{ TPtr8::Set((TUint8*)(aDes.Ptr()),aDes.Length(),aDes.MaxLength()); };
sl@0: 	inline void SetLengthOnly(const TDes8& aDes)
sl@0: 		{ TPtr8::Set((TUint8*)(aDes.Ptr()),aDes.Length(),aDes.Length()); };
sl@0: 	inline void Set(const TPtrC8& aDes)
sl@0: 		{ TPtr8::Set((TUint8*)(aDes.Ptr()),aDes.Length(),aDes.Length()); };
sl@0: 	inline void Shift(TInt aOffset)
sl@0: 		{ SetLength(Length()-aOffset); iMaxLength-=aOffset; iPtr+=aOffset; };
sl@0: 	};
sl@0: 
sl@0: //*******************************************************************
sl@0: //* GSM to 16 bit PCM Codec Class:
sl@0: //*******************************************************************
sl@0: 
sl@0: class CGsmTo16PcmWavCodec : public CBase
sl@0: 	{
sl@0: public:
sl@0: 	CGsmTo16PcmWavCodec();
sl@0: 	~CGsmTo16PcmWavCodec();
sl@0: 
sl@0: 	void ConstructL();
sl@0: 
sl@0: 	void Reset();
sl@0: 	void ResetAllL();
sl@0: 	void ProcessL(TMMFPtr8* aSrc, TMMFPtr8* aDst);
sl@0: 
sl@0: private:
sl@0: 	TUint    iOutBufferCount;
sl@0: 	TUint8* iOutBufferPtr;
sl@0: 	TUint8  iOutBuffer [KPcmInputFrameSize];
sl@0: 	TUint    iInBufferCount;
sl@0: 	TUint8* iInBufferPtr;
sl@0: 	TUint8  iInBuffer [KGsmEncodedFrameSize];
sl@0: 
sl@0: 
sl@0: 	CGSM610FR_Decoder* iGsmDecoder;
sl@0: 	};
sl@0: 
sl@0: 
sl@0: //*******************************************************************
sl@0: //* 16 bit PCM to GSM Codec Class:
sl@0: //*******************************************************************
sl@0: 
sl@0: class C16PcmToGsmWavCodec : public CBase
sl@0: 	{
sl@0: public:
sl@0: 	C16PcmToGsmWavCodec();
sl@0: 	~C16PcmToGsmWavCodec();
sl@0: 	void ConstructL();
sl@0: 
sl@0: 	void Reset();
sl@0: 	void ResetAllL();
sl@0: 	void ProcessL(TMMFPtr8* aSrc, TMMFPtr8* aDst);
sl@0: 	
sl@0: private:
sl@0: 	TUint    iOutBufferCount;
sl@0: 	TUint8* iOutBufferPtr;
sl@0: 	TUint8  iOutBuffer [KGsmEncodedFrameSize];
sl@0: 	TUint    iInBufferCount;
sl@0: 	TUint8* iInBufferPtr;
sl@0: 	TUint8  iInBuffer [KPcmInputFrameSize];
sl@0: 
sl@0: 	CGSM610FR_Encoder* iGsmEncoder;
sl@0: 
sl@0: 	};
sl@0: 
sl@0: class CMMFGsmTo16PcmCodec : public CMMFCodec
sl@0: 	{
sl@0: public:
sl@0: 	static CMMFCodec* NewL(TAny* aInitParams);
sl@0: 	virtual ~CMMFGsmTo16PcmCodec();
sl@0: 	TCodecProcessResult ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDst);
sl@0: 
sl@0: private:
sl@0: 	CMMFGsmTo16PcmCodec();
sl@0: 	void ConstructL(TAny* aInitParams);
sl@0: private:
sl@0: 	//buffers owned by the datapath
sl@0: 	const CMMFDataBuffer* iSrc;
sl@0: 	CMMFDataBuffer* iDst;
sl@0: 	TUint iLastFrameNumber;
sl@0: 
sl@0: 	//the real codec, CMMFGsmTo16PcmCodec is just a wrapper
sl@0: 	CGsmTo16PcmWavCodec* iCodecPtr;
sl@0: 	};
sl@0: 
sl@0: 
sl@0: class CMMF16PcmToGsmCodec : public CMMFCodec
sl@0: 	{
sl@0: public:
sl@0: 	static CMMFCodec* NewL(TAny* aInitParams);
sl@0: 	virtual ~CMMF16PcmToGsmCodec();
sl@0: 	TCodecProcessResult ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDst);
sl@0: 
sl@0: private:
sl@0: 	CMMF16PcmToGsmCodec();
sl@0: 	void ConstructL(TAny* aInitParams);
sl@0: private:
sl@0: 	//buffers owned by the datapath
sl@0: 	const CMMFDataBuffer* iSrc;
sl@0: 	CMMFDataBuffer* iDst;
sl@0: 	TUint iLastFrameNumber;
sl@0: 
sl@0: 	//the real codec, is CMMF16PcmToGsmCodec just a wrapper
sl@0: 	C16PcmToGsmWavCodec* iCodecPtr;
sl@0: 	};
sl@0: 
sl@0: 
sl@0: 
sl@0: #endif