Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
86b6c71c
Commit
86b6c71c
authored
May 07, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformat stats display, protect against division by zero.
parent
b1bb427f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
16 deletions
+27
-16
rtpconn/rtpstats.go
rtpconn/rtpstats.go
+5
-2
static/stats.js
static/stats.js
+18
-13
webserver/webserver.go
webserver/webserver.go
+4
-1
No files found.
rtpconn/rtpstats.go
View file @
86b6c71c
...
@@ -23,8 +23,11 @@ func (c *webClient) GetStats() *stats.Client {
...
@@ -23,8 +23,11 @@ func (c *webClient) GetStats() *stats.Client {
tracks
:=
up
.
getTracks
()
tracks
:=
up
.
getTracks
()
for
_
,
t
:=
range
tracks
{
for
_
,
t
:=
range
tracks
{
s
:=
t
.
cache
.
GetStats
(
false
)
s
:=
t
.
cache
.
GetStats
(
false
)
loss
:=
float64
(
s
.
Expected
-
s
.
Received
)
/
var
loss
float64
float64
(
s
.
Expected
)
if
s
.
Expected
>
0
{
loss
=
float64
(
s
.
Expected
-
s
.
Received
)
/
float64
(
s
.
Expected
)
}
jitter
:=
time
.
Duration
(
t
.
jitter
.
Jitter
())
*
jitter
:=
time
.
Duration
(
t
.
jitter
.
Jitter
())
*
(
time
.
Second
/
time
.
Duration
(
t
.
jitter
.
HZ
()))
(
time
.
Second
/
time
.
Duration
(
t
.
jitter
.
HZ
()))
rate
,
_
:=
t
.
rate
.
Estimate
()
rate
,
_
:=
t
.
rate
.
Estimate
()
...
...
static/stats.js
View file @
86b6c71c
...
@@ -56,11 +56,15 @@ function formatGroup(group) {
...
@@ -56,11 +56,15 @@ function formatGroup(group) {
tr2
.
appendChild
(
td3
);
tr2
.
appendChild
(
td3
);
table
.
appendChild
(
tr2
);
table
.
appendChild
(
tr2
);
if
(
client
.
up
)
if
(
client
.
up
)
for
(
let
j
=
0
;
j
<
client
.
up
.
length
;
j
++
)
for
(
let
j
=
0
;
j
<
client
.
up
.
length
;
j
++
)
{
table
.
appendChild
(
formatConn
(
'
↑
'
,
client
.
up
[
j
]));
let
rows
=
formatConn
(
'
↑
'
,
client
.
up
[
j
]);
rows
.
forEach
(
r
=>
table
.
appendChild
(
r
));
}
if
(
client
.
down
)
if
(
client
.
down
)
for
(
let
j
=
0
;
j
<
client
.
down
.
length
;
j
++
)
for
(
let
j
=
0
;
j
<
client
.
down
.
length
;
j
++
)
{
table
.
appendChild
(
formatConn
(
'
↓
'
,
client
.
down
[
j
]));
let
rows
=
formatConn
(
'
↓
'
,
client
.
down
[
j
]);
rows
.
forEach
(
r
=>
table
.
appendChild
(
r
));
}
}
}
td2
.
appendChild
(
table
);
td2
.
appendChild
(
table
);
tr
.
appendChild
(
td2
);
tr
.
appendChild
(
td2
);
...
@@ -76,24 +80,25 @@ function formatConn(direction, conn) {
...
@@ -76,24 +80,25 @@ function formatConn(direction, conn) {
td2
.
textContent
=
conn
.
id
;
td2
.
textContent
=
conn
.
id
;
tr
.
appendChild
(
td2
);
tr
.
appendChild
(
td2
);
let
td3
=
document
.
createElement
(
'
td
'
);
let
td3
=
document
.
createElement
(
'
td
'
);
if
(
conn
.
maxBitrate
)
td3
.
textContent
=
direction
;
td3
.
textContent
=
direction
+
'
'
+
conn
.
maxBitrate
;
else
td3
.
textContent
=
direction
;
tr
.
appendChild
(
td3
);
tr
.
appendChild
(
td3
);
let
td4
=
document
.
createElement
(
'
td
'
);
let
td4
=
document
.
createElement
(
'
td
'
);
if
(
conn
.
maxBitrate
)
td4
.
textContent
=
`
${
conn
.
maxBitrate
}
`
;
tr
.
appendChild
(
td4
);
let
rows
=
[
tr
];
if
(
conn
.
tracks
)
{
if
(
conn
.
tracks
)
{
let
table
=
document
.
createElement
(
'
table
'
);
for
(
let
i
=
0
;
i
<
conn
.
tracks
.
length
;
i
++
)
for
(
let
i
=
0
;
i
<
conn
.
tracks
.
length
;
i
++
)
table
.
appendChild
(
formatTrack
(
conn
.
tracks
[
i
]));
rows
.
push
(
formatTrack
(
conn
.
tracks
[
i
]));
td4
.
appendChild
(
table
);
}
}
tr
.
appendChild
(
td4
);
return
rows
;
return
tr
;
}
}
function
formatTrack
(
track
)
{
function
formatTrack
(
track
)
{
let
tr
=
document
.
createElement
(
'
tr
'
);
let
tr
=
document
.
createElement
(
'
tr
'
);
tr
.
appendChild
(
document
.
createElement
(
'
td
'
));
tr
.
appendChild
(
document
.
createElement
(
'
td
'
));
tr
.
appendChild
(
document
.
createElement
(
'
td
'
));
let
td
=
document
.
createElement
(
'
td
'
);
let
td
=
document
.
createElement
(
'
td
'
);
if
(
track
.
maxBitrate
)
if
(
track
.
maxBitrate
)
td
.
textContent
=
`
${
track
.
bitrate
||
0
}
/
${
track
.
maxBitrate
}
`
;
td
.
textContent
=
`
${
track
.
bitrate
||
0
}
/
${
track
.
maxBitrate
}
`
;
...
...
webserver/webserver.go
View file @
86b6c71c
...
@@ -370,7 +370,10 @@ func statsHandler(w http.ResponseWriter, r *http.Request, dataDir string) {
...
@@ -370,7 +370,10 @@ func statsHandler(w http.ResponseWriter, r *http.Request, dataDir string) {
ss
:=
stats
.
GetGroups
()
ss
:=
stats
.
GetGroups
()
e
:=
json
.
NewEncoder
(
w
)
e
:=
json
.
NewEncoder
(
w
)
e
.
Encode
(
ss
)
err
=
e
.
Encode
(
ss
)
if
err
!=
nil
{
log
.
Printf
(
"stats.json: %v"
,
err
)
}
return
return
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment