Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

displayer.h

Go to the documentation of this file.
00001 /*
00002 * displayer.h Displayer Objects
00003 * Copyright (C) 2001 Charles Yates <charles.yates@pandora.be>
00004 * Copyright (C) 2001-2007 Dan Dennedy <dan@dennedy.org>
00005 *
00006 * This program is free software; you can redistribute it and/or modify
00007 * it under the terms of the GNU General Public License as published by
00008 * the Free Software Foundation; either version 2 of the License, or
00009 * (at your option) any later version.
00010 *
00011 * This program is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 * GNU General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU General Public License
00017 * along with this program; if not, write to the Free Software Foundation,
00018 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef _KINO_DISPLAYER_H
00022 #define _KINO_DISPLAYER_H
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027 
00028 #include <iostream>
00029 using std::cerr;
00030 using std::endl;
00031 
00032 #include <string.h>
00033 #include <math.h>
00034 
00035 #include <X11/Xlib.h>
00036 #include <sys/ipc.h>
00037 #include <sys/shm.h>
00038 #include <X11/extensions/XShm.h>
00039 #include <X11/extensions/Xvlib.h>
00040 #include <gdk/gdk.h>
00041 #include <gtk/gtk.h>
00042 
00043 #include <time.h>
00044 #include <sys/time.h>
00045 
00046 #include <gtk/gtk.h>
00047 #include <gdk/gdkprivate.h>
00048 
00049 #include "preferences.h"
00050 #include "frame.h"
00051 
00052 class AspectRatioCalculator
00053 {
00054 public:
00055     int x;
00056     int y;
00057     int width;
00058     int height;
00059 
00060     AspectRatioCalculator( int widgetWidth, int widgetHeight,
00061                            int imageWidth, int imageHeight,
00062                            int maxImageWidth, int maxImageHeight );
00063 
00064     AspectRatioCalculator( int widgetWidth, int widgetHeight,
00065                            int imageWidth, int imageHeight, bool isPAL, bool isWidescreen );
00066 };
00067 
00071 typedef enum {
00072     DISPLAY_NONE,
00073     DISPLAY_YUV,
00074     DISPLAY_RGB,
00075     DISPLAY_BGR,
00076     DISPLAY_BGR0,
00077     DISPLAY_RGB16
00078 }
00079 DisplayerInput;
00080 
00081 #define MAX_WIDTH       720
00082 #define MAX_HEIGHT      576
00083 
00104 class Displayer
00105 {
00106 protected:
00107     int img_width;
00108     int img_height;
00109     virtual void put( void * ) = 0;
00110 
00111 public:
00112     virtual ~Displayer()
00113     { }
00114     virtual bool usable();
00115     virtual DisplayerInput format();
00116     virtual int preferredWidth();
00117     virtual int preferredHeight();
00118     virtual void put( void *image, int width, int height );
00119     virtual void put( DisplayerInput inFormat, void *image,
00120                       int width, int height );
00121 
00122 private:
00123     unsigned char pixels[ MAX_WIDTH * MAX_HEIGHT * 4 ];
00124     void reformat( DisplayerInput inFormat, int outFormat, void *image,
00125                    int width, int height );
00126     void Reformat424( unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight );
00127     void Reformat222( unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight );
00128     void Reformat323( unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight );
00129     void Reformat323R( unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight );
00130     void Reformat324( unsigned char *image, int inWidth, int inHeight, int outWidth, int outHeight );
00131 };
00132 
00133 class XDisplayer : public Displayer
00134 {
00135 private:
00136     bool canuse;
00137     int depth;
00138     GtkWidget *drawingarea;
00139     Display *display;
00140     Window window;
00141     GC gc;
00142     XImage *xImage;
00143     XGCValues values;
00144     XShmSegmentInfo shmInfo;
00145 public:
00146     XDisplayer( GtkWidget *drawingarea );
00147     ~XDisplayer();
00148     bool usable();
00149     DisplayerInput format();
00150 protected:
00151     void put( void *data );
00152 };
00153 
00154 class XvDisplayer : public Displayer
00155 {
00156 private:
00157     bool gotPort;
00158     int grabbedPort;
00159     GtkWidget *drawingarea;
00160     Display *display;
00161     Window window;
00162     GC gc;
00163     XGCValues values;
00164     XvImage *xvImage;
00165     unsigned int port;
00166     XShmSegmentInfo shmInfo;
00167     char pix[ MAX_WIDTH * MAX_HEIGHT * 4 ];
00168     bool isPAL;
00169     bool isWidescreen;
00170 
00171 public:
00172     XvDisplayer( GtkWidget *drawingarea, int width, int height, bool isPAL, bool isWidescreen );
00173     ~XvDisplayer();
00174     bool usable();
00175     DisplayerInput format();
00176 
00177 protected:
00178     void put( void *image );
00179 };
00180 
00181 class GdkDisplayer: public Displayer
00182 {
00183 private:
00184     GtkWidget *drawingarea;
00185     bool m_is_wide;
00186 
00187 public:
00188     GdkDisplayer( GtkWidget *drawingarea, int width, int height, bool is_wide );
00189     ~GdkDisplayer();
00190     bool usable();
00191     DisplayerInput format();
00192     void put( void *data );
00193 };
00194 
00195 class FindDisplayer
00196 {
00197 public:
00198     static Displayer *getDisplayer( GtkWidget *drawingarea, Frame &frame );
00199     static Displayer *getDisplayer( GtkWidget *drawingarea, int width, int height );
00200 };
00201 
00202 #endif

Generated on Sun Mar 11 22:11:45 2007 for Kino by  doxygen 1.4.2