livekit-server-sdk 2.8.0 → 2.9.0
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.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.d.ts +1 -1
- package/dist/AgentDispatchClient.d.ts.map +1 -1
- 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/AgentDispatchClient.ts +2 -2
- package/src/SipClient.ts +33 -0
- package/src/TwirpRPC.ts +1 -1
|
@@ -1,82 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
import {
|
|
2
|
+
AgentDispatch,
|
|
3
|
+
CreateAgentDispatchRequest,
|
|
4
|
+
DeleteAgentDispatchRequest,
|
|
5
|
+
ListAgentDispatchRequest,
|
|
6
|
+
ListAgentDispatchResponse
|
|
7
|
+
} from "@livekit/protocol";
|
|
8
|
+
import ServiceBase from "./ServiceBase.js";
|
|
9
|
+
import { TwirpRpc, livekitPackage } from "./TwirpRPC.js";
|
|
10
|
+
const svc = "AgentDispatchService";
|
|
11
|
+
class AgentDispatchClient extends ServiceBase {
|
|
12
|
+
/**
|
|
13
|
+
* @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
|
|
14
|
+
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
|
|
15
|
+
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
16
|
+
*/
|
|
17
|
+
constructor(host, apiKey, secret) {
|
|
18
|
+
super(apiKey, secret);
|
|
19
|
+
this.rpc = new TwirpRpc(host, livekitPackage);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create an explicit dispatch for an agent to join a room. To use explicit
|
|
23
|
+
* dispatch, your agent must be registered with an `agentName`.
|
|
24
|
+
* @param roomName - name of the room to dispatch to
|
|
25
|
+
* @param agentName - name of the agent to dispatch
|
|
26
|
+
* @param options - optional metadata to send along with the dispatch
|
|
27
|
+
* @returns the dispatch that was created
|
|
28
|
+
*/
|
|
29
|
+
async createDispatch(roomName, agentName, options) {
|
|
30
|
+
const req = new CreateAgentDispatchRequest({
|
|
31
|
+
room: roomName,
|
|
32
|
+
agentName,
|
|
33
|
+
metadata: options == null ? void 0 : options.metadata
|
|
34
|
+
}).toJson();
|
|
35
|
+
const data = await this.rpc.request(
|
|
36
|
+
svc,
|
|
37
|
+
"CreateDispatch",
|
|
38
|
+
req,
|
|
39
|
+
await this.authHeader({ roomAdmin: true, room: roomName })
|
|
40
|
+
);
|
|
41
|
+
return AgentDispatch.fromJson(data, { ignoreUnknownFields: true });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Delete an explicit dispatch for an agent in a room.
|
|
45
|
+
* @param dispatchId - id of the dispatch to delete
|
|
46
|
+
* @param roomName - name of the room the dispatch is for
|
|
47
|
+
*/
|
|
48
|
+
async deleteDispatch(dispatchId, roomName) {
|
|
49
|
+
const req = new DeleteAgentDispatchRequest({
|
|
50
|
+
dispatchId,
|
|
51
|
+
room: roomName
|
|
52
|
+
}).toJson();
|
|
53
|
+
await this.rpc.request(
|
|
54
|
+
svc,
|
|
55
|
+
"DeleteDispatch",
|
|
56
|
+
req,
|
|
57
|
+
await this.authHeader({ roomAdmin: true, room: roomName })
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get an Agent dispatch by ID
|
|
62
|
+
* @param dispatchId - id of the dispatch to get
|
|
63
|
+
* @param roomName - name of the room the dispatch is for
|
|
64
|
+
* @returns the dispatch that was found, or undefined if not found
|
|
65
|
+
*/
|
|
66
|
+
async getDispatch(dispatchId, roomName) {
|
|
67
|
+
const req = new ListAgentDispatchRequest({
|
|
68
|
+
dispatchId,
|
|
69
|
+
room: roomName
|
|
70
|
+
}).toJson();
|
|
71
|
+
const data = await this.rpc.request(
|
|
72
|
+
svc,
|
|
73
|
+
"ListDispatch",
|
|
74
|
+
req,
|
|
75
|
+
await this.authHeader({ roomAdmin: true, room: roomName })
|
|
76
|
+
);
|
|
77
|
+
const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });
|
|
78
|
+
if (res.agentDispatches.length === 0) {
|
|
79
|
+
return void 0;
|
|
80
80
|
}
|
|
81
|
+
return res.agentDispatches[0];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* List all agent dispatches for a room
|
|
85
|
+
* @param roomName - name of the room to list dispatches for
|
|
86
|
+
* @returns the list of dispatches
|
|
87
|
+
*/
|
|
88
|
+
async listDispatch(roomName) {
|
|
89
|
+
const req = new ListAgentDispatchRequest({
|
|
90
|
+
room: roomName
|
|
91
|
+
}).toJson();
|
|
92
|
+
const data = await this.rpc.request(
|
|
93
|
+
svc,
|
|
94
|
+
"ListDispatch",
|
|
95
|
+
req,
|
|
96
|
+
await this.authHeader({ roomAdmin: true, room: roomName })
|
|
97
|
+
);
|
|
98
|
+
const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });
|
|
99
|
+
return res.agentDispatches;
|
|
100
|
+
}
|
|
81
101
|
}
|
|
102
|
+
export {
|
|
103
|
+
AgentDispatchClient
|
|
104
|
+
};
|
|
82
105
|
//# sourceMappingURL=AgentDispatchClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/AgentDispatchClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport {\n AgentDispatch,\n CreateAgentDispatchRequest,\n DeleteAgentDispatchRequest,\n ListAgentDispatchRequest,\n ListAgentDispatchResponse,\n} from '@livekit/protocol';\nimport ServiceBase from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\ninterface CreateDispatchOptions {\n // any custom data to send along with the job.\n // note: this is different from room and participant metadata\n metadata?: string;\n}\n\nconst svc = 'AgentDispatchService';\n\n/**\n * Client to access Agent APIs\n */\nexport class AgentDispatchClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n */\n constructor(host: string, apiKey?: string, secret?: string) {\n super(apiKey, secret);\n this.rpc = new TwirpRpc(host, livekitPackage);\n }\n\n /**\n * Create an explicit dispatch for an agent to join a room. To use explicit\n * dispatch, your agent must be registered with an `agentName`.\n * @param roomName - name of the room to dispatch to\n * @param agentName - name of the agent to dispatch\n * @param options - optional metadata to send along with the dispatch\n * @returns the dispatch that was created\n */\n async createDispatch(\n roomName: string,\n agentName: string,\n options?: CreateDispatchOptions,\n ): Promise<AgentDispatch> {\n const req = new CreateAgentDispatchRequest({\n room: roomName,\n agentName,\n metadata: options?.metadata,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'CreateDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n return AgentDispatch.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Delete an explicit dispatch for an agent in a room.\n * @param dispatchId - id of the dispatch to delete\n * @param roomName - name of the room the dispatch is for\n */\n async deleteDispatch(dispatchId: string, roomName: string): Promise<void> {\n const req = new DeleteAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n await this.rpc.request(\n svc,\n 'DeleteDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n }\n\n /**\n * Get an Agent dispatch by ID\n * @param dispatchId - id of the dispatch to get\n * @param roomName - name of the room the dispatch is for\n * @returns the dispatch that was found, or undefined if not found\n */\n async getDispatch(dispatchId: string, roomName: string): Promise<AgentDispatch | undefined> {\n const req = new ListAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n if (res.agentDispatches.length === 0) {\n return undefined;\n }\n return res.agentDispatches[0];\n }\n\n /**\n * List all agent dispatches for a room\n * @param roomName - name of the room to list dispatches for\n * @returns the list of dispatches\n */\n async listDispatch(roomName: string): Promise<AgentDispatch[]> {\n const req = new ListAgentDispatchRequest({\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.agentDispatches;\n }\n}\n"],"mappings":"AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,iBAAiB;AACxB,SAAmB,UAAU,sBAAsB;AAQnD,MAAM,MAAM;AAKL,MAAM,4BAA4B,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnD,YAAY,MAAc,QAAiB,QAAiB;AAC1D,UAAM,QAAQ,MAAM;AACpB,SAAK,MAAM,IAAI,SAAS,MAAM,cAAc;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,eACJ,UACA,WACA,SACwB;AACxB,UAAM,MAAM,IAAI,2BAA2B;AAAA,MACzC,MAAM;AAAA,MACN;AAAA,MACA,UAAU,mCAAS;AAAA,IACrB,CAAC,EAAE,OAAO;AACV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,MAAM,SAAS,CAAC;AAAA,IAC3D;AACA,WAAO,cAAc,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,eAAe,YAAoB,UAAiC;AACxE,UAAM,MAAM,IAAI,2BAA2B;AAAA,MACzC;AAAA,MACA,MAAM;AAAA,IACR,CAAC,EAAE,OAAO;AACV,UAAM,KAAK,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,MAAM,SAAS,CAAC;AAAA,IAC3D;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,YAAY,YAAoB,UAAsD;AAC1F,UAAM,MAAM,IAAI,yBAAyB;AAAA,MACvC;AAAA,MACA,MAAM;AAAA,IACR,CAAC,EAAE,OAAO;AACV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,MAAM,SAAS,CAAC;AAAA,IAC3D;AACA,UAAM,MAAM,0BAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAClF,QAAI,IAAI,gBAAgB,WAAW,GAAG;AACpC,aAAO;AAAA,IACT;AACA,WAAO,IAAI,gBAAgB,CAAC;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,UAA4C;AAC7D,UAAM,MAAM,IAAI,yBAAyB;AAAA,MACvC,MAAM;AAAA,IACR,CAAC,EAAE,OAAO;AACV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,MAAM,SAAS,CAAC;AAAA,IAC3D;AACA,UAAM,MAAM,0BAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAClF,WAAO,IAAI;AAAA,EACb;AACF;","names":[]}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var EgressClient_exports = {};
|
|
30
|
+
__export(EgressClient_exports, {
|
|
31
|
+
EgressClient: () => EgressClient
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(EgressClient_exports);
|
|
34
|
+
var import_protocol = require("@livekit/protocol");
|
|
35
|
+
var import_ServiceBase = __toESM(require("./ServiceBase.cjs"), 1);
|
|
36
|
+
var import_TwirpRPC = require("./TwirpRPC.cjs");
|
|
37
|
+
const svc = "Egress";
|
|
38
|
+
class EgressClient extends import_ServiceBase.default {
|
|
39
|
+
/**
|
|
40
|
+
* @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
|
|
41
|
+
* @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
|
|
42
|
+
* @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
43
|
+
*/
|
|
44
|
+
constructor(host, apiKey, secret) {
|
|
45
|
+
super(apiKey, secret);
|
|
46
|
+
this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage);
|
|
47
|
+
}
|
|
48
|
+
async startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl) {
|
|
49
|
+
let layout;
|
|
50
|
+
if (optsOrLayout !== void 0) {
|
|
51
|
+
if (typeof optsOrLayout === "string") {
|
|
52
|
+
layout = optsOrLayout;
|
|
53
|
+
} else {
|
|
54
|
+
const opts = optsOrLayout;
|
|
55
|
+
layout = opts.layout;
|
|
56
|
+
options = opts.encodingOptions;
|
|
57
|
+
audioOnly = opts.audioOnly;
|
|
58
|
+
videoOnly = opts.videoOnly;
|
|
59
|
+
customBaseUrl = opts.customBaseUrl;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
layout ??= "";
|
|
63
|
+
audioOnly ??= false;
|
|
64
|
+
videoOnly ??= false;
|
|
65
|
+
customBaseUrl ??= "";
|
|
66
|
+
const {
|
|
67
|
+
output: legacyOutput,
|
|
68
|
+
options: egressOptions,
|
|
69
|
+
fileOutputs,
|
|
70
|
+
streamOutputs,
|
|
71
|
+
segmentOutputs,
|
|
72
|
+
imageOutputs
|
|
73
|
+
} = this.getOutputParams(output, options);
|
|
74
|
+
const req = new import_protocol.RoomCompositeEgressRequest({
|
|
75
|
+
roomName,
|
|
76
|
+
layout,
|
|
77
|
+
audioOnly,
|
|
78
|
+
videoOnly,
|
|
79
|
+
customBaseUrl,
|
|
80
|
+
output: legacyOutput,
|
|
81
|
+
options: egressOptions,
|
|
82
|
+
fileOutputs,
|
|
83
|
+
streamOutputs,
|
|
84
|
+
segmentOutputs,
|
|
85
|
+
imageOutputs
|
|
86
|
+
}).toJson();
|
|
87
|
+
const data = await this.rpc.request(
|
|
88
|
+
svc,
|
|
89
|
+
"StartRoomCompositeEgress",
|
|
90
|
+
req,
|
|
91
|
+
await this.authHeader({ roomRecord: true })
|
|
92
|
+
);
|
|
93
|
+
return import_protocol.EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @param url - url
|
|
97
|
+
* @param output - file or stream output
|
|
98
|
+
* @param opts - WebOptions
|
|
99
|
+
*/
|
|
100
|
+
async startWebEgress(url, output, opts) {
|
|
101
|
+
const audioOnly = (opts == null ? void 0 : opts.audioOnly) || false;
|
|
102
|
+
const videoOnly = (opts == null ? void 0 : opts.videoOnly) || false;
|
|
103
|
+
const awaitStartSignal = (opts == null ? void 0 : opts.awaitStartSignal) || false;
|
|
104
|
+
const {
|
|
105
|
+
output: legacyOutput,
|
|
106
|
+
options,
|
|
107
|
+
fileOutputs,
|
|
108
|
+
streamOutputs,
|
|
109
|
+
segmentOutputs,
|
|
110
|
+
imageOutputs
|
|
111
|
+
} = this.getOutputParams(output, opts == null ? void 0 : opts.encodingOptions);
|
|
112
|
+
const req = new import_protocol.WebEgressRequest({
|
|
113
|
+
url,
|
|
114
|
+
audioOnly,
|
|
115
|
+
videoOnly,
|
|
116
|
+
awaitStartSignal,
|
|
117
|
+
output: legacyOutput,
|
|
118
|
+
options,
|
|
119
|
+
fileOutputs,
|
|
120
|
+
streamOutputs,
|
|
121
|
+
segmentOutputs,
|
|
122
|
+
imageOutputs
|
|
123
|
+
}).toJson();
|
|
124
|
+
const data = await this.rpc.request(
|
|
125
|
+
svc,
|
|
126
|
+
"StartWebEgress",
|
|
127
|
+
req,
|
|
128
|
+
await this.authHeader({ roomRecord: true })
|
|
129
|
+
);
|
|
130
|
+
return import_protocol.EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Export a participant's audio and video tracks,
|
|
134
|
+
*
|
|
135
|
+
* @param roomName - room name
|
|
136
|
+
* @param output - one or more outputs
|
|
137
|
+
* @param opts - ParticipantEgressOptions
|
|
138
|
+
*/
|
|
139
|
+
async startParticipantEgress(roomName, identity, output, opts) {
|
|
140
|
+
const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } = this.getOutputParams(output, opts == null ? void 0 : opts.encodingOptions);
|
|
141
|
+
const req = new import_protocol.ParticipantEgressRequest({
|
|
142
|
+
roomName,
|
|
143
|
+
identity,
|
|
144
|
+
options,
|
|
145
|
+
fileOutputs,
|
|
146
|
+
streamOutputs,
|
|
147
|
+
segmentOutputs,
|
|
148
|
+
imageOutputs
|
|
149
|
+
}).toJson();
|
|
150
|
+
const data = await this.rpc.request(
|
|
151
|
+
svc,
|
|
152
|
+
"StartParticipantEgress",
|
|
153
|
+
req,
|
|
154
|
+
await this.authHeader({ roomRecord: true })
|
|
155
|
+
);
|
|
156
|
+
return import_protocol.EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
157
|
+
}
|
|
158
|
+
async startTrackCompositeEgress(roomName, output, optsOrAudioTrackId, videoTrackId, options) {
|
|
159
|
+
let audioTrackId;
|
|
160
|
+
if (optsOrAudioTrackId !== void 0) {
|
|
161
|
+
if (typeof optsOrAudioTrackId === "string") {
|
|
162
|
+
audioTrackId = optsOrAudioTrackId;
|
|
163
|
+
} else {
|
|
164
|
+
const opts = optsOrAudioTrackId;
|
|
165
|
+
audioTrackId = opts.audioTrackId;
|
|
166
|
+
videoTrackId = opts.videoTrackId;
|
|
167
|
+
options = opts.encodingOptions;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
audioTrackId ??= "";
|
|
171
|
+
videoTrackId ??= "";
|
|
172
|
+
const {
|
|
173
|
+
output: legacyOutput,
|
|
174
|
+
options: egressOptions,
|
|
175
|
+
fileOutputs,
|
|
176
|
+
streamOutputs,
|
|
177
|
+
segmentOutputs,
|
|
178
|
+
imageOutputs
|
|
179
|
+
} = this.getOutputParams(output, options);
|
|
180
|
+
const req = new import_protocol.TrackCompositeEgressRequest({
|
|
181
|
+
roomName,
|
|
182
|
+
audioTrackId,
|
|
183
|
+
videoTrackId,
|
|
184
|
+
output: legacyOutput,
|
|
185
|
+
options: egressOptions,
|
|
186
|
+
fileOutputs,
|
|
187
|
+
streamOutputs,
|
|
188
|
+
segmentOutputs,
|
|
189
|
+
imageOutputs
|
|
190
|
+
}).toJson();
|
|
191
|
+
const data = await this.rpc.request(
|
|
192
|
+
svc,
|
|
193
|
+
"StartTrackCompositeEgress",
|
|
194
|
+
req,
|
|
195
|
+
await this.authHeader({ roomRecord: true })
|
|
196
|
+
);
|
|
197
|
+
return import_protocol.EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
198
|
+
}
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
|
+
isEncodedOutputs(output) {
|
|
201
|
+
return output.file !== void 0 || output.stream !== void 0 || output.segments !== void 0 || output.images !== void 0;
|
|
202
|
+
}
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
204
|
+
isEncodedFileOutput(output) {
|
|
205
|
+
return output.filepath !== void 0 || output.fileType !== void 0;
|
|
206
|
+
}
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
208
|
+
isSegmentedFileOutput(output) {
|
|
209
|
+
return output.filenamePrefix !== void 0 || output.playlistName !== void 0 || output.filenameSuffix !== void 0;
|
|
210
|
+
}
|
|
211
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
212
|
+
isStreamOutput(output) {
|
|
213
|
+
return output.protocol !== void 0 || output.urls !== void 0;
|
|
214
|
+
}
|
|
215
|
+
getOutputParams(output, opts) {
|
|
216
|
+
let file;
|
|
217
|
+
let fileOutputs;
|
|
218
|
+
let stream;
|
|
219
|
+
let streamOutputs;
|
|
220
|
+
let segments;
|
|
221
|
+
let segmentOutputs;
|
|
222
|
+
let imageOutputs;
|
|
223
|
+
if (this.isEncodedOutputs(output)) {
|
|
224
|
+
if (output.file !== void 0) {
|
|
225
|
+
fileOutputs = [output.file];
|
|
226
|
+
}
|
|
227
|
+
if (output.stream !== void 0) {
|
|
228
|
+
streamOutputs = [output.stream];
|
|
229
|
+
}
|
|
230
|
+
if (output.segments !== void 0) {
|
|
231
|
+
segmentOutputs = [output.segments];
|
|
232
|
+
}
|
|
233
|
+
if (output.images !== void 0) {
|
|
234
|
+
imageOutputs = [output.images];
|
|
235
|
+
}
|
|
236
|
+
} else if (this.isEncodedFileOutput(output)) {
|
|
237
|
+
file = output;
|
|
238
|
+
fileOutputs = [file];
|
|
239
|
+
} else if (this.isSegmentedFileOutput(output)) {
|
|
240
|
+
segments = output;
|
|
241
|
+
segmentOutputs = [segments];
|
|
242
|
+
} else if (this.isStreamOutput(output)) {
|
|
243
|
+
stream = output;
|
|
244
|
+
streamOutputs = [stream];
|
|
245
|
+
}
|
|
246
|
+
let legacyOutput;
|
|
247
|
+
if (file) {
|
|
248
|
+
legacyOutput = {
|
|
249
|
+
case: "file",
|
|
250
|
+
value: file
|
|
251
|
+
};
|
|
252
|
+
} else if (stream) {
|
|
253
|
+
legacyOutput = {
|
|
254
|
+
case: "stream",
|
|
255
|
+
value: stream
|
|
256
|
+
};
|
|
257
|
+
} else if (segments) {
|
|
258
|
+
legacyOutput = {
|
|
259
|
+
case: "segments",
|
|
260
|
+
value: segments
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
let egressOptions;
|
|
264
|
+
if (opts) {
|
|
265
|
+
if (typeof opts === "number") {
|
|
266
|
+
egressOptions = {
|
|
267
|
+
case: "preset",
|
|
268
|
+
value: opts
|
|
269
|
+
};
|
|
270
|
+
} else {
|
|
271
|
+
egressOptions = {
|
|
272
|
+
case: "advanced",
|
|
273
|
+
value: opts
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
output: legacyOutput,
|
|
279
|
+
options: egressOptions,
|
|
280
|
+
fileOutputs,
|
|
281
|
+
streamOutputs,
|
|
282
|
+
segmentOutputs,
|
|
283
|
+
imageOutputs
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* @param roomName - room name
|
|
288
|
+
* @param output - file or websocket output
|
|
289
|
+
* @param trackId - track Id
|
|
290
|
+
*/
|
|
291
|
+
async startTrackEgress(roomName, output, trackId) {
|
|
292
|
+
let legacyOutput;
|
|
293
|
+
if (typeof output === "string") {
|
|
294
|
+
legacyOutput = {
|
|
295
|
+
case: "websocketUrl",
|
|
296
|
+
value: output
|
|
297
|
+
};
|
|
298
|
+
} else {
|
|
299
|
+
legacyOutput = {
|
|
300
|
+
case: "file",
|
|
301
|
+
value: output
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const req = new import_protocol.TrackEgressRequest({
|
|
305
|
+
roomName,
|
|
306
|
+
trackId,
|
|
307
|
+
output: legacyOutput
|
|
308
|
+
}).toJson();
|
|
309
|
+
const data = await this.rpc.request(
|
|
310
|
+
svc,
|
|
311
|
+
"StartTrackEgress",
|
|
312
|
+
req,
|
|
313
|
+
await this.authHeader({ roomRecord: true })
|
|
314
|
+
);
|
|
315
|
+
return import_protocol.EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* @param egressId -
|
|
319
|
+
* @param layout -
|
|
320
|
+
*/
|
|
321
|
+
async updateLayout(egressId, layout) {
|
|
322
|
+
const data = await this.rpc.request(
|
|
323
|
+
svc,
|
|
324
|
+
"UpdateLayout",
|
|
325
|
+
new import_protocol.UpdateLayoutRequest({ egressId, layout }).toJson(),
|
|
326
|
+
await this.authHeader({ roomRecord: true })
|
|
327
|
+
);
|
|
328
|
+
return import_protocol.EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* @param egressId -
|
|
332
|
+
* @param addOutputUrls -
|
|
333
|
+
* @param removeOutputUrls -
|
|
334
|
+
*/
|
|
335
|
+
async updateStream(egressId, addOutputUrls, removeOutputUrls) {
|
|
336
|
+
addOutputUrls ??= [];
|
|
337
|
+
removeOutputUrls ??= [];
|
|
338
|
+
const data = await this.rpc.request(
|
|
339
|
+
svc,
|
|
340
|
+
"UpdateStream",
|
|
341
|
+
new import_protocol.UpdateStreamRequest({ egressId, addOutputUrls, removeOutputUrls }).toJson(),
|
|
342
|
+
await this.authHeader({ roomRecord: true })
|
|
343
|
+
);
|
|
344
|
+
return import_protocol.EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* @param roomName - list egress for one room only
|
|
348
|
+
*/
|
|
349
|
+
async listEgress(options) {
|
|
350
|
+
let req = {};
|
|
351
|
+
if (typeof options === "string") {
|
|
352
|
+
req.roomName = options;
|
|
353
|
+
} else if (options !== void 0) {
|
|
354
|
+
req = options;
|
|
355
|
+
}
|
|
356
|
+
const data = await this.rpc.request(
|
|
357
|
+
svc,
|
|
358
|
+
"ListEgress",
|
|
359
|
+
new import_protocol.ListEgressRequest(req).toJson(),
|
|
360
|
+
await this.authHeader({ roomRecord: true })
|
|
361
|
+
);
|
|
362
|
+
return import_protocol.ListEgressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* @param egressId -
|
|
366
|
+
*/
|
|
367
|
+
async stopEgress(egressId) {
|
|
368
|
+
const data = await this.rpc.request(
|
|
369
|
+
svc,
|
|
370
|
+
"StopEgress",
|
|
371
|
+
new import_protocol.StopEgressRequest({ egressId }).toJson(),
|
|
372
|
+
await this.authHeader({ roomRecord: true })
|
|
373
|
+
);
|
|
374
|
+
return import_protocol.EgressInfo.fromJson(data, { ignoreUnknownFields: true });
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
378
|
+
0 && (module.exports = {
|
|
379
|
+
EgressClient
|
|
380
|
+
});
|
|
381
|
+
//# sourceMappingURL=EgressClient.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/EgressClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n DirectFileOutput,\n EncodedFileOutput,\n EncodingOptions,\n EncodingOptionsPreset,\n ImageOutput,\n SegmentedFileOutput,\n StreamOutput,\n} from '@livekit/protocol';\nimport {\n EgressInfo,\n ListEgressRequest,\n ListEgressResponse,\n ParticipantEgressRequest,\n RoomCompositeEgressRequest,\n StopEgressRequest,\n TrackCompositeEgressRequest,\n TrackEgressRequest,\n UpdateLayoutRequest,\n UpdateStreamRequest,\n WebEgressRequest,\n} from '@livekit/protocol';\nimport ServiceBase from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Egress';\n\nexport interface RoomCompositeOptions {\n /**\n * egress layout. optional\n */\n layout?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * custom template url. optional\n */\n customBaseUrl?: string;\n}\n\nexport interface WebOptions {\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * await START_RECORDING chrome log\n */\n awaitStartSignal?: boolean;\n}\n\nexport interface ParticipantEgressOptions {\n /**\n * true to capture source screenshare and screenshare_audio\n * false to capture camera and microphone\n */\n screenShare?: boolean;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\nexport interface TrackCompositeOptions {\n /**\n * audio track ID\n */\n audioTrackId?: string;\n /**\n * video track ID\n */\n videoTrackId?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\n/**\n * Used to supply multiple outputs with an egress request\n */\nexport interface EncodedOutputs {\n file?: EncodedFileOutput | undefined;\n stream?: StreamOutput | undefined;\n segments?: SegmentedFileOutput | undefined;\n images?: ImageOutput | undefined;\n}\n\nexport interface ListEgressOptions {\n roomName?: string;\n egressId?: string;\n active?: boolean;\n}\n\n/**\n * Client to access Egress APIs\n */\nexport class EgressClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n */\n constructor(host: string, apiKey?: string, secret?: string) {\n super(apiKey, secret);\n this.rpc = new TwirpRpc(host, livekitPackage);\n }\n\n /**\n * @param roomName - room name\n * @param output - file or stream output\n * @param opts - RoomCompositeOptions\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: RoomCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use RoomCompositeOptions instead\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n layout?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n ): Promise<EgressInfo>;\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrLayout?: RoomCompositeOptions | string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n ): Promise<EgressInfo> {\n let layout: string | undefined;\n if (optsOrLayout !== undefined) {\n if (typeof optsOrLayout === 'string') {\n layout = optsOrLayout;\n } else {\n const opts = <RoomCompositeOptions>optsOrLayout;\n layout = opts.layout;\n options = opts.encodingOptions;\n audioOnly = opts.audioOnly;\n videoOnly = opts.videoOnly;\n customBaseUrl = opts.customBaseUrl;\n }\n }\n\n layout ??= '';\n audioOnly ??= false;\n videoOnly ??= false;\n customBaseUrl ??= '';\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n\n const req = new RoomCompositeEgressRequest({\n roomName,\n layout,\n audioOnly,\n videoOnly,\n customBaseUrl,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartRoomCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param url - url\n * @param output - file or stream output\n * @param opts - WebOptions\n */\n async startWebEgress(\n url: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: WebOptions,\n ): Promise<EgressInfo> {\n const audioOnly = opts?.audioOnly || false;\n const videoOnly = opts?.videoOnly || false;\n const awaitStartSignal = opts?.awaitStartSignal || false;\n const {\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, opts?.encodingOptions);\n\n const req = new WebEgressRequest({\n url,\n audioOnly,\n videoOnly,\n awaitStartSignal,\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartWebEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Export a participant's audio and video tracks,\n *\n * @param roomName - room name\n * @param output - one or more outputs\n * @param opts - ParticipantEgressOptions\n */\n async startParticipantEgress(\n roomName: string,\n identity: string,\n output: EncodedOutputs,\n opts?: ParticipantEgressOptions,\n ): Promise<EgressInfo> {\n const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } =\n this.getOutputParams(output, opts?.encodingOptions);\n const req = new ParticipantEgressRequest({\n roomName,\n identity,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartParticipantEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param roomName - room name\n * @param output - file or stream output\n * @param opts - TrackCompositeOptions\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: TrackCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use TrackCompositeOptions instead\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n audioTrackId?: string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo>;\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrAudioTrackId?: TrackCompositeOptions | string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo> {\n let audioTrackId: string | undefined;\n if (optsOrAudioTrackId !== undefined) {\n if (typeof optsOrAudioTrackId === 'string') {\n audioTrackId = optsOrAudioTrackId;\n } else {\n const opts = <TrackCompositeOptions>optsOrAudioTrackId;\n audioTrackId = opts.audioTrackId;\n videoTrackId = opts.videoTrackId;\n options = opts.encodingOptions;\n }\n }\n\n audioTrackId ??= '';\n videoTrackId ??= '';\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n const req = new TrackCompositeEgressRequest({\n roomName,\n audioTrackId,\n videoTrackId,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedOutputs(output: any): output is EncodedOutputs {\n return (\n (<EncodedOutputs>output).file !== undefined ||\n (<EncodedOutputs>output).stream !== undefined ||\n (<EncodedOutputs>output).segments !== undefined ||\n (<EncodedOutputs>output).images !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedFileOutput(output: any): output is EncodedFileOutput {\n return (\n (<EncodedFileOutput>output).filepath !== undefined ||\n (<EncodedFileOutput>output).fileType !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isSegmentedFileOutput(output: any): output is SegmentedFileOutput {\n return (\n (<SegmentedFileOutput>output).filenamePrefix !== undefined ||\n (<SegmentedFileOutput>output).playlistName !== undefined ||\n (<SegmentedFileOutput>output).filenameSuffix !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isStreamOutput(output: any): output is StreamOutput {\n return (\n (<StreamOutput>output).protocol !== undefined || (<StreamOutput>output).urls !== undefined\n );\n }\n\n private getOutputParams(\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: EncodingOptionsPreset | EncodingOptions,\n ) {\n let file: EncodedFileOutput | undefined;\n let fileOutputs: Array<EncodedFileOutput> | undefined;\n let stream: StreamOutput | undefined;\n let streamOutputs: Array<StreamOutput> | undefined;\n let segments: SegmentedFileOutput | undefined;\n let segmentOutputs: Array<SegmentedFileOutput> | undefined;\n let imageOutputs: Array<ImageOutput> | undefined;\n\n if (this.isEncodedOutputs(output)) {\n if (output.file !== undefined) {\n fileOutputs = [output.file];\n }\n if (output.stream !== undefined) {\n streamOutputs = [output.stream];\n }\n if (output.segments !== undefined) {\n segmentOutputs = [output.segments];\n }\n if (output.images !== undefined) {\n imageOutputs = [output.images];\n }\n } else if (this.isEncodedFileOutput(output)) {\n file = output;\n fileOutputs = [file];\n } else if (this.isSegmentedFileOutput(output)) {\n segments = output;\n segmentOutputs = [segments];\n } else if (this.isStreamOutput(output)) {\n stream = output;\n streamOutputs = [stream];\n }\n\n let legacyOutput:\n | {\n value: EncodedFileOutput;\n case: 'file';\n }\n | {\n value: StreamOutput;\n case: 'stream';\n }\n | {\n value: SegmentedFileOutput;\n case: 'segments';\n }\n | undefined;\n\n if (file) {\n legacyOutput = {\n case: 'file',\n value: file,\n };\n } else if (stream) {\n legacyOutput = {\n case: 'stream',\n value: stream,\n };\n } else if (segments) {\n legacyOutput = {\n case: 'segments',\n value: segments,\n };\n }\n let egressOptions:\n | {\n value: EncodingOptionsPreset;\n case: 'preset';\n }\n | {\n value: EncodingOptions;\n case: 'advanced';\n }\n | undefined;\n if (opts) {\n if (typeof opts === 'number') {\n egressOptions = {\n case: 'preset',\n value: opts,\n };\n } else {\n egressOptions = {\n case: 'advanced',\n value: <EncodingOptions>opts,\n };\n }\n }\n\n return {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n };\n }\n\n /**\n * @param roomName - room name\n * @param output - file or websocket output\n * @param trackId - track Id\n */\n async startTrackEgress(\n roomName: string,\n output: DirectFileOutput | string,\n trackId: string,\n ): Promise<EgressInfo> {\n let legacyOutput:\n | {\n value: DirectFileOutput;\n case: 'file';\n }\n | {\n value: string;\n case: 'websocketUrl';\n }\n | undefined;\n\n if (typeof output === 'string') {\n legacyOutput = {\n case: 'websocketUrl',\n value: output,\n };\n } else {\n legacyOutput = {\n case: 'file',\n value: output,\n };\n }\n\n const req = new TrackEgressRequest({\n roomName,\n trackId,\n output: legacyOutput,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param layout -\n */\n async updateLayout(egressId: string, layout: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'UpdateLayout',\n new UpdateLayoutRequest({ egressId, layout }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param addOutputUrls -\n * @param removeOutputUrls -\n */\n async updateStream(\n egressId: string,\n addOutputUrls?: string[],\n removeOutputUrls?: string[],\n ): Promise<EgressInfo> {\n addOutputUrls ??= [];\n removeOutputUrls ??= [];\n\n const data = await this.rpc.request(\n svc,\n 'UpdateStream',\n new UpdateStreamRequest({ egressId, addOutputUrls, removeOutputUrls }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param options - options to filter listed Egresses, by default returns all\n * Egress instances\n */\n async listEgress(options?: ListEgressOptions): Promise<Array<EgressInfo>>;\n /**\n * @deprecated use `listEgress(options?: ListEgressOptions)` instead\n * @param roomName - list egress for one room only\n */\n async listEgress(roomName?: string): Promise<Array<EgressInfo>>;\n /**\n * @param roomName - list egress for one room only\n */\n async listEgress(options?: string | ListEgressOptions): Promise<Array<EgressInfo>> {\n let req: Partial<ListEgressRequest> = {};\n if (typeof options === 'string') {\n req.roomName = options;\n } else if (options !== undefined) {\n req = options;\n }\n\n const data = await this.rpc.request(\n svc,\n 'ListEgress',\n new ListEgressRequest(req).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return ListEgressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];\n }\n\n /**\n * @param egressId -\n */\n async stopEgress(egressId: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'StopEgress',\n new StopEgressRequest({ egressId }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAYO;AACP,yBAAwB;AAExB,sBAAyC;AAEzC,MAAM,MAAM;AA0FL,MAAM,qBAAqB,mBAAAA,QAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,YAAY,MAAc,QAAiB,QAAiB;AAC1D,UAAM,QAAQ,MAAM;AACpB,SAAK,MAAM,IAAI,yBAAS,MAAM,8BAAc;AAAA,EAC9C;AAAA,EAwBA,MAAM,yBACJ,UACA,QACA,cACA,SACA,WACA,WACA,eACqB;AACrB,QAAI;AACJ,QAAI,iBAAiB,QAAW;AAC9B,UAAI,OAAO,iBAAiB,UAAU;AACpC,iBAAS;AAAA,MACX,OAAO;AACL,cAAM,OAA6B;AACnC,iBAAS,KAAK;AACd,kBAAU,KAAK;AACf,oBAAY,KAAK;AACjB,oBAAY,KAAK;AACjB,wBAAgB,KAAK;AAAA,MACvB;AAAA,IACF;AAEA,eAAW;AACX,kBAAc;AACd,kBAAc;AACd,sBAAkB;AAElB,UAAM;AAAA,MACJ,QAAQ;AAAA,MACR,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,KAAK,gBAAgB,QAAQ,OAAO;AAExC,UAAM,MAAM,IAAI,2CAA2B;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,EAAE,OAAO;AAEV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,M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