// --------------------------------------------------------------
#ifndef _RADIO_SYMBOLIZER_HPP_
#define	_RADIO_SYMBOLIZER_HPP_

#include <radio/radio_types.h>
#include <radio/cpx.h>
#include "Formatter.hpp"


class ISymbolizer
{
public:
	ISymbolizer() {}
	virtual ~ISymbolizer() {}
	virtual void onSymbol(symbol_t symbol) = 0;
};

class Symbolizer : public IFormatter
{
public:
	Symbolizer(ISymbolizer *pSymbolHandler);
	~Symbolizer();
	void process(data_t src);
	void process(void *pSrc, uint32_t len);
	void setNumBitsPerSymbol(uint32_t nBitsPerSym);

private:
	uint32_t m_nBitsPerSym;
	ISymbolizer *m_pSymbolHandler;
	uint32_t m_symbolBitCount;
	symbol_t m_lastSymbol;
	symbol_t m_symbolMask;
	symbol_t differentialEncode(symbol_t symbol);
	void onFrame(void *pFrame, uint32_t size) override;
};

class DeSymbolizer
{
public:
	DeSymbolizer(IData *pDataHandler);
	~DeSymbolizer();
	void process(symbol_t src);
	void setNumBitsPerSymbol(uint32_t nBitsPerSym);

private:
	uint32_t m_nBitsPerSym;
	IData *m_pDataHandler;
	uint32_t m_bitCount;
	uint32_t m_dataBitCount;
	symbol_t m_lastSymbol;
	symbol_t m_symbolMask;
	symbol_t differentialDecode(symbol_t symbol);
};

// --------------------------------------------------------------
#endif // _RADIO_SYMBOLIZER_HPP_
