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
06f2ecec
Commit
06f2ecec
authored
Aug 22, 2021
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the list of public groups when expiring.
Thanks to Jeroen van Veen for suggesting the feature.
parent
f837c59d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
33 deletions
+38
-33
galene.go
galene.go
+3
-2
group/group.go
group/group.go
+35
-31
No files found.
galene.go
View file @
06f2ecec
...
@@ -114,7 +114,8 @@ func main() {
...
@@ -114,7 +114,8 @@ func main() {
ice
.
ICEFilename
=
filepath
.
Join
(
dataDir
,
"ice-servers.json"
)
ice
.
ICEFilename
=
filepath
.
Join
(
dataDir
,
"ice-servers.json"
)
go
group
.
ReadPublicGroups
()
// make sure the list of public groups is updated early
go
group
.
Update
()
// causes the built-in server to start if required
// causes the built-in server to start if required
ice
.
Update
()
ice
.
Update
()
...
@@ -143,7 +144,7 @@ func main() {
...
@@ -143,7 +144,7 @@ func main() {
for
{
for
{
select
{
select
{
case
<-
ticker
.
C
:
case
<-
ticker
.
C
:
go
group
.
Expir
e
()
go
group
.
Updat
e
()
case
<-
slowTicker
.
C
:
case
<-
slowTicker
.
C
:
go
relayTest
()
go
relayTest
()
case
<-
terminate
:
case
<-
terminate
:
...
...
group/group.go
View file @
06f2ecec
...
@@ -129,6 +129,15 @@ func (g *Group) DisplayName() string {
...
@@ -129,6 +129,15 @@ func (g *Group) DisplayName() string {
return
g
.
description
.
DisplayName
return
g
.
description
.
DisplayName
}
}
func
(
g
*
Group
)
EmptyTime
()
time
.
Duration
{
g
.
mu
.
Lock
()
defer
g
.
mu
.
Unlock
()
if
len
(
g
.
clients
)
>
0
{
return
0
}
return
time
.
Since
(
g
.
timestamp
)
}
var
groups
struct
{
var
groups
struct
{
mu
sync
.
Mutex
mu
sync
.
Mutex
groups
map
[
string
]
*
Group
groups
map
[
string
]
*
Group
...
@@ -162,7 +171,7 @@ func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, erro
...
@@ -162,7 +171,7 @@ func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, erro
return
96
,
nil
return
96
,
nil
case
"video/vp9"
:
case
"video/vp9"
:
profile
:=
fmtpValue
(
codec
.
SDPFmtpLine
,
"profile-id"
)
profile
:=
fmtpValue
(
codec
.
SDPFmtpLine
,
"profile-id"
)
switch
(
profile
)
{
switch
profile
{
case
"0"
:
case
"0"
:
return
98
,
nil
return
98
,
nil
case
"2"
:
case
"2"
:
...
@@ -177,7 +186,7 @@ func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, erro
...
@@ -177,7 +186,7 @@ func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, erro
if
len
(
profile
)
<
4
{
if
len
(
profile
)
<
4
{
return
0
,
errors
.
New
(
"malforned H.264 profile"
)
return
0
,
errors
.
New
(
"malforned H.264 profile"
)
}
}
switch
(
strings
.
ToLower
(
profile
[
:
4
])
)
{
switch
strings
.
ToLower
(
profile
[
:
4
]
)
{
case
"4200"
:
case
"4200"
:
return
102
,
nil
return
102
,
nil
case
"42e0"
:
case
"42e0"
:
...
@@ -499,34 +508,6 @@ func deleteUnlocked(g *Group) bool {
...
@@ -499,34 +508,6 @@ func deleteUnlocked(g *Group) bool {
return
true
return
true
}
}
func
Expire
()
{
names
:=
GetNames
()
now
:=
time
.
Now
()
for
_
,
name
:=
range
names
{
g
:=
Get
(
name
)
if
g
==
nil
{
continue
}
old
:=
false
g
.
mu
.
Lock
()
empty
:=
len
(
g
.
clients
)
==
0
if
empty
&&
!
g
.
description
.
Public
{
age
:=
now
.
Sub
(
g
.
timestamp
)
old
=
age
>
maxHistoryAge
(
g
.
description
)
}
// We cannot take groups.mu at this point without a deadlock.
g
.
mu
.
Unlock
()
if
empty
&&
old
{
// Delete will check if the group is still empty
Delete
(
name
)
}
}
}
func
AddClient
(
group
string
,
c
Client
)
(
*
Group
,
error
)
{
func
AddClient
(
group
string
,
c
Client
)
(
*
Group
,
error
)
{
g
,
err
:=
Add
(
group
,
nil
)
g
,
err
:=
Add
(
group
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -1029,7 +1010,30 @@ func GetPublic() []Public {
...
@@ -1029,7 +1010,30 @@ func GetPublic() []Public {
return
gs
return
gs
}
}
func
ReadPublicGroups
()
{
// Update checks that all in-memory groups are up-to-date and updates the
// list of public groups. It also removes from memory any non-public
// groups that haven't been accessed in maxHistoryAge.
func
Update
()
{
names
:=
GetNames
()
for
_
,
name
:=
range
names
{
g
:=
Get
(
name
)
if
g
==
nil
{
continue
}
deleted
:=
false
historyAge
:=
maxHistoryAge
(
g
.
description
)
if
!
g
.
description
.
Public
&&
g
.
EmptyTime
()
>
historyAge
{
// Delete checks if the group is still empty
deleted
=
Delete
(
name
)
}
if
!
deleted
&&
descriptionChanged
(
name
,
nil
)
{
Add
(
name
,
nil
)
}
}
err
:=
filepath
.
Walk
(
err
:=
filepath
.
Walk
(
Directory
,
Directory
,
func
(
path
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
func
(
path
string
,
fi
os
.
FileInfo
,
err
error
)
error
{
...
...
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