-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcapt_sel.h
127 lines (108 loc) · 3.93 KB
/
capt_sel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**************************************************************************************************************************************************************
capt_sel.h
Copyright © 2023 Maksim Kryukov <fagear@mail.ru>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created: 2022-09
**************************************************************************************************************************************************************/
#ifndef CAPT_SEL_H
#define CAPT_SEL_H
#include <QDebug>
#include <QDialog>
#include <QElapsedTimer>
#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QImage>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QPixmap>
#include <QThread>
#include <QTimer>
#include <QtConcurrent>
#include "config.h"
#include "ffmpegwrapper.h"
namespace Ui {
class capt_sel;
}
//------------------------ Capture device selection dialog.
class capt_sel : public QDialog
{
Q_OBJECT
private:
// Default preview resolution.
enum
{
PV_WIDTH = 640,
PV_HEIGHT = 480
};
// FFMPEG timeouts (in ms).
enum
{
FMPG_TIME_DEV_LIST = 5000, // Maximum time for device listing.
FMPG_TIME_OPEN = 3000, // Maximum time for device opening.
FMPG_TIME_FRAME = 1500 // Maximum time for one frame capture.
};
// Dropout action list indexes for [lbxColorCh].
enum
{
LIST_COLORS_ALL,
LIST_COLOR_R,
LIST_COLOR_G,
LIST_COLOR_B,
};
private:
Ui::capt_sel *ui;
QGraphicsScene *scene;
QGraphicsPixmapItem *pixels;
QPixmap preview_pix; // Blank screen for preview.
QThread *ffmpeg_thread; // Thread for FFMPEG wrapper.
FFMPEGWrapper *capt_dev; // FFMPEG Qt-wrapper.
QTimer capture_poll; // Timer for polling opened capture device for new frames.
QTimer capt_busy; // Timer for measuring FFMPEG response.
QElapsedTimer capt_meas; // Timer for measuring capture rate.
bool img_buf_free;
uint8_t capture_rate;
public:
explicit capt_sel(QWidget *parent = 0);
~capt_sel();
int exec();
private:
void disableOffset();
void enableOffset();
void stopCapture();
void stopPreview();
private slots:
void usrRefresh();
void usrSave();
void usrClose();
void toggleDefaults();
void selectDevice();
void usrSetNTSC();
void usrSetPAL();
void pollCapture();
void lostFFMPEG();
void refillDevList(VCapList);
void captureReady(int in_width, int in_height, uint32_t in_frames, float in_fps);
void captureClosed();
void captureError(uint32_t);
void redrawPreview(QImage, bool);
signals:
void requestDropDet(bool); // Set droped frames detector.
void requestColor(vid_preset_t); // Set color channel.
void requestResize(uint16_t, uint16_t); // Set capture dimensions.
void requestFPS(uint8_t); // Set capture framerate.
void requestOffset(uint16_t, uint16_t); // Set screencap offset from top left corner.
void requestDeviceList(); // Request video capture device list.
void openDevice(QString, QString); // Request opening file/device as video source.
void closeDevice(); // Request closing capture.
void requestFrame(); // Request next frame from the capture.
};
#endif // CAPT_SEL_H