Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outbound processor #212

Merged
merged 1 commit into from
Oct 25, 2024
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/jfreymuth/oggvorbis v1.0.5
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
github.com/livekit/mediatransportutil v0.0.0-20240730083616-559fa5ece598
github.com/livekit/protocol v1.26.1-0.20241022031344-538889e5de0a
github.com/livekit/protocol v1.27.1-0.20241025171050-32abc4d3e929
github.com/livekit/psrpc v0.6.1-0.20240924010758-9f0a4268a3b9
github.com/livekit/server-sdk-go/v2 v2.2.2-0.20241015094126-b8538ae5d67b
github.com/mjibson/go-dsp v0.0.0-20180508042940-11479a337f12
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
github.com/livekit/mediatransportutil v0.0.0-20240730083616-559fa5ece598 h1:yLlkHk2feSLHstD9n4VKg7YEBR4rLODTI4WE8gNBEnQ=
github.com/livekit/mediatransportutil v0.0.0-20240730083616-559fa5ece598/go.mod h1:jwKUCmObuiEDH0iiuJHaGMXwRs3RjrB4G6qqgkr/5oE=
github.com/livekit/protocol v1.26.1-0.20241022031344-538889e5de0a h1:31YXXJLEwCflp7KEe9rRAwmONyCwHFujTl4MdxegTxw=
github.com/livekit/protocol v1.26.1-0.20241022031344-538889e5de0a/go.mod h1:nxRzmQBKSYK64gqr7ABWwt78hvrgiO2wYuCojRYb7Gs=
github.com/livekit/protocol v1.27.1-0.20241025171050-32abc4d3e929 h1:qunGP1opJF4NfcJW5tLyV/cLE/npfnh7P3nyyLECb68=
github.com/livekit/protocol v1.27.1-0.20241025171050-32abc4d3e929/go.mod h1:nxRzmQBKSYK64gqr7ABWwt78hvrgiO2wYuCojRYb7Gs=
github.com/livekit/psrpc v0.6.1-0.20240924010758-9f0a4268a3b9 h1:33oBjGpVD9tYkDXQU42tnHl8eCX9G6PVUToBVuCUyOs=
github.com/livekit/psrpc v0.6.1-0.20240924010758-9f0a4268a3b9/go.mod h1:CQUBSPfYYAaevg1TNCc6/aYsa8DJH4jSRFdCeSZk5u0=
github.com/livekit/server-sdk-go/v2 v2.2.2-0.20241015094126-b8538ae5d67b h1:R1GpKwVbSYsG08k5sIkNCukvnrkOE18R8IO1YeujR8o=
Expand Down
1 change: 1 addition & 0 deletions pkg/sip/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func (c *Client) createSIPParticipant(ctx context.Context, req *rpc.InternalCrea
headersToAttrs: req.HeadersToAttributes,
ringingTimeout: req.RingingTimeout.AsDuration(),
maxCallDuration: req.MaxCallDuration.AsDuration(),
enabledFeatures: req.EnabledFeatures,
}
log.Infow("Creating SIP participant")
call, err := c.newCall(ctx, c.conf, log, LocalTag(req.SipCallId), roomConf, sipConf)
Expand Down
8 changes: 4 additions & 4 deletions pkg/sip/media_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ func (p *MediaPort) decodeSDP(data []byte) (*sdp.SessionDescription, *MediaConf,
return desc, c, nil
}

// SetAnswer decodes and applies SDP answer for offer from NewOffer. It calls SetConfig with a decoded configuration.
func (p *MediaPort) SetAnswer(answer []byte) error {
// SetAnswer decodes and applies SDP answer for offer from NewOffer. SetConfig must be called with the decoded configuration.
func (p *MediaPort) SetAnswer(answer []byte) (*MediaConf, error) {
_, c, err := p.decodeSDP(answer)
if err != nil {
return err
return nil, err
}
return p.SetConfig(c)
return c, nil
}

// SetOffer decodes the offer from another party and returns encoded answer. To accept the offer, call SetConfig.
Expand Down
8 changes: 6 additions & 2 deletions pkg/sip/media_port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/livekit/mediatransportutil/pkg/rtcconfig"
"github.com/livekit/protocol/logger"
"github.com/stretchr/testify/require"

"github.com/livekit/sip/pkg/media"
"github.com/livekit/sip/pkg/media/rtp"
Expand Down Expand Up @@ -183,7 +184,10 @@ func TestMediaPort(t *testing.T) {

t.Logf("SDP answer:\n%s", string(answer))

err = m1.SetAnswer(answer)
mc, err := m1.SetAnswer(answer)
require.NoError(t, err)

err = m1.SetConfig(mc)
require.NoError(t, err)

err = m2.SetConfig(conf)
Expand Down
10 changes: 9 additions & 1 deletion pkg/sip/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/tracer"
"github.com/livekit/psrpc"
lksdk "github.com/livekit/server-sdk-go/v2"
Expand All @@ -55,6 +56,7 @@ type sipOutboundConfig struct {
headersToAttrs map[string]string
ringingTimeout time.Duration
maxCallDuration time.Duration
enabledFeatures []rpc.SIPFeature
}

type outboundCall struct {
Expand Down Expand Up @@ -399,9 +401,15 @@ func (c *outboundCall) sipSignal(ctx context.Context) error {

c.log = LoggerWithHeaders(c.log, c.cc)

if err := c.media.SetAnswer(sdpResp); err != nil {
mc, err := c.media.SetAnswer(sdpResp)
if err != nil {
return err
}
mc.Processor = c.c.handler.GetMediaProcessor(c.sipConf.enabledFeatures)
if err = c.media.SetConfig(mc); err != nil {
return err
}

c.c.cmu.Lock()
c.c.byRemote[c.cc.Tag()] = c
c.c.cmu.Unlock()
Expand Down
Loading