-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamer.cpp
62 lines (51 loc) · 1.18 KB
/
streamer.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
#include "streamer.h"
#include "packet_receiver.h"
#include "packet_file_writer.h"
#include "synchronized_queue.h"
#ifndef PCL_DATA_PORT
#define PCL_DATA_PORT 51180
#endif
#ifndef DEV_DATA_PORT
#define DEV_DATA_PORT 8866
#endif
Streamer::Streamer(QObject *parent) : QObject(parent)
{
m_receiver = std::make_unique<PacketReceiver>();
m_receiver->bind(DEV_DATA_PORT);
m_receiver->setReceiverCallback(std::bind(&Streamer::enqueueDev, this, std::placeholders::_1));
}
Streamer::~Streamer()
{
}
void Streamer::start()
{
m_receiver->start();
}
void Streamer::startRecording(const std::string &dev)
{
this->stopRecording();
this->m_writer = std::make_shared<PacketFileWriter>();
this->m_writer->start(dev);
}
void Streamer::stopRecording()
{
if (this->m_writer)
{
this->m_writer->stop();
this->m_writer.reset();
}
}
bool Streamer::isRecording()
{
return (this->m_writer && this->m_writer) ? true : false;
}
void Streamer::enqueuePcl(NetworkPacket *packet)
{
if(this->m_writer)
this->m_writer->enqueue(packet);
}
void Streamer::enqueueDev(NetworkPacket *packet)
{
if(this->m_writer)
this->m_writer->enqueue(packet);
}