Skip to content

Commit

Permalink
Pass SIP statuses as RPC error details. (#958)
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc authored Jan 29, 2025
1 parent 4cbefae commit c909c95
Show file tree
Hide file tree
Showing 9 changed files with 1,761 additions and 1,199 deletions.
2,140 changes: 1,246 additions & 894 deletions livekit/livekit_sip.pb.go

Large diffs are not rendered by default.

400 changes: 224 additions & 176 deletions livekit/livekit_sip.twirp.go

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions livekit/sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@ import (
"fmt"
"regexp"
"slices"
"strconv"
"strings"

"github.com/livekit/protocol/utils/xtwirp"
)

var _ xtwirp.ErrorMeta = (*SIPStatus)(nil)

func (p *SIPStatus) TwirpErrorMeta() map[string]string {
status := p.Status
if status == "" {
status = p.Code.String()
}
return map[string]string{
"sip_status_code": strconv.Itoa(int(p.Code)),
"sip_status": status,
}
}

// ToProto implements DataPacket in Go SDK.
func (p *SipDTMF) ToProto() *DataPacket {
return &DataPacket{
Expand Down
63 changes: 63 additions & 0 deletions protobufs/livekit_sip.proto
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,69 @@ service SIP {
rpc TransferSIPParticipant(TransferSIPParticipantRequest) returns (google.protobuf.Empty);
}

enum SIPStatusCode {
SIP_STATUS_UNKNOWN = 0;

SIP_STATUS_TRYING = 100;
SIP_STATUS_RINGING = 180;
SIP_STATUS_CALL_IS_FORWARDED = 181;
SIP_STATUS_QUEUED = 182;
SIP_STATUS_SESSION_PROGRESS = 183;

SIP_STATUS_OK = 200;
SIP_STATUS_ACCEPTED = 202;

SIP_STATUS_MOVED_PERMANENTLY = 301;
SIP_STATUS_MOVED_TEMPORARILY = 302;
SIP_STATUS_USE_PROXY = 305;

SIP_STATUS_BAD_REQUEST = 400;
SIP_STATUS_UNAUTHORIZED = 401;
SIP_STATUS_PAYMENT_REQUIRED = 402;
SIP_STATUS_FORBIDDEN = 403;
SIP_STATUS_NOTFOUND = 404;
SIP_STATUS_METHOD_NOT_ALLOWED = 405;
SIP_STATUS_NOT_ACCEPTABLE = 406;
SIP_STATUS_PROXY_AUTH_REQUIRED = 407;
SIP_STATUS_REQUEST_TIMEOUT = 408;
SIP_STATUS_CONFLICT = 409;
SIP_STATUS_GONE = 410;
SIP_STATUS_REQUEST_ENTITY_TOO_LARGE = 413;
SIP_STATUS_REQUEST_URI_TOO_LONG = 414;
SIP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415;
SIP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
SIP_STATUS_BAD_EXTENSION = 420;
SIP_STATUS_EXTENSION_REQUIRED = 421;
SIP_STATUS_INTERVAL_TOO_BRIEF = 423;
SIP_STATUS_TEMPORARILY_UNAVAILABLE = 480;
SIP_STATUS_CALL_TRANSACTION_DOES_NOT_EXISTS = 481;
SIP_STATUS_LOOP_DETECTED = 482;
SIP_STATUS_TOO_MANY_HOPS = 483;
SIP_STATUS_ADDRESS_INCOMPLETE = 484;
SIP_STATUS_AMBIGUOUS = 485;
SIP_STATUS_BUSY_HERE = 486;
SIP_STATUS_REQUEST_TERMINATED = 487;
SIP_STATUS_NOT_ACCEPTABLE_HERE = 488;

SIP_STATUS_INTERNAL_SERVER_ERROR = 500;
SIP_STATUS_NOT_IMPLEMENTED = 501;
SIP_STATUS_BAD_GATEWAY = 502;
SIP_STATUS_SERVICE_UNAVAILABLE = 503;
SIP_STATUS_GATEWAY_TIMEOUT = 504;
SIP_STATUS_VERSION_NOT_SUPPORTED = 505;
SIP_STATUS_MESSAGE_TOO_LARGE = 513;

SIP_STATUS_GLOBAL_BUSY_EVERYWHERE = 600;
SIP_STATUS_GLOBAL_DECLINE = 603;
SIP_STATUS_GLOBAL_DOES_NOT_EXIST_ANYWHERE = 604;
SIP_STATUS_GLOBAL_NOT_ACCEPTABLE = 606;
}

// SIPStatus is returned as an error detail in CreateSIPParticipant.
message SIPStatus {
SIPStatusCode code = 1;
string status = 2;
}

message CreateSIPTrunkRequest {
option deprecated = true;
Expand Down
3 changes: 0 additions & 3 deletions protobufs/rpc/sip.proto
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ message InternalCreateSIPParticipantResponse {
string participant_id = 1;
string participant_identity = 2;
string sip_call_id = 3;

uint32 sip_failure_code = 4;
string sip_failure_reason = 5;
}

message InternalTransferSIPParticipantRequest {
Expand Down
99 changes: 39 additions & 60 deletions rpc/sip.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c909c95

Please sign in to comment.