-
Notifications
You must be signed in to change notification settings - Fork 0
/
writer.cpp
101 lines (72 loc) · 1.62 KB
/
writer.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
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
#include "writer.h"
#include <QDebug>
#include <zmq.h>
#include "kinectcapture.h"
#include <QFileDevice>
#include <QDateTime>
#include <QDir>
WriterBase::WriterBase(KinectCapture *kc, void *ctx)
:_kc(kc)
,_ctx(ctx)
//,_mmf("d:\\Test.avi")
{
//_mmf.open(QFile::WriteOnly);
// _mmf.map(0,)
}
WriterBase::~WriterBase()
{
}
//void WriterBase::InitializeMessageQueue()
//{
// _sock = zmq_socket(_ctx,ZMQ_SUB);
// zmq_setsockopt(_sock,ZMQ_SUBSCRIBE,0,0);
// zmq_connect(_sock,"inproc://stopper");
//}
//bool WriterBase::IsStopped()
//{
// int len = zmq_recv(_sock,_buf,7,ZMQ_DONTWAIT);
// return len > 0;
//}
//void WriterBase::ReleaseMessageQueue()
//{
// zmq_close(_sock);
// //return true;
//}
void WriterBase::run()
{
void* rcv = zmq_socket(_ctx,ZMQ_SUB);
zmq_setsockopt(rcv,ZMQ_SUBSCRIBE,0,0);
zmq_connect(rcv,"inproc://stopper");
void* puller = zmq_socket(_ctx,ZMQ_PULL);
zmq_connect(puller,"inproc://writer");
char buf[8];
int count = 0;
QString fmt("yyyyMMdd_HHmmss_zzz");
QDir dir("E:/Video");
QString path;
bool canWrite = false;
//cv::VideoWriter* cvw = nullptr;
zmq_pollitem_t items[] = {
{puller,0,ZMQ_POLLIN,0}
};
while(true)
{
if(zmq_recv(rcv,buf,7,ZMQ_DONTWAIT)>0)
{
break;
}
int rc = zmq_poll(items,1,3000);
if(rc==-1)
{
break;
}
if(items[0].revents & ZMQ_POLLIN)
{
if(zmq_recv(puller,buf,7,ZMQ_DONTWAIT)>0)
{
}
}
}
zmq_close(rcv);
zmq_close(puller);
}