Skip to content

Commit

Permalink
Fix handling of empty RTP payloads with padding (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 authored Dec 19, 2024
1 parent 6f179b0 commit 877ca24
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions service/rtc/sfu.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,15 @@ func (s *Server) InitSession(cfg SessionConfig, closeCb func() error) error {
return
}

// Mitigating against https://github.com/pion/webrtc/issues/2403
// The padding will be stripped by pion but the header bit will be forwarded as is (set).
// This causes clients (e.g. calls-transcriber) to fail to decode the packet.
// Since the payload is empty, we simply reset the padding to 0.
if packet.Padding && len(packet.Payload) == 0 {
packet.Padding = false
packet.PaddingSize = 0
}

if hasVAD {
var ext rtp.AudioLevelExtension
audioExtData := packet.GetExtension(uint8(audioLevelExtensionID))
Expand Down Expand Up @@ -644,6 +653,15 @@ func (s *Server) InitSession(cfg SessionConfig, closeCb func() error) error {
return
}

// Mitigating against https://github.com/pion/webrtc/issues/2403
// The padding will be stripped by pion but the header bit will be forwarded as is (set).
// This causes clients (e.g. calls-transcriber) to fail to decode the packet.
// Since the payload is empty, we simply reset the padding to 0.
if packet.Padding && len(packet.Payload) == 0 {
packet.Padding = false
packet.PaddingSize = 0
}

rm.PushSample(packet.MarshalSize())
if limiter.Allow() {
rate, dur := rm.GetRate()
Expand Down

0 comments on commit 877ca24

Please sign in to comment.