Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/sip/media_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,14 @@ type MediaPort interface {
GetOutboundDTMFWriter() msdk.WriteCloser[*livekit.SipDTMF]

// WriteInboundAudioTo tells port where to write inbound SIP audio.
//
// MediaPort.Close() will propagate to the argument writer. The caller is
// responsible for closing the returned media writer.
WriteInboundAudioTo(w msdk.PCM16Writer) msdk.PCM16Writer

// WriteInboundDTMFTo tells port where to write inbound SIP DTMF.
//
// Has similar close semantics to WriteInboundAudioTo (see comment above).
WriteInboundDTMFTo(w msdk.WriteCloser[*livekit.SipDTMF]) msdk.WriteCloser[*livekit.SipDTMF]

// If there is no offer, this generates an offer.
Expand Down Expand Up @@ -735,7 +741,6 @@ func (p *mediaPort) GetOutboundAudioWriter() msdk.PCM16Writer {
return p.audioOut
}

// WriteInboundAudioTo sets audio writer that will receive decoded PCM from incoming RTP packets.
func (p *mediaPort) WriteInboundAudioTo(w msdk.PCM16Writer) msdk.PCM16Writer {
return p.audioIn.Swap(w)
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/sip/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ func (c *outboundCall) connectMedia() {
old.Close()
c.log.Warnw("media port has unexpected inbound audio writer", nil)
}
// WriteInboundAudioTo takes ownership of c.lkRoomIn, so nil it out to avoid
// double-closing later.
c.lkRoomIn = nil

if old := c.media.WriteInboundDTMFTo(c.lkRoom.GetInboundDTMFWriter()); old != nil {
old.Close()
Expand Down