2022-10-12 18:17:10 +08:00
|
|
|
#ifndef VIDEOWIN_H
|
|
|
|
#define VIDEOWIN_H
|
|
|
|
#include "basewin.h"
|
|
|
|
|
|
|
|
#define HAVE_REMOTE
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include "pcap.h"
|
|
|
|
#include <QThread>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QRadioButton>
|
2022-12-16 15:08:53 +08:00
|
|
|
#include <QCheckBox>
|
2022-10-12 18:17:10 +08:00
|
|
|
#include "Win32-Extensions.h"
|
|
|
|
|
|
|
|
#pragma comment(lib, "wpcap.lib")
|
|
|
|
#pragma comment(lib, "Ws2_32.lib")
|
|
|
|
|
|
|
|
class VideoSendThread : public QThread {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit VideoSendThread(pcap *pcap);
|
|
|
|
~VideoSendThread() {
|
|
|
|
pcap_close(pcap);
|
|
|
|
}
|
|
|
|
pcap *pcap;
|
|
|
|
std::atomic<char> status{0};
|
|
|
|
QList<QImage> imgs;
|
|
|
|
std::mutex mtx;
|
|
|
|
protected:
|
|
|
|
void run();
|
|
|
|
signals:
|
|
|
|
void onErr(QString);
|
|
|
|
};
|
|
|
|
class VideoRecThread : public QThread {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit VideoRecThread(pcap *pcap);
|
|
|
|
~VideoRecThread() {
|
|
|
|
pcap_close(pcap);
|
|
|
|
}
|
|
|
|
pcap *pcap;
|
|
|
|
std::atomic<char> status{0};
|
2022-12-16 15:08:53 +08:00
|
|
|
bool showImg{true};
|
2022-10-12 18:17:10 +08:00
|
|
|
protected:
|
|
|
|
void run();
|
|
|
|
signals:
|
2022-10-14 18:46:16 +08:00
|
|
|
void onMsg(QImage, int, int);
|
2022-10-12 18:17:10 +08:00
|
|
|
void onErr(char *);
|
|
|
|
};
|
|
|
|
|
2022-10-14 18:46:16 +08:00
|
|
|
class Canvas : public QWidget {
|
|
|
|
public:
|
|
|
|
QImage img;
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *event);
|
|
|
|
};
|
|
|
|
|
2022-10-12 18:17:10 +08:00
|
|
|
class VideoWin : public BaseWin {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2022-12-16 15:08:53 +08:00
|
|
|
static VideoWin *newIns(QByteArray &, QWidget *);
|
2022-10-12 18:17:10 +08:00
|
|
|
|
|
|
|
~VideoWin() {
|
|
|
|
if(thdRece) thdRece->status = 2;
|
|
|
|
if(sendThd) sendThd->status = 2;
|
|
|
|
if(timerId) killTimer(timerId);
|
|
|
|
}
|
|
|
|
VideoRecThread *thdRece{0};
|
|
|
|
VideoSendThread *sendThd{0};
|
|
|
|
QScreen *screen;
|
|
|
|
int timerId{0};
|
2022-12-16 15:08:53 +08:00
|
|
|
QSpinBox *fdWidth, *fdHeight, *fdMsecCapScr,*fdYxj;
|
|
|
|
QRadioButton *fdShowImg;
|
|
|
|
bool showImg{true};
|
2022-10-12 18:17:10 +08:00
|
|
|
QRadioButton *fdEnd;
|
2022-10-14 18:46:16 +08:00
|
|
|
QLabel *fdInfo, *fdLostTimes, *fdLostPkts;
|
2022-10-12 18:17:10 +08:00
|
|
|
QString info;
|
|
|
|
qint64 last_epoch{0};
|
2022-10-14 18:46:16 +08:00
|
|
|
int lostTimes{0}, lostPkts{0};
|
2022-10-12 18:17:10 +08:00
|
|
|
protected:
|
2022-12-16 15:08:53 +08:00
|
|
|
explicit VideoWin(pcap *, pcap *, QWidget *parent = nullptr);
|
2022-10-12 18:17:10 +08:00
|
|
|
void timerEvent(QTimerEvent *event) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VIDEOWIN_H
|