livekit-server-sdk 1.0.3 → 1.1.2
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/dist/AccessToken.js +6 -0
- package/dist/AccessToken.js.map +1 -1
- package/dist/EgressClient.d.ts +38 -8
- package/dist/EgressClient.js +84 -21
- package/dist/EgressClient.js.map +1 -1
- package/dist/IngressClient.d.ts +84 -0
- package/dist/IngressClient.js +112 -0
- package/dist/IngressClient.js.map +1 -0
- package/dist/RoomServiceClient.d.ts +21 -6
- package/dist/RoomServiceClient.js +15 -22
- package/dist/RoomServiceClient.js.map +1 -1
- package/dist/ServiceBase.d.ts +16 -0
- package/dist/ServiceBase.js +27 -0
- package/dist/ServiceBase.js.map +1 -0
- package/dist/grants.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/proto/google/protobuf/timestamp.d.ts +5 -5
- package/dist/proto/google/protobuf/timestamp.js +17 -32
- package/dist/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/proto/livekit_egress.d.ts +9725 -1848
- package/dist/proto/livekit_egress.js +1131 -597
- package/dist/proto/livekit_egress.js.map +1 -1
- package/dist/proto/livekit_ingress.d.ts +744 -384
- package/dist/proto/livekit_ingress.js +492 -323
- package/dist/proto/livekit_ingress.js.map +1 -1
- package/dist/proto/livekit_models.d.ts +154 -59
- package/dist/proto/livekit_models.js +682 -446
- package/dist/proto/livekit_models.js.map +1 -1
- package/dist/proto/livekit_room.d.ts +1746 -320
- package/dist/proto/livekit_room.js +198 -224
- package/dist/proto/livekit_room.js.map +1 -1
- package/dist/proto/livekit_webhook.d.ts +3277 -465
- package/dist/proto/livekit_webhook.js +43 -68
- package/dist/proto/livekit_webhook.js.map +1 -1
- package/generate-proto.sh +25 -0
- package/package.json +3 -3
- package/dist/proto/google/protobuf/empty.d.ts +0 -31
- package/dist/proto/google/protobuf/empty.js +0 -67
- package/dist/proto/google/protobuf/empty.js.map +0 -1
package/dist/AccessToken.js
CHANGED
|
@@ -39,6 +39,12 @@ class AccessToken {
|
|
|
39
39
|
if (!apiKey || !apiSecret) {
|
|
40
40
|
throw Error('api-key and api-secret must be set');
|
|
41
41
|
}
|
|
42
|
+
else if (typeof document !== 'undefined') {
|
|
43
|
+
// check against document rather than window because deno provides window
|
|
44
|
+
console.error('You should not include your API secret in your web client bundle.\n\n' +
|
|
45
|
+
'Your web client should request a token from your backend server which should then use ' +
|
|
46
|
+
'the API secret to generate a token. See https://docs.livekit.io/client/connect/');
|
|
47
|
+
}
|
|
42
48
|
this.apiKey = apiKey;
|
|
43
49
|
this.apiSecret = apiSecret;
|
|
44
50
|
this.grants = {};
|
package/dist/AccessToken.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessToken.js","sourceRoot":"","sources":["../src/AccessToken.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAoC;AAGpC,UAAU;AACV,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;AA0B/B,MAAa,WAAW;IAWtB;;;;OAIG;IACH,YAAY,MAAe,EAAE,SAAkB,EAAE,OAA4B;QAC3E,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;SACtC;QACD,IAAI,CAAC,SAAS,EAAE;YACd,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;SAC5C;QACD,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE;YACzB,MAAM,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE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E,IAAI,CAAC,CAAC;IACrD,CAAC;CACF;AA7FD,kCA6FC;AAED,MAAa,aAAa;IAKxB,YAAY,MAAc,EAAE,SAAiB;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,KAAK,CAAC,eAAe,CAAC,CAAC;SAC9B;QAED,OAAO,OAAsB,CAAC;IAChC,CAAC;CACF;AAlBD,sCAkBC"}
|
package/dist/EgressClient.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DirectFileOutput, EgressInfo, EncodedFileOutput, EncodingOptions, EncodingOptionsPreset, SegmentedFileOutput, StreamOutput } from './proto/livekit_egress';
|
|
2
|
+
import ServiceBase from './ServiceBase';
|
|
2
3
|
export interface RoomCompositeOptions {
|
|
3
4
|
/**
|
|
4
5
|
* egress layout. optional
|
|
@@ -21,6 +22,20 @@ export interface RoomCompositeOptions {
|
|
|
21
22
|
*/
|
|
22
23
|
customBaseUrl?: string;
|
|
23
24
|
}
|
|
25
|
+
export interface WebOptions {
|
|
26
|
+
/**
|
|
27
|
+
* encoding options or preset. optional
|
|
28
|
+
*/
|
|
29
|
+
encodingOptions?: EncodingOptionsPreset | EncodingOptions;
|
|
30
|
+
/**
|
|
31
|
+
* record audio only. optional
|
|
32
|
+
*/
|
|
33
|
+
audioOnly?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* record video only. optional
|
|
36
|
+
*/
|
|
37
|
+
videoOnly?: boolean;
|
|
38
|
+
}
|
|
24
39
|
export interface TrackCompositeOptions {
|
|
25
40
|
/**
|
|
26
41
|
* audio track ID
|
|
@@ -35,13 +50,19 @@ export interface TrackCompositeOptions {
|
|
|
35
50
|
*/
|
|
36
51
|
encodingOptions?: EncodingOptionsPreset | EncodingOptions;
|
|
37
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Used to supply multiple outputs with an egress request
|
|
55
|
+
*/
|
|
56
|
+
export interface EncodedOutputs {
|
|
57
|
+
file?: EncodedFileOutput | undefined;
|
|
58
|
+
stream?: StreamOutput | undefined;
|
|
59
|
+
segments?: SegmentedFileOutput | undefined;
|
|
60
|
+
}
|
|
38
61
|
/**
|
|
39
62
|
* Client to access Egress APIs
|
|
40
63
|
*/
|
|
41
|
-
export declare class EgressClient {
|
|
64
|
+
export declare class EgressClient extends ServiceBase {
|
|
42
65
|
private readonly rpc;
|
|
43
|
-
private readonly apiKey?;
|
|
44
|
-
private readonly secret?;
|
|
45
66
|
/**
|
|
46
67
|
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
47
68
|
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
@@ -53,21 +74,31 @@ export declare class EgressClient {
|
|
|
53
74
|
* @param output file or stream output
|
|
54
75
|
* @param opts RoomCompositeOptions
|
|
55
76
|
*/
|
|
56
|
-
startRoomCompositeEgress(roomName: string, output: EncodedFileOutput |
|
|
77
|
+
startRoomCompositeEgress(roomName: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, opts?: RoomCompositeOptions): Promise<EgressInfo>;
|
|
57
78
|
/**
|
|
58
79
|
* @deprecated use RoomCompositeOptions instead
|
|
59
80
|
*/
|
|
60
|
-
startRoomCompositeEgress(roomName: string, output: EncodedFileOutput |
|
|
81
|
+
startRoomCompositeEgress(roomName: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, layout?: string, options?: EncodingOptionsPreset | EncodingOptions, audioOnly?: boolean, videoOnly?: boolean, customBaseUrl?: string): Promise<EgressInfo>;
|
|
82
|
+
/**
|
|
83
|
+
* @param url url
|
|
84
|
+
* @param output file or stream output
|
|
85
|
+
* @param opts WebOptions
|
|
86
|
+
*/
|
|
87
|
+
startWebEgress(url: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, opts?: WebOptions): Promise<EgressInfo>;
|
|
61
88
|
/**
|
|
62
89
|
* @param roomName room name
|
|
63
90
|
* @param output file or stream output
|
|
64
91
|
* @param opts TrackCompositeOptions
|
|
65
92
|
*/
|
|
66
|
-
startTrackCompositeEgress(roomName: string, output: EncodedFileOutput |
|
|
93
|
+
startTrackCompositeEgress(roomName: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, opts?: TrackCompositeOptions): Promise<EgressInfo>;
|
|
67
94
|
/**
|
|
68
95
|
* @deprecated use TrackCompositeOptions instead
|
|
69
96
|
*/
|
|
70
|
-
startTrackCompositeEgress(roomName: string, output: EncodedFileOutput |
|
|
97
|
+
startTrackCompositeEgress(roomName: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, audioTrackId?: string, videoTrackId?: string, options?: EncodingOptionsPreset | EncodingOptions): Promise<EgressInfo>;
|
|
98
|
+
private isEncodedOutputs;
|
|
99
|
+
private isEncodedFileOutput;
|
|
100
|
+
private isSegmentedFileOutput;
|
|
101
|
+
private isStreamOutput;
|
|
71
102
|
private getOutputParams;
|
|
72
103
|
/**
|
|
73
104
|
* @param roomName room name
|
|
@@ -94,5 +125,4 @@ export declare class EgressClient {
|
|
|
94
125
|
* @param egressId
|
|
95
126
|
*/
|
|
96
127
|
stopEgress(egressId: string): Promise<EgressInfo>;
|
|
97
|
-
private authHeader;
|
|
98
128
|
}
|
package/dist/EgressClient.js
CHANGED
|
@@ -8,25 +8,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.EgressClient = void 0;
|
|
13
|
-
const AccessToken_1 = require("./AccessToken");
|
|
14
16
|
const livekit_egress_1 = require("./proto/livekit_egress");
|
|
17
|
+
const ServiceBase_1 = __importDefault(require("./ServiceBase"));
|
|
15
18
|
const TwirpRPC_1 = require("./TwirpRPC");
|
|
16
19
|
const svc = 'Egress';
|
|
17
20
|
/**
|
|
18
21
|
* Client to access Egress APIs
|
|
19
22
|
*/
|
|
20
|
-
class EgressClient {
|
|
23
|
+
class EgressClient extends ServiceBase_1.default {
|
|
21
24
|
/**
|
|
22
25
|
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
23
26
|
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
24
27
|
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
25
28
|
*/
|
|
26
29
|
constructor(host, apiKey, secret) {
|
|
30
|
+
super(apiKey, secret);
|
|
27
31
|
this.rpc = new TwirpRPC_1.TwirpRpc(host, TwirpRPC_1.livekitPackage);
|
|
28
|
-
this.apiKey = apiKey;
|
|
29
|
-
this.secret = secret;
|
|
30
32
|
}
|
|
31
33
|
startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl) {
|
|
32
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -48,7 +50,7 @@ class EgressClient {
|
|
|
48
50
|
audioOnly !== null && audioOnly !== void 0 ? audioOnly : (audioOnly = false);
|
|
49
51
|
videoOnly !== null && videoOnly !== void 0 ? videoOnly : (videoOnly = false);
|
|
50
52
|
customBaseUrl !== null && customBaseUrl !== void 0 ? customBaseUrl : (customBaseUrl = '');
|
|
51
|
-
const { file,
|
|
53
|
+
const { file, stream, segments, preset, advanced, fileOutputs, streamOutputs, segmentOutputs } = this.getOutputParams(output, options);
|
|
52
54
|
const req = livekit_egress_1.RoomCompositeEgressRequest.toJSON({
|
|
53
55
|
roomName,
|
|
54
56
|
layout,
|
|
@@ -60,11 +62,41 @@ class EgressClient {
|
|
|
60
62
|
segments,
|
|
61
63
|
preset,
|
|
62
64
|
advanced,
|
|
65
|
+
fileOutputs,
|
|
66
|
+
streamOutputs,
|
|
67
|
+
segmentOutputs,
|
|
63
68
|
});
|
|
64
69
|
const data = yield this.rpc.request(svc, 'StartRoomCompositeEgress', req, this.authHeader({ roomRecord: true }));
|
|
65
70
|
return livekit_egress_1.EgressInfo.fromJSON(data);
|
|
66
71
|
});
|
|
67
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* @param url url
|
|
75
|
+
* @param output file or stream output
|
|
76
|
+
* @param opts WebOptions
|
|
77
|
+
*/
|
|
78
|
+
startWebEgress(url, output, opts) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const audioOnly = (opts === null || opts === void 0 ? void 0 : opts.audioOnly) || false;
|
|
81
|
+
const videoOnly = (opts === null || opts === void 0 ? void 0 : opts.videoOnly) || false;
|
|
82
|
+
const { file, stream, segments, preset, advanced, fileOutputs, streamOutputs, segmentOutputs } = this.getOutputParams(output, opts === null || opts === void 0 ? void 0 : opts.encodingOptions);
|
|
83
|
+
const req = livekit_egress_1.WebEgressRequest.toJSON({
|
|
84
|
+
url,
|
|
85
|
+
audioOnly,
|
|
86
|
+
videoOnly,
|
|
87
|
+
file,
|
|
88
|
+
stream,
|
|
89
|
+
segments,
|
|
90
|
+
preset,
|
|
91
|
+
advanced,
|
|
92
|
+
fileOutputs,
|
|
93
|
+
streamOutputs,
|
|
94
|
+
segmentOutputs,
|
|
95
|
+
});
|
|
96
|
+
const data = yield this.rpc.request(svc, 'StartWebEgress', req, this.authHeader({ roomRecord: true }));
|
|
97
|
+
return livekit_egress_1.EgressInfo.fromJSON(data);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
68
100
|
startTrackCompositeEgress(roomName, output, optsOrAudioTrackId, videoTrackId, options) {
|
|
69
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
102
|
let audioTrackId;
|
|
@@ -81,7 +113,7 @@ class EgressClient {
|
|
|
81
113
|
}
|
|
82
114
|
audioTrackId !== null && audioTrackId !== void 0 ? audioTrackId : (audioTrackId = '');
|
|
83
115
|
videoTrackId !== null && videoTrackId !== void 0 ? videoTrackId : (videoTrackId = '');
|
|
84
|
-
const { file,
|
|
116
|
+
const { file, stream, segments, preset, advanced, fileOutputs, streamOutputs, segmentOutputs } = this.getOutputParams(output, options);
|
|
85
117
|
const req = livekit_egress_1.TrackCompositeEgressRequest.toJSON({
|
|
86
118
|
roomName,
|
|
87
119
|
audioTrackId,
|
|
@@ -91,25 +123,62 @@ class EgressClient {
|
|
|
91
123
|
segments,
|
|
92
124
|
preset,
|
|
93
125
|
advanced,
|
|
126
|
+
fileOutputs,
|
|
127
|
+
streamOutputs,
|
|
128
|
+
segmentOutputs,
|
|
94
129
|
});
|
|
95
130
|
const data = yield this.rpc.request(svc, 'StartTrackCompositeEgress', req, this.authHeader({ roomRecord: true }));
|
|
96
131
|
return livekit_egress_1.EgressInfo.fromJSON(data);
|
|
97
132
|
});
|
|
98
133
|
}
|
|
134
|
+
isEncodedOutputs(output) {
|
|
135
|
+
return (output.file !== undefined ||
|
|
136
|
+
output.stream !== undefined ||
|
|
137
|
+
output.segments !== undefined);
|
|
138
|
+
}
|
|
139
|
+
isEncodedFileOutput(output) {
|
|
140
|
+
return (output.filepath !== undefined ||
|
|
141
|
+
output.fileType !== undefined);
|
|
142
|
+
}
|
|
143
|
+
isSegmentedFileOutput(output) {
|
|
144
|
+
return (output.filenamePrefix !== undefined ||
|
|
145
|
+
output.playlistName !== undefined ||
|
|
146
|
+
output.filenameSuffix !== undefined);
|
|
147
|
+
}
|
|
148
|
+
isStreamOutput(output) {
|
|
149
|
+
return (output.protocol !== undefined || output.urls !== undefined);
|
|
150
|
+
}
|
|
99
151
|
getOutputParams(output, options) {
|
|
100
152
|
let file;
|
|
153
|
+
let fileOutputs;
|
|
101
154
|
let stream;
|
|
155
|
+
let streamOutputs;
|
|
102
156
|
let segments;
|
|
157
|
+
let segmentOutputs;
|
|
103
158
|
let preset;
|
|
104
159
|
let advanced;
|
|
105
|
-
if (output
|
|
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
|
+
}
|
|
171
|
+
else if (this.isEncodedFileOutput(output)) {
|
|
106
172
|
file = output;
|
|
173
|
+
fileOutputs = [file];
|
|
107
174
|
}
|
|
108
|
-
else if (output
|
|
175
|
+
else if (this.isSegmentedFileOutput(output)) {
|
|
109
176
|
segments = output;
|
|
177
|
+
segmentOutputs = [segments];
|
|
110
178
|
}
|
|
111
|
-
else {
|
|
179
|
+
else if (this.isStreamOutput(output)) {
|
|
112
180
|
stream = output;
|
|
181
|
+
streamOutputs = [stream];
|
|
113
182
|
}
|
|
114
183
|
if (options) {
|
|
115
184
|
if (typeof options === 'number') {
|
|
@@ -119,7 +188,7 @@ class EgressClient {
|
|
|
119
188
|
advanced = options;
|
|
120
189
|
}
|
|
121
190
|
}
|
|
122
|
-
return { file,
|
|
191
|
+
return { file, stream, segments, preset, advanced, fileOutputs, streamOutputs, segmentOutputs };
|
|
123
192
|
}
|
|
124
193
|
/**
|
|
125
194
|
* @param roomName room name
|
|
@@ -130,11 +199,11 @@ class EgressClient {
|
|
|
130
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
200
|
let file;
|
|
132
201
|
let websocketUrl;
|
|
133
|
-
if (output
|
|
134
|
-
|
|
202
|
+
if (typeof output === 'string') {
|
|
203
|
+
websocketUrl = output;
|
|
135
204
|
}
|
|
136
205
|
else {
|
|
137
|
-
|
|
206
|
+
file = output;
|
|
138
207
|
}
|
|
139
208
|
const req = livekit_egress_1.TrackEgressRequest.toJSON({
|
|
140
209
|
roomName,
|
|
@@ -173,10 +242,11 @@ class EgressClient {
|
|
|
173
242
|
* @param roomName list egress for one room only
|
|
174
243
|
*/
|
|
175
244
|
listEgress(roomName) {
|
|
245
|
+
var _a;
|
|
176
246
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
247
|
roomName !== null && roomName !== void 0 ? roomName : (roomName = '');
|
|
178
248
|
const data = yield this.rpc.request(svc, 'ListEgress', livekit_egress_1.ListEgressRequest.toJSON({ roomName }), this.authHeader({ roomRecord: true }));
|
|
179
|
-
return livekit_egress_1.ListEgressResponse.fromJSON(data).items;
|
|
249
|
+
return (_a = livekit_egress_1.ListEgressResponse.fromJSON(data).items) !== null && _a !== void 0 ? _a : [];
|
|
180
250
|
});
|
|
181
251
|
}
|
|
182
252
|
/**
|
|
@@ -188,13 +258,6 @@ class EgressClient {
|
|
|
188
258
|
return livekit_egress_1.EgressInfo.fromJSON(data);
|
|
189
259
|
});
|
|
190
260
|
}
|
|
191
|
-
authHeader(grant) {
|
|
192
|
-
const at = new AccessToken_1.AccessToken(this.apiKey, this.secret, { ttl: '10m' });
|
|
193
|
-
at.addGrant(grant);
|
|
194
|
-
return {
|
|
195
|
-
Authorization: `Bearer ${at.toJwt()}`,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
261
|
}
|
|
199
262
|
exports.EgressClient = EgressClient;
|
|
200
263
|
//# sourceMappingURL=EgressClient.js.map
|
package/dist/EgressClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EgressClient.js","sourceRoot":"","sources":["../src/EgressClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EgressClient.js","sourceRoot":"","sources":["../src/EgressClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAiBg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;;YAChC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,IAAR,QAAQ,GAAK,EAAE,EAAC;YAEhB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,YAAY,EACZ,kCAAiB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EACtC,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CACtC,CAAC;YACF,OAAO,MAAA,mCAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,mCAAI,EAAE,CAAC;;KACtD;IAED;;OAEG;IACG,UAAU,CAAC,QAAgB;;YAC/B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,YAAY,EACZ,kCAAiB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EACtC,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CACtC,CAAC;YACF,OAAO,2BAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;KAAA;CACF;AA9WD,oCA8WC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { IngressAudioOptions, IngressInfo, IngressInput, IngressVideoOptions } from './proto/livekit_ingress';
|
|
2
|
+
import ServiceBase from './ServiceBase';
|
|
3
|
+
export interface CreateIngressOptions {
|
|
4
|
+
/**
|
|
5
|
+
* ingress name. optional
|
|
6
|
+
*/
|
|
7
|
+
name?: string;
|
|
8
|
+
/**
|
|
9
|
+
* name of the room to send media to. optional
|
|
10
|
+
*/
|
|
11
|
+
roomName?: string;
|
|
12
|
+
/**
|
|
13
|
+
* unique identity of the participant. optional
|
|
14
|
+
*/
|
|
15
|
+
participantIdentity?: string;
|
|
16
|
+
/**
|
|
17
|
+
* participant display name
|
|
18
|
+
*/
|
|
19
|
+
participantName?: string;
|
|
20
|
+
/**
|
|
21
|
+
* custom audio encoding parameters. optional
|
|
22
|
+
*/
|
|
23
|
+
audio?: IngressAudioOptions;
|
|
24
|
+
/**
|
|
25
|
+
* custom video encoding parameters. optional
|
|
26
|
+
*/
|
|
27
|
+
video?: IngressVideoOptions;
|
|
28
|
+
}
|
|
29
|
+
export interface UpdateIngressOptions {
|
|
30
|
+
/**
|
|
31
|
+
* ingress name. optional
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
/**
|
|
35
|
+
* name of the room to send media to. optional
|
|
36
|
+
*/
|
|
37
|
+
roomName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* unique identity of the participant. optional
|
|
40
|
+
*/
|
|
41
|
+
participantIdentity?: string;
|
|
42
|
+
/**
|
|
43
|
+
* participant display name
|
|
44
|
+
*/
|
|
45
|
+
participantName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* custom audio encoding parameters. optional
|
|
48
|
+
*/
|
|
49
|
+
audio?: IngressAudioOptions;
|
|
50
|
+
/**
|
|
51
|
+
* custom video encoding parameters. optional
|
|
52
|
+
*/
|
|
53
|
+
video?: IngressVideoOptions;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Client to access Ingress APIs
|
|
57
|
+
*/
|
|
58
|
+
export declare class IngressClient extends ServiceBase {
|
|
59
|
+
private readonly rpc;
|
|
60
|
+
/**
|
|
61
|
+
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
62
|
+
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
63
|
+
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
64
|
+
*/
|
|
65
|
+
constructor(host: string, apiKey?: string, secret?: string);
|
|
66
|
+
/**
|
|
67
|
+
* @param inputType protocol for the ingress
|
|
68
|
+
* @param opts CreateIngressOptions
|
|
69
|
+
*/
|
|
70
|
+
createIngress(inputType: IngressInput, opts?: CreateIngressOptions): Promise<IngressInfo>;
|
|
71
|
+
/**
|
|
72
|
+
* @param ingressId ID of the ingress to update
|
|
73
|
+
* @param opts UpdateIngressOptions
|
|
74
|
+
*/
|
|
75
|
+
updateIngress(ingressId: string, opts: UpdateIngressOptions): Promise<IngressInfo>;
|
|
76
|
+
/**
|
|
77
|
+
* @param roomName list ingress for one room only
|
|
78
|
+
*/
|
|
79
|
+
listIngress(roomName?: string): Promise<Array<IngressInfo>>;
|
|
80
|
+
/**
|
|
81
|
+
* @param ingressId ingress to delete
|
|
82
|
+
*/
|
|
83
|
+
deleteIngress(ingressId: string): Promise<IngressInfo>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.IngressClient = void 0;
|
|
16
|
+
const livekit_ingress_1 = require("./proto/livekit_ingress");
|
|
17
|
+
const ServiceBase_1 = __importDefault(require("./ServiceBase"));
|
|
18
|
+
const TwirpRPC_1 = require("./TwirpRPC");
|
|
19
|
+
const svc = 'Ingress';
|
|
20
|
+
/**
|
|
21
|
+
* Client to access Ingress APIs
|
|
22
|
+
*/
|
|
23
|
+
class IngressClient extends ServiceBase_1.default {
|
|
24
|
+
/**
|
|
25
|
+
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
26
|
+
* @param apiKey API Key, can be set in env var LIVEKIT_API_KEY
|
|
27
|
+
* @param secret API Secret, can be set in env var LIVEKIT_API_SECRET
|
|
28
|
+
*/
|
|
29
|
+
constructor(host, apiKey, secret) {
|
|
30
|
+
super(apiKey, secret);
|
|
31
|
+
this.rpc = new TwirpRPC_1.TwirpRpc(host, TwirpRPC_1.livekitPackage);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @param inputType protocol for the ingress
|
|
35
|
+
* @param opts CreateIngressOptions
|
|
36
|
+
*/
|
|
37
|
+
createIngress(inputType, opts) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
let name = '';
|
|
40
|
+
let roomName = '';
|
|
41
|
+
let participantName = '';
|
|
42
|
+
let participantIdentity = '';
|
|
43
|
+
let audio;
|
|
44
|
+
let video;
|
|
45
|
+
if (opts !== undefined) {
|
|
46
|
+
name = opts.name || '';
|
|
47
|
+
roomName = opts.roomName || '';
|
|
48
|
+
participantName = opts.participantName || '';
|
|
49
|
+
participantIdentity = opts.participantIdentity || '';
|
|
50
|
+
audio = opts.audio;
|
|
51
|
+
video = opts.video;
|
|
52
|
+
}
|
|
53
|
+
const req = livekit_ingress_1.CreateIngressRequest.toJSON({
|
|
54
|
+
inputType,
|
|
55
|
+
name,
|
|
56
|
+
roomName,
|
|
57
|
+
participantIdentity,
|
|
58
|
+
participantName,
|
|
59
|
+
audio,
|
|
60
|
+
video,
|
|
61
|
+
});
|
|
62
|
+
const data = yield this.rpc.request(svc, 'CreateIngress', req, this.authHeader({ ingressAdmin: true }));
|
|
63
|
+
return livekit_ingress_1.IngressInfo.fromJSON(data);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @param ingressId ID of the ingress to update
|
|
68
|
+
* @param opts UpdateIngressOptions
|
|
69
|
+
*/
|
|
70
|
+
updateIngress(ingressId, opts) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const name = opts.name || '';
|
|
73
|
+
const roomName = opts.roomName || '';
|
|
74
|
+
const participantName = opts.participantName || '';
|
|
75
|
+
const participantIdentity = opts.participantIdentity || '';
|
|
76
|
+
const { audio, video } = opts;
|
|
77
|
+
const req = livekit_ingress_1.UpdateIngressRequest.toJSON({
|
|
78
|
+
ingressId,
|
|
79
|
+
name,
|
|
80
|
+
roomName,
|
|
81
|
+
participantIdentity,
|
|
82
|
+
participantName,
|
|
83
|
+
audio,
|
|
84
|
+
video,
|
|
85
|
+
});
|
|
86
|
+
const data = yield this.rpc.request(svc, 'UpdateIngress', req, this.authHeader({ ingressAdmin: true }));
|
|
87
|
+
return livekit_ingress_1.IngressInfo.fromJSON(data);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @param roomName list ingress for one room only
|
|
92
|
+
*/
|
|
93
|
+
listIngress(roomName) {
|
|
94
|
+
var _a;
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
roomName !== null && roomName !== void 0 ? roomName : (roomName = '');
|
|
97
|
+
const data = yield this.rpc.request(svc, 'ListIngress', livekit_ingress_1.ListIngressRequest.toJSON({ roomName }), this.authHeader({ ingressAdmin: true }));
|
|
98
|
+
return (_a = livekit_ingress_1.ListIngressResponse.fromJSON(data).items) !== null && _a !== void 0 ? _a : [];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @param ingressId ingress to delete
|
|
103
|
+
*/
|
|
104
|
+
deleteIngress(ingressId) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const data = yield this.rpc.request(svc, 'DeleteIngress', livekit_ingress_1.DeleteIngressRequest.toJSON({ ingressId }), this.authHeader({ ingressAdmin: true }));
|
|
107
|
+
return livekit_ingress_1.IngressInfo.fromJSON(data);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.IngressClient = IngressClient;
|
|
112
|
+
//# sourceMappingURL=IngressClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IngressClient.js","sourceRoot":"","sources":["../src/IngressClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6DAUiC;AACjC,gEAAwC;AACxC,yCAA2D;AAE3D,MAAM,GAAG,GAAG,SAAS,CAAC;AAwDtB;;GAEG;AACH,MAAa,aAAc,SAAQ,qBAAW;IAG5C;;;;OAIG;IACH,YAAY,IAAY,EAAE,MAAe,EAAE,MAAe;QACxD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,GAAG,IAAI,mBAAQ,CAAC,IAAI,EAAE,yBAAc,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACG,aAAa,CAAC,SAAuB,EAAE,IAA2B;;YACtE,IAAI,IAAI,GAAW,EAAE,CAAC;YACtB,IAAI,QAAQ,GAAW,EAAE,CAAC;YAC1B,IAAI,eAAe,GAAW,EAAE,CAAC;YACjC,IAAI,mBAAmB,GAAW,EAAE,CAAC;YACrC,IAAI,KAAsC,CAAC;YAC3C,IAAI,KAAsC,CAAC;YAE3C,IAAI,IAAI,KAAK,SAAS,EAAE;gBACtB,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;gBACvB,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;gBAC/B,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,EAAE,CAAC;gBAC7C,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC;gBACrD,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;gBACnB,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;aACpB;YAED,MAAM,GAAG,GAAG,sCAAoB,CAAC,MAAM,CAAC;gBACtC,SAAS;gBACT,IAAI;gBAC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IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,aAAa,EACb,oCAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EACvC,IAAI,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CACxC,CAAC;YACF,OAAO,MAAA,qCAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,mCAAI,EAAE,CAAC;;KACvD;IAED;;OAEG;IACG,aAAa,CAAC,SAAiB;;YACnC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CACjC,GAAG,EACH,eAAe,EACf,sCAAoB,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAC1C,IAAI,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CACxC,CAAC;YACF,OAAO,6BAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;KAAA;CACF;AA9GD,sCA8GC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataPacket_Kind, ParticipantInfo, ParticipantPermission, Room, TrackInfo } from './proto/livekit_models';
|
|
2
2
|
import { RoomEgress } from './proto/livekit_room';
|
|
3
|
+
import ServiceBase from './ServiceBase';
|
|
3
4
|
/**
|
|
4
5
|
* Options for when creating a room
|
|
5
6
|
*/
|
|
@@ -17,21 +18,28 @@ export interface CreateOptions {
|
|
|
17
18
|
*/
|
|
18
19
|
maxParticipants?: number;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
+
* initial room metadata
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
metadata?: string;
|
|
23
24
|
/**
|
|
24
25
|
* add egress options
|
|
25
26
|
*/
|
|
26
27
|
egress?: RoomEgress;
|
|
28
|
+
/**
|
|
29
|
+
* override the node room is allocated to, for debugging
|
|
30
|
+
* does not work with Cloud
|
|
31
|
+
*/
|
|
32
|
+
nodeId?: string;
|
|
27
33
|
}
|
|
34
|
+
export declare type SendDataOptions = {
|
|
35
|
+
destinationSids?: string[];
|
|
36
|
+
topic?: string;
|
|
37
|
+
};
|
|
28
38
|
/**
|
|
29
39
|
* Client to access Room APIs
|
|
30
40
|
*/
|
|
31
|
-
export declare class RoomServiceClient {
|
|
41
|
+
export declare class RoomServiceClient extends ServiceBase {
|
|
32
42
|
private readonly rpc;
|
|
33
|
-
private readonly apiKey?;
|
|
34
|
-
private readonly secret?;
|
|
35
43
|
/**
|
|
36
44
|
*
|
|
37
45
|
* @param host hostname including protocol. i.e. 'https://cluster.livekit.io'
|
|
@@ -105,6 +113,14 @@ export declare class RoomServiceClient {
|
|
|
105
113
|
* @param subscribe true to subscribe, false to unsubscribe
|
|
106
114
|
*/
|
|
107
115
|
updateSubscriptions(room: string, identity: string, trackSids: string[], subscribe: boolean): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Sends data message to participants in the room
|
|
118
|
+
* @param room
|
|
119
|
+
* @param data opaque payload to send
|
|
120
|
+
* @param kind delivery reliability
|
|
121
|
+
* @param options optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)
|
|
122
|
+
*/
|
|
123
|
+
sendData(room: string, data: Uint8Array, kind: DataPacket_Kind, options: SendDataOptions): Promise<void>;
|
|
108
124
|
/**
|
|
109
125
|
* Sends data message to participants in the room
|
|
110
126
|
* @param room
|
|
@@ -113,5 +129,4 @@ export declare class RoomServiceClient {
|
|
|
113
129
|
* @param destinationSids optional. when empty, message is sent to everyone
|
|
114
130
|
*/
|
|
115
131
|
sendData(room: string, data: Uint8Array, kind: DataPacket_Kind, destinationSids?: string[]): Promise<void>;
|
|
116
|
-
private authHeader;
|
|
117
132
|
}
|