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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/AccessToken.cjs +169 -0
  3. package/dist/AccessToken.cjs.map +1 -0
  4. package/dist/AccessToken.d.ts.map +1 -1
  5. package/dist/AccessToken.js +130 -137
  6. package/dist/AccessToken.js.map +1 -1
  7. package/dist/AccessToken.test.cjs +147 -0
  8. package/dist/AccessToken.test.cjs.map +1 -0
  9. package/dist/AccessToken.test.js +129 -0
  10. package/dist/AccessToken.test.js.map +1 -0
  11. package/dist/AgentDispatchClient.cjs +133 -0
  12. package/dist/AgentDispatchClient.cjs.map +1 -0
  13. package/dist/AgentDispatchClient.js +102 -79
  14. package/dist/AgentDispatchClient.js.map +1 -1
  15. package/dist/EgressClient.cjs +381 -0
  16. package/dist/EgressClient.cjs.map +1 -0
  17. package/dist/EgressClient.js +349 -288
  18. package/dist/EgressClient.js.map +1 -1
  19. package/dist/IngressClient.cjs +164 -0
  20. package/dist/IngressClient.cjs.map +1 -0
  21. package/dist/IngressClient.js +131 -106
  22. package/dist/IngressClient.js.map +1 -1
  23. package/dist/RoomServiceClient.cjs +240 -0
  24. package/dist/RoomServiceClient.cjs.map +1 -0
  25. package/dist/RoomServiceClient.js +219 -151
  26. package/dist/RoomServiceClient.js.map +1 -1
  27. package/dist/ServiceBase.cjs +49 -0
  28. package/dist/ServiceBase.cjs.map +1 -0
  29. package/dist/ServiceBase.js +25 -28
  30. package/dist/ServiceBase.js.map +1 -1
  31. package/dist/SipClient.cjs +379 -0
  32. package/dist/SipClient.cjs.map +1 -0
  33. package/dist/SipClient.d.ts +15 -0
  34. package/dist/SipClient.d.ts.map +1 -1
  35. package/dist/SipClient.js +360 -260
  36. package/dist/SipClient.js.map +1 -1
  37. package/dist/TwirpRPC.cjs +71 -0
  38. package/dist/TwirpRPC.cjs.map +1 -0
  39. package/dist/TwirpRPC.d.ts.map +1 -1
  40. package/dist/TwirpRPC.js +32 -29
  41. package/dist/TwirpRPC.js.map +1 -1
  42. package/dist/WebhookReceiver.cjs +78 -0
  43. package/dist/WebhookReceiver.cjs.map +1 -0
  44. package/dist/WebhookReceiver.js +48 -45
  45. package/dist/WebhookReceiver.js.map +1 -1
  46. package/dist/WebhookReceiver.test.cjs +38 -0
  47. package/dist/WebhookReceiver.test.cjs.map +1 -0
  48. package/dist/WebhookReceiver.test.js +37 -0
  49. package/dist/WebhookReceiver.test.js.map +1 -0
  50. package/dist/grants.cjs +53 -0
  51. package/dist/grants.cjs.map +1 -0
  52. package/dist/grants.js +25 -23
  53. package/dist/grants.js.map +1 -1
  54. package/dist/grants.test.cjs +27 -0
  55. package/dist/grants.test.cjs.map +1 -0
  56. package/dist/grants.test.js +26 -0
  57. package/dist/grants.test.js.map +1 -0
  58. package/dist/index.cjs +136 -0
  59. package/dist/index.cjs.map +1 -0
  60. package/dist/index.js +104 -12
  61. package/dist/index.js.map +1 -1
  62. package/package.json +12 -3
  63. package/src/AccessToken.ts +3 -1
  64. package/src/SipClient.ts +33 -0
  65. package/src/TwirpRPC.ts +2 -2
