net.h

00001
00002 /***************************************************************************
00003  *  net.h - This header defines an fuse network client camera
00004  *
00005  *  Created: Wed Feb 01 12:22:06 2006
00006  *  Copyright  2005-2007  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_NET_H_
00025 #define __FIREVISION_CAMS_NET_H_
00026 
00027 #include <cams/camera.h>
00028 #include <fvutils/net/fuse_client_handler.h>
00029 #include <vector>
00030
00031 class CameraArgumentParser;
00032 class FuseClient;
00033 class FuseImageContent;
00034 class FuseNetworkMessage;
00035 class JpegImageDecompressor;
00036
00037 class NetworkCamera : public Camera, public FuseClientHandler
00038 {
00039
00040  public:
00041   NetworkCamera(const char *host, unsigned short port, bool jpeg = false);
00042   NetworkCamera(const char *host, unsigned short port, const char *image_id,
00043                 bool jpeg = false);
00044   NetworkCamera(const CameraArgumentParser *cap);
00045
00046   virtual ~NetworkCamera();
00047
00048   virtual void open();
00049   virtual void start();
00050   virtual void stop();
00051   virtual void close();
00052   virtual void flush();
00053   virtual void capture();
00054   virtual void print_info();
00055   virtual bool ready();
00056
00057   virtual unsigned char* buffer();
00058   virtual unsigned int   buffer_size();
00059   virtual void           dispose_buffer();
00060
00061   virtual unsigned int   pixel_width();
00062   virtual unsigned int   pixel_height();
00063   virtual colorspace_t   colorspace();
00064
00065   virtual void           set_image_id(const char *image_id);
00066   virtual void           set_image_number(unsigned int n);
00067
00068   virtual fawkes::Time * capture_time();
00069
00070   virtual std::vector<FUSE_imageinfo_t>& image_list();
00071
00072   virtual void fuse_invalid_server_version(uint32_t local_version,
00073                                            uint32_t remote_version) throw();
00074   virtual void fuse_connection_established() throw();
00075   virtual void fuse_connection_died() throw();
00076   virtual void fuse_inbound_received(FuseNetworkMessage *m) throw();
00077
00078  private:
00079   bool __started;
00080   bool __opened;
00081
00082   bool         __connected;
00083   unsigned int __local_version;
00084   unsigned int __remote_version;
00085
00086   char               *__host;
00087   unsigned short      __port;
00088   char               *__image_id;
00089
00090   bool __get_jpeg;
00091   JpegImageDecompressor *__decompressor;
00092   unsigned char      *__decompressed_buffer;
00093   unsigned int        __last_width;
00094   unsigned int        __last_height;
00095
00096   FuseClient         *__fusec;
00097   FuseImageContent   *__fuse_image;
00098   FuseNetworkMessage *__fuse_message;
00099
00100   FUSE_imageinfo_t   *__fuse_imageinfo;
00101
00102   std::vector<FUSE_imageinfo_t> __image_list;
00103 };
00104
00105 #endif