/**
 *  GraphTFT plugin for the Video Disk Recorder 
 * 
 *  fbrenderer.h - A plugin for the Video Disk Recorder
 *
 *  (c) 2004 Lars Tegeler, Sascha Volkenandt  
 *
 * This code is distributed under the terms and conditions of the
 * GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
 *
 * $Id: fbrenderer.h,v 1.4 2004/05/17 14:50:50 tegeler Exp $
 *
 **/

//The most part of this Code is from the MMS V.2 Project:

#ifndef __GTFT_FBRENDERER_HPP
#define __GTFT_FBRENDERER_HPP

#include "imlibrenderer.h"
#include "mpeg2decoder.h"

#include <linux/fb.h>

class FbRenderer : public ImlibRenderer
{
private:
		char *fb_dev_name;
		int _initialized;
		cMpeg2Decoder *decoder;
		bool _showImage;

		Imlib_Image _resized;

		int fb_dev_fd;
		int fb_depth;
		int fb_type;
		size_t fb_size;
		int fb_line_len;
		int y_offset;

		struct fb_var_screeninfo fb_orig_vinfo;
		struct fb_fix_screeninfo fb_finfo;

		void fbdev_draw_32(unsigned char * frame);
		void fbdev_draw_24(unsigned char * frame);
		void fbdev_draw_16(unsigned char * frame);

public:	
		FbRenderer();
		~FbRenderer();

		void init(int devnum);
		void deinit();

		void refresh();
		void clear();

		int playVideo(const uchar *Data, int Length);
		bool devicePoll(cPoller &Poller, int TimeoutMs = 0);
		void setPlayMode(bool Video);
		void deviceClear(void);
};

#endif // __GTFT_FBRENDERER_H
