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
a813cc9c
Commit
a813cc9c
authored
Apr 29, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out sending loop into a separate function.
parent
9bd093e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
48 deletions
+49
-48
client.go
client.go
+49
-48
No files found.
client.go
View file @
a813cc9c
...
...
@@ -286,10 +286,9 @@ func addUpConn(c *client, id string) (*upConnection, error) {
c
.
mu
.
Unlock
()
return
}
list
:=
packetlist
.
New
(
32
)
track
:=
&
upTrack
{
track
:
remote
,
list
:
list
,
list
:
packetlist
.
New
(
32
)
,
maxBitrate
:
^
uint64
(
0
),
}
u
.
tracks
=
append
(
u
.
tracks
,
track
)
...
...
@@ -304,60 +303,62 @@ func addUpConn(c *client, id string) (*upConnection, error) {
}
}
go
func
()
{
buf
:=
make
([]
byte
,
packetlist
.
BufSize
)
var
packet
rtp
.
Packet
var
local
[]
*
downTrack
var
localTime
time
.
Time
window
:=
packetwindow
.
New
()
for
{
now
:=
time
.
Now
()
if
now
.
Sub
(
localTime
)
>
time
.
Second
/
2
{
local
=
track
.
getLocal
()
localTime
=
now
}
go
upLoop
(
conn
,
track
)
})
i
,
err
:=
remote
.
Read
(
buf
)
if
err
!=
nil
{
if
err
!=
io
.
EOF
{
log
.
Printf
(
"%v"
,
err
)
}
break
}
return
conn
,
nil
}
err
=
packet
.
Unmarshal
(
buf
[
:
i
])
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
continue
}
func
upLoop
(
conn
*
upConnection
,
track
*
upTrack
)
{
buf
:=
make
([]
byte
,
packetlist
.
BufSize
)
var
packet
rtp
.
Packet
var
local
[]
*
downTrack
var
localTime
time
.
Time
window
:=
packetwindow
.
New
()
for
{
now
:=
time
.
Now
()
if
now
.
Sub
(
localTime
)
>
time
.
Second
/
2
{
local
=
track
.
getLocal
()
localTime
=
now
}
window
.
Set
(
packet
.
SequenceNumber
)
if
packet
.
SequenceNumber
-
window
.
First
()
>
24
{
first
,
bitmap
:=
window
.
Get17
()
if
bitmap
!=
^
uint16
(
0
)
{
err
:=
conn
.
sendNACK
(
track
,
first
,
^
bitmap
)
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
}
}
}
i
,
err
:=
track
.
track
.
Read
(
buf
)
if
err
!=
nil
{
if
err
!=
io
.
EOF
{
log
.
Printf
(
"%v"
,
err
)
}
break
}
list
.
Store
(
packet
.
SequenceNumber
,
buf
[
:
i
])
err
=
packet
.
Unmarshal
(
buf
[
:
i
])
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
continue
}
for
_
,
l
:=
range
local
{
if
l
.
muted
()
{
continue
}
err
:=
l
.
track
.
WriteRTP
(
&
packet
)
if
err
!=
nil
&&
err
!=
io
.
ErrClosedPipe
{
log
.
Printf
(
"%v"
,
err
)
}
window
.
Set
(
packet
.
SequenceNumber
)
if
packet
.
SequenceNumber
-
window
.
First
()
>
24
{
first
,
bitmap
:=
window
.
Get17
()
if
bitmap
!=
^
uint16
(
0
)
{
err
:=
conn
.
sendNACK
(
track
,
first
,
^
bitmap
)
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
}
}
}()
})
}
return
conn
,
nil
track
.
list
.
Store
(
packet
.
SequenceNumber
,
buf
[
:
i
])
for
_
,
l
:=
range
local
{
if
l
.
muted
()
{
continue
}
err
:=
l
.
track
.
WriteRTP
(
&
packet
)
if
err
!=
nil
&&
err
!=
io
.
ErrClosedPipe
{
log
.
Printf
(
"%v"
,
err
)
}
}
}
}
func
delUpConn
(
c
*
client
,
id
string
)
{
...
...
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