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
a2cf8966
Commit
a2cf8966
authored
4 years ago
by
bodzsoaa
Browse files
Options
Downloads
Patches
Plain Diff
Move MuebTransmitterPrivate to private header file
parent
9ea9ea7b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/CMakeLists.txt
+1
-1
1 addition, 1 deletion
src/CMakeLists.txt
src/muebtransmitter.cc
+1
-91
1 addition, 91 deletions
src/muebtransmitter.cc
src/muebtransmitter_p.h
+97
-0
97 additions, 0 deletions
src/muebtransmitter_p.h
with
99 additions
and
92 deletions
src/CMakeLists.txt
+
1
−
1
View file @
a2cf8966
...
...
@@ -2,7 +2,7 @@ add_library(
muebtransmitter SHARED
${
CMAKE_SOURCE_DIR
}
/include/libmueb/libmueb_global.h
${
CMAKE_SOURCE_DIR
}
/include/libmueb/muebtransmitter.h configuration.h
muebtransmitter.cc configuration.cc
)
muebtransmitter_p.h
muebtransmitter.cc configuration.cc
)
target_include_directories
(
muebtransmitter PUBLIC ../include/
${
PROJECT_NAME
}
)
target_link_libraries
(
muebtransmitter
...
...
This diff is collapsed.
Click to expand it.
src/muebtransmitter.cc
+
1
−
91
View file @
a2cf8966
#include
"muebtransmitter.h"
#include
<QByteArray>
#include
<QDebug>
#include
<QNetworkDatagram>
#include
<QUdpSocket>
#include
<QtConcurrent>
#include
"configuration.h"
class
MuebTransmitterPrivate
{
Q_DECLARE_PUBLIC
(
MuebTransmitter
)
Q_DISABLE_COPY
(
MuebTransmitterPrivate
)
public:
explicit
MuebTransmitterPrivate
(
MuebTransmitter
*
q
)
:
datagram_
(
QByteArray
(),
configuration_
.
target_address
(),
configuration_
.
broadcast_animation_port
()),
q_ptr
(
q
)
{
qInfo
().
noquote
()
<<
"[MuebTransmitter] UDP Socket will send frame to"
<<
QString
(
"%1:%2"
)
.
arg
(
configuration_
.
target_address
().
toString
())
.
arg
(
configuration_
.
broadcast_animation_port
());
}
void
SendFrame
(
libmueb
::
Frame
frame
)
{
std
::
uint8_t
packet_number
{
0
};
QByteArray
reduced_compressed_frame
;
// Frame color reduction and compression
if
(
configuration_
.
color_depth
()
<
5
)
{
reduced_compressed_frame
=
QtConcurrent
::
blockingMappedReduced
<
QByteArray
>
(
frame
.
constBits
(),
frame
.
constBits
()
+
frame
.
sizeInBytes
(),
/* Reference:
* http://threadlocalmutex.com/?p=48
* http://threadlocalmutex.com/?page_id=60
*/
[
this
](
const
uchar
&
color
)
->
uchar
{
if
(
configuration_
.
color_depth
()
==
3
)
{
return
(
color
*
225
+
4096
)
>>
13
;
}
else
if
(
configuration_
.
color_depth
()
==
4
)
{
return
(
color
*
15
+
135
)
>>
8
;
}
return
color
;
},
[
this
](
QByteArray
&
compressed_colors
,
const
uchar
&
color
)
{
static
bool
msb
{
true
};
// Compress 2 color components into 1 byte
if
(
msb
)
{
compressed_colors
.
append
(
color
<<
configuration_
.
factor
());
}
else
{
compressed_colors
.
back
()
=
compressed_colors
.
back
()
|
color
;
}
msb
=
!
msb
;
},
QtConcurrent
::
OrderedReduce
|
QtConcurrent
::
SequentialReduce
);
}
// No compression
else
{
reduced_compressed_frame
.
setRawData
(
reinterpret_cast
<
const
char
*>
(
frame
.
bits
()),
frame
.
sizeInBytes
());
}
if
(
configuration_
.
max_packet_number
()
==
1
)
{
reduced_compressed_frame
.
insert
(
0
,
configuration_
.
protocol_type
())
.
insert
(
1
,
packet_number
);
datagram_
.
setData
(
reduced_compressed_frame
);
}
else
{
for
(
std
::
uint8_t
i
=
0
;
i
<
configuration_
.
max_packet_number
();
++
i
)
{
QByteArray
data
;
data
.
append
(
configuration_
.
protocol_type
())
.
append
(
packet_number
++
)
.
append
(
reduced_compressed_frame
.
sliced
(
i
*
configuration_
.
frame_fragment_size
(),
configuration_
.
frame_fragment_size
()));
datagram_
.
setData
(
data
);
}
}
socket_
.
writeDatagram
(
datagram_
);
}
Configuration
configuration_
;
QUdpSocket
socket_
;
QNetworkDatagram
datagram_
;
MuebTransmitter
*
q_ptr
;
};
#include
"muebtransmitter_p.h"
MuebTransmitter
::
MuebTransmitter
(
QObject
*
parent
)
:
QObject
(
parent
),
d_ptr_
(
new
MuebTransmitterPrivate
(
this
))
{}
...
...
This diff is collapsed.
Click to expand it.
src/muebtransmitter_p.h
0 → 100644
+
97
−
0
View file @
a2cf8966
#ifndef LIBMUEB_MUEBTRANSMITTER_P_H_
#define LIBMUEB_MUEBTRANSMITTER_P_H_
#include
<QByteArray>
#include
<QDebug>
#include
<QNetworkDatagram>
#include
<QUdpSocket>
#include
<QtConcurrent>
#include
"configuration.h"
#include
"muebtransmitter.h"
class
MuebTransmitterPrivate
{
Q_DECLARE_PUBLIC
(
MuebTransmitter
)
Q_DISABLE_COPY
(
MuebTransmitterPrivate
)
public:
explicit
MuebTransmitterPrivate
(
MuebTransmitter
*
q
)
:
datagram_
(
QByteArray
(),
configuration_
.
target_address
(),
configuration_
.
broadcast_animation_port
()),
q_ptr
(
q
)
{
qInfo
().
noquote
()
<<
"[MuebTransmitter] UDP Socket will send frame to"
<<
QString
(
"%1:%2"
)
.
arg
(
configuration_
.
target_address
().
toString
())
.
arg
(
configuration_
.
broadcast_animation_port
());
}
void
SendFrame
(
libmueb
::
Frame
frame
)
{
std
::
uint8_t
packet_number
{
0
};
QByteArray
reduced_compressed_frame
;
// Frame color reduction and compression
if
(
configuration_
.
color_depth
()
<
5
)
{
reduced_compressed_frame
=
QtConcurrent
::
blockingMappedReduced
<
QByteArray
>
(
frame
.
constBits
(),
frame
.
constBits
()
+
frame
.
sizeInBytes
(),
/* Reference:
* http://threadlocalmutex.com/?p=48
* http://threadlocalmutex.com/?page_id=60
*/
[
this
](
const
uchar
&
color
)
->
uchar
{
if
(
configuration_
.
color_depth
()
==
3
)
{
return
(
color
*
225
+
4096
)
>>
13
;
}
else
if
(
configuration_
.
color_depth
()
==
4
)
{
return
(
color
*
15
+
135
)
>>
8
;
}
return
color
;
},
[
this
](
QByteArray
&
compressed_colors
,
const
uchar
&
color
)
{
static
bool
msb
{
true
};
// Compress 2 color components into 1 byte
if
(
msb
)
{
compressed_colors
.
append
(
color
<<
configuration_
.
factor
());
}
else
{
compressed_colors
.
back
()
=
compressed_colors
.
back
()
|
color
;
}
msb
=
!
msb
;
},
QtConcurrent
::
OrderedReduce
|
QtConcurrent
::
SequentialReduce
);
}
// No compression
else
{
reduced_compressed_frame
.
setRawData
(
reinterpret_cast
<
const
char
*>
(
frame
.
bits
()),
frame
.
sizeInBytes
());
}
if
(
configuration_
.
max_packet_number
()
==
1
)
{
reduced_compressed_frame
.
insert
(
0
,
configuration_
.
protocol_type
())
.
insert
(
1
,
packet_number
);
datagram_
.
setData
(
reduced_compressed_frame
);
}
else
{
for
(
std
::
uint8_t
i
=
0
;
i
<
configuration_
.
max_packet_number
();
++
i
)
{
QByteArray
data
;
data
.
append
(
configuration_
.
protocol_type
())
.
append
(
packet_number
++
)
.
append
(
reduced_compressed_frame
.
sliced
(
i
*
configuration_
.
frame_fragment_size
(),
configuration_
.
frame_fragment_size
()));
datagram_
.
setData
(
data
);
}
}
socket_
.
writeDatagram
(
datagram_
);
}
Configuration
configuration_
;
QUdpSocket
socket_
;
QNetworkDatagram
datagram_
;
MuebTransmitter
*
q_ptr
;
};
#endif // LIBMUEB_MUEBTRANSMITTER_P_H_
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