00001 /*************************************************************************** 00002 l1394_window.h - description 00003 ------------------- 00004 begin : Thu Nov 30 2000 00005 copyright : (C) 2000-2004 by Michael Repplinger 00006 email : repplinger@cs.uni-sb.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef L1394_MM_WINDOW_H 00019 #define L1394_MM_WINDOW_H 00020 #include "l1394_converter.h" 00021 #include <l1394_session.h> 00022 00023 namespace L1394_MM{ 00024 00025 /*! \class Window 00026 * \ingroup L1394_Display 00027 * \brief This abstract class represents the interface for all windows. 00028 * 00029 * If you want to use your own window classes with this library, you inherit 00030 * the new window class from this class and implement the abstract functions. 00031 * For Example see class XShmImg. 00032 * 00033 *@author Michael Repplinger 00034 */ 00035 00036 class Window : protected L1394::EventHandle { 00037 public: 00038 00039 00040 /*! \ fn Window() 00041 * \ brief constructor 00042 */ 00043 Window(l1394_converter dec); 00044 00045 /*! \fn ~Window() 00046 * \brief destructor 00047 */ 00048 virtual ~Window(); 00049 00050 00051 /*! \fn getBuffer() const 00052 * \brief This function return the window buffer to write data in it. 00053 * 00054 * If the window has no own buffer, the assigned buffer will be returned, if it is 00055 * set, if not NULL is returned. 00056 * \return char* : pointer to buffer, represent as char array. 00057 */ 00058 virtual unsigned char* getBuffer() const =0; 00059 00060 00061 /*! \fn void setTitle(const char* title) 00062 * \brief With this function you can set the title of window. 00063 * \param title : const char* with the name of the window 00064 */ 00065 virtual void setTitle(const char* title) = 0; 00066 00067 00068 /*! \fn void update() 00069 * \brief This function update the display. 00070 * 00071 * This function must be called to show changes on the buffer. 00072 */ 00073 virtual void update() = 0; 00074 00075 00076 /*! \fn getColorDepth() const 00077 * \brief This function return the color depth of the window. 00078 * 00079 * This value depends on your X-Server settings. 00080 * \return int : the color depth as integer value, normally 16 or 24 00081 */ 00082 virtual int getColorDepth() const =0; 00083 00084 00085 /*! \fn start() 00086 * \brief This function starts the converter and diplay the frames. 00087 * 00088 * You don't need to reimplement this function if you use the run_static function 00089 * to run the window. 00090 */ 00091 virtual void start(); 00092 00093 00094 /*! \fn stop() 00095 * \brief This function stops the running window. 00096 */ 00097 virtual void stop(); 00098 00099 00100 /*! \fn connect(L1394::Device* device) 00101 * \brief This function connects an L1394::Device to this window. 00102 * 00103 * This class inherits from class EventHandle and adds themself to 00104 * the device eventhandling. If the device is deleted this object delete 00105 * themself and you must not delete the window object. 00106 * \param device: pointer to the device. 00107 */ 00108 virtual void connect(L1394::Device*); 00109 00110 /** Disconnects a previous connected device, so the window can be reused by 00111 * another device 00112 */ 00113 virtual void disconnect(); 00114 00115 /** Returns true, if the window is started, else false 00116 */ 00117 bool isRunning() const {return running;} 00118 protected: 00119 00120 00121 L1394::Device* getDevice() const {return device;} 00122 L1394::internal::Message* message; 00123 00124 private: 00125 //! This function create a thread with function initWindow(); 00126 static void* run_static(void*); 00127 00128 //! This function gets a frame from the device, converts it and updates the window. 00129 virtual void* initWindow(); 00130 00131 00132 //! In this thread runs the initWindow() function. 00133 L1394::Thread window_thread; 00134 00135 //! While running is true, the initWindow() function is running 00136 bool running; 00137 00138 //! The converter function 00139 l1394_converter conv; 00140 00141 //! The connected device 00142 L1394::Device* device; 00143 00144 L1394::ThreadMutex mutex; 00145 }; 00146 00147 } 00148 #endif