00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AXIS_SOURCE_H
00023 #define AXIS_SOURCE_H
00024
00025 #include "ImageSource.h"
00026 #include "Image.h"
00027
00028 #include <stdio.h>
00029 #include <stdlib.h>
00030 #include <stddef.h>
00031 #include <unistd.h>
00032 #include <errno.h>
00033
00034 #include <string.h>
00035 #ifndef __linux__
00036 #include <bstring.h>
00037 #endif
00038
00039 #include <netdb.h>
00040 #include <netinet/in.h>
00041 #include <netinet/tcp.h>
00042
00043 #include <sys/types.h>
00044 #include <sys/socket.h>
00045 #include <fcntl.h>
00046
00047 #include <iostream>
00048 #include <string>
00049 #include <strstream>
00050
00051
00052 extern "C" {
00053 #include "jpeglib.h"
00054 void jpeg_mem_src(j_decompress_ptr, unsigned char *, int);
00055 }
00056
00057 using namespace std;
00058
00059
00060 #define PORT 80
00061
00062
00064 enum FrameSize { HALF, FULL , CIF};
00065
00066 class AxisSource : public ImageSource
00075 {
00076 private:
00077
00078
00079 int vs;
00080 int dims[2];
00081 unsigned char* img_ptr;
00082
00083 public:
00085 AxisSource(char* axis_name, FrameSize frame_size);
00086 AxisSource();
00087 ~AxisSource();
00088
00089
00090
00091 virtual ImageSource& operator >> (ImageRGB&);
00092 virtual ImageSource& operator >> (ImageGrey&);
00093 virtual ImageSource& operator >> (Image&);
00094
00095 int get_width(){ return dims[0];}
00096 int get_height(){ return dims[1];}
00097
00098 private:
00099 int videoSocket(char*);
00100 void requestStream (int);
00101 int readFrame (int, unsigned char* &, int&);
00102 void readNextFrame (int, unsigned char* &, int [2]);
00103 int readSocket (int, unsigned char*, int);
00104 void decodeFrame(unsigned char* imgBuff, int buffLength,
00105 unsigned char* &image, int imgSize[2]);
00106 };
00107
00108
00109 #endif // AXIS_SOURCE_H