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
5a2dbf36
Commit
5a2dbf36
authored
May 20, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Signal new tracks explicitly.
parent
5916028e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
28 deletions
+47
-28
client.go
client.go
+31
-26
group.go
group.go
+16
-2
No files found.
client.go
View file @
5a2dbf36
...
...
@@ -353,6 +353,8 @@ func addUpConn(c *client, id string) (*upConnection, error) {
rate
:
estimator
.
New
(
time
.
Second
),
jitter
:
jitter
.
New
(
remote
.
Codec
()
.
ClockRate
),
maxBitrate
:
^
uint64
(
0
),
localCh
:
make
(
chan
struct
{},
2
),
writerDone
:
make
(
chan
struct
{}),
}
u
.
tracks
=
append
(
u
.
tracks
,
track
)
var
tracks
[]
*
upTrack
...
...
@@ -432,41 +434,40 @@ func readLoop(conn *upConnection, track *upTrack) {
}
func
writeLoop
(
conn
*
upConnection
,
track
*
upTrack
,
ch
<-
chan
packetIndex
)
{
var
localTime
uint64
var
local
[]
*
downTrack
defer
close
(
track
.
writerDone
)
buf
:=
make
([]
byte
,
packetcache
.
BufSize
)
var
packet
rtp
.
Packet
local
:=
track
.
getLocal
()
for
{
now
:=
mono
.
Microseconds
()
if
now
<
localTime
||
now
>
localTime
+
500000
{
select
{
case
<-
track
.
localCh
:
local
=
track
.
getLocal
()
localTime
=
now
}
pi
,
ok
:=
<-
ch
if
!
ok
{
return
}
bytes
:=
track
.
cache
.
GetAt
(
pi
.
seqno
,
pi
.
index
,
buf
)
if
bytes
==
0
{
continue
}
case
pi
,
ok
:=
<-
ch
:
if
!
ok
{
return
}
err
:=
packet
.
Unmarshal
(
buf
[
:
bytes
])
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
continue
}
bytes
:=
track
.
cache
.
GetAt
(
pi
.
seqno
,
pi
.
index
,
buf
)
if
bytes
==
0
{
continue
}
for
_
,
l
:=
range
local
{
err
:=
l
.
track
.
WriteRTP
(
&
packet
)
if
err
!=
nil
&&
err
!=
io
.
ErrClosedPipe
{
err
:=
packet
.
Unmarshal
(
buf
[
:
bytes
])
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
continue
}
for
_
,
l
:=
range
local
{
err
:=
l
.
track
.
WriteRTP
(
&
packet
)
if
err
!=
nil
&&
err
!=
io
.
ErrClosedPipe
{
log
.
Printf
(
"%v"
,
err
)
}
l
.
rate
.
Add
(
uint32
(
bytes
))
}
l
.
rate
.
Add
(
uint32
(
bytes
))
}
}
}
...
...
@@ -637,7 +638,11 @@ func addDownConn(c *client, id string, remote *upConnection) (*downConnection, e
if
c
.
down
==
nil
{
c
.
down
=
make
(
map
[
string
]
*
downConnection
)
}
conn
:=
&
downConnection
{
id
:
id
,
pc
:
pc
,
remote
:
remote
}
conn
:=
&
downConnection
{
id
:
id
,
pc
:
pc
,
remote
:
remote
,
}
c
.
mu
.
Lock
()
defer
c
.
mu
.
Unlock
()
...
...
group.go
View file @
5a2dbf36
...
...
@@ -35,25 +35,39 @@ type upTrack struct {
lastSenderReport
uint32
lastSenderReportTime
uint32
localCh
chan
struct
{}
// signals that local has changed
writerDone
chan
struct
{}
// closed when the loop dies
mu
sync
.
Mutex
local
[]
*
downTrack
}
func
(
up
*
upTrack
)
notifyLocal
()
{
var
s
struct
{}
select
{
case
up
.
localCh
<-
s
:
case
<-
up
.
writerDone
:
}
}
func
(
up
*
upTrack
)
addLocal
(
local
*
downTrack
)
{
up
.
mu
.
Lock
()
defer
up
.
mu
.
Unlock
()
up
.
local
=
append
(
up
.
local
,
local
)
up
.
mu
.
Unlock
()
up
.
notifyLocal
()
}
func
(
up
*
upTrack
)
delLocal
(
local
*
downTrack
)
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
:
]
...
)
up
.
mu
.
Unlock
()
up
.
notifyLocal
()
return
true
}
}
up
.
mu
.
Unlock
()
return
false
}
...
...
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