/**
 * receiver_softdevice.h: Controller for softdevice receiver
 * 
 * Copyright: See COPYING file that comes with this distribution
 *
 * Author: Matthias Feistel <hitman_47@users.sourceforge.net>, (C) 2006, 2007
 */
/*
 * Media Player plugin for VDR
 *
 * Copyright (C) 2005 Martin Wache
 *
 * This code is distributed under the terms and conditions of the
 * GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
 *
 * $Id: Receiver.h,v 1.1 2006/03/12 20:23:23 wachm Exp $
 */

#ifndef __RECEIVER_H__
#define __RECEIVER_H__

#include "vdr/receiver.h"
#include "vdr/thread.h"
#include "vdr/device.h"
#include "vdr/remux.h"
#include "receiver_softhandles.h" // modified by hitman_47 on 2007-08-15
class cSoftplayReceiver : public cReceiver, public cThread
{
private:
	friend class cReceiverController;
	cRingBufferLinear *buffer;
	cDevice *device;
	cRemux *remux;
	PacketHandlesV100 softHandles;

	bool active;

	bool transfer, transfer_stopped;
	cChannel startChannel;
	cChannel currChannel;
public:
	cSoftplayReceiver( const cChannel *Channel, cDevice *Device,
			PacketHandlesV100 &SoftHandles );
	virtual ~cSoftplayReceiver( );
protected:
	virtual void Activate( bool On );
	virtual void Receive( uchar *Data, int Length );
	virtual void Action( void );
public:
	inline void StopTransfer( void )
	{
		transfer=false;
		while( !transfer_stopped )
			usleep( 10000 );
	}
	inline void StartTransfer( void )
	{
		transfer=true;
	}
};

#endif // __RECEIVER_H_
