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
bfdc22ff
Commit
bfdc22ff
authored
May 23, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maintain local connections explicitly.
parent
4699c338
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
21 deletions
+50
-21
client.go
client.go
+10
-21
conn.go
conn.go
+40
-0
No files found.
client.go
View file @
bfdc22ff
...
@@ -612,28 +612,12 @@ func delUpConn(c *client, id string) bool {
...
@@ -612,28 +612,12 @@ func delUpConn(c *client, id string) bool {
}
}
}
}
type
clientId
struct
{
local
:=
conn
.
getLocal
()
client
*
client
go
func
()
{
id
string
for
_
,
l
:=
range
local
{
}
l
.
Close
()
cids
:=
make
([]
clientId
,
0
)
clients
:=
c
.
group
.
getClients
(
c
)
for
_
,
cc
:=
range
clients
{
cc
.
mu
.
Lock
()
for
_
,
otherconn
:=
range
cc
.
down
{
if
otherconn
.
remote
==
conn
{
cids
=
append
(
cids
,
clientId
{
cc
,
otherconn
.
id
})
}
}
cc
.
mu
.
Unlock
()
}
go
func
(
cids
[]
clientId
)
{
for
_
,
cid
:=
range
cids
{
cid
.
client
.
action
(
delConnAction
{
cid
.
id
})
}
}
}(
cids
)
}()
conn
.
pc
.
Close
()
conn
.
pc
.
Close
()
delete
(
c
.
up
,
id
)
delete
(
c
.
up
,
id
)
...
@@ -691,17 +675,21 @@ func addDownConn(c *client, id string, remote *upConnection) (*downConnection, e
...
@@ -691,17 +675,21 @@ func addDownConn(c *client, id string, remote *upConnection) (*downConnection, e
}
}
conn
:=
&
downConnection
{
conn
:=
&
downConnection
{
id
:
id
,
id
:
id
,
client
:
c
,
pc
:
pc
,
pc
:
pc
,
remote
:
remote
,
remote
:
remote
,
}
}
c
.
mu
.
Lock
()
c
.
mu
.
Lock
()
defer
c
.
mu
.
Unlock
()
defer
c
.
mu
.
Unlock
()
if
c
.
down
[
id
]
!=
nil
||
(
c
.
up
!=
nil
&&
c
.
up
[
id
]
!=
nil
)
{
if
c
.
down
[
id
]
!=
nil
||
(
c
.
up
!=
nil
&&
c
.
up
[
id
]
!=
nil
)
{
conn
.
pc
.
Close
()
conn
.
pc
.
Close
()
return
nil
,
errors
.
New
(
"Adding duplicate connection"
)
return
nil
,
errors
.
New
(
"Adding duplicate connection"
)
}
}
c
.
down
[
id
]
=
conn
c
.
down
[
id
]
=
conn
remote
.
addLocal
(
conn
)
return
conn
,
nil
return
conn
,
nil
}
}
...
@@ -717,6 +705,7 @@ func delDownConn(c *client, id string) bool {
...
@@ -717,6 +705,7 @@ func delDownConn(c *client, id string) bool {
return
false
return
false
}
}
conn
.
remote
.
delLocal
(
conn
)
for
_
,
track
:=
range
conn
.
tracks
{
for
_
,
track
:=
range
conn
.
tracks
{
found
:=
track
.
remote
.
delLocal
(
track
)
found
:=
track
.
remote
.
delLocal
(
track
)
if
!
found
{
if
!
found
{
...
...
conn.go
View file @
bfdc22ff
...
@@ -100,12 +100,47 @@ type upConnection struct {
...
@@ -100,12 +100,47 @@ type upConnection struct {
tracks
[]
*
upTrack
tracks
[]
*
upTrack
labels
map
[
string
]
string
labels
map
[
string
]
string
iceCandidates
[]
*
webrtc
.
ICECandidateInit
iceCandidates
[]
*
webrtc
.
ICECandidateInit
mu
sync
.
Mutex
local
[]
*
downConnection
}
}
func
(
up
*
upConnection
)
getPC
()
*
webrtc
.
PeerConnection
{
func
(
up
*
upConnection
)
getPC
()
*
webrtc
.
PeerConnection
{
return
up
.
pc
return
up
.
pc
}
}
func
(
up
*
upConnection
)
addLocal
(
local
*
downConnection
)
{
up
.
mu
.
Lock
()
defer
up
.
mu
.
Unlock
()
for
_
,
t
:=
range
up
.
local
{
if
t
==
local
{
up
.
mu
.
Unlock
()
return
}
}
up
.
local
=
append
(
up
.
local
,
local
)
}
func
(
up
*
upConnection
)
delLocal
(
local
*
downConnection
)
bool
{
up
.
mu
.
Lock
()
defer
up
.
mu
.
Unlock
()
for
i
,
l
:=
range
up
.
local
{
if
l
==
local
{
up
.
local
=
append
(
up
.
local
[
:
i
],
up
.
local
[
i
+
1
:
]
...
)
return
true
}
}
return
false
}
func
(
up
*
upConnection
)
getLocal
()
[]
*
downConnection
{
up
.
mu
.
Lock
()
defer
up
.
mu
.
Unlock
()
local
:=
make
([]
*
downConnection
,
len
(
up
.
local
))
copy
(
local
,
up
.
local
)
return
local
}
func
(
up
*
upConnection
)
addICECandidate
(
candidate
*
webrtc
.
ICECandidateInit
)
error
{
func
(
up
*
upConnection
)
addICECandidate
(
candidate
*
webrtc
.
ICECandidateInit
)
error
{
if
up
.
pc
.
RemoteDescription
()
!=
nil
{
if
up
.
pc
.
RemoteDescription
()
!=
nil
{
return
up
.
pc
.
AddICECandidate
(
*
candidate
)
return
up
.
pc
.
AddICECandidate
(
*
candidate
)
...
@@ -224,12 +259,17 @@ func (down *downTrack) GetMaxBitrate(now uint64) uint64 {
...
@@ -224,12 +259,17 @@ func (down *downTrack) GetMaxBitrate(now uint64) uint64 {
type
downConnection
struct
{
type
downConnection
struct
{
id
string
id
string
client
*
client
pc
*
webrtc
.
PeerConnection
pc
*
webrtc
.
PeerConnection
remote
*
upConnection
remote
*
upConnection
tracks
[]
*
downTrack
tracks
[]
*
downTrack
iceCandidates
[]
*
webrtc
.
ICECandidateInit
iceCandidates
[]
*
webrtc
.
ICECandidateInit
}
}
func
(
down
*
downConnection
)
Close
()
error
{
return
down
.
client
.
action
(
delConnAction
{
down
.
id
})
}
func
(
down
*
downConnection
)
getPC
()
*
webrtc
.
PeerConnection
{
func
(
down
*
downConnection
)
getPC
()
*
webrtc
.
PeerConnection
{
return
down
.
pc
return
down
.
pc
}
}
...
...
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