diff --git a/pkg/sip/client.go b/pkg/sip/client.go index 81d104a..8c616ea 100644 --- a/pkg/sip/client.go +++ b/pkg/sip/client.go @@ -167,9 +167,11 @@ func (c *Client) createSIPParticipant(ctx context.Context, req *rpc.InternalCrea callInfo.Error = retErr.Error() } - c.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ - CallInfo: callInfo, - }) + if c.ioClient != nil { + c.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ + CallInfo: callInfo, + }) + } }() roomConf := RoomConfig{ @@ -215,9 +217,11 @@ func (c *Client) createSIPParticipant(ctx context.Context, req *rpc.InternalCrea callInfo.CallStatus = livekit.SIPCallStatus_SCS_DISCONNECTED } - c.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ - CallInfo: callInfo, - }) + if c.ioClient != nil { + c.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ + CallInfo: callInfo, + }) + } }() diff --git a/pkg/sip/inbound.go b/pkg/sip/inbound.go index 697ec47..364a7c5 100644 --- a/pkg/sip/inbound.go +++ b/pkg/sip/inbound.go @@ -130,9 +130,11 @@ func (s *Server) onInvite(req *sip.Request, tx sip.ServerTransaction) { } callInfo.EndedAt = time.Now().UnixNano() - s.ioClient.UpdateSIPCallState(context.Background(), &rpc.UpdateSIPCallStateRequest{ - CallInfo: callInfo, - }) + if s.ioClient != nil { + s.ioClient.UpdateSIPCallState(context.Background(), &rpc.UpdateSIPCallStateRequest{ + CallInfo: callInfo, + }) + } } } @@ -166,9 +168,11 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (*liv CreatedAt: time.Now().UnixNano(), } - s.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ - CallInfo: callInfo, - }) + if s.ioClient != nil { + s.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ + CallInfo: callInfo, + }) + } if err := cc.ValidateInvite(); err != nil { if s.conf.HideInboundPort { @@ -483,9 +487,11 @@ func (c *inboundCall) handleInvite(ctx context.Context, req *sip.Request, trunkI c.started.Break() - c.s.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ - CallInfo: c.callInfo, - }) + if c.s.ioClient != nil { + c.s.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ + CallInfo: c.callInfo, + }) + } // Wait for the caller to terminate the call. select { diff --git a/pkg/sip/outbound.go b/pkg/sip/outbound.go index 826ba44..84b05a9 100644 --- a/pkg/sip/outbound.go +++ b/pkg/sip/outbound.go @@ -142,9 +142,11 @@ func (c *outboundCall) Start(ctx context.Context) { c.callInfo.StartedAt = time.Now().UnixNano() c.callInfo.CallStatus = livekit.SIPCallStatus_SCS_ACTIVE - c.c.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ - CallInfo: c.callInfo, - }) + if c.c.ioClient != nil { + c.c.ioClient.UpdateSIPCallState(context.WithoutCancel(ctx), &rpc.UpdateSIPCallStateRequest{ + CallInfo: c.callInfo, + }) + } select { case <-c.Disconnected(): diff --git a/pkg/sip/service_test.go b/pkg/sip/service_test.go index b596e17..c143567 100644 --- a/pkg/sip/service_test.go +++ b/pkg/sip/service_test.go @@ -14,7 +14,6 @@ import ( "github.com/livekit/mediatransportutil/pkg/rtcconfig" "github.com/livekit/protocol/logger" "github.com/livekit/protocol/rpc" - "github.com/livekit/psrpc" "github.com/livekit/sip/pkg/media" @@ -91,16 +90,12 @@ func testInvite(t *testing.T, h Handler, hidden bool, from, to string, test func mon, err := stats.NewMonitor(&config.Config{MaxCpuUtilization: 0.9}) require.NoError(t, err) - bus := psrpc.NewLocalMessageBus() - psrpcClient, err := rpc.NewIOInfoClient(bus) - require.NoError(t, err) - s, err := NewService(&config.Config{ HideInboundPort: hidden, SIPPort: sipPort, SIPPortListen: sipPort, RTPPort: rtcconfig.PortRange{Start: testPortRTPMin, End: testPortRTPMax}, - }, mon, logger.GetLogger(), psrpcClient) + }, mon, logger.GetLogger(), nil) require.NoError(t, err) require.NotNil(t, s) t.Cleanup(s.Stop)