Skip to content

Commit aa38dce

Browse files
committed
merged 'ed/spaces'
Squashed commit of the following: commit b7c333e4454f6f4dce2daf87f76e42f3a1662045 Author: Ed Ropple <[email protected]> Date: Thu May 19 15:47:39 2022 -0400 mapped to pc/spaces
1 parent 8f21702 commit aa38dce

File tree

4 files changed

+164
-1
lines changed

4 files changed

+164
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mux/mux-node",
3-
"version": "5.0.0-rc.5",
3+
"version": "5.0.0",
44
"description": "Mux API wrapper",
55
"keywords": [
66
"mux",

src/video/domain.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,73 @@ export interface PlaybackRestrictionResponse {
337337
export interface ListPlaybackRestrictionsResponse {
338338
data: Array<PlaybackRestriction>;
339339
}
340+
341+
export type SpaceStatus = 'idle' | 'active';
342+
export type BroadcastStatus = 'idle' | 'active';
343+
export type BroadcastLayout = 'gallery' | 'active-speaker';
344+
export type BroadcastResolution =
345+
| '1920x1080'
346+
| '1280x720'
347+
| '1080x1920'
348+
| '720x1280'
349+
| '1080x1080'
350+
| '720x720';
351+
352+
export interface Broadcast {
353+
id: string;
354+
live_stream_id: string;
355+
status: BroadcastStatus;
356+
layout: BroadcastLayout;
357+
resolution: BroadcastResolution;
358+
359+
passthrough?: string;
360+
background?: string;
361+
}
362+
363+
export interface Space {
364+
id: string;
365+
created_at: string;
366+
type: 'server';
367+
status: SpaceStatus;
368+
passthrough?: string;
369+
broadcasts?: Array<Broadcast>;
370+
}
371+
372+
export interface CreateBroadcastRequest {
373+
live_stream_id: string;
374+
375+
passthrough?: string;
376+
layout?: BroadcastLayout;
377+
resolution?: BroadcastResolution;
378+
}
379+
380+
export interface CreateSpaceRequest {
381+
type?: 'server';
382+
passthrough?: string;
383+
broadcasts?: Array<CreateBroadcastRequest>;
384+
}
385+
386+
export interface SpaceResponse {
387+
data: Space;
388+
}
389+
390+
export interface BroadcastResponse {
391+
data: Broadcast;
392+
}
393+
394+
export interface ListSpacesRequest {
395+
limit?: number;
396+
page?: number;
397+
}
398+
399+
export interface ListSpacesResponse {
400+
data: Array<Space>;
401+
}
402+
403+
export interface StartSpaceBroadcastResponse {
404+
data: {};
405+
}
406+
407+
export interface StopSpaceBroadcastResponse {
408+
data: {};
409+
}

src/video/resources/spaces.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { Base } from '../../base.js';
2+
import { RequestOptions } from '../../RequestOptions.js';
3+
import {
4+
BroadcastResponse,
5+
CreateBroadcastRequest,
6+
CreateSpaceRequest,
7+
ListSpacesRequest,
8+
ListSpacesResponse,
9+
SpaceResponse,
10+
StartSpaceBroadcastResponse,
11+
StopSpaceBroadcastResponse,
12+
} from '../domain.js';
13+
14+
const BASE_PATH = '/video/v1/spaces';
15+
16+
const SPACE_PATH = (spaceId: string) => `${BASE_PATH}/${spaceId}`;
17+
const BROADCAST_PATH = (spaceId: string, broadcastId: string) =>
18+
`${SPACE_PATH(spaceId)}/broadcasts/${broadcastId}`;
19+
20+
export class Broadcasts extends Base {
21+
create(
22+
spaceId: string,
23+
request: CreateBroadcastRequest
24+
): Promise<BroadcastResponse> {
25+
return this.http.post(`${SPACE_PATH(spaceId)}/broadcasts`, request);
26+
}
27+
28+
get(spaceId: string, broadcastId: string): Promise<BroadcastResponse> {
29+
return this.http.get(BROADCAST_PATH(spaceId, broadcastId));
30+
}
31+
32+
delete(spaceId: string, broadcastId: string): Promise<BroadcastResponse> {
33+
return this.http.delete(BROADCAST_PATH(spaceId, broadcastId));
34+
}
35+
36+
start(
37+
spaceId: string,
38+
broadcastId: string
39+
): Promise<StartSpaceBroadcastResponse> {
40+
return this.http.post(`${BROADCAST_PATH(spaceId, broadcastId)}/start`);
41+
}
42+
43+
stop(
44+
spaceId: string,
45+
broadcastId: string
46+
): Promise<StopSpaceBroadcastResponse> {
47+
return this.http.post(`${BROADCAST_PATH(spaceId, broadcastId)}/stop`);
48+
}
49+
}
50+
51+
export class Spaces extends Base {
52+
readonly Broadcasts: Broadcasts;
53+
54+
constructor(base: Base);
55+
constructor(config: RequestOptions);
56+
constructor(accessToken: string, secret: string, config: RequestOptions);
57+
constructor(
58+
accessTokenOrConfigOrBase: string | RequestOptions | Base,
59+
secret?: string,
60+
config?: RequestOptions
61+
) {
62+
if (accessTokenOrConfigOrBase instanceof Base) {
63+
super(accessTokenOrConfigOrBase);
64+
} else if (typeof accessTokenOrConfigOrBase === 'object') {
65+
super(accessTokenOrConfigOrBase);
66+
} else {
67+
super(accessTokenOrConfigOrBase, secret!, config!);
68+
}
69+
70+
this.Broadcasts = new Broadcasts(this);
71+
}
72+
73+
create(req: CreateSpaceRequest): Promise<SpaceResponse> {
74+
return this.http.post(BASE_PATH, req);
75+
}
76+
77+
list(params: ListSpacesRequest): Promise<ListSpacesResponse> {
78+
return this.http.get(BASE_PATH, { params });
79+
}
80+
81+
get(spaceId: string): Promise<SpaceResponse> {
82+
return this.http.get(SPACE_PATH(spaceId));
83+
}
84+
85+
delete(spaceId: string): Promise<SpaceResponse> {
86+
return this.http.delete(SPACE_PATH(spaceId));
87+
}
88+
}

src/video/video.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Uploads } from './resources/uploads.js';
1313
import { SigningKeys } from './resources/signingKeys.js';
1414
import { DeliveryUsage } from './resources/deliveryUsage.js';
1515
import { PlaybackRestrictions } from './resources/playbackRestrictions.js';
16+
import { Spaces } from './resources/spaces.js';
1617

1718
/**
1819
* @ignore
@@ -37,6 +38,7 @@ export class Video extends Base {
3738
readonly Uploads: Uploads;
3839
readonly SigningKeys: SigningKeys;
3940
readonly DeliveryUsage: DeliveryUsage;
41+
readonly Spaces: Spaces;
4042

4143
constructor(base: Base);
4244
constructor(config: RequestOptions);
@@ -74,5 +76,8 @@ export class Video extends Base {
7476

7577
/** @Type {PlaybackRestrictions} */
7678
this.PlaybackRestrictions = new PlaybackRestrictions(this);
79+
80+
/** @Type {Spaces} */
81+
this.Spaces = new Spaces(this);
7782
}
7883
}

0 commit comments

Comments
 (0)