os/mm/mmlibs/mmfw/src/Plugin/Codec/audio/GSM610/GSM610.H
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __GSM610_H__
    17 #define __GSM610_H__
    18 
    19 
    20 //*******************************************************************
    21 //* INCLUDE FILES:
    22 //*******************************************************************
    23 
    24 // Standard EPOC32 includes required by this header file
    25 #include <e32base.h>
    26 #include <mmf/server/mmfcodec.h>
    27 #include <mmf/server/mmfdatabuffer.h>
    28 #include <e32std.h>
    29 
    30 #include "gsm610fr.h"
    31 
    32 const TUint	KGsmEncodedFrameSize = 65;
    33 
    34 const TUint	KPcmEncodedFrameSize = 160*2;
    35 const TUint	KPcmInputFrameSize   = KPcmEncodedFrameSize*2;	// cache 2 frames
    36 
    37 
    38 // Internal to Symbian
    39 // Used to be TMMFPtr8 - useful aid to porting
    40 class TMMFPtr8 : public TPtr8
    41 	{
    42 public:
    43 	TMMFPtr8()
    44 		: TPtr8(0,0,0) {};
    45 	inline void Set(const TDes8& aDes)
    46 		{ TPtr8::Set((TUint8*)(aDes.Ptr()),aDes.Length(),aDes.MaxLength()); };
    47 	inline void SetLengthOnly(const TDes8& aDes)
    48 		{ TPtr8::Set((TUint8*)(aDes.Ptr()),aDes.Length(),aDes.Length()); };
    49 	inline void Set(const TPtrC8& aDes)
    50 		{ TPtr8::Set((TUint8*)(aDes.Ptr()),aDes.Length(),aDes.Length()); };
    51 	inline void Shift(TInt aOffset)
    52 		{ SetLength(Length()-aOffset); iMaxLength-=aOffset; iPtr+=aOffset; };
    53 	};
    54 
    55 //*******************************************************************
    56 //* GSM to 16 bit PCM Codec Class:
    57 //*******************************************************************
    58 
    59 class CGsmTo16PcmWavCodec : public CBase
    60 	{
    61 public:
    62 	CGsmTo16PcmWavCodec();
    63 	~CGsmTo16PcmWavCodec();
    64 
    65 	void ConstructL();
    66 
    67 	void Reset();
    68 	void ResetAllL();
    69 	void ProcessL(TMMFPtr8* aSrc, TMMFPtr8* aDst);
    70 
    71 private:
    72 	TUint    iOutBufferCount;
    73 	TUint8* iOutBufferPtr;
    74 	TUint8  iOutBuffer [KPcmInputFrameSize];
    75 	TUint    iInBufferCount;
    76 	TUint8* iInBufferPtr;
    77 	TUint8  iInBuffer [KGsmEncodedFrameSize];
    78 
    79 
    80 	CGSM610FR_Decoder* iGsmDecoder;
    81 	};
    82 
    83 
    84 //*******************************************************************
    85 //* 16 bit PCM to GSM Codec Class:
    86 //*******************************************************************
    87 
    88 class C16PcmToGsmWavCodec : public CBase
    89 	{
    90 public:
    91 	C16PcmToGsmWavCodec();
    92 	~C16PcmToGsmWavCodec();
    93 	void ConstructL();
    94 
    95 	void Reset();
    96 	void ResetAllL();
    97 	void ProcessL(TMMFPtr8* aSrc, TMMFPtr8* aDst);
    98 	
    99 private:
   100 	TUint    iOutBufferCount;
   101 	TUint8* iOutBufferPtr;
   102 	TUint8  iOutBuffer [KGsmEncodedFrameSize];
   103 	TUint    iInBufferCount;
   104 	TUint8* iInBufferPtr;
   105 	TUint8  iInBuffer [KPcmInputFrameSize];
   106 
   107 	CGSM610FR_Encoder* iGsmEncoder;
   108 
   109 	};
   110 
   111 class CMMFGsmTo16PcmCodec : public CMMFCodec
   112 	{
   113 public:
   114 	static CMMFCodec* NewL(TAny* aInitParams);
   115 	virtual ~CMMFGsmTo16PcmCodec();
   116 	TCodecProcessResult ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDst);
   117 
   118 private:
   119 	CMMFGsmTo16PcmCodec();
   120 	void ConstructL(TAny* aInitParams);
   121 private:
   122 	//buffers owned by the datapath
   123 	const CMMFDataBuffer* iSrc;
   124 	CMMFDataBuffer* iDst;
   125 	TUint iLastFrameNumber;
   126 
   127 	//the real codec, CMMFGsmTo16PcmCodec is just a wrapper
   128 	CGsmTo16PcmWavCodec* iCodecPtr;
   129 	};
   130 
   131 
   132 class CMMF16PcmToGsmCodec : public CMMFCodec
   133 	{
   134 public:
   135 	static CMMFCodec* NewL(TAny* aInitParams);
   136 	virtual ~CMMF16PcmToGsmCodec();
   137 	TCodecProcessResult ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDst);
   138 
   139 private:
   140 	CMMF16PcmToGsmCodec();
   141 	void ConstructL(TAny* aInitParams);
   142 private:
   143 	//buffers owned by the datapath
   144 	const CMMFDataBuffer* iSrc;
   145 	CMMFDataBuffer* iDst;
   146 	TUint iLastFrameNumber;
   147 
   148 	//the real codec, is CMMF16PcmToGsmCodec just a wrapper
   149 	C16PcmToGsmWavCodec* iCodecPtr;
   150 	};
   151 
   152 
   153 
   154 #endif