Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
net.h
1 
2 /***************************************************************************
3  * net.h - This header defines an fuse network client camera
4  *
5  * Created: Wed Feb 01 12:22:06 2006
6  * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __FIREVISION_CAMS_NET_H_
25 #define __FIREVISION_CAMS_NET_H_
26 
27 #include <fvcams/camera.h>
28 #include <fvutils/net/fuse_client_handler.h>
29 #include <vector>
30 
31 namespace firevision {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
36 class CameraArgumentParser;
37 class FuseClient;
38 class FuseImageContent;
39 class FuseNetworkMessage;
40 class JpegImageDecompressor;
41 
42 class NetworkCamera : public Camera, public FuseClientHandler
43 {
44 
45  public:
46  NetworkCamera(const char *host, unsigned short port, bool jpeg = false);
47  NetworkCamera(const char *host, unsigned short port, const char *image_id,
48  bool jpeg = false);
50 
51  virtual ~NetworkCamera();
52 
53  virtual void open();
54  virtual void start();
55  virtual void stop();
56  virtual void close();
57  virtual void flush();
58  virtual void capture();
59  virtual void print_info();
60  virtual bool ready();
61 
62  virtual unsigned char* buffer();
63  virtual unsigned int buffer_size();
64  virtual void dispose_buffer();
65 
66  virtual unsigned int pixel_width();
67  virtual unsigned int pixel_height();
68  virtual colorspace_t colorspace();
69 
70  virtual void set_image_id(const char *image_id);
71  virtual void set_image_number(unsigned int n);
72 
73  virtual fawkes::Time * capture_time();
74 
75  virtual std::vector<FUSE_imageinfo_t>& image_list();
76 
77  virtual void fuse_invalid_server_version(uint32_t local_version,
78  uint32_t remote_version) throw();
79  virtual void fuse_connection_established() throw();
80  virtual void fuse_connection_died() throw();
81  virtual void fuse_inbound_received(FuseNetworkMessage *m) throw();
82 
83  private:
84  bool __started;
85  bool __opened;
86 
87  bool __connected;
88  unsigned int __local_version;
89  unsigned int __remote_version;
90 
91  char *__host;
92  unsigned short __port;
93  char *__image_id;
94 
95  bool __get_jpeg;
96  JpegImageDecompressor *__decompressor;
97  unsigned char *__decompressed_buffer;
98  unsigned int __last_width;
99  unsigned int __last_height;
100 
101  FuseClient *__fusec;
102  FuseImageContent *__fuse_image;
103  FuseNetworkMessage *__fuse_message;
104 
105  FUSE_imageinfo_t *__fuse_imageinfo;
106 
107  std::vector<FUSE_imageinfo_t> __image_list;
108 };
109 
110 } // end namespace firevision
111 
112 #endif