-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathglvideosurface.cpp
75 lines (63 loc) · 2.19 KB
/
glvideosurface.cpp
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
#include "glvideosurface.h"
#include <QDebug>
GLVideoSurface::GLVideoSurface(QObject *parent) : QAbstractVideoSurface(parent) {}
QList<QVideoFrame::PixelFormat> GLVideoSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const
{
Q_UNUSED(handleType);
return QList<QVideoFrame::PixelFormat>()
<< QVideoFrame::Format_ARGB32
<< QVideoFrame::Format_ARGB32_Premultiplied
<< QVideoFrame::Format_RGB32
<< QVideoFrame::Format_RGB24
<< QVideoFrame::Format_RGB565
<< QVideoFrame::Format_RGB555
<< QVideoFrame::Format_ARGB8565_Premultiplied
<< QVideoFrame::Format_BGRA32
<< QVideoFrame::Format_BGRA32_Premultiplied
<< QVideoFrame::Format_BGR32
<< QVideoFrame::Format_BGR24
<< QVideoFrame::Format_BGR565
<< QVideoFrame::Format_BGR555
<< QVideoFrame::Format_BGRA5658_Premultiplied
<< QVideoFrame::Format_AYUV444
<< QVideoFrame::Format_AYUV444_Premultiplied
<< QVideoFrame::Format_YUV444
<< QVideoFrame::Format_YUV420P
<< QVideoFrame::Format_YV12
<< QVideoFrame::Format_UYVY
<< QVideoFrame::Format_YUYV
<< QVideoFrame::Format_NV12
<< QVideoFrame::Format_NV21
<< QVideoFrame::Format_IMC1
<< QVideoFrame::Format_IMC2
<< QVideoFrame::Format_IMC3
<< QVideoFrame::Format_IMC4
<< QVideoFrame::Format_Y8
<< QVideoFrame::Format_Y16
<< QVideoFrame::Format_Jpeg
<< QVideoFrame::Format_CameraRaw
<< QVideoFrame::Format_AdobeDng;
}
bool GLVideoSurface::present(const QVideoFrame &frame)
{
QVideoFrame bufferFrame(frame);
bufferFrame.map(QAbstractVideoBuffer::ReadOnly);
if (!bufferFrame.isValid()) {
return false;
}
cv::Mat mat = cv::Mat(bufferFrame.height(), bufferFrame.width(), CV_8UC3, bufferFrame.bits());
emit frameReceived(mat);
bufferFrame.unmap();
return true;
}
bool GLVideoSurface::start(const QVideoSurfaceFormat &format)
{
QAbstractVideoSurface::start(format);
emit presentationStarted();
return true;
}
void GLVideoSurface::stop()
{
QAbstractVideoSurface::stop();
emit presentationStopped();
}