Skip to content

Commit c909c95

Browse files
authored
Pass SIP statuses as RPC error details. (#958)
1 parent 4cbefae commit c909c95

File tree

9 files changed

+1761
-1199
lines changed

9 files changed

+1761
-1199
lines changed

livekit/livekit_sip.pb.go

Lines changed: 1246 additions & 894 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

livekit/livekit_sip.twirp.go

Lines changed: 224 additions & 176 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

livekit/sip.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,25 @@ import (
55
"fmt"
66
"regexp"
77
"slices"
8+
"strconv"
89
"strings"
10+
11+
"github.com/livekit/protocol/utils/xtwirp"
912
)
1013

14+
var _ xtwirp.ErrorMeta = (*SIPStatus)(nil)
15+
16+
func (p *SIPStatus) TwirpErrorMeta() map[string]string {
17+
status := p.Status
18+
if status == "" {
19+
status = p.Code.String()
20+
}
21+
return map[string]string{
22+
"sip_status_code": strconv.Itoa(int(p.Code)),
23+
"sip_status": status,
24+
}
25+
}
26+
1127
// ToProto implements DataPacket in Go SDK.
1228
func (p *SipDTMF) ToProto() *DataPacket {
1329
return &DataPacket{

protobufs/livekit_sip.proto

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,69 @@ service SIP {
7272
rpc TransferSIPParticipant(TransferSIPParticipantRequest) returns (google.protobuf.Empty);
7373
}
7474

75+
enum SIPStatusCode {
76+
SIP_STATUS_UNKNOWN = 0;
77+
78+
SIP_STATUS_TRYING = 100;
79+
SIP_STATUS_RINGING = 180;
80+
SIP_STATUS_CALL_IS_FORWARDED = 181;
81+
SIP_STATUS_QUEUED = 182;
82+
SIP_STATUS_SESSION_PROGRESS = 183;
83+
84+
SIP_STATUS_OK = 200;
85+
SIP_STATUS_ACCEPTED = 202;
86+
87+
SIP_STATUS_MOVED_PERMANENTLY = 301;
88+
SIP_STATUS_MOVED_TEMPORARILY = 302;
89+
SIP_STATUS_USE_PROXY = 305;
90+
91+
SIP_STATUS_BAD_REQUEST = 400;
92+
SIP_STATUS_UNAUTHORIZED = 401;
93+
SIP_STATUS_PAYMENT_REQUIRED = 402;
94+
SIP_STATUS_FORBIDDEN = 403;
95+
SIP_STATUS_NOTFOUND = 404;
96+
SIP_STATUS_METHOD_NOT_ALLOWED = 405;
97+
SIP_STATUS_NOT_ACCEPTABLE = 406;
98+
SIP_STATUS_PROXY_AUTH_REQUIRED = 407;
99+
SIP_STATUS_REQUEST_TIMEOUT = 408;
100+
SIP_STATUS_CONFLICT = 409;
101+
SIP_STATUS_GONE = 410;
102+
SIP_STATUS_REQUEST_ENTITY_TOO_LARGE = 413;
103+
SIP_STATUS_REQUEST_URI_TOO_LONG = 414;
104+
SIP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415;
105+
SIP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
106+
SIP_STATUS_BAD_EXTENSION = 420;
107+
SIP_STATUS_EXTENSION_REQUIRED = 421;
108+
SIP_STATUS_INTERVAL_TOO_BRIEF = 423;
109+
SIP_STATUS_TEMPORARILY_UNAVAILABLE = 480;
110+
SIP_STATUS_CALL_TRANSACTION_DOES_NOT_EXISTS = 481;
111+
SIP_STATUS_LOOP_DETECTED = 482;
112+
SIP_STATUS_TOO_MANY_HOPS = 483;
113+
SIP_STATUS_ADDRESS_INCOMPLETE = 484;
114+
SIP_STATUS_AMBIGUOUS = 485;
115+
SIP_STATUS_BUSY_HERE = 486;
116+
SIP_STATUS_REQUEST_TERMINATED = 487;
117+
SIP_STATUS_NOT_ACCEPTABLE_HERE = 488;
118+
119+
SIP_STATUS_INTERNAL_SERVER_ERROR = 500;
120+
SIP_STATUS_NOT_IMPLEMENTED = 501;
121+
SIP_STATUS_BAD_GATEWAY = 502;
122+
SIP_STATUS_SERVICE_UNAVAILABLE = 503;
123+
SIP_STATUS_GATEWAY_TIMEOUT = 504;
124+
SIP_STATUS_VERSION_NOT_SUPPORTED = 505;
125+
SIP_STATUS_MESSAGE_TOO_LARGE = 513;
126+
127+
SIP_STATUS_GLOBAL_BUSY_EVERYWHERE = 600;
128+
SIP_STATUS_GLOBAL_DECLINE = 603;
129+
SIP_STATUS_GLOBAL_DOES_NOT_EXIST_ANYWHERE = 604;
130+
SIP_STATUS_GLOBAL_NOT_ACCEPTABLE = 606;
131+
}
132+
133+
// SIPStatus is returned as an error detail in CreateSIPParticipant.
134+
message SIPStatus {
135+
SIPStatusCode code = 1;
136+
string status = 2;
137+
}
75138

76139
message CreateSIPTrunkRequest {
77140
option deprecated = true;

protobufs/rpc/sip.proto

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ message InternalCreateSIPParticipantResponse {
111111
string participant_id = 1;
112112
string participant_identity = 2;
113113
string sip_call_id = 3;
114-
115-
uint32 sip_failure_code = 4;
116-
string sip_failure_reason = 5;
117114
}
118115

119116
message InternalTransferSIPParticipantRequest {

rpc/sip.pb.go

Lines changed: 39 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)