00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __MXCPC_ASYNCHRONOUSCAMERALIVEMXPEGFASTSTREAM_H__
00021 #define __MXCPC_ASYNCHRONOUSCAMERALIVEMXPEGFASTSTREAM_H__
00022
00023
00024
00025 #define MXCPC_ASYNCHRONOUSCAMERALIVEMXPEGFASTSTREAM_HEADERBUFFER_SIZE 1024
00026
00027
00028
00029 #include <mxcpcCameraLiveMxPEGFastStream.h>
00030 #include <mxcpcIPAddress.h>
00031 #include <mxcpcProxyConfiguration.h>
00032
00033 #include <QTcpSocket>
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 class mxcpcAsynchronousCameraLiveMxPEGFastStream
00054 : public QObject,
00055 public mxcpcCameraLiveMxPEGFastStream {
00056
00057 Q_OBJECT
00058
00059 private:
00060 enum HTTPNegotiationState {
00061 SendGET_NoAuth,
00062 ReceiveResponseHeader_NoAuth,
00063 RaisedAuthenticationDialog,
00064 WaitForAuthenticationDialog,
00065 SendGET_EnteredAuth,
00066 ReceiveResponseHeader_EnteredAuth,
00067 NegotiationSucceeded,
00068 NegotiationFailed
00069 };
00070
00071 private:
00072 QTcpSocket *AsyncSocket;
00073 mxcpcIPAddress CameraIP;
00074 int CameraPort;
00075 mxcpcProxyConfiguration CameraProxyConfiguration;
00076 float FPS;
00077 bool HTTPNegotiationMode;
00078 HTTPNegotiationState NegotiationState;
00079 char HTTPHeaderBuffer
00080 [MXCPC_ASYNCHRONOUSCAMERALIVEMXPEGFASTSTREAM_HEADERBUFFER_SIZE];
00081 int HTTPHeaderBytesRead;
00082 int HTTPHeaderSize;
00083 bool AuthenticationEntered;
00084 bool AuthenticationDialogRaised;
00085 bool AuthenticationDialogWasRaised;
00086 QString AuthenticationUser;
00087 QString AuthenticationPassword;
00088
00089 public:
00090 mxcpcAsynchronousCameraLiveMxPEGFastStream(
00091 const mxcpcIPAddress& camera_ip,
00092 int camera_port,
00093 const mxcpcProxyConfiguration& camera_proxy_configuration,
00094 float fps = 4
00095 );
00096 mxcpcAsynchronousCameraLiveMxPEGFastStream(const mxcpcIPAddress& camera_ip,
00097 int port,
00098 float fps = 4);
00099 mxcpcAsynchronousCameraLiveMxPEGFastStream(const mxcpcIPAddress& camera_ip,
00100 int port,
00101 int fps = 4);
00102 mxcpcAsynchronousCameraLiveMxPEGFastStream(int ip1, int ip2, int ip3, int ip4,
00103 int port,
00104 int fps = 4);
00105 ~mxcpcAsynchronousCameraLiveMxPEGFastStream();
00106 private:
00107 void constructCommonStuff(const mxcpcIPAddress& camera_ip, int camera_port,
00108 float fps);
00109
00110 signals:
00111
00112 void bytesAvailable(void);
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 void authenticationRequest(QString msg);
00123
00124 public slots:
00125
00126
00127
00128 void processAuthentication(const QString& user, const QString& password);
00129
00130
00131
00132 void processAuthenticationCancellation(void);
00133
00134 public:
00135
00136 int fetchBytes(unsigned char *buffer, int num);
00137
00138 bool stillUp(void);
00139
00140 bool waitForBytes(int timeout_msecs = -1);
00141
00142
00143 bool isAuthenticationDialogRaised(void);
00144
00145
00146 bool wasAuthenticationDialogRaised(void);
00147
00148 private slots:
00149
00150 void processIncomingBytes(void);
00151
00152 private:
00153
00154 void establishConnection(void);
00155
00156 void sendGETRequest(const char *user = 0, const char *password = 0);
00157
00158 bool receiveHTTPHeader(void);
00159 };
00160
00161
00162
00163 #endif // __MXCPC_ASYNCHRONOUSCAMERALIVEMXPEGFASTSTREAM_H__
00164