Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sfu
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
Alain Takoudjou
sfu
Commits
b265aacd
Commit
b265aacd
authored
May 17, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Push complete connections rather than individual tracks.
parent
b26a8cad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
50 deletions
+63
-50
client.go
client.go
+59
-45
group.go
group.go
+4
-5
No files found.
client.go
View file @
b265aacd
...
@@ -308,15 +308,21 @@ func addUpConn(c *client, id string) (*upConnection, error) {
...
@@ -308,15 +308,21 @@ func addUpConn(c *client, id string) (*upConnection, error) {
maxBitrate
:
^
uint64
(
0
),
maxBitrate
:
^
uint64
(
0
),
}
}
u
.
tracks
=
append
(
u
.
tracks
,
track
)
u
.
tracks
=
append
(
u
.
tracks
,
track
)
done
:=
u
.
complete
()
var
tracks
[]
*
upTrack
if
u
.
complete
()
{
tracks
=
make
([]
*
upTrack
,
len
(
u
.
tracks
))
copy
(
tracks
,
u
.
tracks
)
}
if
remote
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
{
if
remote
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
{
atomic
.
AddUint32
(
&
c
.
group
.
videoCount
,
1
)
atomic
.
AddUint32
(
&
c
.
group
.
videoCount
,
1
)
}
}
c
.
mu
.
Unlock
()
c
.
mu
.
Unlock
()
clients
:=
c
.
group
.
getClients
(
c
)
if
tracks
!=
nil
{
for
_
,
cc
:=
range
clients
{
clients
:=
c
.
group
.
getClients
(
c
)
pushTracks
(
cc
,
u
,
[]
*
upTrack
{
track
},
done
,
u
.
label
)
for
_
,
cc
:=
range
clients
{
pushConn
(
cc
,
u
,
tracks
,
u
.
label
)
}
}
}
go
upLoop
(
conn
,
track
)
go
upLoop
(
conn
,
track
)
...
@@ -578,16 +584,7 @@ func delDownConn(c *client, id string) bool {
...
@@ -578,16 +584,7 @@ func delDownConn(c *client, id string) bool {
return
true
return
true
}
}
func
addDownTrack
(
c
*
client
,
id
string
,
remoteTrack
*
upTrack
,
remoteConn
*
upConnection
)
(
*
downConnection
,
*
webrtc
.
RTPSender
,
error
)
{
func
addDownTrack
(
c
*
client
,
conn
*
downConnection
,
remoteTrack
*
upTrack
,
remoteConn
*
upConnection
)
(
*
webrtc
.
RTPSender
,
error
)
{
conn
:=
getDownConn
(
c
,
id
)
if
conn
==
nil
{
var
err
error
conn
,
err
=
addDownConn
(
c
,
id
,
remoteConn
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
}
local
,
err
:=
conn
.
pc
.
NewTrack
(
local
,
err
:=
conn
.
pc
.
NewTrack
(
remoteTrack
.
track
.
PayloadType
(),
remoteTrack
.
track
.
PayloadType
(),
remoteTrack
.
track
.
SSRC
(),
remoteTrack
.
track
.
SSRC
(),
...
@@ -595,12 +592,12 @@ func addDownTrack(c *client, id string, remoteTrack *upTrack, remoteConn *upConn
...
@@ -595,12 +592,12 @@ func addDownTrack(c *client, id string, remoteTrack *upTrack, remoteConn *upConn
remoteTrack
.
track
.
Label
(),
remoteTrack
.
track
.
Label
(),
)
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
err
}
}
s
,
err
:=
conn
.
pc
.
AddTrack
(
local
)
s
,
err
:=
conn
.
pc
.
AddTrack
(
local
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
err
}
}
track
:=
&
downTrack
{
track
:=
&
downTrack
{
...
@@ -616,7 +613,7 @@ func addDownTrack(c *client, id string, remoteTrack *upTrack, remoteConn *upConn
...
@@ -616,7 +613,7 @@ func addDownTrack(c *client, id string, remoteTrack *upTrack, remoteConn *upConn
go
rtcpDownListener
(
conn
,
track
,
s
)
go
rtcpDownListener
(
conn
,
track
,
s
)
return
conn
,
s
,
nil
return
s
,
nil
}
}
const
(
const
(
...
@@ -831,7 +828,7 @@ func sendRecovery(p *rtcp.TransportLayerNack, track *downTrack) {
...
@@ -831,7 +828,7 @@ func sendRecovery(p *rtcp.TransportLayerNack, track *downTrack) {
}
}
}
}
func
negotiate
(
c
*
client
,
id
string
,
down
*
downConnection
)
error
{
func
negotiate
(
c
*
client
,
down
*
downConnection
)
error
{
offer
,
err
:=
down
.
pc
.
CreateOffer
(
nil
)
offer
,
err
:=
down
.
pc
.
CreateOffer
(
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -849,7 +846,7 @@ func negotiate(c *client, id string, down *downConnection) error {
...
@@ -849,7 +846,7 @@ func negotiate(c *client, id string, down *downConnection) error {
return
c
.
write
(
clientMessage
{
return
c
.
write
(
clientMessage
{
Type
:
"offer"
,
Type
:
"offer"
,
Id
:
id
,
Id
:
down
.
id
,
Offer
:
&
offer
,
Offer
:
&
offer
,
Labels
:
labels
,
Labels
:
labels
,
})
})
...
@@ -946,7 +943,7 @@ func (c *client) setRequested(requested []string) error {
...
@@ -946,7 +943,7 @@ func (c *client) setRequested(requested []string) error {
go
func
()
{
go
func
()
{
clients
:=
c
.
group
.
getClients
(
c
)
clients
:=
c
.
group
.
getClients
(
c
)
for
_
,
cc
:=
range
clients
{
for
_
,
cc
:=
range
clients
{
cc
.
action
(
push
Track
sAction
{
c
})
cc
.
action
(
push
Conn
sAction
{
c
})
}
}
}()
}()
...
@@ -962,14 +959,41 @@ func (c *client) isRequested(label string) bool {
...
@@ -962,14 +959,41 @@ func (c *client) isRequested(label string) bool {
return
false
return
false
}
}
func
pushTracks
(
c
*
client
,
conn
*
upConnection
,
tracks
[]
*
upTrack
,
done
bool
,
label
string
)
{
func
addDownConnTracks
(
c
*
client
,
remote
*
upConnection
,
tracks
[]
*
upTrack
)
(
*
downConnection
,
error
)
{
for
i
,
t
:=
range
tracks
{
requested
:=
false
c
.
action
(
addTrackAction
{
t
,
conn
,
done
&&
i
==
len
(
tracks
)
-
1
})
for
_
,
t
:=
range
tracks
{
if
c
.
isRequested
(
t
.
label
)
{
requested
=
true
break
}
}
if
!
requested
{
return
nil
,
nil
}
}
if
done
&&
label
!=
""
{
down
,
err
:=
addDownConn
(
c
,
remote
.
id
,
remote
)
c
.
action
(
addLabelAction
{
conn
.
id
,
conn
.
label
})
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
t
:=
range
tracks
{
if
!
c
.
isRequested
(
t
.
label
)
{
continue
}
_
,
err
=
addDownTrack
(
c
,
down
,
t
,
remote
)
if
err
!=
nil
{
delDownConn
(
c
,
down
.
id
)
return
nil
,
err
}
}
return
down
,
nil
}
func
pushConn
(
c
*
client
,
conn
*
upConnection
,
tracks
[]
*
upTrack
,
label
string
)
{
c
.
action
(
addConnAction
{
conn
,
tracks
})
if
label
!=
""
{
c
.
action
(
addLabelAction
{
conn
.
id
,
conn
.
label
})
}
}
}
}
...
@@ -1030,21 +1054,15 @@ func clientLoop(c *client, conn *websocket.Conn) error {
...
@@ -1030,21 +1054,15 @@ func clientLoop(c *client, conn *websocket.Conn) error {
}
}
case
a
:=
<-
c
.
actionCh
:
case
a
:=
<-
c
.
actionCh
:
switch
a
:=
a
.
(
type
)
{
switch
a
:=
a
.
(
type
)
{
case
addTrackAction
:
case
addConnAction
:
var
down
*
downConnection
down
,
err
:=
addDownConnTracks
(
var
err
error
c
,
a
.
conn
,
a
.
tracks
,
if
c
.
isRequested
(
a
.
track
.
label
)
{
)
down
,
_
,
err
=
addDownTrack
(
if
err
!=
nil
{
c
,
a
.
remote
.
id
,
a
.
track
,
return
err
a
.
remote
)
if
err
!=
nil
{
return
err
}
}
else
{
down
=
getDownConn
(
c
,
a
.
remote
.
id
)
}
}
if
a
.
done
&&
down
!=
nil
{
if
down
!=
nil
{
err
=
negotiate
(
c
,
a
.
remote
.
id
,
down
)
err
=
negotiate
(
c
,
down
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -1063,15 +1081,11 @@ func clientLoop(c *client, conn *websocket.Conn) error {
...
@@ -1063,15 +1081,11 @@ func clientLoop(c *client, conn *websocket.Conn) error {
Id
:
a
.
id
,
Id
:
a
.
id
,
Value
:
a
.
label
,
Value
:
a
.
label
,
})
})
case
push
Track
sAction
:
case
push
Conn
sAction
:
for
_
,
u
:=
range
c
.
up
{
for
_
,
u
:=
range
c
.
up
{
tracks
:=
make
([]
*
upTrack
,
len
(
u
.
tracks
))
tracks
:=
make
([]
*
upTrack
,
len
(
u
.
tracks
))
copy
(
tracks
,
u
.
tracks
)
copy
(
tracks
,
u
.
tracks
)
go
pushTracks
(
go
pushConn
(
a
.
c
,
u
,
tracks
,
u
.
label
)
a
.
c
,
u
,
tracks
,
u
.
complete
(),
u
.
label
,
)
}
}
case
connectionFailedAction
:
case
connectionFailedAction
:
found
:=
delUpConn
(
c
,
a
.
id
)
found
:=
delUpConn
(
c
,
a
.
id
)
...
...
group.go
View file @
b265aacd
...
@@ -209,10 +209,9 @@ type delConnAction struct {
...
@@ -209,10 +209,9 @@ type delConnAction struct {
id
string
id
string
}
}
type
addTrackAction
struct
{
type
addConnAction
struct
{
track
*
upTrack
conn
*
upConnection
remote
*
upConnection
tracks
[]
*
upTrack
done
bool
}
}
type
addLabelAction
struct
{
type
addLabelAction
struct
{
...
@@ -224,7 +223,7 @@ type getUpAction struct {
...
@@ -224,7 +223,7 @@ type getUpAction struct {
ch
chan
<-
string
ch
chan
<-
string
}
}
type
push
Track
sAction
struct
{
type
push
Conn
sAction
struct
{
c
*
client
c
*
client
}
}
...
...
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