Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libmueb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
KSZK
Schönherz Mátrix
libmueb
Commits
aea1cc42
Commit
aea1cc42
authored
4 years ago
by
bodzsoaa
Browse files
Options
Downloads
Patches
Plain Diff
Use Q_D macro
parent
f09c3c69
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/muebreceiver.cc
+15
-15
15 additions, 15 deletions
src/muebreceiver.cc
src/muebtransmitter.cc
+14
-6
14 additions, 6 deletions
src/muebtransmitter.cc
with
29 additions
and
21 deletions
src/muebreceiver.cc
+
15
−
15
View file @
aea1cc42
...
...
@@ -21,38 +21,38 @@ inline void datagram_uncompress_error() {
}
void
MuebReceiver
::
ReadPendingDatagrams
()
{
while
(
d_ptr_
->
socket
.
hasPendingDatagrams
())
{
if
(
d_ptr_
->
socket
.
pendingDatagramSize
()
==
d_ptr_
->
configuration
.
packet_size
())
{
QNetworkDatagram
datagram
=
d_ptr_
->
socket
.
receiveDatagram
();
Q_D
(
MuebReceiver
);
while
(
d
->
socket
.
hasPendingDatagrams
())
{
if
(
d
->
socket
.
pendingDatagramSize
()
==
d
->
configuration
.
packet_size
())
{
QNetworkDatagram
datagram
=
d
->
socket
.
receiveDatagram
();
QByteArray
data
=
datagram
.
data
();
// Process datagram
// Packet header check
// Check protocol
if
(
data
[
0
]
!=
d
_ptr_
->
configuration
.
protocol_type
())
{
if
(
data
[
0
]
!=
d
->
configuration
.
protocol_type
())
{
datagram_uncompress_error
();
return
;
}
auto
packet_number
=
data
[
1
];
if
(
packet_number
>=
d
_ptr_
->
configuration
.
max_packet_number
()
||
if
(
packet_number
>=
d
->
configuration
.
max_packet_number
()
||
packet_number
<
0
)
{
datagram_uncompress_error
();
return
;
}
data
.
remove
(
0
,
d_ptr_
->
configuration
.
packet_header_size
());
auto
frame_begin
=
d_ptr_
->
frame
.
bits
()
+
packet_number
*
d_ptr_
->
configuration
.
frame_fragment_size
();
data
.
remove
(
0
,
d
->
configuration
.
packet_header_size
());
auto
frame_begin
=
d
->
frame
.
bits
()
+
packet_number
*
d
->
configuration
.
frame_fragment_size
();
// Uncompress 1 byte into 2 color components
if
(
d
_ptr_
->
configuration
.
color_depth
()
<
5
)
{
if
(
d
->
configuration
.
color_depth
()
<
5
)
{
for
(
auto
i
:
data
)
{
*
frame_begin
=
i
&
0xf0
;
frame_begin
++
;
*
frame_begin
=
(
i
&
0x0f
)
<<
d
_ptr_
->
configuration
.
factor
();
*
frame_begin
=
(
i
&
0x0f
)
<<
d
->
configuration
.
factor
();
frame_begin
++
;
}
// No compression
...
...
@@ -64,14 +64,14 @@ void MuebReceiver::ReadPendingDatagrams() {
}
}
emit
(
FrameChanged
(
d
_ptr_
->
frame
));
emit
(
FrameChanged
(
d
->
frame
));
}
// Drop invalid packet
else
{
qWarning
()
<<
"[MuebReceiver] Packet has invalid size!"
<<
d
_ptr_
->
socket
.
pendingDatagramSize
()
<<
"bytes"
;
<<
d
->
socket
.
pendingDatagramSize
()
<<
"bytes"
;
d
_ptr_
->
socket
.
receiveDatagram
(
0
);
d
->
socket
.
receiveDatagram
(
0
);
}
}
}
This diff is collapsed.
Click to expand it.
src/muebtransmitter.cc
+
14
−
6
View file @
aea1cc42
...
...
@@ -8,15 +8,17 @@ MuebTransmitter::MuebTransmitter(QObject* parent)
MuebTransmitter
::~
MuebTransmitter
()
{
delete
d_ptr_
;
}
void
MuebTransmitter
::
SendFrame
(
libmueb
::
Frame
frame
)
{
Q_D
(
MuebTransmitter
);
if
(
frame
.
isNull
()
||
frame
.
format
()
==
QImage
::
Format_Invalid
||
frame
.
width
()
!=
d
_ptr_
->
configuration_
.
width
()
||
frame
.
height
()
!=
d
_ptr_
->
configuration_
.
height
())
{
frame
.
width
()
!=
d
->
configuration_
.
width
()
||
frame
.
height
()
!=
d
->
configuration_
.
height
())
{
qWarning
()
<<
"[MuebTransmitter] Frame is invalid"
;
return
;
}
frame
.
convertTo
(
QImage
::
Format_RGB888
);
d
_ptr_
->
SendFrame
(
frame
);
d
->
SendFrame
(
frame
);
}
MuebTransmitter
&
MuebTransmitter
::
Instance
()
{
...
...
@@ -26,13 +28,19 @@ MuebTransmitter& MuebTransmitter::Instance() {
}
std
::
int32_t
MuebTransmitter
::
width
()
const
{
return
d_ptr_
->
configuration_
.
width
();
Q_D
(
const
MuebTransmitter
);
return
d
->
configuration_
.
width
();
}
std
::
int32_t
MuebTransmitter
::
height
()
const
{
return
d_ptr_
->
configuration_
.
height
();
Q_D
(
const
MuebTransmitter
);
return
d
->
configuration_
.
height
();
}
libmueb
::
Frame
MuebTransmitter
::
frame
()
const
{
return
d_ptr_
->
configuration_
.
frame
();
Q_D
(
const
MuebTransmitter
);
return
d
->
configuration_
.
frame
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment