Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
438a9207
Commit
438a9207
authored
4 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Code tidy and latency fix
parent
0b362656
No related branches found
No related tags found
No related merge requests found
Pipeline
#28675
failed
4 years ago
Stage: all
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
applications/vision/src/main.cpp
+44
-50
44 additions, 50 deletions
applications/vision/src/main.cpp
components/streams/src/netstream.cpp
+5
-2
5 additions, 2 deletions
components/streams/src/netstream.cpp
components/streams/src/sender.cpp
+9
-0
9 additions, 0 deletions
components/streams/src/sender.cpp
with
58 additions
and
52 deletions
applications/vision/src/main.cpp
+
44
−
50
View file @
438a9207
...
...
@@ -165,18 +165,14 @@ static void run(ftl::Configurable *root) {
// Send channels on flush
auto
flushhandle
=
pool
.
onFlushSet
([
sender
,
&
encodable
](
ftl
::
data
::
FrameSet
&
fs
,
ftl
::
codecs
::
Channel
c
)
{
// Always send data channels
if
((
int
)
c
>=
32
)
sender
->
post
(
fs
,
c
);
else
{
// Only encode some of the video channels
if
(
encodable
.
count
(
c
))
{
sender
->
post
(
fs
,
c
);
}
else
{
//switch (c) {
//case Channel::Colour :
//case Channel::Colour2 :
//case Channel::Depth :
sender
->
post
(
fs
,
c
,
true
);
//break;
//default : sender->fakePost(fs, c);
//}
sender
->
post
(
fs
,
c
,
true
);
}
}
return
true
;
...
...
@@ -198,15 +194,18 @@ static void run(ftl::Configurable *root) {
busy
.
clear
();
auto
h
=
creator
->
onFrameSet
([
sender
,
outstream
,
&
stats_count
,
&
latency
,
&
frames
,
&
stats_time
,
pipeline
,
&
busy
,
&
encodable
,
&
previous_encodable
](
const
ftl
::
data
::
FrameSetPtr
&
fs
)
{
encodable
.
clear
();
// Decide what to encode here
.
// Decide what to encode here
, based upon what remote users select
const
auto
sel
=
outstream
->
selectedNoExcept
(
fs
->
frameset
());
encodable
.
clear
();
encodable
.
insert
(
sel
.
begin
(),
sel
.
end
());
// Only allow the two encoders to exist
if
(
encodable
.
size
()
>
2
)
{
// Only allow the two encoders to exist, remove the rest
int
max_encodeable
=
sender
->
value
(
"max_encodeable"
,
2
);
if
(
encodable
.
size
()
>
max_encodeable
)
{
auto
enciter
=
encodable
.
begin
();
std
::
advance
(
enciter
,
2
);
std
::
advance
(
enciter
,
max_encodeable
);
encodable
.
erase
(
enciter
,
encodable
.
end
());
}
...
...
@@ -214,45 +213,40 @@ static void run(ftl::Configurable *root) {
if
(
encodable
!=
previous_encodable
)
sender
->
resetEncoders
(
fs
->
frameset
());
previous_encodable
=
encodable
;
// Do all processing in another thread... only if encoding of depth
//if (encodable.find(Channel::Depth) != encodable.end()) {
ftl
::
pool
.
push
([
sender
,
&
stats_count
,
&
latency
,
&
frames
,
&
stats_time
,
pipeline
,
&
busy
,
fs
](
int
id
)
mutable
{
// Do pipeline here... if not still busy doing it
if
(
busy
.
test_and_set
())
{
LOG
(
WARNING
)
<<
"Depth pipeline drop: "
<<
fs
->
timestamp
();
fs
->
firstFrame
().
message
(
ftl
::
data
::
Message
::
Warning_PIPELINE_DROP
,
"Depth pipeline drop"
);
return
;
}
pipeline
->
apply
(
*
fs
,
*
fs
);
busy
.
clear
();
++
frames
;
latency
+=
float
(
ftl
::
timer
::
get_time
()
-
fs
->
timestamp
());
// Destruct frameset as soon as possible to send the data...
if
(
fs
->
hasAnyChanged
(
Channel
::
Depth
))
fs
->
flush
(
Channel
::
Depth
);
const_cast
<
ftl
::
data
::
FrameSetPtr
&>
(
fs
).
reset
();
if
(
!
quiet
&&
--
stats_count
<=
0
)
{
latency
/=
float
(
frames
);
int64_t
nowtime
=
ftl
::
timer
::
get_time
();
stats_time
=
nowtime
-
stats_time
;
float
fps
=
float
(
frames
)
/
(
float
(
stats_time
)
/
1000.0
f
);
LOG
(
INFO
)
<<
"Frame rate: "
<<
fps
<<
", Latency: "
<<
latency
;
stats_count
=
20
;
frames
=
0
;
latency
=
0.0
f
;
stats_time
=
nowtime
;
}
});
//} else {
//LOG(INFO) << "NOT DOING DEPTH";
// sender->forceAvailable(*fs, Channel::Depth);
// busy = false;
//}
// Lock colour right now to encode in parallel
// Do all processing in another thread...
ftl
::
pool
.
push
([
sender
,
&
stats_count
,
&
latency
,
&
frames
,
&
stats_time
,
pipeline
,
&
busy
,
fs
](
int
id
)
mutable
{
// Do pipeline here... if not still busy doing it
if
(
busy
.
test_and_set
())
{
LOG
(
WARNING
)
<<
"Depth pipeline drop: "
<<
fs
->
timestamp
();
fs
->
firstFrame
().
message
(
ftl
::
data
::
Message
::
Warning_PIPELINE_DROP
,
"Depth pipeline drop"
);
return
;
}
pipeline
->
apply
(
*
fs
,
*
fs
);
busy
.
clear
();
++
frames
;
latency
+=
float
(
ftl
::
timer
::
get_time
()
-
fs
->
timestamp
());
// Destruct frameset as soon as possible to send the data...
if
(
fs
->
hasAnyChanged
(
Channel
::
Depth
))
fs
->
flush
(
Channel
::
Depth
);
const_cast
<
ftl
::
data
::
FrameSetPtr
&>
(
fs
).
reset
();
if
(
!
quiet
&&
--
stats_count
<=
0
)
{
latency
/=
float
(
frames
);
int64_t
nowtime
=
ftl
::
timer
::
get_time
();
stats_time
=
nowtime
-
stats_time
;
float
fps
=
float
(
frames
)
/
(
float
(
stats_time
)
/
1000.0
f
);
LOG
(
INFO
)
<<
"Frame rate: "
<<
fps
<<
", Latency: "
<<
latency
;
stats_count
=
20
;
frames
=
0
;
latency
=
0.0
f
;
stats_time
=
nowtime
;
}
});
// Lock colour right now to encode in parallel, same for audio
ftl
::
pool
.
push
([
fs
](
int
id
){
fs
->
flush
(
ftl
::
codecs
::
Channel
::
Colour
);
});
if
(
fs
->
hasAnyChanged
(
Channel
::
Audio
))
{
ftl
::
pool
.
push
([
fs
](
int
id
){
fs
->
flush
(
ftl
::
codecs
::
Channel
::
Audio
);
});
}
...
...
This diff is collapsed.
Click to expand it.
components/streams/src/netstream.cpp
+
5
−
2
View file @
438a9207
...
...
@@ -67,6 +67,10 @@ Net::Net(nlohmann::json &config, ftl::net::Universe *net) : Stream(config), acti
Net
::~
Net
()
{
end
();
// FIXME: Wait to ensure no net callbacks are active.
// Do something better than this
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
10
));
}
bool
Net
::
post
(
const
ftl
::
codecs
::
StreamPacket
&
spkt
,
const
ftl
::
codecs
::
Packet
&
pkt
)
{
...
...
@@ -173,7 +177,6 @@ bool Net::begin() {
spkt
.
localTimestamp
=
now
-
int64_t
(
ttimeoff
);
spkt
.
hint_capability
=
0
;
spkt
.
hint_source_total
=
0
;
//LOG(INFO) << "LATENCY: " << ftl::timer::get_time() - spkt.localTimestamp() << " : " << spkt.timestamp << " - " << clock_adjust_;
spkt
.
version
=
4
;
// Manage recuring requests
...
...
@@ -457,7 +460,7 @@ bool Net::end() {
}
active_
=
false
;
net_
->
unbind
(
uri_
);
net_
->
unbind
(
base_
uri_
);
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
components/streams/src/sender.cpp
+
9
−
0
View file @
438a9207
...
...
@@ -212,6 +212,7 @@ void Sender::post(ftl::data::FrameSet &fs, ftl::codecs::Channel c, bool noencode
StreamPacket
spkt
;
spkt
.
version
=
5
;
spkt
.
timestamp
=
fs
.
timestamp
();
spkt
.
localTimestamp
=
fs
.
localTimestamp
;
spkt
.
streamID
=
fs
.
frameset
();
//fs.id;
spkt
.
frame_number
=
i
;
spkt
.
channel
=
c
;
...
...
@@ -235,6 +236,7 @@ void Sender::post(ftl::data::FrameSet &fs, ftl::codecs::Channel c, bool noencode
StreamPacket
spkt
;
spkt
.
version
=
5
;
spkt
.
timestamp
=
fs
.
timestamp
();
spkt
.
localTimestamp
=
fs
.
localTimestamp
;
spkt
.
streamID
=
fs
.
frameset
();
spkt
.
frame_number
=
255
;
spkt
.
channel
=
c
;
...
...
@@ -257,6 +259,7 @@ void Sender::forceAvailable(ftl::data::FrameSet &fs, ftl::codecs::Channel c) {
StreamPacket
spkt
;
spkt
.
version
=
5
;
spkt
.
timestamp
=
fs
.
timestamp
();
spkt
.
localTimestamp
=
fs
.
localTimestamp
;
spkt
.
streamID
=
fs
.
frameset
();
spkt
.
frame_number
=
255
;
spkt
.
channel
=
c
;
...
...
@@ -305,6 +308,7 @@ void Sender::post(ftl::data::Frame &frame, ftl::codecs::Channel c) {
StreamPacket
spkt
;
spkt
.
version
=
5
;
spkt
.
timestamp
=
frame
.
timestamp
();
spkt
.
localTimestamp
=
spkt
.
timestamp
;
spkt
.
streamID
=
frame
.
frameset
();
//fs.id;
spkt
.
frame_number
=
frame
.
source
();
spkt
.
channel
=
c
;
...
...
@@ -335,6 +339,7 @@ void Sender::post(ftl::data::Frame &frame, ftl::codecs::Channel c) {
StreamPacket
spkt
;
spkt
.
version
=
5
;
spkt
.
timestamp
=
frame
.
timestamp
();
spkt
.
localTimestamp
=
spkt
.
timestamp
;
spkt
.
streamID
=
frame
.
frameset
();
spkt
.
frame_number
=
255
;
spkt
.
channel
=
c
;
...
...
@@ -419,6 +424,7 @@ void Sender::_encodeVideoChannel(ftl::data::FrameSet &fs, Channel c, bool reset,
StreamPacket
spkt
;
spkt
.
version
=
5
;
spkt
.
timestamp
=
fs
.
timestamp
();
spkt
.
localTimestamp
=
fs
.
localTimestamp
;
spkt
.
streamID
=
fs
.
frameset
();
spkt
.
frame_number
=
offset
;
spkt
.
channel
=
c
;
...
...
@@ -513,6 +519,7 @@ void Sender::_encodeAudioChannel(ftl::data::FrameSet &fs, Channel c, bool reset,
StreamPacket
spkt
;
spkt
.
version
=
5
;
spkt
.
timestamp
=
fs
.
timestamp
();
spkt
.
localTimestamp
=
fs
.
localTimestamp
;
spkt
.
streamID
=
fs
.
frameset
();
spkt
.
frame_number
=
i
;
spkt
.
channel
=
c
;
...
...
@@ -552,6 +559,7 @@ void Sender::_encodeDataChannel(ftl::data::FrameSet &fs, Channel c, bool reset,
StreamPacket
spkt
;
spkt
.
version
=
5
;
spkt
.
timestamp
=
fs
.
timestamp
();
spkt
.
localTimestamp
=
fs
.
localTimestamp
;
spkt
.
streamID
=
fs
.
frameset
();
spkt
.
frame_number
=
i
++
;
spkt
.
channel
=
c
;
...
...
@@ -578,6 +586,7 @@ void Sender::_encodeDataChannel(ftl::data::Frame &f, Channel c, bool reset) {
StreamPacket
spkt
;
spkt
.
version
=
5
;
spkt
.
timestamp
=
f
.
timestamp
();
spkt
.
localTimestamp
=
spkt
.
timestamp
;
spkt
.
streamID
=
f
.
frameset
();
spkt
.
frame_number
=
f
.
source
();
spkt
.
channel
=
c
;
...
...
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