livekit-server-sdk 0.6.6 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/banner_dark.png +0 -0
- data/.github/banner_light.png +0 -0
- data/.github/workflows/test.yml +15 -15
- data/Gemfile.lock +16 -9
- data/README.md +11 -8
- data/Rakefile +3 -0
- data/lib/livekit/access_token.rb +36 -5
- data/lib/livekit/auth_mixin.rb +10 -2
- data/lib/livekit/egress_service_client.rb +10 -10
- data/lib/livekit/grants.rb +52 -3
- data/lib/livekit/ingress_service_client.rb +4 -4
- data/lib/livekit/proto/livekit_agent_dispatch_pb.rb +25 -0
- data/lib/livekit/proto/livekit_agent_dispatch_twirp.rb +19 -0
- data/lib/livekit/proto/livekit_agent_pb.rb +37 -0
- data/lib/livekit/proto/livekit_agent_twirp.rb +8 -0
- data/lib/livekit/proto/livekit_egress_pb.rb +1 -1
- data/lib/livekit/proto/livekit_metrics_pb.rb +23 -0
- data/lib/livekit/proto/livekit_metrics_twirp.rb +8 -0
- data/lib/livekit/proto/livekit_models_pb.rb +11 -1
- data/lib/livekit/proto/livekit_room_pb.rb +4 -1
- data/lib/livekit/proto/livekit_sip_pb.rb +24 -1
- data/lib/livekit/proto/livekit_sip_twirp.rb +7 -1
- data/lib/livekit/room_service_client.rb +26 -12
- data/lib/livekit/sip_service_client.rb +226 -0
- data/lib/livekit/version.rb +1 -1
- data/lib/livekit.rb +1 -0
- metadata +9 -2
@@ -0,0 +1,226 @@
|
|
1
|
+
require "livekit/proto/livekit_sip_twirp"
|
2
|
+
require "livekit/auth_mixin"
|
3
|
+
require 'livekit/utils'
|
4
|
+
|
5
|
+
module LiveKit
|
6
|
+
class SIPServiceClient < Twirp::Client
|
7
|
+
client_for Proto::SIPService
|
8
|
+
include AuthMixin
|
9
|
+
attr_accessor :api_key, :api_secret
|
10
|
+
|
11
|
+
def initialize(base_url, api_key: nil, api_secret: nil)
|
12
|
+
super(File.join(Utils.to_http_url(base_url), "/twirp"))
|
13
|
+
@api_key = api_key
|
14
|
+
@api_secret = api_secret
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_sip_inbound_trunk(
|
18
|
+
# name to identify the trunk
|
19
|
+
name,
|
20
|
+
# numbers associated with LiveKit SIP. The Trunk will only accept calls made to these numbers.
|
21
|
+
numbers,
|
22
|
+
# optional, metadata to attach to the trunk
|
23
|
+
metadata: nil,
|
24
|
+
# optional, CIDR or IPs that traffic is accepted from.
|
25
|
+
allowed_addresses: nil,
|
26
|
+
# CIDR or IPs that traffic is accepted from.
|
27
|
+
allowed_numbers: nil,
|
28
|
+
# optional, Username and password used to authenticate inbound SIP invites.
|
29
|
+
auth_username: nil,
|
30
|
+
auth_password: nil,
|
31
|
+
# optional, include these SIP X-* headers in 200 OK responses.
|
32
|
+
headers: nil,
|
33
|
+
# optional map SIP X-* headers from INVITE to SIP participant attributes.
|
34
|
+
headers_to_attributes: nil
|
35
|
+
)
|
36
|
+
request = Proto::CreateSIPInboundTrunkRequest.new(
|
37
|
+
trunk: Proto::SIPInboundTrunkInfo.new(
|
38
|
+
name: name,
|
39
|
+
metadata: metadata,
|
40
|
+
numbers: numbers,
|
41
|
+
allowed_addresses: allowed_addresses,
|
42
|
+
allowed_numbers: allowed_numbers,
|
43
|
+
auth_username: auth_username,
|
44
|
+
auth_password: auth_password,
|
45
|
+
headers: headers,
|
46
|
+
headers_to_attributes: headers_to_attributes
|
47
|
+
)
|
48
|
+
)
|
49
|
+
self.rpc(
|
50
|
+
:CreateSIPInboundTrunk,
|
51
|
+
request,
|
52
|
+
headers: auth_header(sip_grant: SIPGrant.new(admin: true)),
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_sip_outbound_trunk(
|
57
|
+
# name to identify the trunk
|
58
|
+
name,
|
59
|
+
# Hostname or IP that SIP INVITE is sent too.
|
60
|
+
address,
|
61
|
+
# Numbers used to make the calls. Random one from this list will be selected.
|
62
|
+
numbers,
|
63
|
+
# optional, metadata to attach to the trunk
|
64
|
+
metadata: nil,
|
65
|
+
# SIP Transport used for outbound call.
|
66
|
+
transport: nil,
|
67
|
+
# optional, Username and password used to authenticate inbound SIP invites.
|
68
|
+
auth_username: nil,
|
69
|
+
auth_password: nil,
|
70
|
+
# optional, include these SIP X-* headers in 200 OK responses.
|
71
|
+
headers: nil,
|
72
|
+
# optional map SIP X-* headers from INVITE to SIP participant attributes.
|
73
|
+
headers_to_attributes: nil
|
74
|
+
)
|
75
|
+
request = Proto::CreateSIPOutboundTrunkRequest.new(
|
76
|
+
trunk: Proto::SIPOutboundTrunkInfo.new(
|
77
|
+
name: name,
|
78
|
+
address: address,
|
79
|
+
numbers: numbers,
|
80
|
+
metadata: metadata,
|
81
|
+
transport: transport,
|
82
|
+
auth_username: auth_username,
|
83
|
+
auth_password: auth_password,
|
84
|
+
headers: headers,
|
85
|
+
headers_to_attributes: headers_to_attributes
|
86
|
+
)
|
87
|
+
)
|
88
|
+
self.rpc(
|
89
|
+
:CreateSIPOutboundTrunk,
|
90
|
+
request,
|
91
|
+
headers: auth_header(sip_grant: SIPGrant.new(admin: true)),
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
def list_sip_inbound_trunk
|
96
|
+
request = Proto::ListSIPInboundTrunkRequest.new
|
97
|
+
self.rpc(
|
98
|
+
:ListSIPInboundTrunk,
|
99
|
+
request,
|
100
|
+
headers: auth_header(sip_grant: SIPGrant.new(admin: true)),
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
def list_sip_outbound_trunk
|
105
|
+
request = Proto::ListSIPOutboundTrunkRequest.new
|
106
|
+
self.rpc(
|
107
|
+
:ListSIPOutboundTrunk,
|
108
|
+
request,
|
109
|
+
headers: auth_header(sip_grant: SIPGrant.new(admin: true)),
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
def delete_sip_trunk(sip_trunk_id)
|
114
|
+
request = Proto::DeleteSIPTrunkRequest.new(
|
115
|
+
sip_trunk_id: sip_trunk_id,
|
116
|
+
)
|
117
|
+
self.rpc(
|
118
|
+
:DeleteSIPTrunk,
|
119
|
+
request,
|
120
|
+
headers: auth_header(sip_grant: SIPGrant.new(admin: true)),
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
def create_sip_dispatch_rule(
|
125
|
+
rule,
|
126
|
+
name: nil,
|
127
|
+
trunk_ids: nil,
|
128
|
+
inbound_numbers: nil,
|
129
|
+
hide_phone_number: nil,
|
130
|
+
metadata: nil,
|
131
|
+
attributes: nil
|
132
|
+
)
|
133
|
+
request = Proto::CreateSIPDispatchRuleRequest.new(
|
134
|
+
rule: rule,
|
135
|
+
name: name,
|
136
|
+
trunk_ids: trunk_ids,
|
137
|
+
inbound_numbers: inbound_numbers,
|
138
|
+
hide_phone_number: hide_phone_number,
|
139
|
+
metadata: metadata,
|
140
|
+
attributes: attributes,
|
141
|
+
)
|
142
|
+
self.rpc(
|
143
|
+
:CreateSIPDispatchRule,
|
144
|
+
request,
|
145
|
+
headers: auth_header(sip_grant: SIPGrant.new(admin: true)),
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
def list_sip_dispatch_rule
|
150
|
+
request = Proto::ListSIPDispatchRuleRequest.new
|
151
|
+
self.rpc(
|
152
|
+
:ListSIPDispatchRule,
|
153
|
+
request,
|
154
|
+
headers: auth_header(sip_grant: SIPGrant.new(admin: true)),
|
155
|
+
)
|
156
|
+
end
|
157
|
+
|
158
|
+
def delete_sip_dispatch_rule(sip_dispatch_rule_id)
|
159
|
+
request = Proto::DeleteSIPDispatchRuleRequest.new(
|
160
|
+
sip_dispatch_rule_id: sip_dispatch_rule_id,
|
161
|
+
)
|
162
|
+
self.rpc(
|
163
|
+
:DeleteSIPDispatchRule,
|
164
|
+
request,
|
165
|
+
headers: auth_header(sip_grant: SIPGrant.new(admin: true)),
|
166
|
+
)
|
167
|
+
end
|
168
|
+
|
169
|
+
def create_sip_participant(
|
170
|
+
sip_trunk_id,
|
171
|
+
sip_call_to,
|
172
|
+
room_name,
|
173
|
+
participant_identity: nil,
|
174
|
+
participant_name: nil,
|
175
|
+
participant_metadata: nil,
|
176
|
+
dtmf: nil,
|
177
|
+
play_ringtone: nil, # deprecated, use play_dialtone
|
178
|
+
play_dialtone: nil,
|
179
|
+
hide_phone_number: nil
|
180
|
+
)
|
181
|
+
|
182
|
+
if (play_ringtone == true || play_dialtone == true)
|
183
|
+
play_dialtone = true
|
184
|
+
play_ringtone = true
|
185
|
+
end
|
186
|
+
|
187
|
+
request = Proto::CreateSIPParticipantRequest.new(
|
188
|
+
sip_trunk_id: sip_trunk_id,
|
189
|
+
sip_call_to: sip_call_to,
|
190
|
+
room_name: room_name,
|
191
|
+
participant_identity: participant_identity,
|
192
|
+
participant_name: participant_name,
|
193
|
+
participant_metadata: participant_metadata,
|
194
|
+
dtmf: dtmf,
|
195
|
+
play_ringtone: play_ringtone,
|
196
|
+
play_dialtone: play_dialtone,
|
197
|
+
hide_phone_number: hide_phone_number,
|
198
|
+
)
|
199
|
+
self.rpc(
|
200
|
+
:CreateSIPParticipant,
|
201
|
+
request,
|
202
|
+
headers: auth_header(sip_grant: SIPGrant.new(call: true)),
|
203
|
+
)
|
204
|
+
end
|
205
|
+
|
206
|
+
def transfer_sip_participant(
|
207
|
+
room_name,
|
208
|
+
participant_identity,
|
209
|
+
transfer_to,
|
210
|
+
play_dialtone: nil
|
211
|
+
)
|
212
|
+
|
213
|
+
request = Proto::TransferSIPParticipantRequest.new(
|
214
|
+
room_name: room_name,
|
215
|
+
participant_identity: participant_identity,
|
216
|
+
transfer_to: transfer_to,
|
217
|
+
play_dialtone: play_dialtone,
|
218
|
+
)
|
219
|
+
self.rpc(
|
220
|
+
:TransferSIPParticipant,
|
221
|
+
request,
|
222
|
+
headers: auth_header(video_grant: VideoGrant.new(roomAdmin: true, room: room_name), sip_grant: SIPGrant.new(call: true)),
|
223
|
+
)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
data/lib/livekit/version.rb
CHANGED
data/lib/livekit.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livekit-server-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omri Gabay
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-protobuf
|
@@ -133,10 +133,16 @@ files:
|
|
133
133
|
- lib/livekit/egress_service_client.rb
|
134
134
|
- lib/livekit/grants.rb
|
135
135
|
- lib/livekit/ingress_service_client.rb
|
136
|
+
- lib/livekit/proto/livekit_agent_dispatch_pb.rb
|
137
|
+
- lib/livekit/proto/livekit_agent_dispatch_twirp.rb
|
138
|
+
- lib/livekit/proto/livekit_agent_pb.rb
|
139
|
+
- lib/livekit/proto/livekit_agent_twirp.rb
|
136
140
|
- lib/livekit/proto/livekit_egress_pb.rb
|
137
141
|
- lib/livekit/proto/livekit_egress_twirp.rb
|
138
142
|
- lib/livekit/proto/livekit_ingress_pb.rb
|
139
143
|
- lib/livekit/proto/livekit_ingress_twirp.rb
|
144
|
+
- lib/livekit/proto/livekit_metrics_pb.rb
|
145
|
+
- lib/livekit/proto/livekit_metrics_twirp.rb
|
140
146
|
- lib/livekit/proto/livekit_models_pb.rb
|
141
147
|
- lib/livekit/proto/livekit_models_twirp.rb
|
142
148
|
- lib/livekit/proto/livekit_room_pb.rb
|
@@ -146,6 +152,7 @@ files:
|
|
146
152
|
- lib/livekit/proto/livekit_webhook_pb.rb
|
147
153
|
- lib/livekit/proto/livekit_webhook_twirp.rb
|
148
154
|
- lib/livekit/room_service_client.rb
|
155
|
+
- lib/livekit/sip_service_client.rb
|
149
156
|
- lib/livekit/token_verifier.rb
|
150
157
|
- lib/livekit/utils.rb
|
151
158
|
- lib/livekit/version.rb
|