forked from mavlink/qgroundcontrol
-
Notifications
You must be signed in to change notification settings - Fork 3
/
TDRVideoReceiver.cpp
58 lines (50 loc) · 1.73 KB
/
TDRVideoReceiver.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
//
// TDRVideoReceiver.cpp
// QGroundControl
//
// Created by Lauren on 12/21/18.
//
#include "TDRVideoReceiver.h"
#define TDR_VIDEO_UDP_PORT 5601
//QGC_LOGGING_CATEGORY(TaisyncVideoReceiverLog, "TaisyncVideoReceiverLog")
//-----------------------------------------------------------------------------
TDRVideoReceiver::TDRVideoReceiver(QObject* parent)
: TaisyncHandler(parent)
{
}
//-----------------------------------------------------------------------------
void
TDRVideoReceiver::close()
{
TaisyncHandler::close();
//qCDebug(TaisyncVideoReceiverLog) << "Close Taisync Video Receiver";
if(_udpVideoSocket) {
_udpVideoSocket->close();
_udpVideoSocket->deleteLater();
_udpVideoSocket = nullptr;
}
}
//-----------------------------------------------------------------------------
bool
TDRVideoReceiver::start()
{
//qCDebug(TaisyncVideoReceiverLog) << "Start Taisync Video Receiver";
_udpVideoSocket = new QUdpSocket(this);
return _start(TDR_VIDEO_UDP_PORT);
}
//-----------------------------------------------------------------------------
void
TDRVideoReceiver::_readBytes()
{
QByteArray bytesIn = _tcpSocket->read(_tcpSocket->bytesAvailable());
QHostAddress hostAddress = QHostAddress(QString("127.0.0.1"));
_udpVideoSocket->writeDatagram(bytesIn, hostAddress, TDR_VIDEO_UDP_PORT);
//_udpVideoSocket->writeDatagram(bytesIn, QHostAddress::LocalHost, TDR_VIDEO_UDP_PORT);
}
//-----------------------------------------------------------------------------
//void
//TDRVideoReceiver::_writeBytes(QByteArray bytesIn)
//{
// //QByteArray bytesIn = _tcpSocket->read(_tcpSocket->bytesAvailable());
// _udpVideoSocket->writeDatagram(bytesIn, QHostAddress::LocalHost, TDR_VIDEO_UDP_PORT);
//}