#ifndef __CDSTATUS_H                   
#define __CDSTATUS_H

#include <linux/cdrom.h>

#include <vdr/status.h>
#include <vdr/thread.h>

enum eMediaStatus { mediaNoChange, mediaReqEject, mediaNew, mediaRemoval, mediaChange };

class cCDStatus : public cThread {
  private:
	bool running;
	cCondWait newSet;
	char *cd_device;
	int fd;
	eMediaStatus mediaStatus;
  protected:
	virtual void Action();
	int WaitCmd(int fd, struct cdrom_generic_command *cgc, unsigned char *buffer,
	     int len, int ddir, int timeout);
	int GetMediaEvent(int fd);
  public:
	cCDStatus(char *device);
	~cCDStatus();
    bool Start(void);
	int EjectRequest(void);
//	int Mount(const char *device);
	eMediaStatus GetMediaStatus(void);
};

#endif
