Skip to content

Commit

Permalink
Fix PCM audio quality for WebRTC
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jul 26, 2024
1 parent 68fa422 commit 57d48f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/webrtc/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ func (c *Conn) AddTrack(media *core.Media, codec *core.Codec, track *core.Receiv
}

case core.CodecPCMA, core.CodecPCMU, core.CodecPCM, core.CodecPCML:
// Fix audio quality https://github.com/AlexxIT/WebRTC/issues/500
// should be before ResampleToG711, because it will be called last
sender.Handler = pcm.RepackG711(false, sender.Handler)

if codec.ClockRate == 0 {
if codec.Name == core.CodecPCM || codec.Name == core.CodecPCML {
codec.Name = core.CodecPCMA
}
codec.ClockRate = 8000
sender.Handler = pcm.ResampleToG711(track.Codec, 8000, sender.Handler)
}

// Fix audio quality https://github.com/AlexxIT/WebRTC/issues/500
sender.Handler = pcm.RepackG711(false, sender.Handler)
}

// TODO: rewrite this dirty logic
Expand Down

0 comments on commit 57d48f5

Please sign in to comment.