This commit is contained in:
Benjamin Pracht
2024-10-11 15:42:19 -07:00
parent 9e9e6999fd
commit 460ea2ecfe
3 changed files with 29 additions and 3 deletions

View File

@@ -22,6 +22,8 @@ import (
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/rpc"
"github.com/livekit/protocol/sip"
"github.com/livekit/psrpc"
"google.golang.org/protobuf/types/known/emptypb"
)
// matchSIPTrunk finds a SIP Trunk definition matching the request.
@@ -100,3 +102,27 @@ func (s *IOInfoService) GetSIPTrunkAuthentication(ctx context.Context, req *rpc.
Password: trunk.AuthPassword,
}, nil
}
func (s *IOInfoService) UpdateSIPCallState(ctx context.Context, req *rpc.UpdateSIPCallStateRequest) (*emptypb.Empty, error) {
log := logger.GetLogger()
log = log.WithValues("callID", req.CallInfo.CallId, "callStatus", req.CallInfo.CallStatus.String())
log.Infow("SIP call state updated")
if req.CallInfo == nil {
return nil, psrpc.NewErrorf(psrpc.InvalidArgument, "no call info in UpdateSIPCallState request")
}
switch req.CallInfo.CallStatus {
case livekit.SIPCallStatus_SIP_CALL_STATUS_PARTICIPANT_JOINED:
s.telemetry.SIPParticipantCreated(ctx, req.CallInfo)
case livekit.SIPCallStatus_SIP_CALL_STATUS_CALL_INCOMING:
s.telemetry.SIPCallIncoming(ctx, req.CallInfo)
case livekit.SIPCallStatus_SIP_CALL_STATUS_ACTIVE:
s.telemetry.SIPCallStarted(ctx, req.CallInfo)
case livekit.SIPCallStatus_SIP_CALL_STATUS_DISCONNECTED:
s.telemetry.SIPCallEnded(ctx, req.CallInfo)
}
return &emptypb.Empty{}, nil
}

View File

@@ -544,9 +544,9 @@ func (t *telemetryService) SIPParticipantCreated(ctx context.Context, sipCall *l
})
}
func (t *telemetryService) SIPCallAccepted(ctx context.Context, sipCall *livekit.SIPCallInfo) {
func (t *telemetryService) SIPCallIncoming(ctx context.Context, sipCall *livekit.SIPCallInfo) {
t.enqueue(func() {
t.SendEvent(ctx, newSIPCallEvent(livekit.AnalyticsEventType_SIP_CALL_ACCEPTED, sipCall))
t.SendEvent(ctx, newSIPCallEvent(livekit.AnalyticsEventType_SIP_CALL_INCOMING, sipCall))
})
}

View File

@@ -82,7 +82,7 @@ type TelemetryService interface {
SIPDispatchRuleCreated(ctx context.Context, dispatchRule *livekit.SIPDispatchRuleInfo)
SIPDispatchRuleDeleted(ctx context.Context, dispatchRule *livekit.SIPDispatchRuleInfo)
SIPParticipantCreated(ctx context.Context, sipCall *livekit.SIPCallInfo)
SIPCallAccepted(ctx context.Context, sipCall *livekit.SIPCallInfo)
SIPCallIncoming(ctx context.Context, sipCall *livekit.SIPCallInfo)
SIPCallStarted(ctx context.Context, sipCall *livekit.SIPCallInfo)
SIPCallEnded(ctx context.Context, sipCall *livekit.SIPCallInfo)