shmem.h
00001 00002 /*************************************************************************** 00003 * shmem.h - This header defines a reader for shared memory images 00004 * 00005 * Created: Thu Jan 12 19:41:17 2006 00006 * Copyright 2005-2009 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __FIREVISION_CAMS_SHMEM_H_ 00025 #define __FIREVISION_CAMS_SHMEM_H_ 00026 00027 #include <cams/camera.h> 00028 #include <fvutils/color/colorspaces.h> 00029 #include <fvutils/ipc/shm_image.h> 00030 00031 class CameraArgumentParser; 00032 00033 class SharedMemoryCamera : public Camera 00034 { 00035 00036 public: 00037 00038 SharedMemoryCamera(const char *image_id, bool deep_copy = false); 00039 SharedMemoryCamera(const CameraArgumentParser *cap); 00040 ~SharedMemoryCamera(); 00041 00042 virtual void open(); 00043 virtual void start(); 00044 virtual void stop(); 00045 virtual void close(); 00046 virtual void flush(); 00047 virtual void capture(); 00048 virtual void print_info(); 00049 00050 virtual bool ready(); 00051 00052 virtual unsigned char* buffer(); 00053 virtual unsigned int buffer_size(); 00054 virtual void dispose_buffer(); 00055 00056 virtual unsigned int pixel_width(); 00057 virtual unsigned int pixel_height(); 00058 virtual colorspace_t colorspace(); 00059 virtual fawkes::Time * capture_time(); 00060 00061 virtual void set_image_number(unsigned int n); 00062 00063 SharedMemoryImageBuffer * shared_memory_image_buffer(); 00064 00065 virtual void lock_for_read(); 00066 virtual bool try_lock_for_read(); 00067 virtual void lock_for_write(); 00068 virtual bool try_lock_for_write(); 00069 virtual void unlock(); 00070 00071 private: 00072 void init(); 00073 00074 bool __deep_copy; 00075 bool __opened; 00076 unsigned int __width; 00077 unsigned int __height; 00078 char * __image_id; 00079 00080 SharedMemoryImageBuffer *__shm_buffer; 00081 00082 unsigned char *__deep_buffer; 00083 00084 fawkes::Time *__capture_time; 00085 }; 00086 00087 #endif

