livekit-server-sdk 2.8.1 → 2.9.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.
- package/README.md +1 -1
- package/dist/AccessToken.cjs +169 -0
- package/dist/AccessToken.cjs.map +1 -0
- package/dist/AccessToken.d.ts.map +1 -1
- package/dist/AccessToken.js +130 -137
- package/dist/AccessToken.js.map +1 -1
- package/dist/AccessToken.test.cjs +147 -0
- package/dist/AccessToken.test.cjs.map +1 -0
- package/dist/AccessToken.test.js +129 -0
- package/dist/AccessToken.test.js.map +1 -0
- package/dist/AgentDispatchClient.cjs +133 -0
- package/dist/AgentDispatchClient.cjs.map +1 -0
- package/dist/AgentDispatchClient.js +102 -79
- package/dist/AgentDispatchClient.js.map +1 -1
- package/dist/EgressClient.cjs +381 -0
- package/dist/EgressClient.cjs.map +1 -0
- package/dist/EgressClient.js +349 -288
- package/dist/EgressClient.js.map +1 -1
- package/dist/IngressClient.cjs +164 -0
- package/dist/IngressClient.cjs.map +1 -0
- package/dist/IngressClient.js +131 -106
- package/dist/IngressClient.js.map +1 -1
- package/dist/RoomServiceClient.cjs +240 -0
- package/dist/RoomServiceClient.cjs.map +1 -0
- package/dist/RoomServiceClient.js +219 -151
- package/dist/RoomServiceClient.js.map +1 -1
- package/dist/ServiceBase.cjs +49 -0
- package/dist/ServiceBase.cjs.map +1 -0
- package/dist/ServiceBase.js +25 -28
- package/dist/ServiceBase.js.map +1 -1
- package/dist/SipClient.cjs +379 -0
- package/dist/SipClient.cjs.map +1 -0
- package/dist/SipClient.d.ts +15 -0
- package/dist/SipClient.d.ts.map +1 -1
- package/dist/SipClient.js +360 -260
- package/dist/SipClient.js.map +1 -1
- package/dist/TwirpRPC.cjs +71 -0
- package/dist/TwirpRPC.cjs.map +1 -0
- package/dist/TwirpRPC.d.ts.map +1 -1
- package/dist/TwirpRPC.js +32 -29
- package/dist/TwirpRPC.js.map +1 -1
- package/dist/WebhookReceiver.cjs +78 -0
- package/dist/WebhookReceiver.cjs.map +1 -0
- package/dist/WebhookReceiver.js +48 -45
- package/dist/WebhookReceiver.js.map +1 -1
- package/dist/WebhookReceiver.test.cjs +38 -0
- package/dist/WebhookReceiver.test.cjs.map +1 -0
- package/dist/WebhookReceiver.test.js +37 -0
- package/dist/WebhookReceiver.test.js.map +1 -0
- package/dist/grants.cjs +53 -0
- package/dist/grants.cjs.map +1 -0
- package/dist/grants.js +25 -23
- package/dist/grants.js.map +1 -1
- package/dist/grants.test.cjs +27 -0
- package/dist/grants.test.cjs.map +1 -0
- package/dist/grants.test.js +26 -0
- package/dist/grants.test.js.map +1 -0
- package/dist/index.cjs +136 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +104 -12
- package/dist/index.js.map +1 -1
- package/package.json +12 -3
- package/src/AccessToken.ts +3 -1
- package/src/SipClient.ts +33 -0
- package/src/TwirpRPC.ts +2 -2
package/dist/EgressClient.js
CHANGED
|
@@ -1,298 +1,359 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import {
|
|
2
|
+
EgressInfo,
|
|
3
|
+
ListEgressRequest,
|
|
4
|
+
ListEgressResponse,
|
|
5
|
+
ParticipantEgressRequest,
|
|
6
|
+
RoomCompositeEgressRequest,
|
|
7
|
+
StopEgressRequest,
|
|
8
|
+
TrackCompositeEgressRequest,
|
|
9
|
+
TrackEgressRequest,
|
|
10
|
+
UpdateLayoutRequest,
|
|
11
|
+
UpdateStreamRequest,
|
|
12
|
+
WebEgressRequest
|
|
13
|
+
} from "@livekit/protocol";
|
|
14
|
+
import ServiceBase from "./ServiceBase.js";
|
|
15
|
+
import { TwirpRpc, livekitPackage } from "./TwirpRPC.js";
|
|
16
|
+
const svc = "Egress";
|
|
17
|
+
class EgressClient extends ServiceBase {
|
|
18
|
+
/**
|
|
19
|
+
* @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
|
|
20
|
+
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
|
|
21
|
+
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
22
|
+
*/
|
|
23
|
+
constructor(host, apiKey, secret) {
|
|
24
|
+
super(apiKey, secret);
|
|
25
|
+
this.rpc = new TwirpRpc(host, livekitPackage);
|
|
26
|
+
}
|
|
27
|
+
async startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl) {
|
|
28
|
+
let layout;
|
|
29
|
+
if (optsOrLayout !== void 0) {
|
|
30
|
+
if (typeof optsOrLayout === "string") {
|
|
31
|
+
layout = optsOrLayout;
|
|
32
|
+
} else {
|
|
33
|
+
const opts = optsOrLayout;
|
|
34
|
+
layout = opts.layout;
|
|
35
|
+
options = opts.encodingOptions;
|
|
36
|
+
audioOnly = opts.audioOnly;
|
|
37
|
+
videoOnly = opts.videoOnly;
|
|
38
|
+
customBaseUrl = opts.customBaseUrl;
|
|
39
|
+
}
|
|
17
40
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
layout ??= "";
|
|
42
|
+
audioOnly ??= false;
|
|
43
|
+
videoOnly ??= false;
|
|
44
|
+
customBaseUrl ??= "";
|
|
45
|
+
const {
|
|
46
|
+
output: legacyOutput,
|
|
47
|
+
options: egressOptions,
|
|
48
|
+
fileOutputs,
|
|
49
|
+
streamOutputs,
|
|
50
|
+
segmentOutputs,
|
|
51
|
+
imageOutputs
|
|
52
|
+
} = this.getOutputParams(output, options);
|
|
53
|
+
const req = new RoomCompositeEgressRequest({
|
|
54
|
+
roomName,
|
|
55
|
+
layout,
|
|
56
|
+
audioOnly,
|
|
57
|
+
videoOnly,
|
|
58
|
+
customBaseUrl,
|
|
59
|
+
output: legacyOutput,
|
|
60
|
+
options: egressOptions,
|
|
61
|
+
fileOutputs,
|
|
62
|
+
streamOutputs,
|
|
63
|
+
segmentOutputs,
|
|
64
|
+
imageOutputs
|
|
65
|
+
}).toJson();
|
|
66
|
+
const data = await this.rpc.request(
|
|
67
|
+
svc,
|
|
68
|
+
"StartRoomCompositeEgress",
|
|
69
|
+
req,
|
|
70
|
+
await this.authHeader({ roomRecord: true })
|
|
71
|
+
);
|
|
72
|
+
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @param url - url
|
|
76
|
+
* @param output - file or stream output
|
|
77
|
+
* @param opts - WebOptions
|
|
78
|
+
*/
|
|
79
|
+
async startWebEgress(url, output, opts) {
|
|
80
|
+
const audioOnly = (opts == null ? void 0 : opts.audioOnly) || false;
|
|
81
|
+
const videoOnly = (opts == null ? void 0 : opts.videoOnly) || false;
|
|
82
|
+
const awaitStartSignal = (opts == null ? void 0 : opts.awaitStartSignal) || false;
|
|
83
|
+
const {
|
|
84
|
+
output: legacyOutput,
|
|
85
|
+
options,
|
|
86
|
+
fileOutputs,
|
|
87
|
+
streamOutputs,
|
|
88
|
+
segmentOutputs,
|
|
89
|
+
imageOutputs
|
|
90
|
+
} = this.getOutputParams(output, opts == null ? void 0 : opts.encodingOptions);
|
|
91
|
+
const req = new WebEgressRequest({
|
|
92
|
+
url,
|
|
93
|
+
audioOnly,
|
|
94
|
+
videoOnly,
|
|
95
|
+
awaitStartSignal,
|
|
96
|
+
output: legacyOutput,
|
|
97
|
+
options,
|
|
98
|
+
fileOutputs,
|
|
99
|
+
streamOutputs,
|
|
100
|
+
segmentOutputs,
|
|
101
|
+
imageOutputs
|
|
102
|
+
}).toJson();
|
|
103
|
+
const data = await this.rpc.request(
|
|
104
|
+
svc,
|
|
105
|
+
"StartWebEgress",
|
|
106
|
+
req,
|
|
107
|
+
await this.authHeader({ roomRecord: true })
|
|
108
|
+
);
|
|
109
|
+
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Export a participant's audio and video tracks,
|
|
113
|
+
*
|
|
114
|
+
* @param roomName - room name
|
|
115
|
+
* @param output - one or more outputs
|
|
116
|
+
* @param opts - ParticipantEgressOptions
|
|
117
|
+
*/
|
|
118
|
+
async startParticipantEgress(roomName, identity, output, opts) {
|
|
119
|
+
const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } = this.getOutputParams(output, opts == null ? void 0 : opts.encodingOptions);
|
|
120
|
+
const req = new ParticipantEgressRequest({
|
|
121
|
+
roomName,
|
|
122
|
+
identity,
|
|
123
|
+
options,
|
|
124
|
+
fileOutputs,
|
|
125
|
+
streamOutputs,
|
|
126
|
+
segmentOutputs,
|
|
127
|
+
imageOutputs
|
|
128
|
+
}).toJson();
|
|
129
|
+
const data = await this.rpc.request(
|
|
130
|
+
svc,
|
|
131
|
+
"StartParticipantEgress",
|
|
132
|
+
req,
|
|
133
|
+
await this.authHeader({ roomRecord: true })
|
|
134
|
+
);
|
|
135
|
+
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
136
|
+
}
|
|
137
|
+
async startTrackCompositeEgress(roomName, output, optsOrAudioTrackId, videoTrackId, options) {
|
|
138
|
+
let audioTrackId;
|
|
139
|
+
if (optsOrAudioTrackId !== void 0) {
|
|
140
|
+
if (typeof optsOrAudioTrackId === "string") {
|
|
141
|
+
audioTrackId = optsOrAudioTrackId;
|
|
142
|
+
} else {
|
|
143
|
+
const opts = optsOrAudioTrackId;
|
|
144
|
+
audioTrackId = opts.audioTrackId;
|
|
145
|
+
videoTrackId = opts.videoTrackId;
|
|
146
|
+
options = opts.encodingOptions;
|
|
147
|
+
}
|
|
53
148
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
149
|
+
audioTrackId ??= "";
|
|
150
|
+
videoTrackId ??= "";
|
|
151
|
+
const {
|
|
152
|
+
output: legacyOutput,
|
|
153
|
+
options: egressOptions,
|
|
154
|
+
fileOutputs,
|
|
155
|
+
streamOutputs,
|
|
156
|
+
segmentOutputs,
|
|
157
|
+
imageOutputs
|
|
158
|
+
} = this.getOutputParams(output, options);
|
|
159
|
+
const req = new TrackCompositeEgressRequest({
|
|
160
|
+
roomName,
|
|
161
|
+
audioTrackId,
|
|
162
|
+
videoTrackId,
|
|
163
|
+
output: legacyOutput,
|
|
164
|
+
options: egressOptions,
|
|
165
|
+
fileOutputs,
|
|
166
|
+
streamOutputs,
|
|
167
|
+
segmentOutputs,
|
|
168
|
+
imageOutputs
|
|
169
|
+
}).toJson();
|
|
170
|
+
const data = await this.rpc.request(
|
|
171
|
+
svc,
|
|
172
|
+
"StartTrackCompositeEgress",
|
|
173
|
+
req,
|
|
174
|
+
await this.authHeader({ roomRecord: true })
|
|
175
|
+
);
|
|
176
|
+
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
177
|
+
}
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
179
|
+
isEncodedOutputs(output) {
|
|
180
|
+
return output.file !== void 0 || output.stream !== void 0 || output.segments !== void 0 || output.images !== void 0;
|
|
181
|
+
}
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
|
+
isEncodedFileOutput(output) {
|
|
184
|
+
return output.filepath !== void 0 || output.fileType !== void 0;
|
|
185
|
+
}
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
187
|
+
isSegmentedFileOutput(output) {
|
|
188
|
+
return output.filenamePrefix !== void 0 || output.playlistName !== void 0 || output.filenameSuffix !== void 0;
|
|
189
|
+
}
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
191
|
+
isStreamOutput(output) {
|
|
192
|
+
return output.protocol !== void 0 || output.urls !== void 0;
|
|
193
|
+
}
|
|
194
|
+
getOutputParams(output, opts) {
|
|
195
|
+
let file;
|
|
196
|
+
let fileOutputs;
|
|
197
|
+
let stream;
|
|
198
|
+
let streamOutputs;
|
|
199
|
+
let segments;
|
|
200
|
+
let segmentOutputs;
|
|
201
|
+
let imageOutputs;
|
|
202
|
+
if (this.isEncodedOutputs(output)) {
|
|
203
|
+
if (output.file !== void 0) {
|
|
204
|
+
fileOutputs = [output.file];
|
|
205
|
+
}
|
|
206
|
+
if (output.stream !== void 0) {
|
|
207
|
+
streamOutputs = [output.stream];
|
|
208
|
+
}
|
|
209
|
+
if (output.segments !== void 0) {
|
|
210
|
+
segmentOutputs = [output.segments];
|
|
211
|
+
}
|
|
212
|
+
if (output.images !== void 0) {
|
|
213
|
+
imageOutputs = [output.images];
|
|
214
|
+
}
|
|
215
|
+
} else if (this.isEncodedFileOutput(output)) {
|
|
216
|
+
file = output;
|
|
217
|
+
fileOutputs = [file];
|
|
218
|
+
} else if (this.isSegmentedFileOutput(output)) {
|
|
219
|
+
segments = output;
|
|
220
|
+
segmentOutputs = [segments];
|
|
221
|
+
} else if (this.isStreamOutput(output)) {
|
|
222
|
+
stream = output;
|
|
223
|
+
streamOutputs = [stream];
|
|
78
224
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
imageOutputs,
|
|
96
|
-
}).toJson();
|
|
97
|
-
const data = await this.rpc.request(svc, 'StartParticipantEgress', req, await this.authHeader({ roomRecord: true }));
|
|
98
|
-
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
225
|
+
let legacyOutput;
|
|
226
|
+
if (file) {
|
|
227
|
+
legacyOutput = {
|
|
228
|
+
case: "file",
|
|
229
|
+
value: file
|
|
230
|
+
};
|
|
231
|
+
} else if (stream) {
|
|
232
|
+
legacyOutput = {
|
|
233
|
+
case: "stream",
|
|
234
|
+
value: stream
|
|
235
|
+
};
|
|
236
|
+
} else if (segments) {
|
|
237
|
+
legacyOutput = {
|
|
238
|
+
case: "segments",
|
|
239
|
+
value: segments
|
|
240
|
+
};
|
|
99
241
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
else {
|
|
107
|
-
const opts = optsOrAudioTrackId;
|
|
108
|
-
audioTrackId = opts.audioTrackId;
|
|
109
|
-
videoTrackId = opts.videoTrackId;
|
|
110
|
-
options = opts.encodingOptions;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
audioTrackId !== null && audioTrackId !== void 0 ? audioTrackId : (audioTrackId = '');
|
|
114
|
-
videoTrackId !== null && videoTrackId !== void 0 ? videoTrackId : (videoTrackId = '');
|
|
115
|
-
const { output: legacyOutput, options: egressOptions, fileOutputs, streamOutputs, segmentOutputs, imageOutputs, } = this.getOutputParams(output, options);
|
|
116
|
-
const req = new TrackCompositeEgressRequest({
|
|
117
|
-
roomName,
|
|
118
|
-
audioTrackId,
|
|
119
|
-
videoTrackId,
|
|
120
|
-
output: legacyOutput,
|
|
121
|
-
options: egressOptions,
|
|
122
|
-
fileOutputs,
|
|
123
|
-
streamOutputs,
|
|
124
|
-
segmentOutputs,
|
|
125
|
-
imageOutputs,
|
|
126
|
-
}).toJson();
|
|
127
|
-
const data = await this.rpc.request(svc, 'StartTrackCompositeEgress', req, await this.authHeader({ roomRecord: true }));
|
|
128
|
-
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
129
|
-
}
|
|
130
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
-
isEncodedOutputs(output) {
|
|
132
|
-
return (output.file !== undefined ||
|
|
133
|
-
output.stream !== undefined ||
|
|
134
|
-
output.segments !== undefined ||
|
|
135
|
-
output.images !== undefined);
|
|
136
|
-
}
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
-
isEncodedFileOutput(output) {
|
|
139
|
-
return (output.filepath !== undefined ||
|
|
140
|
-
output.fileType !== undefined);
|
|
141
|
-
}
|
|
142
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
143
|
-
isSegmentedFileOutput(output) {
|
|
144
|
-
return (output.filenamePrefix !== undefined ||
|
|
145
|
-
output.playlistName !== undefined ||
|
|
146
|
-
output.filenameSuffix !== undefined);
|
|
147
|
-
}
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
|
-
isStreamOutput(output) {
|
|
150
|
-
return (output.protocol !== undefined || output.urls !== undefined);
|
|
151
|
-
}
|
|
152
|
-
getOutputParams(output, opts) {
|
|
153
|
-
let file;
|
|
154
|
-
let fileOutputs;
|
|
155
|
-
let stream;
|
|
156
|
-
let streamOutputs;
|
|
157
|
-
let segments;
|
|
158
|
-
let segmentOutputs;
|
|
159
|
-
let imageOutputs;
|
|
160
|
-
if (this.isEncodedOutputs(output)) {
|
|
161
|
-
if (output.file !== undefined) {
|
|
162
|
-
fileOutputs = [output.file];
|
|
163
|
-
}
|
|
164
|
-
if (output.stream !== undefined) {
|
|
165
|
-
streamOutputs = [output.stream];
|
|
166
|
-
}
|
|
167
|
-
if (output.segments !== undefined) {
|
|
168
|
-
segmentOutputs = [output.segments];
|
|
169
|
-
}
|
|
170
|
-
if (output.images !== undefined) {
|
|
171
|
-
imageOutputs = [output.images];
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
else if (this.isEncodedFileOutput(output)) {
|
|
175
|
-
file = output;
|
|
176
|
-
fileOutputs = [file];
|
|
177
|
-
}
|
|
178
|
-
else if (this.isSegmentedFileOutput(output)) {
|
|
179
|
-
segments = output;
|
|
180
|
-
segmentOutputs = [segments];
|
|
181
|
-
}
|
|
182
|
-
else if (this.isStreamOutput(output)) {
|
|
183
|
-
stream = output;
|
|
184
|
-
streamOutputs = [stream];
|
|
185
|
-
}
|
|
186
|
-
let legacyOutput;
|
|
187
|
-
if (file) {
|
|
188
|
-
legacyOutput = {
|
|
189
|
-
case: 'file',
|
|
190
|
-
value: file,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
else if (stream) {
|
|
194
|
-
legacyOutput = {
|
|
195
|
-
case: 'stream',
|
|
196
|
-
value: stream,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
else if (segments) {
|
|
200
|
-
legacyOutput = {
|
|
201
|
-
case: 'segments',
|
|
202
|
-
value: segments,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
let egressOptions;
|
|
206
|
-
if (opts) {
|
|
207
|
-
if (typeof opts === 'number') {
|
|
208
|
-
egressOptions = {
|
|
209
|
-
case: 'preset',
|
|
210
|
-
value: opts,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
egressOptions = {
|
|
215
|
-
case: 'advanced',
|
|
216
|
-
value: opts,
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
output: legacyOutput,
|
|
222
|
-
options: egressOptions,
|
|
223
|
-
fileOutputs,
|
|
224
|
-
streamOutputs,
|
|
225
|
-
segmentOutputs,
|
|
226
|
-
imageOutputs,
|
|
242
|
+
let egressOptions;
|
|
243
|
+
if (opts) {
|
|
244
|
+
if (typeof opts === "number") {
|
|
245
|
+
egressOptions = {
|
|
246
|
+
case: "preset",
|
|
247
|
+
value: opts
|
|
227
248
|
};
|
|
249
|
+
} else {
|
|
250
|
+
egressOptions = {
|
|
251
|
+
case: "advanced",
|
|
252
|
+
value: opts
|
|
253
|
+
};
|
|
254
|
+
}
|
|
228
255
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* @param egressId -
|
|
258
|
-
* @param layout -
|
|
259
|
-
*/
|
|
260
|
-
async updateLayout(egressId, layout) {
|
|
261
|
-
const data = await this.rpc.request(svc, 'UpdateLayout', new UpdateLayoutRequest({ egressId, layout }).toJson(), await this.authHeader({ roomRecord: true }));
|
|
262
|
-
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* @param egressId -
|
|
266
|
-
* @param addOutputUrls -
|
|
267
|
-
* @param removeOutputUrls -
|
|
268
|
-
*/
|
|
269
|
-
async updateStream(egressId, addOutputUrls, removeOutputUrls) {
|
|
270
|
-
addOutputUrls !== null && addOutputUrls !== void 0 ? addOutputUrls : (addOutputUrls = []);
|
|
271
|
-
removeOutputUrls !== null && removeOutputUrls !== void 0 ? removeOutputUrls : (removeOutputUrls = []);
|
|
272
|
-
const data = await this.rpc.request(svc, 'UpdateStream', new UpdateStreamRequest({ egressId, addOutputUrls, removeOutputUrls }).toJson(), await this.authHeader({ roomRecord: true }));
|
|
273
|
-
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* @param roomName - list egress for one room only
|
|
277
|
-
*/
|
|
278
|
-
async listEgress(options) {
|
|
279
|
-
var _a;
|
|
280
|
-
let req = {};
|
|
281
|
-
if (typeof options === 'string') {
|
|
282
|
-
req.roomName = options;
|
|
283
|
-
}
|
|
284
|
-
else if (options !== undefined) {
|
|
285
|
-
req = options;
|
|
286
|
-
}
|
|
287
|
-
const data = await this.rpc.request(svc, 'ListEgress', new ListEgressRequest(req).toJson(), await this.authHeader({ roomRecord: true }));
|
|
288
|
-
return (_a = ListEgressResponse.fromJson(data, { ignoreUnknownFields: true }).items) !== null && _a !== void 0 ? _a : [];
|
|
256
|
+
return {
|
|
257
|
+
output: legacyOutput,
|
|
258
|
+
options: egressOptions,
|
|
259
|
+
fileOutputs,
|
|
260
|
+
streamOutputs,
|
|
261
|
+
segmentOutputs,
|
|
262
|
+
imageOutputs
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* @param roomName - room name
|
|
267
|
+
* @param output - file or websocket output
|
|
268
|
+
* @param trackId - track Id
|
|
269
|
+
*/
|
|
270
|
+
async startTrackEgress(roomName, output, trackId) {
|
|
271
|
+
let legacyOutput;
|
|
272
|
+
if (typeof output === "string") {
|
|
273
|
+
legacyOutput = {
|
|
274
|
+
case: "websocketUrl",
|
|
275
|
+
value: output
|
|
276
|
+
};
|
|
277
|
+
} else {
|
|
278
|
+
legacyOutput = {
|
|
279
|
+
case: "file",
|
|
280
|
+
value: output
|
|
281
|
+
};
|
|
289
282
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
283
|
+
const req = new TrackEgressRequest({
|
|
284
|
+
roomName,
|
|
285
|
+
trackId,
|
|
286
|
+
output: legacyOutput
|
|
287
|
+
}).toJson();
|
|
288
|
+
const data = await this.rpc.request(
|
|
289
|
+
svc,
|
|
290
|
+
"StartTrackEgress",
|
|
291
|
+
req,
|
|
292
|
+
await this.authHeader({ roomRecord: true })
|
|
293
|
+
);
|
|
294
|
+
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* @param egressId -
|
|
298
|
+
* @param layout -
|
|
299
|
+
*/
|
|
300
|
+
async updateLayout(egressId, layout) {
|
|
301
|
+
const data = await this.rpc.request(
|
|
302
|
+
svc,
|
|
303
|
+
"UpdateLayout",
|
|
304
|
+
new UpdateLayoutRequest({ egressId, layout }).toJson(),
|
|
305
|
+
await this.authHeader({ roomRecord: true })
|
|
306
|
+
);
|
|
307
|
+
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* @param egressId -
|
|
311
|
+
* @param addOutputUrls -
|
|
312
|
+
* @param removeOutputUrls -
|
|
313
|
+
*/
|
|
314
|
+
async updateStream(egressId, addOutputUrls, removeOutputUrls) {
|
|
315
|
+
addOutputUrls ??= [];
|
|
316
|
+
removeOutputUrls ??= [];
|
|
317
|
+
const data = await this.rpc.request(
|
|
318
|
+
svc,
|
|
319
|
+
"UpdateStream",
|
|
320
|
+
new UpdateStreamRequest({ egressId, addOutputUrls, removeOutputUrls }).toJson(),
|
|
321
|
+
await this.authHeader({ roomRecord: true })
|
|
322
|
+
);
|
|
323
|
+
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* @param roomName - list egress for one room only
|
|
327
|
+
*/
|
|
328
|
+
async listEgress(options) {
|
|
329
|
+
let req = {};
|
|
330
|
+
if (typeof options === "string") {
|
|
331
|
+
req.roomName = options;
|
|
332
|
+
} else if (options !== void 0) {
|
|
333
|
+
req = options;
|
|
296
334
|
}
|
|
335
|
+
const data = await this.rpc.request(
|
|
336
|
+
svc,
|
|
337
|
+
"ListEgress",
|
|
338
|
+
new ListEgressRequest(req).toJson(),
|
|
339
|
+
await this.authHeader({ roomRecord: true })
|
|
340
|
+
);
|
|
341
|
+
return ListEgressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* @param egressId -
|
|
345
|
+
*/
|
|
346
|
+
async stopEgress(egressId) {
|
|
347
|
+
const data = await this.rpc.request(
|
|
348
|
+
svc,
|
|
349
|
+
"StopEgress",
|
|
350
|
+
new StopEgressRequest({ egressId }).toJson(),
|
|
351
|
+
await this.authHeader({ roomRecord: true })
|
|
352
|
+
);
|
|
353
|
+
return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
354
|
+
}
|
|
297
355
|
}
|
|
356
|
+
export {
|
|
357
|
+
EgressClient
|
|
358
|
+
};
|
|
298
359
|
//# sourceMappingURL=EgressClient.js.map
|