-
Notifications
You must be signed in to change notification settings - Fork 4
/
videoappsink.cpp
41 lines (29 loc) · 894 Bytes
/
videoappsink.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
#include "videoappsink.h"
VideoAppSink::VideoAppSink(QObject *parent) :
QObject(parent), QGst::Utils::ApplicationSink()
{
}
void VideoAppSink::eos()
{
}
QGst::FlowReturn VideoAppSink::newPreroll()
{
QGst::SamplePtr sample = pullPreroll();
QGst::MapInfo mapInfo;
sample->buffer()->map(mapInfo, QGst::MapRead);
QImage image((uchar*) mapInfo.data(), 640, 360, QImage::Format_ARGB32);
sample->buffer()->unmap(mapInfo);
emit newPrerollImage(image);
return QGst::FlowOk;
}
QGst::FlowReturn VideoAppSink::newSample()
{
// TODO: Allow to delay the buffer/frame here
QGst::SamplePtr sample = pullSample();
QGst::MapInfo mapInfo;
sample->buffer()->map(mapInfo, QGst::MapRead);
QImage image((uchar*) mapInfo.data(), 640, 360, QImage::Format_ARGB32);
sample->buffer()->unmap(mapInfo);
emit newImage(image);
return QGst::FlowOk;
}