-
Notifications
You must be signed in to change notification settings - Fork 60
/
spaces.ts
425 lines (378 loc) · 14.6 KB
/
spaces.ts
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import * as Core from '@mux/mux-node/core';
import { APIResource } from '@mux/mux-node/resource';
import { isRequestOptions } from '@mux/mux-node/core';
import * as SpacesAPI from '@mux/mux-node/resources/video/spaces';
import { BasePage, type BasePageParams } from '@mux/mux-node/pagination';
export class Spaces extends APIResource {
/**
* Create a new space. Spaces are used to build
* [real-time video applications.](https://mux.com/real-time-video)
*
* @deprecated Mux Real-Time Video has been sunset and is unavailable for new usage.
* Existing access will end on December 31, 2023.
* We [recommend migrating your application to our partner, LiveKit](https://livekit.io/mux-livekit).
*/
create(body: SpaceCreateParams, options?: Core.RequestOptions): Core.APIPromise<Space> {
return (
this._client.post('/video/v1/spaces', { body, ...options }) as Core.APIPromise<{ data: Space }>
)._thenUnwrap((obj) => obj.data);
}
/**
* Retrieves the details of a space that has previously been created. Supply the
* unique space ID that was returned from your create space request, and Mux will
* return the information about the corresponding space. The same information is
* returned when creating a space.
*
* @deprecated Mux Real-Time Video has been sunset and is unavailable for new usage.
* Existing access will end on December 31, 2023.
* We [recommend migrating your application to our partner, LiveKit](https://livekit.io/mux-livekit).
*/
retrieve(spaceId: string, options?: Core.RequestOptions): Core.APIPromise<Space> {
return (
this._client.get(`/video/v1/spaces/${spaceId}`, options) as Core.APIPromise<{ data: Space }>
)._thenUnwrap((obj) => obj.data);
}
/**
* List all spaces in the current environment.
*
* @deprecated Mux Real-Time Video has been sunset and is unavailable for new usage.
* Existing access will end on December 31, 2023.
* We [recommend migrating your application to our partner, LiveKit](https://livekit.io/mux-livekit).
*/
list(query?: SpaceListParams, options?: Core.RequestOptions): Core.PagePromise<SpacesBasePage, Space>;
list(options?: Core.RequestOptions): Core.PagePromise<SpacesBasePage, Space>;
list(
query: SpaceListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<SpacesBasePage, Space> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/video/v1/spaces', SpacesBasePage, { query, ...options });
}
/**
* Deletes a space. Spaces can only be deleted when `idle`.
*
* @deprecated Mux Real-Time Video has been sunset and is unavailable for new usage.
* Existing access will end on December 31, 2023.
* We [recommend migrating your application to our partner, LiveKit](https://livekit.io/mux-livekit).
*/
delete(spaceId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.delete(`/video/v1/spaces/${spaceId}`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Creates a new broadcast. Broadcasts are used to create composited versions of
* your space, which can be broadcast to live streams. **Note:** By default only a
* single broadcast destination can be specified. Contact Mux support if you need
* more.
*
* @deprecated Mux Real-Time Video has been sunset and is unavailable for new usage.
* Existing access will end on December 31, 2023.
* We [recommend migrating your application to our partner, LiveKit](https://livekit.io/mux-livekit).
*/
createBroadcast(
spaceId: string,
body: SpaceCreateBroadcastParams,
options?: Core.RequestOptions,
): Core.APIPromise<Broadcast> {
return (
this._client.post(`/video/v1/spaces/${spaceId}/broadcasts`, { body, ...options }) as Core.APIPromise<{
data: Broadcast;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Deletes a single broadcast of a specific space. Broadcasts can only be deleted
* when `idle`.
*
* @deprecated Mux Real-Time Video has been sunset and is unavailable for new usage.
* Existing access will end on December 31, 2023.
* We [recommend migrating your application to our partner, LiveKit](https://livekit.io/mux-livekit).
*/
deleteBroadcast(
spaceId: string,
broadcastId: string,
options?: Core.RequestOptions,
): Core.APIPromise<void> {
return this._client.delete(`/video/v1/spaces/${spaceId}/broadcasts/${broadcastId}`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Retrieves the details of a broadcast of a specific space.
*
* @deprecated Mux Real-Time Video has been sunset and is unavailable for new usage.
* Existing access will end on December 31, 2023.
* We [recommend migrating your application to our partner, LiveKit](https://livekit.io/mux-livekit).
*/
retrieveBroadcast(
spaceId: string,
broadcastId: string,
options?: Core.RequestOptions,
): Core.APIPromise<Broadcast> {
return (
this._client.get(`/video/v1/spaces/${spaceId}/broadcasts/${broadcastId}`, options) as Core.APIPromise<{
data: Broadcast;
}>
)._thenUnwrap((obj) => obj.data);
}
/**
* Starts broadcasting a space to the associated destination. Broadcasts can only
* be started when the space is `active` (when there are participants connected).
*
* @deprecated Mux Real-Time Video has been sunset and is unavailable for new usage.
* Existing access will end on December 31, 2023.
* We [recommend migrating your application to our partner, LiveKit](https://livekit.io/mux-livekit).
*/
startBroadcast(spaceId: string, broadcastId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.post(`/video/v1/spaces/${spaceId}/broadcasts/${broadcastId}/start`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
/**
* Stops broadcasting a space, causing the destination live stream to become idle.
* This API also automatically calls `complete` on the destination live stream.
* Broadcasts are also automatically stopped when a space becomes idle.
*
* @deprecated Mux Real-Time Video has been sunset and is unavailable for new usage.
* Existing access will end on December 31, 2023.
* We [recommend migrating your application to our partner, LiveKit](https://livekit.io/mux-livekit).
*/
stopBroadcast(spaceId: string, broadcastId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.post(`/video/v1/spaces/${spaceId}/broadcasts/${broadcastId}/stop`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
}
}
export class SpacesBasePage extends BasePage<Space> {}
export interface Broadcast {
/**
* Unique identifier for the broadcast. Max 255 characters.
*/
id: string;
/**
* The layout used when broadcasting the space.
*
* The `gallery` layout will show participants in a grid that automatically resizes
* each participant’s stream to best fit up to 10 participants in the window. The
* `active-speaker` layout will show only the current active speaker, without a
* border. The `crop` layout uses as much of the available space as possible to
* show the participant's stream.
*
* Defaults to `gallery` if not set.
*/
layout: BroadcastLayout;
/**
* The ID of the live stream that the broadcast will be sent to.
*/
live_stream_id: string;
/**
* The resolution of the composited video sent to the live stream. Defaults to
* `1920x1080` if not set.
*/
resolution: BroadcastResolution;
/**
* The status of the broadcast. You can start and stop broadcasts with the `start`
* and `stop` APIs.
*/
status: BroadcastStatus;
/**
* URL of an image to display as the background of the broadcast. Its dimensions
* should match the provided resolution.
*/
background?: string;
/**
* Arbitrary user-supplied metadata that will be included in the broadcast details
* and related webhooks. Max: 255 characters.
*/
passthrough?: string;
}
/**
* The layout used when broadcasting the space.
*
* The `gallery` layout will show participants in a grid that automatically resizes
* each participant’s stream to best fit up to 10 participants in the window. The
* `active-speaker` layout will show only the current active speaker, without a
* border. The `crop` layout uses as much of the available space as possible to
* show the participant's stream.
*
* Defaults to `gallery` if not set.
*/
export type BroadcastLayout = 'gallery' | 'active-speaker' | 'crop';
/**
* The resolution of the composited video sent to the live stream. Defaults to
* `1920x1080` if not set.
*/
export type BroadcastResolution =
| '1920x1080'
| '1280x720'
| '1080x1920'
| '720x1280'
| '1080x1080'
| '720x720';
export interface BroadcastResponse {
data: Broadcast;
}
/**
* The status of the broadcast. You can start and stop broadcasts with the `start`
* and `stop` APIs.
*/
export type BroadcastStatus = 'idle' | 'active';
export interface Space {
/**
* Unique identifier for the space. Max 255 characters.
*/
id: string;
/**
* Time the space was created, defined as a Unix timestamp (seconds since epoch).
*/
created_at: string;
/**
* The status of the space. Spaces are `idle` when there are no participants
* connected, and `active` when there are participants connected.
*/
status: SpaceStatus;
/**
* Specify the network architecture of the space. In `server` spaces, all video
* travels through Mux's video infrastructure. Defaults to `server` if not set.
*/
type: SpaceType;
/**
* Unique identifier for the current lifecycle of the space. Only set when the
* space is `active` and is set to a new value each time the space transitions from
* `idle` to `active`. This value is useful for logging and debugging issues. Max
* 255 characters.
*/
active_session_id?: string;
/**
* An array of broadcast destinations.
*/
broadcasts?: Array<Broadcast>;
/**
* Arbitrary user-supplied metadata that will be included in the space details and
* related webhooks. Max: 255 characters.
*/
passthrough?: string;
}
export interface SpaceResponse {
data: Space;
}
/**
* The status of the space. Spaces are `idle` when there are no participants
* connected, and `active` when there are participants connected.
*/
export type SpaceStatus = 'idle' | 'active';
/**
* Specify the network architecture of the space. In `server` spaces, all video
* travels through Mux's video infrastructure. Defaults to `server` if not set.
*/
export type SpaceType = 'server';
export interface SpaceCreateParams {
/**
* An array of broadcast destinations you want to stream the space to. **Note:** By
* default only a single broadcast destination can be specified. Contact Mux
* support if you need more.
*/
broadcasts?: Array<SpaceCreateParams.Broadcast>;
/**
* Arbitrary user-supplied metadata that will be included in the space details and
* related webhooks. Max: 255 characters.
*/
passthrough?: string;
/**
* Specify the network architecture of the space. In `server` spaces, all video
* travels through Mux's video infrastructure. Defaults to `server` if not set.
*/
type?: SpaceType;
}
export namespace SpaceCreateParams {
export interface Broadcast {
/**
* The ID of the live stream that you want to broadcast to.
*/
live_stream_id: string;
/**
* URL of an image to display as the background of the broadcast. Its dimensions
* should match the provided resolution.
*/
background?: string;
/**
* The layout used when broadcasting the space.
*
* The `gallery` layout will show participants in a grid that automatically resizes
* each participant’s stream to best fit up to 10 participants in the window. The
* `active-speaker` layout will show only the current active speaker, without a
* border. The `crop` layout uses as much of the available space as possible to
* show the participant's stream.
*
* Defaults to `gallery` if not set.
*/
layout?: SpacesAPI.BroadcastLayout;
/**
* Arbitrary user-supplied metadata that will be included in the broadcast details
* and related webhooks. Max: 255 characters.
*/
passthrough?: string;
/**
* The resolution of the composited video sent to the live stream. Defaults to
* `1920x1080` if not set.
*/
resolution?: SpacesAPI.BroadcastResolution;
}
}
export interface SpaceListParams extends BasePageParams {}
export interface SpaceCreateBroadcastParams {
/**
* The ID of the live stream that you want to broadcast to.
*/
live_stream_id: string;
/**
* URL of an image to display as the background of the broadcast. Its dimensions
* should match the provided resolution.
*/
background?: string;
/**
* The layout used when broadcasting the space.
*
* The `gallery` layout will show participants in a grid that automatically resizes
* each participant’s stream to best fit up to 10 participants in the window. The
* `active-speaker` layout will show only the current active speaker, without a
* border. The `crop` layout uses as much of the available space as possible to
* show the participant's stream.
*
* Defaults to `gallery` if not set.
*/
layout?: BroadcastLayout;
/**
* Arbitrary user-supplied metadata that will be included in the broadcast details
* and related webhooks. Max: 255 characters.
*/
passthrough?: string;
/**
* The resolution of the composited video sent to the live stream. Defaults to
* `1920x1080` if not set.
*/
resolution?: BroadcastResolution;
}
export namespace Spaces {
export import Broadcast = SpacesAPI.Broadcast;
export import BroadcastLayout = SpacesAPI.BroadcastLayout;
export import BroadcastResolution = SpacesAPI.BroadcastResolution;
export import BroadcastResponse = SpacesAPI.BroadcastResponse;
export import BroadcastStatus = SpacesAPI.BroadcastStatus;
export import Space = SpacesAPI.Space;
export import SpaceResponse = SpacesAPI.SpaceResponse;
export import SpaceStatus = SpacesAPI.SpaceStatus;
export import SpaceType = SpacesAPI.SpaceType;
export import SpacesBasePage = SpacesAPI.SpacesBasePage;
export import SpaceCreateParams = SpacesAPI.SpaceCreateParams;
export import SpaceListParams = SpacesAPI.SpaceListParams;
export import SpaceCreateBroadcastParams = SpacesAPI.SpaceCreateBroadcastParams;
}