76 lines
1.5 KiB
C
76 lines
1.5 KiB
C
|
#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>
|
||
|
#include "Win32-Extensions.h"
|
||
|
|
||
|
#pragma comment(lib, "wpcap.lib")
|
||
|
#pragma comment(lib, "Ws2_32.lib")
|
||
|
|
||
|
QByteArray getNetDev(QWidget *parent);
|
||
|
|
||
|
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};
|
||
|
protected:
|
||
|
void run();
|
||
|
signals:
|
||
|
void onMsg(QImage);
|
||
|
void onErr(char *);
|
||
|
};
|
||
|
|
||
|
class VideoWin : public BaseWin {
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
static VideoWin *newIns(QWidget *);
|
||
|
|
||
|
explicit VideoWin(pcap *, pcap *, QWidget *parent = nullptr);
|
||
|
~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};
|
||
|
QSpinBox *fdWidth, *fdHeight;
|
||
|
QRadioButton *fdEnd;
|
||
|
QLabel *fdInfo;
|
||
|
QString info;
|
||
|
qint64 last_epoch{0};
|
||
|
protected:
|
||
|
void timerEvent(QTimerEvent *event) override;
|
||
|
};
|
||
|
|
||
|
#endif // VIDEOWIN_H
|