Skip to content

Commit c608cea

Browse files
Add a Name helper for SIPTransport. (#1175)
* Add a Name helper for SIPTransport. * generated protobuf --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent a6f8432 commit c608cea

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.changeset/sip-transport-name.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"github.com/livekit/protocol": minor
3+
---
4+
5+
Add a Name helper for SIPTransport.

livekit/sip.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,23 @@ func (p *SIPStatus) TwirpErrorMeta() map[string]string {
9595
}
9696
}
9797

98+
// Name returns a lower-case short name for the transport.
99+
// It returns an empty string if transport is not specified.
100+
func (p SIPTransport) Name() string {
101+
switch p {
102+
case SIPTransport_SIP_TRANSPORT_AUTO:
103+
return ""
104+
case SIPTransport_SIP_TRANSPORT_UDP:
105+
return "udp"
106+
case SIPTransport_SIP_TRANSPORT_TCP:
107+
return "tcp"
108+
case SIPTransport_SIP_TRANSPORT_TLS:
109+
return "tls"
110+
default:
111+
return strings.TrimPrefix(p.String(), "SIP_TRANSPORT_")
112+
}
113+
}
114+
98115
// ToProto implements DataPacket in Go SDK.
99116
func (p *SipDTMF) ToProto() *DataPacket {
100117
return &DataPacket{

0 commit comments

Comments
 (0)