00001 /*************************************************************************** 00002 l1394_device.h - description 00003 ------------------- 00004 begin : Mon Jan 1 2001 00005 copyright : (C) 2001-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 L1394MM_DEVICE_H 00019 #define L1394MM_DEVICE_H 00020 00021 #include <string> 00022 00023 00024 using std::string; 00025 #include "l1394_eventhandle.h" 00026 #include "l1394_resource.h" 00027 #include "l1394_frame.h" 00028 namespace L1394{ 00029 00030 #define FREE_ISO_CHANNEL -1 00031 00032 enum Videomode 00033 { 00034 /*Begin > For DCC Cameras*/ 00035 DEVICE_160x120_YUV_444 = 0, 00036 DEVICE_320x240_YUV_422, 00037 DEVICE_640x480_YUV_411, 00038 DEVICE_640x480_YUV_422, 00039 DEVICE_640x480_RGB, 00040 DEVICE_640x480_MONO, 00041 00042 DEVICE_800x600_YUV_422, 00043 DEVICE_800x600_RGB, 00044 DEVICE_800x600_MONO, 00045 DEVICE_1024x768_YUV_422, 00046 DEVICE_1024x768_RGB, 00047 DEVICE_1024x768_MONO, 00048 00049 DEVICE_1280x960_YUV_422, 00050 DEVICE_1280x960_RGB, 00051 DEVICE_1280x960_MONO, 00052 DEVICE_1600x1200_YUV_422, 00053 DEVICE_1600x1200_RGB, 00054 DEVICE_1600x1200_MONO, 00055 /*End > For DCC Cameras*/ 00056 DEVICE_DV 00057 00058 }; 00059 00060 enum Framerate 00061 { 00062 // 00063 DEVICE_FRAMES_0 = 0, 00064 //! Framerate 3.75 fps24 00065 DEVICE_FRAMES_3_75 , 00066 00067 //! Framerate 7.5 fps 00068 DEVICE_FRAMES_7_5, 00069 00070 //! Framerate 15 fps 00071 DEVICE_FRAMES_15, 00072 00073 //! Framerate 30 fps 00074 DEVICE_FRAMES_30, 00075 00076 //! Framerate 60 fps 00077 DEVICE_FRAMES_60, 00078 00079 DEVICE_FRAMES_DV 00080 }; 00081 00082 enum Isomode 00083 { 00084 //! Use free running isochronous receive 00085 DEVICE_ISO_RUN = 0, 00086 00087 //! Use one-shot mode 00088 DEVICE_ISO_ONESHOT, 00089 00090 DEVICE_ISO_MULTISHOT, 00091 00092 //! No iso receive (for camera control only) 00093 DEVICE_ISO_NO 00094 }; 00095 00096 /*! \class L1394_Device 00097 * \ingroup L1394_Device 00098 * \brief This abstract class defines some basic methods for all L1394 devices. 00099 * 00100 * This class is base class for all L1394 devices and defines some basic methods, like 00101 * start, stop and init for the different devices. 00102 * 00103 *@author Michael Repplinger 00104 */ 00105 class Node; 00106 00107 class Device { 00108 public: 00109 /*! \name Device constructor 00110 * These functions creates the Device objects. 00111 */ 00112 //@{ 00113 Device(Node* parent_node); 00114 00115 /*! Destructor 00116 */ 00117 virtual ~Device() {}; 00118 //@} 00119 /** \name Event handling 00120 * These methods provide access to the event handling mechanism in this library. 00121 */ 00122 //@{ 00123 /*! \fn addEventHandle(L1394::EventHandle* event_handle,const Event) 00124 * \brief This method adds an EventHandle to a specific event 00125 * \param event_handle : pointer to the EventHandle object. 00126 * \param event : integer value for the event. (see class EventHandle ) 00127 */ 00128 virtual void addEventHandle(L1394::EventHandle*,const EVENT event); 00129 00130 00131 /*! \fn addEventHandle(L1394::EventHandle* event_handle) 00132 * \brief This method adds an EventHandle, to all events of a node. 00133 * \param event_handle : pointer to the EventHandle object. 00134 */ 00135 virtual void addEventHandle(L1394::EventHandle*); 00136 00137 00138 /*! \fn removeEventHandle(L1394::EventHandle* event_handle,const Event) 00139 * \brief This method removes an EventHandle from a specific event. 00140 * 00141 * If an EventHandle object is destroyed it must be removed from all Node objects 00142 * \param event_handle : pointer to the EventHandle object. 00143 * \param event : integer value for the event. (see class EventHandle ) 00144 */ 00145 virtual void removeEventHandle(L1394::EventHandle*,const EVENT event); 00146 00147 00148 /*! \fn removeEventHandle(L1394::EventHandle* event_handle) 00149 * \brief This method removes an EventHandle from any event. 00150 * 00151 * If an EventHandle object is destroyed it must be removed from all Node objects 00152 * \param event_handle : pointer to the EventHandle object. 00153 */ 00154 virtual void removeEventHandle(L1394::EventHandle* handle); 00155 //@} 00156 00157 00158 /** \name Device information 00159 * These methods provide specific device information. 00160 */ 00161 //@{ 00162 /*! assign a name with this device 00163 */ 00164 void setName(const string& name) {this->name = name;} 00165 00166 /*! returns the device name 00167 */ 00168 const string& getName() const {return name;} 00169 00170 /*! \fn getFrameSize() const 00171 * \brief This method returns the frame size 00172 * \return u_int : returns the frame size 00173 */ 00174 virtual u_int getFrameSize() const {return frame_size;} 00175 00176 00177 /*! \fn getFrameWidth() const 00178 * \brief This method returns the frame size. (obsolete) 00179 * 00180 * Devices supporting more than one resolution, provides normaly an init 00181 * method. Before you call init, this method returns the 00182 * default settings of the device. 00183 * 00184 * \return u_int : size of a frame in bytes. 00185 */ 00186 virtual u_int getFrameWidth() const {return frame_width;} 00187 00188 00189 /*! \fn getFrameHeight() const 00190 * \brief This method returns the width of a frame. 00191 * 00192 * Devices supporting more than one resolution provides normaly an init 00193 * method. Before you call init, this method returns the 00194 * default setting of the device. 00195 * \return u_int : size of a frame in bytes. 00196 */ 00197 virtual u_int getFrameHeight() const {return frame_height;} 00198 00199 00200 /*! \fn getParentNode() const 00201 * \brief This method returns the parent node. 00202 * 00203 * \return Node* : pointer to the parent node. 00204 */ 00205 virtual const Node* getParentNode() const {return parent_node;} 00206 00207 00208 /*! \fn getDeviceType() const 00209 * \brief This abstract method must be implemented by all devices. 00210 * 00211 * This method is normaly for internal use. You can use it for save down_casting. 00212 * The following types are defined: 00213 * 00214 * return int : type of the device. 00215 */ 00216 virtual DeviceType getDeviceType() const = 0; 00217 00218 00219 /*! \fn hasVideoFormat(const Videomode videomode) 00220 * \brief This method tests, if a videomode is supported by a Camera. 00221 * \return bool : true if the videomode is supported, false if not 00222 */ 00223 virtual bool hasVideoFormat(const Videomode videomode) = 0; 00224 00225 00226 /*! \fn hasFramerate(const Videomode videomode, const Framerate framerate) 00227 * \brief This method tests, if a framerate, with a videomode is supported by the camera. 00228 * \param videomode : the videomode for the framerate. 00229 * \param framerate : the framerate that should be tested. 00230 * \return bool : true, if a framerate is supported, false if not 00231 */ 00232 virtual bool hasFramerate(const Videomode videomode,const Framerate framerate) = 0; 00233 //@} 00234 00235 00236 /** \name Basic operations 00237 * Every device must implement these basic functions. 00238 */ 00239 //@{ 00240 /*! \fn getFrame() 00241 * \brief This method returns the actual frame of a camera. 00242 * 00243 * At this time this method blocks until it gets a frame. 00244 * \return u_char* : pointer to the actual frame. 00245 */ 00246 virtual Frame* getFrame() ; 00247 00248 00249 /*! \fn void releaseFrame(Frame* frame) 00250 * \brief This method releases a frame. 00251 * 00252 * You must only call this function, if the autorelease mode is disabled. 00253 * See also frameMode() 00254 * param frame : pointer to the frame. 00255 */ 00256 virtual void releaseFrame(Frame* frame) ; 00257 00258 00259 /*! \fn setFrameMode(bool mode) 00260 * \brief This method enables or disables the autorelease mode for frames. 00261 * 00262 * By default the autorelease mode is enabled. So if you call the function 00263 * getFrame() the last frame is released and the actual frame is returned 00264 * You can disable the automode but you MUST call the method releaseFrame(u_char*) 00265 * for every frame you get. 00266 * \param mode : true enables the automode, false disables the automode. 00267 */ 00268 virtual void setFrameMode(const bool frame_mode) ; 00269 00270 00271 /*! \fn getFrameMode() const 00272 * \brief This method returns the framemode 00273 * \return bool : true if the autorelease mode is enabled else false 00274 */ 00275 virtual bool getFrameMode() const ; 00276 00277 00278 /*! \fn setParameter(const int buffercount, const int channel, const Isomode isomode, const Videomode videomode, const Framerate framerate) 00279 * \brief This method sets the device-specific parameter for iso-receive. 00280 * 00281 * Some parameter are fixed for some devices (like DV-devices) and they take no effect, if you change it. 00282 * \param buffercount : set how many Frame buffer are reserved 00283 * \param isomode : set the isomode 00284 * \param channel : set the iso-channel. A value of -1 (or FREE_ISO_CHANNEL) 00285 * searches for a for iso channel. Be carefull using this feature, because the used channel 00286 * are stored in local member variables. So if you run more programms using this library at the same 00287 * time, this feature can cause serious problems(if two devices uses the same iso-channel). 00288 * 00289 * The current Iso-Master don't store the used channels (or the devices don't allocate a channel) so 00290 * the register values for used channels are invalid. 00291 * 00292 * \param videomode : set the video-mode 00293 * \param framerate : set the framerate 00294 */ 00295 virtual int setParameter(const int buffercount, const int channel, const Isomode isomode, const Videomode videomode, const Framerate framerate) = 0; 00296 00297 virtual void flushIsoQueue(); 00298 /*! \fn isSending() const 00299 * \brief This method reports if a camera is sending or not. 00300 * 00301 * \return bool : true, if a camera is sending, false if not. 00302 */ 00303 virtual bool isSending() const {return is_sending;} 00304 00305 00306 /*! \fn init() 00307 * \brief This method allocates ressoures for isochronous transmission. 00308 * 00309 * If you write your own device you can use this method to allocate iso- 00310 * resources. 00311 * \return int : L1394_SUCCESS if allocating success, else L1394_Failed. 00312 */ 00313 virtual int init() {return L1394_SUCCESS;} 00314 00315 00316 /*! \fn start() 00317 * \brief This method starts a FireWire device and iso-receive. 00318 * \return int : returns L1394_FAILED if an error occur, else L1394_SUCCESS 00319 */ 00320 virtual int start() =0; 00321 00322 00323 /*! \fn stop() 00324 * \brief This method stops a sending device and the Iso-receive. 00325 * \return int : returns L1394_FAILED if an error occur, else L1394_SUCCESS 00326 */ 00327 virtual int stop() =0; 00328 //@} 00329 protected: 00330 00331 void setFrameSize (const int frame_size) {this->frame_size = frame_size;} 00332 void setFrameWidth (const int frame_width) {this->frame_width = frame_width;} 00333 void setFrameHeight(const int frame_height){this->frame_height= frame_height;} 00334 void setSending (const bool is_sending) {this->is_sending = is_sending;} 00335 00336 private: 00337 int frame_size; 00338 int frame_width; 00339 int frame_height; 00340 int device_type; 00341 00342 bool is_sending; 00343 00344 Node* parent_node; 00345 00346 string name; 00347 }; 00348 } 00349 #endif