@@ -43,6 +43,7 @@ type MediaConfig struct {
4343 Ports rtcconfig.PortRange
4444 MediaTimeoutInitial time.Duration
4545 MediaTimeout time.Duration
46+ EnableJitterBuffer bool
4647}
4748
4849func NewMediaPort (log logger.Logger , mon * stats.CallMonitor , conf * MediaConfig , sampleRate int ) (* MediaPort , error ) {
@@ -52,10 +53,11 @@ func NewMediaPort(log logger.Logger, mon *stats.CallMonitor, conf *MediaConfig,
5253func NewMediaPortWith (log logger.Logger , mon * stats.CallMonitor , conn rtp.UDPConn , conf * MediaConfig , sampleRate int ) (* MediaPort , error ) {
5354 mediaTimeout := make (chan struct {})
5455 p := & MediaPort {
55- log : log ,
56- mon : mon ,
57- externalIP : conf .IP ,
58- mediaTimeout : mediaTimeout ,
56+ log : log ,
57+ mon : mon ,
58+ externalIP : conf .IP ,
59+ mediaTimeout : mediaTimeout ,
60+ jitterEnabled : conf .EnableJitterBuffer ,
5961 conn : rtp .NewConnWith (conn , & rtp.ConnConfig {
6062 MediaTimeoutInitial : conf .MediaTimeoutInitial ,
6163 MediaTimeout : conf .MediaTimeout ,
@@ -81,6 +83,7 @@ type MediaPort struct {
8183 conn * rtp.Conn
8284 mediaTimeout <- chan struct {}
8385 dtmfAudioEnabled bool
86+ jitterEnabled bool
8487 closed atomic.Bool
8588
8689 mu sync.Mutex
@@ -236,7 +239,9 @@ func (p *MediaPort) setupInput() {
236239 // Decoding pipeline (SIP -> LK)
237240 audioHandler := p .conf .Audio .Codec .DecodeRTP (p .audioIn , p .conf .Audio .Type )
238241 p .audioInHandler = audioHandler
239- audioHandler = rtp .HandleJitter (p .conf .Audio .Codec .Info ().RTPClockRate , audioHandler )
242+ if p .jitterEnabled {
243+ audioHandler = rtp .HandleJitter (p .conf .Audio .Codec .Info ().RTPClockRate , audioHandler )
244+ }
240245 mux := rtp .NewMux (nil )
241246 mux .SetDefault (newRTPStatsHandler (p .mon , "" , nil ))
242247 mux .Register (p .conf .Audio .Type , newRTPStatsHandler (p .mon , p .conf .Audio .Codec .Info ().SDPName , audioHandler ))
0 commit comments