qt/ledset/videowin.h

83 lines
1.7 KiB
C
Raw Normal View History

#ifndef VIDEOWIN_H
#define VIDEOWIN_H
#include "basewin.h"
#define HAVE_REMOTE
#include "pcap.h"
2023-03-20 11:30:19 +08:00
#include <winsock2.h>
#include <QThread>
#include <QSpinBox>
#include <QLabel>
#include <QRadioButton>
2022-12-16 15:08:53 +08:00
#include <QCheckBox>
#include "Win32-Extensions.h"
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 16:16:12 +08:00
bool noReview{false};
protected:
void run();
signals:
2022-10-14 18:46:16 +08:00
void onMsg(QImage, int, int);
void onErr(char *);
};
2022-10-14 18:46:16 +08:00
class Canvas : public QWidget {
public:
QImage img;
protected:
void paintEvent(QPaintEvent *event);
};
class VideoWin : public BaseWin {
Q_OBJECT
public:
2022-12-16 15:08:53 +08:00
static VideoWin *newIns(QByteArray &, QWidget *);
~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;
2022-12-16 16:16:12 +08:00
QCheckBox *fdNoReview;
bool noReview{false};
QRadioButton *fdEnd;
2022-10-14 18:46:16 +08:00
QLabel *fdInfo, *fdLostTimes, *fdLostPkts;
QString info;
qint64 last_epoch{0};
2022-10-14 18:46:16 +08:00
int lostTimes{0}, lostPkts{0};
protected:
2022-12-16 15:08:53 +08:00
explicit VideoWin(pcap *, pcap *, QWidget *parent = nullptr);
void timerEvent(QTimerEvent *event) override;
};
#endif // VIDEOWIN_H