@@ -1,298 +1,359 @@
1
- import { EgressInfo, ListEgressRequest, ListEgressResponse, ParticipantEgressRequest, RoomCompositeEgressRequest, StopEgressRequest, TrackCompositeEgressRequest, TrackEgressRequest, UpdateLayoutRequest, UpdateStreamRequest, WebEgressRequest, } from '@livekit/protocol';
2
- import ServiceBase from './ServiceBase.js';
3
- import { TwirpRpc, livekitPackage } from './TwirpRPC.js';
4
- const svc = 'Egress';
5
- /**
6
- * Client to access Egress APIs
7
- */
8
- export class EgressClient extends ServiceBase {
9
- /**
10
- * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
11
- * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
12
- * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
13
- */
14
- constructor(host, apiKey, secret) {
15
- super(apiKey, secret);
16
- this.rpc = new TwirpRpc(host, livekitPackage);
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
- async startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl) {
19
- let layout;
20
- if (optsOrLayout !== undefined) {
21
- if (typeof optsOrLayout === 'string') {
22
- layout = optsOrLayout;
23
- }
24
- else {
25
- const opts = optsOrLayout;
26
- layout = opts.layout;
27
- options = opts.encodingOptions;
28
- audioOnly = opts.audioOnly;
29
- videoOnly = opts.videoOnly;
30
- customBaseUrl = opts.customBaseUrl;
31
- }
32
- }
33
- layout !== null && layout !== void 0 ? layout : (layout = '');
34
- audioOnly !== null && audioOnly !== void 0 ? audioOnly : (audioOnly = false);
35
- videoOnly !== null && videoOnly !== void 0 ? videoOnly : (videoOnly = false);
36
- customBaseUrl !== null && customBaseUrl !== void 0 ? customBaseUrl : (customBaseUrl = '');
37
- const { output: legacyOutput, options: egressOptions, fileOutputs, streamOutputs, segmentOutputs, imageOutputs, } = this.getOutputParams(output, options);
38
- const req = new RoomCompositeEgressRequest({
39
- roomName,
40
- layout,
41
- audioOnly,
42
- videoOnly,
43
- customBaseUrl,
44
- output: legacyOutput,
45
- options: egressOptions,
46
- fileOutputs,
47
- streamOutputs,
48
- segmentOutputs,
49
- imageOutputs,
50
- }).toJson();
51
- const data = await this.rpc.request(svc, 'StartRoomCompositeEgress', req, await this.authHeader({ roomRecord: true }));
52
- return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
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
- * @param url - url
56
- * @param output - file or stream output
57
- * @param opts - WebOptions
58
- */
59
- async startWebEgress(url, output, opts) {
60
- const audioOnly = (opts === null || opts === void 0 ? void 0 : opts.audioOnly) || false;
61
- const videoOnly = (opts === null || opts === void 0 ? void 0 : opts.videoOnly) || false;
62
- const awaitStartSignal = (opts === null || opts === void 0 ? void 0 : opts.awaitStartSignal) || false;
63
- const { output: legacyOutput, options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs, } = this.getOutputParams(output, opts === null || opts === void 0 ? void 0 : opts.encodingOptions);
64
- const req = new WebEgressRequest({
65
- url,
66
- audioOnly,
67
- videoOnly,
68
- awaitStartSignal,
69
- output: legacyOutput,
70
- options,
71
- fileOutputs,
72
- streamOutputs,
73
- segmentOutputs,
74
- imageOutputs,
75
- }).toJson();
76
- const data = await this.rpc.request(svc, 'StartWebEgress', req, await this.authHeader({ roomRecord: true }));
77
- return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
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
- * Export a participant's audio and video tracks,
81
- *
82
- * @param roomName - room name
83
- * @param output - one or more outputs
84
- * @param opts - ParticipantEgressOptions
85
- */
86
- async startParticipantEgress(roomName, identity, output, opts) {
87
- const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } = this.getOutputParams(output, opts === null || opts === void 0 ? void 0 : opts.encodingOptions);
88
- const req = new ParticipantEgressRequest({
89
- roomName,
90
- identity,
91
- options,
92
- fileOutputs,
93
- streamOutputs,
94
- segmentOutputs,
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
- async startTrackCompositeEgress(roomName, output, optsOrAudioTrackId, videoTrackId, options) {
101
- let audioTrackId;
102
- if (optsOrAudioTrackId !== undefined) {
103
- if (typeof optsOrAudioTrackId === 'string') {
104
- audioTrackId = optsOrAudioTrackId;
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
- * @param roomName - room name
231
- * @param output - file or websocket output
232
- * @param trackId - track Id
233
- */
234
- async startTrackEgress(roomName, output, trackId) {
235
- let legacyOutput;
236
- if (typeof output === 'string') {
237
- legacyOutput = {
238
- case: 'websocketUrl',
239
- value: output,
240
- };
241
- }
242
- else {
243
- legacyOutput = {
244
- case: 'file',
245
- value: output,
246
- };
247
- }
248
- const req = new TrackEgressRequest({
249
- roomName,
250
- trackId,
251
- output: legacyOutput,
252
- }).toJson();
253
- const data = await this.rpc.request(svc, 'StartTrackEgress', req, await this.authHeader({ roomRecord: true }));
254
- return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
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
- * @param egressId -
292
- */
293
- async stopEgress(egressId) {
294
- const data = await this.rpc.request(svc, 'StopEgress', new StopEgressRequest({ egressId }).toJson(), await this.authHeader({ roomRecord: true }));
295
- return EgressInfo.fromJson(data, { ignoreUnknownFields: true });
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