From 866518e7e606569a73a80987ccc09c7e514bd2e5 Mon Sep 17 00:00:00 2001 From: David Colburn Date: Wed, 2 Oct 2024 13:32:44 -0700 Subject: [PATCH] update processor --- pkg/media/processor.go | 5 +---- pkg/sip/media_port.go | 8 ++------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/media/processor.go b/pkg/media/processor.go index cc864d0..c1d6fde 100644 --- a/pkg/media/processor.go +++ b/pkg/media/processor.go @@ -14,9 +14,6 @@ package media -type Processor[T any] interface { - SetWriter(writer WriteCloser[T]) - WriteCloser[T] -} +type Processor[T any] func(w WriteCloser[T]) WriteCloser[T] type PCM16Processor = Processor[PCM16Sample] diff --git a/pkg/sip/media_port.go b/pkg/sip/media_port.go index d4eb97f..1676cf7 100644 --- a/pkg/sip/media_port.go +++ b/pkg/sip/media_port.go @@ -209,15 +209,11 @@ func (p *MediaPort) setupOutput() { // TODO: this says "audio", but actually includes DTMF too s := rtp.NewSeqWriter(newRTPStatsWriter(p.mon, "audio", p.conn)) p.audioOutRTP = s.NewStream(p.conf.AudioType, p.conf.Audio.Info().RTPClockRate) + // Encoding pipeline (LK -> SIP) audioOut := p.conf.Audio.EncodeRTP(p.audioOutRTP) - if processor := p.conf.Processor; processor != nil { - if audioOut.SampleRate() != processor.SampleRate() { - audioOut = media.ResampleWriter(audioOut, processor.SampleRate()) - } - processor.SetWriter(audioOut) - audioOut = processor + audioOut = processor(audioOut) } if p.conf.DTMFType != 0 {