Skip to content

Commit

Permalink
Add RTCP packet reader for output streams
Browse files Browse the repository at this point in the history
Default interceptors need those.
  • Loading branch information
sergystepanov committed Feb 13, 2024
1 parent 61b4108 commit 6258f9a
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions pkg/network/webrtc/webrtc.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,20 @@ func (p *Peer) NewCall(vCodec, aCodec string, onICECandidate func(ice any)) (sdp
if err != nil {
return "", err
}
if _, err = p.conn.AddTrack(video); err != nil {
vs, err := p.conn.AddTrack(video)
if err != nil {
return "", err
}
// Read incoming RTCP packets
go func() {
rtcpBuf := make([]byte, 1500)
for {
_, _, rtcpErr := vs.Read(rtcpBuf)
if rtcpErr != nil {
return
}
}
}()
p.v = video
p.log.Debug().Msgf("Added [%s] track", video.Codec().MimeType)

Expand All @@ -53,9 +64,20 @@ func (p *Peer) NewCall(vCodec, aCodec string, onICECandidate func(ice any)) (sdp
if err != nil {
return "", err
}
if _, err = p.conn.AddTrack(audio); err != nil {
as, err := p.conn.AddTrack(audio)
if err != nil {
return "", err
}
// Read incoming RTCP packets
go func() {
rtcpBuf := make([]byte, 1500)
for {
_, _, rtcpErr := as.Read(rtcpBuf)
if rtcpErr != nil {
return
}
}
}()
p.log.Debug().Msgf("Added [%s] track", audio.Codec().MimeType)
p.a = audio

Expand Down

0 comments on commit 6258f9a

Please sign in to comment.