-
Notifications
You must be signed in to change notification settings - Fork 7
/
framebroadcast.cpp
50 lines (42 loc) · 956 Bytes
/
framebroadcast.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
#include "framebroadcast.h"
FrameBroadcast::FrameBroadcast(QObject *parent) : QObject(parent)
{
timer = new QTimer();
timer->setInterval(500);
timer->setTimerType(Qt::TimerType::VeryCoarseTimer);
timer->setSingleShot(false);
connect(timer,SIGNAL(timeout()),this,SLOT(tick()));
}
void FrameBroadcast::startCapture()
{
timer->start();
}
void FrameBroadcast::stopCapture()
{
timer->stop();
}
static void deleteFrame(Frame *obj)
{
delete obj->buffer;
delete obj;
}
void FrameBroadcast::tick()
{
QSharedPointer<Frame> frame(new Frame,deleteFrame);
frame->height=getHeight();
frame->width=getWidth();
frame->lenght=getLenght();
while(true)
{
frame->buffer=new unsigned char[frame->lenght];
if(tryCaptureFrame(frame->buffer))
{
emit frameCaptured(frame);
break;
}
else
{
delete frame->buffer;
}
}
}