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
28b7c6d5
Commit
28b7c6d5
authored
Oct 03, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move RTP writer to separate file.
parent
3083b89d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
60 deletions
+72
-60
rtpconn/rtpconn.go
rtpconn/rtpconn.go
+0
-60
rtpconn/rtpreader.go
rtpconn/rtpreader.go
+72
-0
No files found.
rtpconn/rtpconn.go
View file @
28b7c6d5
...
@@ -455,66 +455,6 @@ func newUpConn(c group.Client, id string) (*rtpUpConnection, error) {
...
@@ -455,66 +455,6 @@ func newUpConn(c group.Client, id string) (*rtpUpConnection, error) {
return
up
,
nil
return
up
,
nil
}
}
func
readLoop
(
conn
*
rtpUpConnection
,
track
*
rtpUpTrack
)
{
writers
:=
rtpWriterPool
{
conn
:
conn
,
track
:
track
}
defer
func
()
{
writers
.
close
()
close
(
track
.
readerDone
)
}()
isvideo
:=
track
.
track
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
buf
:=
make
([]
byte
,
packetcache
.
BufSize
)
var
packet
rtp
.
Packet
for
{
bytes
,
err
:=
track
.
track
.
Read
(
buf
)
if
err
!=
nil
{
if
err
!=
io
.
EOF
{
log
.
Printf
(
"%v"
,
err
)
}
break
}
track
.
rate
.
Accumulate
(
uint32
(
bytes
))
err
=
packet
.
Unmarshal
(
buf
[
:
bytes
])
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
continue
}
track
.
jitter
.
Accumulate
(
packet
.
Timestamp
)
first
,
index
:=
track
.
cache
.
Store
(
packet
.
SequenceNumber
,
buf
[
:
bytes
])
if
packet
.
SequenceNumber
-
first
>
24
{
found
,
first
,
bitmap
:=
track
.
cache
.
BitmapGet
()
if
found
{
err
:=
conn
.
sendNACK
(
track
,
first
,
bitmap
)
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
}
}
}
_
,
rate
:=
track
.
rate
.
Estimate
()
delay
:=
uint32
(
rtptime
.
JiffiesPerSec
/
1024
)
if
rate
>
512
{
delay
=
rtptime
.
JiffiesPerSec
/
rate
/
2
}
writers
.
write
(
packet
.
SequenceNumber
,
index
,
delay
,
isvideo
,
packet
.
Marker
)
select
{
case
action
:=
<-
track
.
localCh
:
err
:=
writers
.
add
(
action
.
track
,
action
.
add
)
if
err
!=
nil
{
log
.
Printf
(
"add/remove track: %v"
,
err
)
}
default
:
}
}
}
var
ErrUnsupportedFeedback
=
errors
.
New
(
"unsupported feedback type"
)
var
ErrUnsupportedFeedback
=
errors
.
New
(
"unsupported feedback type"
)
var
ErrRateLimited
=
errors
.
New
(
"rate limited"
)
var
ErrRateLimited
=
errors
.
New
(
"rate limited"
)
...
...
rtpconn/rtpreader.go
0 → 100644
View file @
28b7c6d5
package
rtpconn
import
(
"io"
"log"
"github.com/pion/rtp"
"github.com/pion/webrtc/v3"
"sfu/packetcache"
"sfu/rtptime"
)
func
readLoop
(
conn
*
rtpUpConnection
,
track
*
rtpUpTrack
)
{
writers
:=
rtpWriterPool
{
conn
:
conn
,
track
:
track
}
defer
func
()
{
writers
.
close
()
close
(
track
.
readerDone
)
}()
isvideo
:=
track
.
track
.
Kind
()
==
webrtc
.
RTPCodecTypeVideo
buf
:=
make
([]
byte
,
packetcache
.
BufSize
)
var
packet
rtp
.
Packet
for
{
bytes
,
err
:=
track
.
track
.
Read
(
buf
)
if
err
!=
nil
{
if
err
!=
io
.
EOF
{
log
.
Printf
(
"%v"
,
err
)
}
break
}
track
.
rate
.
Accumulate
(
uint32
(
bytes
))
err
=
packet
.
Unmarshal
(
buf
[
:
bytes
])
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
continue
}
track
.
jitter
.
Accumulate
(
packet
.
Timestamp
)
first
,
index
:=
track
.
cache
.
Store
(
packet
.
SequenceNumber
,
buf
[
:
bytes
])
if
packet
.
SequenceNumber
-
first
>
24
{
found
,
first
,
bitmap
:=
track
.
cache
.
BitmapGet
()
if
found
{
err
:=
conn
.
sendNACK
(
track
,
first
,
bitmap
)
if
err
!=
nil
{
log
.
Printf
(
"%v"
,
err
)
}
}
}
_
,
rate
:=
track
.
rate
.
Estimate
()
delay
:=
uint32
(
rtptime
.
JiffiesPerSec
/
1024
)
if
rate
>
512
{
delay
=
rtptime
.
JiffiesPerSec
/
rate
/
2
}
writers
.
write
(
packet
.
SequenceNumber
,
index
,
delay
,
isvideo
,
packet
.
Marker
)
select
{
case
action
:=
<-
track
.
localCh
:
err
:=
writers
.
add
(
action
.
track
,
action
.
add
)
if
err
!=
nil
{
log
.
Printf
(
"add/remove track: %v"
,
err
)
}
default
:
}
}
}
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