/* 
 * pes2ts.h: PES2TS remux
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#ifndef PES2TSREMUX_H
#define PES2TSREMUX_H

#include <vdr/ringbuffer.h>
#include <vdr/tools.h>

#define INPUTBUFSIZE	KILOBYTE(2048)
#define OUTPUTBUFSIZE	KILOBYTE(2048)
#define TS_SIZE         188
#define IPACKS		2048

class cPES2TSRemux: public cThread {
private:
	cRingBufferLinear *m_OutputBuffer;
	cRingBufferLinear *m_InputBuffer;
	bool               m_Active;
	unsigned short	   vpid;
	unsigned short	   apid;
        cMutex  	   mutex;
  
protected:
	virtual void Action(void);

public:
	cPES2TSRemux(int VPid, int APid);
	virtual ~cPES2TSRemux();

	int Put(const uchar *Data, int Count);
	uchar *Get(int &Count) { return m_OutputBuffer->Get(Count); }
	void DelOutput(int Count) { m_OutputBuffer->Del(Count); }
	void DelInput (int Count) { mutex.Lock(); m_InputBuffer ->Del(Count); mutex.Unlock(); }
};

#endif // PES2TSREMUX_H
