livekit-server-sdk 2.12.0 → 2.13.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.
@@ -35,7 +35,7 @@ class EgressClient extends import_ServiceBase.ServiceBase {
35
35
  super(apiKey, secret);
36
36
  this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage);
37
37
  }
38
- async startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl) {
38
+ async startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl, audioMixing) {
39
39
  let layout;
40
40
  if (optsOrLayout !== void 0) {
41
41
  if (typeof optsOrLayout === "string") {
@@ -47,12 +47,14 @@ class EgressClient extends import_ServiceBase.ServiceBase {
47
47
  audioOnly = opts.audioOnly;
48
48
  videoOnly = opts.videoOnly;
49
49
  customBaseUrl = opts.customBaseUrl;
50
+ audioMixing = opts.audioMixing;
50
51
  }
51
52
  }
52
53
  layout ??= "";
53
54
  audioOnly ??= false;
54
55
  videoOnly ??= false;
55
56
  customBaseUrl ??= "";
57
+ audioMixing ??= import_protocol.AudioMixing.DEFAULT_MIXING;
56
58
  const {
57
59
  output: legacyOutput,
58
60
  options: egressOptions,
@@ -65,6 +67,7 @@ class EgressClient extends import_ServiceBase.ServiceBase {
65
67
  roomName,
66
68
  layout,
67
69
  audioOnly,
70
+ audioMixing,
68
71
  videoOnly,
69
72
  customBaseUrl,
70
73
  output: legacyOutput,
@@ -1 +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 screenShare: opts?.screenShare ?? false,\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,yBAA4B;AAE5B,sBAAyC;AAEzC,MAAM,MAAM;AA0FL,MAAM,qBAAqB,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ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B,UAAI,WAAW;AAAA,IACjB,WAAW,YAAY,QAAW;AAChC,YAAM;AAAA,IACR;AAEA,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kCAAkB,GAAG,EAAE,OAAO;AAAA,MAClC,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,mCAAmB,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC,EAAE,SAAS,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,UAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kCAAkB,EAAE,SAAS,CAAC,EAAE,OAAO;AAAA,MAC3C,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,2BAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AACF;","names":[]}
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 AudioMixing,\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 * audio mixing options. optional\n */\n audioMixing?: AudioMixing;\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 audioMixing?: AudioMixing,\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 audioMixing?: AudioMixing,\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 audioMixing = opts.audioMixing;\n }\n }\n\n layout ??= '';\n audioOnly ??= false;\n videoOnly ??= false;\n customBaseUrl ??= '';\n audioMixing ??= AudioMixing.DEFAULT_MIXING;\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 audioMixing,\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 screenShare: opts?.screenShare ?? false,\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,sBAaO;AACP,yBAA4B;AAE5B,sBAAyC;AAEzC,MAAM,MAAM;AA8FL,MAAM,qBAAqB,+BAAY;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,EAyBA,MAAM,yBACJ,UACA,QACA,cACA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IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kCAAkB,GAAG,EAAE,OAAO;AAAA,MAClC,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,mCAAmB,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC,EAAE,SAAS,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,UAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kCAAkB,EAAE,SAAS,CAAC,EAAE,OAAO;AAAA,MAC3C,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,2BAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- import { EncodingOptionsPreset, EncodingOptions, EncodedFileOutput, StreamOutput, SegmentedFileOutput, ImageOutput, EgressInfo, DirectFileOutput } from '@livekit/protocol';
1
+ import { EncodingOptionsPreset, EncodingOptions, AudioMixing, EncodedFileOutput, StreamOutput, SegmentedFileOutput, ImageOutput, EgressInfo, DirectFileOutput } from '@livekit/protocol';
2
2
  import { ServiceBase } from './ServiceBase.cjs';
3
3
  import './grants.cjs';
4
4
  import 'jose';
@@ -24,6 +24,10 @@ interface RoomCompositeOptions {
24
24
  * custom template url. optional
25
25
  */
26
26
  customBaseUrl?: string;
27
+ /**
28
+ * audio mixing options. optional
29
+ */
30
+ audioMixing?: AudioMixing;
27
31
  }
28
32
  interface WebOptions {
29
33
  /**
@@ -102,7 +106,7 @@ declare class EgressClient extends ServiceBase {
102
106
  /**
103
107
  * @deprecated use RoomCompositeOptions instead
104
108
  */
105
- startRoomCompositeEgress(roomName: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, layout?: string, options?: EncodingOptionsPreset | EncodingOptions, audioOnly?: boolean, videoOnly?: boolean, customBaseUrl?: string): Promise<EgressInfo>;
109
+ startRoomCompositeEgress(roomName: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, layout?: string, options?: EncodingOptionsPreset | EncodingOptions, audioOnly?: boolean, videoOnly?: boolean, customBaseUrl?: string, audioMixing?: AudioMixing): Promise<EgressInfo>;
106
110
  /**
107
111
  * @param url - url
108
112
  * @param output - file or stream output
@@ -1,5 +1,5 @@
1
1
  import type { DirectFileOutput, EncodedFileOutput, EncodingOptions, EncodingOptionsPreset, ImageOutput, SegmentedFileOutput, StreamOutput } from '@livekit/protocol';
2
- import { EgressInfo } from '@livekit/protocol';
2
+ import { AudioMixing, EgressInfo } from '@livekit/protocol';
3
3
  import { ServiceBase } from './ServiceBase.js';
4
4
  export interface RoomCompositeOptions {
5
5
  /**
@@ -22,6 +22,10 @@ export interface RoomCompositeOptions {
22
22
  * custom template url. optional
23
23
  */
24
24
  customBaseUrl?: string;
25
+ /**
26
+ * audio mixing options. optional
27
+ */
28
+ audioMixing?: AudioMixing;
25
29
  }
26
30
  export interface WebOptions {
27
31
  /**
@@ -100,7 +104,7 @@ export declare class EgressClient extends ServiceBase {
100
104
  /**
101
105
  * @deprecated use RoomCompositeOptions instead
102
106
  */
103
- startRoomCompositeEgress(roomName: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, layout?: string, options?: EncodingOptionsPreset | EncodingOptions, audioOnly?: boolean, videoOnly?: boolean, customBaseUrl?: string): Promise<EgressInfo>;
107
+ startRoomCompositeEgress(roomName: string, output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput, layout?: string, options?: EncodingOptionsPreset | EncodingOptions, audioOnly?: boolean, videoOnly?: boolean, customBaseUrl?: string, audioMixing?: AudioMixing): Promise<EgressInfo>;
104
108
  /**
105
109
  * @param url - url
106
110
  * @param output - file or stream output
@@ -1 +1 @@
1
- {"version":3,"file":"EgressClient.d.ts","sourceRoot":"","sources":["../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AY,CAChB,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,EAAE,EACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,OAAO,CAAC,UAAU,CAAC;IAatB;;;OAGG;IACG,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACzE;;;OAGG;IACG,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAqB/D;;OAEG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CASxD"}
@@ -1,4 +1,5 @@
1
1
  import {
2
+ AudioMixing,
2
3
  EgressInfo,
3
4
  ListEgressRequest,
4
5
  ListEgressResponse,
@@ -24,7 +25,7 @@ class EgressClient extends ServiceBase {
24
25
  super(apiKey, secret);
25
26
  this.rpc = new TwirpRpc(host, livekitPackage);
26
27
  }
27
- async startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl) {
28
+ async startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl, audioMixing) {
28
29
  let layout;
29
30
  if (optsOrLayout !== void 0) {
30
31
  if (typeof optsOrLayout === "string") {
@@ -36,12 +37,14 @@ class EgressClient extends ServiceBase {
36
37
  audioOnly = opts.audioOnly;
37
38
  videoOnly = opts.videoOnly;
38
39
  customBaseUrl = opts.customBaseUrl;
40
+ audioMixing = opts.audioMixing;
39
41
  }
40
42
  }
41
43
  layout ??= "";
42
44
  audioOnly ??= false;
43
45
  videoOnly ??= false;
44
46
  customBaseUrl ??= "";
47
+ audioMixing ??= AudioMixing.DEFAULT_MIXING;
45
48
  const {
46
49
  output: legacyOutput,
47
50
  options: egressOptions,
@@ -54,6 +57,7 @@ class EgressClient extends ServiceBase {
54
57
  roomName,
55
58
  layout,
56
59
  audioOnly,
60
+ audioMixing,
57
61
  videoOnly,
58
62
  customBaseUrl,
59
63
  output: legacyOutput,
@@ -1 +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 screenShare: opts?.screenShare ?? false,\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":"AAYA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAE5B,SAAS,UAAU,sBAAsB;AAEzC,MAAM,MAAM;AA0FL,MAAM,qBAAqB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,YAAY,MAAc,QAAiB,QAAiB;AAC1D,UAAM,QAAQ,MAAM;AACpB,SAAK,MAAM,IAAI,SAAS,MAAM,cAAc;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,2BAA2B;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,O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ACA,eACA,kBACqB;AACrB,sBAAkB,CAAC;AACnB,yBAAqB,CAAC;AAEtB,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,oBAAoB,EAAE,UAAU,eAAe,iBAAiB,CAAC,EAAE,OAAO;AAAA,MAC9E,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,WAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,WAAW,SAAkE;AACjF,QAAI,MAAkC,CAAC;AACvC,QAAI,OAAO,YAAY,UAAU;AAC/B,UAAI,WAAW;AAAA,IACjB,WAAW,YAAY,QAAW;AAChC,YAAM;AAAA,IACR;AAEA,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kBAAkB,GAAG,EAAE,OAAO;AAAA,MAClC,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,mBAAmB,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC,EAAE,SAAS,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,UAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kBAAkB,EAAE,SAAS,CAAC,EAAE,OAAO;AAAA,MAC3C,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,WAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AACF;","names":[]}
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 AudioMixing,\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 * audio mixing options. optional\n */\n audioMixing?: AudioMixing;\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 audioMixing?: AudioMixing,\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 audioMixing?: AudioMixing,\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 audioMixing = opts.audioMixing;\n }\n }\n\n layout ??= '';\n audioOnly ??= false;\n videoOnly ??= false;\n customBaseUrl ??= '';\n audioMixing ??= AudioMixing.DEFAULT_MIXING;\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 audioMixing,\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 screenShare: opts?.screenShare ?? false,\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":"AAYA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAE5B,SAAS,UAAU,sBAAsB;AAEzC,MAAM,MAAM;AA8FL,MAAM,qBAAqB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,YAAY,MAAc,QAAiB,QAAiB;AAC1D,UAAM,QAAQ,MAAM;AACpB,SAAK,MAAM,IAAI,SAAS,MAAM,cAAc;AAAA,EAC9C;AAAA,EAyBA,MAAM,yBACJ,UACA,QACA,cACA,SACA,WACA,WACA,eACA,aACqB;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;AACrB,sBAAc,KAAK;AAAA,MACrB;AAAA,IACF;AAEA,eAAW;AACX,kBAAc;AACd,kBAAc;AACd,sBAAkB;AAClB,oBAAgB,YAAY;AAE5B,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,2BAA2B;AAAA,MACzC;AAAA,MACA;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,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ACqB;AACrB,sBAAkB,CAAC;AACnB,yBAAqB,CAAC;AAEtB,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,oBAAoB,EAAE,UAAU,eAAe,iBAAiB,CAAC,EAAE,OAAO;AAAA,MAC9E,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,WAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,WAAW,SAAkE;AACjF,QAAI,MAAkC,CAAC;AACvC,QAAI,OAAO,YAAY,UAAU;AAC/B,UAAI,WAAW;AAAA,IACjB,WAAW,YAAY,QAAW;AAChC,YAAM;AAAA,IACR;AAEA,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kBAAkB,GAAG,EAAE,OAAO;AAAA,MAClC,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,mBAAmB,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC,EAAE,SAAS,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,UAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kBAAkB,EAAE,SAAS,CAAC,EAAE,OAAO;AAAA,MAC3C,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,WAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AACF;","names":[]}
@@ -142,6 +142,9 @@ class RoomServiceClient extends import_ServiceBase.ServiceBase {
142
142
  * participant. When the source participant disconnects or the
143
143
  * `RemoveParticipant` method is called in the destination room, the
144
144
  * forwarding will be stopped.
145
+ * @param room -
146
+ * @param identity -
147
+ * @param destinationRoom - the room to forward the participant to
145
148
  */
146
149
  async forwardParticipant(room, identity, destinationRoom) {
147
150
  await this.rpc.request(
@@ -151,6 +154,22 @@ class RoomServiceClient extends import_ServiceBase.ServiceBase {
151
154
  await this.authHeader({ roomAdmin: true, room, destinationRoom })
152
155
  );
153
156
  }
157
+ /**
158
+ * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.
159
+ * The participant will be removed from the current room and added to the destination room.
160
+ * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.
161
+ * @param room -
162
+ * @param identity -
163
+ * @param destinationRoom - the room to move the participant to
164
+ */
165
+ async moveParticipant(room, identity, destinationRoom) {
166
+ await this.rpc.request(
167
+ svc,
168
+ "MoveParticipant",
169
+ new import_protocol.MoveParticipantRequest({ room, identity, destinationRoom }).toJson(),
170
+ await this.authHeader({ roomAdmin: true, room, destinationRoom })
171
+ );
172
+ }
154
173
  /**
155
174
  * Mutes a track that the participant has published.
156
175
  * @param room -
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/RoomServiceClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { DataPacket_Kind, RoomEgress, TrackInfo } from '@livekit/protocol';\nimport {\n CreateRoomRequest,\n DeleteRoomRequest,\n ForwardParticipantRequest,\n ListParticipantsRequest,\n ListParticipantsResponse,\n ListRoomsRequest,\n ListRoomsResponse,\n MuteRoomTrackRequest,\n MuteRoomTrackResponse,\n ParticipantInfo,\n ParticipantPermission,\n Room,\n RoomParticipantIdentity,\n SendDataRequest,\n UpdateParticipantRequest,\n UpdateRoomMetadataRequest,\n UpdateSubscriptionsRequest,\n} from '@livekit/protocol';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\nimport { getRandomBytes } from './crypto/uuid.js';\n\n/**\n * Options for when creating a room\n */\nexport interface CreateOptions {\n /**\n * name of the room. required\n */\n name: string;\n\n /**\n * number of seconds to keep the room open before any participant joins\n */\n emptyTimeout?: number;\n\n /**\n * number of seconds to keep the room open after the last participant leaves\n * this option is helpful to give a grace period for participants to re-join\n */\n departureTimeout?: number;\n\n /**\n * limit to the number of participants in a room at a time\n */\n maxParticipants?: number;\n\n /**\n * initial room metadata\n */\n metadata?: string;\n\n /**\n * add egress options\n */\n egress?: RoomEgress;\n\n /**\n * minimum playout delay in milliseconds\n */\n minPlayoutDelay?: number;\n\n /**\n * maximum playout delay in milliseconds\n */\n maxPlayoutDelay?: number;\n\n /**\n * improves A/V sync when min_playout_delay set to a value larger than 200ms.\n * It will disables transceiver re-use -- this option is not recommended\n * for rooms with frequent subscription changes\n */\n syncStreams?: boolean;\n\n /**\n * override the node room is allocated to, for debugging\n * does not work with Cloud\n */\n nodeId?: string;\n}\n\nexport type SendDataOptions = {\n /** If set, only deliver to listed participant identities */\n destinationIdentities?: string[];\n destinationSids?: string[];\n topic?: string;\n};\n\nexport type UpdateParticipantOptions = {\n /** only attributes you'd want to update should be set, set value to empty string to remove it */\n attributes?: { [key: string]: string };\n metadata?: string;\n /** permissions are updated atomically - all desired permissions would need to be set */\n permission?: Partial<ParticipantPermission>;\n name?: string;\n};\n\nconst svc = 'RoomService';\n\n/**\n * Client to access Room APIs\n */\nexport class RoomServiceClient extends ServiceBase {\n private readonly rpc: Rpc;\n\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 * Creates a new room. Explicit room creation is not required, since rooms will\n * be automatically created when the first participant joins. This method can be\n * used to customize room settings.\n * @param options -\n */\n async createRoom(options: CreateOptions): Promise<Room> {\n const data = await this.rpc.request(\n svc,\n 'CreateRoom',\n new CreateRoomRequest(options).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List active rooms\n * @param names - when undefined or empty, list all rooms.\n * otherwise returns rooms with matching names\n * @returns\n */\n async listRooms(names?: string[]): Promise<Room[]> {\n const data = await this.rpc.request(\n svc,\n 'ListRooms',\n new ListRoomsRequest({ names: names ?? [] }).toJson(),\n await this.authHeader({ roomList: true }),\n );\n const res = ListRoomsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.rooms ?? [];\n }\n\n async deleteRoom(room: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'DeleteRoom',\n new DeleteRoomRequest({ room }).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n }\n\n /**\n * Update metadata of a room\n * @param room - name of the room\n * @param metadata - the new metadata for the room\n */\n async updateRoomMetadata(room: string, metadata: string) {\n const data = await this.rpc.request(\n svc,\n 'UpdateRoomMetadata',\n new UpdateRoomMetadataRequest({ room, metadata }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List participants in a room\n * @param room - name of the room\n */\n async listParticipants(room: string): Promise<ParticipantInfo[]> {\n const data = await this.rpc.request(\n svc,\n 'ListParticipants',\n new ListParticipantsRequest({ room }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = ListParticipantsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.participants ?? [];\n }\n\n /**\n * Get information on a specific participant, including the tracks that participant\n * has published\n * @param room - name of the room\n * @param identity - identity of the participant to return\n */\n async getParticipant(room: string, identity: string): Promise<ParticipantInfo> {\n const data = await this.rpc.request(\n svc,\n 'GetParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Removes a participant in the room. This will disconnect the participant\n * and will emit a Disconnected event for that participant.\n * Even after being removed, the participant can still re-join the room.\n * @param room -\n * @param identity -\n */\n async removeParticipant(room: string, identity: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'RemoveParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Forwards a participant's track to another room. This will create a\n * participant to join the destination room that has same information\n * with the source participant except the kind to be `Forwarded`. All\n * changes to the source participant will be reflected to the forwarded\n * participant. When the source participant disconnects or the\n * `RemoveParticipant` method is called in the destination room, the\n * forwarding will be stopped.\n */\n async forwardParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'ForwardParticipant',\n new ForwardParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Mutes a track that the participant has published.\n * @param room -\n * @param identity -\n * @param trackSid - sid of the track to be muted\n * @param muted - true to mute, false to unmute\n */\n async mutePublishedTrack(\n room: string,\n identity: string,\n trackSid: string,\n muted: boolean,\n ): Promise<TrackInfo> {\n const req = new MuteRoomTrackRequest({\n room,\n identity,\n trackSid,\n muted,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'MutePublishedTrack',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = MuteRoomTrackResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.track!;\n }\n\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n options: UpdateParticipantOptions,\n ): Promise<ParticipantInfo>;\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n metadata?: string,\n permission?: Partial<ParticipantPermission>,\n name?: string,\n ): Promise<ParticipantInfo>;\n async updateParticipant(\n room: string,\n identity: string,\n metadataOrOptions?: string | UpdateParticipantOptions,\n maybePermission?: Partial<ParticipantPermission>,\n maybeName?: string,\n ): Promise<ParticipantInfo> {\n const hasOptions = typeof metadataOrOptions === 'object';\n const metadata = hasOptions ? metadataOrOptions?.metadata : metadataOrOptions;\n const permission = hasOptions ? metadataOrOptions.permission : maybePermission;\n const name = hasOptions ? metadataOrOptions.name : maybeName;\n const attributes: Record<string, string> | undefined = hasOptions\n ? metadataOrOptions.attributes\n : {};\n\n const req = new UpdateParticipantRequest({\n room,\n identity,\n attributes,\n metadata,\n name,\n });\n if (permission) {\n req.permission = new ParticipantPermission(permission);\n }\n const data = await this.rpc.request(\n svc,\n 'UpdateParticipant',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Updates a participant's subscription to tracks\n * @param room -\n * @param identity -\n * @param trackSids -\n * @param subscribe - true to subscribe, false to unsubscribe\n */\n async updateSubscriptions(\n room: string,\n identity: string,\n trackSids: string[],\n subscribe: boolean,\n ): Promise<void> {\n const req = new UpdateSubscriptionsRequest({\n room,\n identity,\n trackSids,\n subscribe,\n participantTracks: [],\n }).toJson();\n await this.rpc.request(\n svc,\n 'UpdateSubscriptions',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Sends data message to participants in the room\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param options - optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions,\n ): Promise<void>;\n /**\n * Sends data message to participants in the room\n * @deprecated use sendData(room, data, kind, options) instead\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param destinationSids - optional. when empty, message is sent to everyone\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n destinationSids?: string[],\n ): Promise<void>;\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions | string[] = {},\n ): Promise<void> {\n const destinationSids = Array.isArray(options) ? options : options.destinationSids;\n const topic = Array.isArray(options) ? undefined : options.topic;\n const req = new SendDataRequest({\n room,\n data,\n kind,\n destinationSids: destinationSids ?? [],\n topic,\n });\n if (!Array.isArray(options) && options.destinationIdentities) {\n req.destinationIdentities = options.destinationIdentities;\n }\n req.nonce = await getRandomBytes(16);\n await this.rpc.request(\n svc,\n 'SendData',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAkBO;AACP,yBAA4B;AAE5B,sBAAyC;AACzC,kBAA+B;AA6E/B,MAAM,MAAM;AAKL,MAAM,0BAA0B,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjD,YAAY,MAAc,QAAiB,QAAiB;AAC1D,UAAM,QAAQ,MAAM;AACpB,SAAK,MAAM,IAAI,yBAAS,MAAM,8BAAc;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,WAAW,SAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kCAAkB,OAAO,EAAE,OAAO;AAAA,MACtC,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,qBAAK,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UAAU,OAAmC;AACjD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,iCAAiB,EAAE,OAAO,SAAS,CAAC,EAAE,CAAC,EAAE,OAAO;AAAA,MACpD,MAAM,KAAK,WAAW,EAAE,UAAU,KAAK,CAAC;AAAA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AAQ,OAAO,KAAK,QAAQ,uBAAuB;AAC5D,UAAI,wBAAwB,QAAQ;AAAA,IACtC;AACA,QAAI,QAAQ,UAAM,4BAAe,EAAE;AACnC,UAAM,KAAK,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA,IAAI,OAAO;AAAA,MACX,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,KAAK,CAAC;AAAA,IACjD;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/RoomServiceClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { DataPacket_Kind, RoomEgress, TrackInfo } from '@livekit/protocol';\nimport {\n CreateRoomRequest,\n DeleteRoomRequest,\n ForwardParticipantRequest,\n ListParticipantsRequest,\n ListParticipantsResponse,\n ListRoomsRequest,\n ListRoomsResponse,\n MoveParticipantRequest,\n MuteRoomTrackRequest,\n MuteRoomTrackResponse,\n ParticipantInfo,\n ParticipantPermission,\n Room,\n RoomParticipantIdentity,\n SendDataRequest,\n UpdateParticipantRequest,\n UpdateRoomMetadataRequest,\n UpdateSubscriptionsRequest,\n} from '@livekit/protocol';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\nimport { getRandomBytes } from './crypto/uuid.js';\n\n/**\n * Options for when creating a room\n */\nexport interface CreateOptions {\n /**\n * name of the room. required\n */\n name: string;\n\n /**\n * number of seconds to keep the room open before any participant joins\n */\n emptyTimeout?: number;\n\n /**\n * number of seconds to keep the room open after the last participant leaves\n * this option is helpful to give a grace period for participants to re-join\n */\n departureTimeout?: number;\n\n /**\n * limit to the number of participants in a room at a time\n */\n maxParticipants?: number;\n\n /**\n * initial room metadata\n */\n metadata?: string;\n\n /**\n * add egress options\n */\n egress?: RoomEgress;\n\n /**\n * minimum playout delay in milliseconds\n */\n minPlayoutDelay?: number;\n\n /**\n * maximum playout delay in milliseconds\n */\n maxPlayoutDelay?: number;\n\n /**\n * improves A/V sync when min_playout_delay set to a value larger than 200ms.\n * It will disables transceiver re-use -- this option is not recommended\n * for rooms with frequent subscription changes\n */\n syncStreams?: boolean;\n\n /**\n * override the node room is allocated to, for debugging\n * does not work with Cloud\n */\n nodeId?: string;\n}\n\nexport type SendDataOptions = {\n /** If set, only deliver to listed participant identities */\n destinationIdentities?: string[];\n destinationSids?: string[];\n topic?: string;\n};\n\nexport type UpdateParticipantOptions = {\n /** only attributes you'd want to update should be set, set value to empty string to remove it */\n attributes?: { [key: string]: string };\n metadata?: string;\n /** permissions are updated atomically - all desired permissions would need to be set */\n permission?: Partial<ParticipantPermission>;\n name?: string;\n};\n\nconst svc = 'RoomService';\n\n/**\n * Client to access Room APIs\n */\nexport class RoomServiceClient extends ServiceBase {\n private readonly rpc: Rpc;\n\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 * Creates a new room. Explicit room creation is not required, since rooms will\n * be automatically created when the first participant joins. This method can be\n * used to customize room settings.\n * @param options -\n */\n async createRoom(options: CreateOptions): Promise<Room> {\n const data = await this.rpc.request(\n svc,\n 'CreateRoom',\n new CreateRoomRequest(options).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List active rooms\n * @param names - when undefined or empty, list all rooms.\n * otherwise returns rooms with matching names\n * @returns\n */\n async listRooms(names?: string[]): Promise<Room[]> {\n const data = await this.rpc.request(\n svc,\n 'ListRooms',\n new ListRoomsRequest({ names: names ?? [] }).toJson(),\n await this.authHeader({ roomList: true }),\n );\n const res = ListRoomsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.rooms ?? [];\n }\n\n async deleteRoom(room: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'DeleteRoom',\n new DeleteRoomRequest({ room }).toJson(),\n await this.authHeader({ roomCreate: true }),\n );\n }\n\n /**\n * Update metadata of a room\n * @param room - name of the room\n * @param metadata - the new metadata for the room\n */\n async updateRoomMetadata(room: string, metadata: string) {\n const data = await this.rpc.request(\n svc,\n 'UpdateRoomMetadata',\n new UpdateRoomMetadataRequest({ room, metadata }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return Room.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * List participants in a room\n * @param room - name of the room\n */\n async listParticipants(room: string): Promise<ParticipantInfo[]> {\n const data = await this.rpc.request(\n svc,\n 'ListParticipants',\n new ListParticipantsRequest({ room }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = ListParticipantsResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.participants ?? [];\n }\n\n /**\n * Get information on a specific participant, including the tracks that participant\n * has published\n * @param room - name of the room\n * @param identity - identity of the participant to return\n */\n async getParticipant(room: string, identity: string): Promise<ParticipantInfo> {\n const data = await this.rpc.request(\n svc,\n 'GetParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Removes a participant in the room. This will disconnect the participant\n * and will emit a Disconnected event for that participant.\n * Even after being removed, the participant can still re-join the room.\n * @param room -\n * @param identity -\n */\n async removeParticipant(room: string, identity: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'RemoveParticipant',\n new RoomParticipantIdentity({ room, identity }).toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Forwards a participant's track to another room. This will create a\n * participant to join the destination room that has same information\n * with the source participant except the kind to be `Forwarded`. All\n * changes to the source participant will be reflected to the forwarded\n * participant. When the source participant disconnects or the\n * `RemoveParticipant` method is called in the destination room, the\n * forwarding will be stopped.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to forward the participant to\n */\n async forwardParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'ForwardParticipant',\n new ForwardParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.\n * The participant will be removed from the current room and added to the destination room.\n * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.\n * @param room -\n * @param identity -\n * @param destinationRoom - the room to move the participant to\n */\n async moveParticipant(room: string, identity: string, destinationRoom: string): Promise<void> {\n await this.rpc.request(\n svc,\n 'MoveParticipant',\n new MoveParticipantRequest({ room, identity, destinationRoom }).toJson(),\n await this.authHeader({ roomAdmin: true, room, destinationRoom }),\n );\n }\n\n /**\n * Mutes a track that the participant has published.\n * @param room -\n * @param identity -\n * @param trackSid - sid of the track to be muted\n * @param muted - true to mute, false to unmute\n */\n async mutePublishedTrack(\n room: string,\n identity: string,\n trackSid: string,\n muted: boolean,\n ): Promise<TrackInfo> {\n const req = new MuteRoomTrackRequest({\n room,\n identity,\n trackSid,\n muted,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'MutePublishedTrack',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n const res = MuteRoomTrackResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.track!;\n }\n\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n options: UpdateParticipantOptions,\n ): Promise<ParticipantInfo>;\n /**\n * Updates a participant's state or permissions\n * @param room - target room\n * @param identity - participant identity\n * @param options - participant fields to update\n */\n async updateParticipant(\n room: string,\n identity: string,\n metadata?: string,\n permission?: Partial<ParticipantPermission>,\n name?: string,\n ): Promise<ParticipantInfo>;\n async updateParticipant(\n room: string,\n identity: string,\n metadataOrOptions?: string | UpdateParticipantOptions,\n maybePermission?: Partial<ParticipantPermission>,\n maybeName?: string,\n ): Promise<ParticipantInfo> {\n const hasOptions = typeof metadataOrOptions === 'object';\n const metadata = hasOptions ? metadataOrOptions?.metadata : metadataOrOptions;\n const permission = hasOptions ? metadataOrOptions.permission : maybePermission;\n const name = hasOptions ? metadataOrOptions.name : maybeName;\n const attributes: Record<string, string> | undefined = hasOptions\n ? metadataOrOptions.attributes\n : {};\n\n const req = new UpdateParticipantRequest({\n room,\n identity,\n attributes,\n metadata,\n name,\n });\n if (permission) {\n req.permission = new ParticipantPermission(permission);\n }\n const data = await this.rpc.request(\n svc,\n 'UpdateParticipant',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n return ParticipantInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Updates a participant's subscription to tracks\n * @param room -\n * @param identity -\n * @param trackSids -\n * @param subscribe - true to subscribe, false to unsubscribe\n */\n async updateSubscriptions(\n room: string,\n identity: string,\n trackSids: string[],\n subscribe: boolean,\n ): Promise<void> {\n const req = new UpdateSubscriptionsRequest({\n room,\n identity,\n trackSids,\n subscribe,\n participantTracks: [],\n }).toJson();\n await this.rpc.request(\n svc,\n 'UpdateSubscriptions',\n req,\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n\n /**\n * Sends data message to participants in the room\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param options - optionally specify a topic and destinationSids (when destinationSids is empty, message is sent to everyone)\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions,\n ): Promise<void>;\n /**\n * Sends data message to participants in the room\n * @deprecated use sendData(room, data, kind, options) instead\n * @param room -\n * @param data - opaque payload to send\n * @param kind - delivery reliability\n * @param destinationSids - optional. when empty, message is sent to everyone\n */\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n destinationSids?: string[],\n ): Promise<void>;\n async sendData(\n room: string,\n data: Uint8Array,\n kind: DataPacket_Kind,\n options: SendDataOptions | string[] = {},\n ): Promise<void> {\n const destinationSids = Array.isArray(options) ? options : options.destinationSids;\n const topic = Array.isArray(options) ? undefined : options.topic;\n const req = new SendDataRequest({\n room,\n data,\n kind,\n destinationSids: destinationSids ?? [],\n topic,\n });\n if (!Array.isArray(options) && options.destinationIdentities) {\n req.destinationIdentities = options.destinationIdentities;\n }\n req.nonce = await getRandomBytes(16);\n await this.rpc.request(\n svc,\n 'SendData',\n req.toJson(),\n await this.authHeader({ roomAdmin: true, room }),\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,sBAmBO;AACP,yBAA4B;AAE5B,sBAAyC;AACzC,kBAA+B;AA6E/B,MAAM,MAAM;AAKL,MAAM,0BAA0B,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASjD,YAAY,MAAc,QAAiB,QAAiB;AAC1D,UAAM,QAAQ,MAAM;AACpB,SAAK,MAAM,IAAI,yBAAS,MAAM,8BAAc;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,WAAW,SAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kCAAkB,OAAO,EAAE,OAAO;AAAA,MACtC,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,qBAAK,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UAAU,OAAmC;AACjD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,iCAAiB,EAAE,OAAO,SAAS,CAAC,EAAE,CAAC,EAAE,OAAO;AAAA,MACpD,MAA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,KAAK,CAAC;AAAA,IACjD;AAAA,EACF;AAAA,EA6BA,MAAM,SACJ,MACA,MACA,MACA,UAAsC,CAAC,GACxB;AACf,UAAM,kBAAkB,MAAM,QAAQ,OAAO,IAAI,UAAU,QAAQ;AACnE,UAAM,QAAQ,MAAM,QAAQ,OAAO,IAAI,SAAY,QAAQ;AAC3D,UAAM,MAAM,IAAI,gCAAgB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB,mBAAmB,CAAC;AAAA,MACrC;AAAA,IACF,CAAC;AACD,QAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,uBAAuB;AAC5D,UAAI,wBAAwB,QAAQ;AAAA,IACtC;AACA,QAAI,QAAQ,UAAM,4BAAe,EAAE;AACnC,UAAM,KAAK,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA,IAAI,OAAO;AAAA,MACX,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,KAAK,CAAC;AAAA,IACjD;AAAA,EACF;AACF;","names":[]}
@@ -129,8 +129,20 @@ declare class RoomServiceClient extends ServiceBase {
129
129
  * participant. When the source participant disconnects or the
130
130
  * `RemoveParticipant` method is called in the destination room, the
131
131
  * forwarding will be stopped.
132
+ * @param room -
133
+ * @param identity -
134
+ * @param destinationRoom - the room to forward the participant to
132
135
  */
133
136
  forwardParticipant(room: string, identity: string, destinationRoom: string): Promise<void>;
137
+ /**
138
+ * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.
139
+ * The participant will be removed from the current room and added to the destination room.
140
+ * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.
141
+ * @param room -
142
+ * @param identity -
143
+ * @param destinationRoom - the room to move the participant to
144
+ */
145
+ moveParticipant(room: string, identity: string, destinationRoom: string): Promise<void>;
134
146
  /**
135
147
  * Mutes a track that the participant has published.
136
148
  * @param room -
@@ -127,8 +127,20 @@ export declare class RoomServiceClient extends ServiceBase {
127
127
  * participant. When the source participant disconnects or the
128
128
  * `RemoveParticipant` method is called in the destination room, the
129
129
  * forwarding will be stopped.
130
+ * @param room -
131
+ * @param identity -
132
+ * @param destinationRoom - the room to forward the participant to
130
133
  */
131
134
  forwardParticipant(room: string, identity: string, destinationRoom: string): Promise<void>;
135
+ /**
136
+ * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.
137
+ * The participant will be removed from the current room and added to the destination room.
138
+ * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.
139
+ * @param room -
140
+ * @param identity -
141
+ * @param destinationRoom - the room to move the participant to
142
+ */
143
+ moveParticipant(room: string, identity: string, destinationRoom: string): Promise<void>;
132
144
  /**
133
145
  * Mutes a track that the participant has published.
134
146
  * @param room -
@@ -1 +1 @@
1
- {"version":3,"file":"RoomServiceClient.d.ts","sourceRoot":"","sources":["../src/RoomServiceClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAUL,eAAe,EACf,qBAAqB,EACrB,IAAI,EAML,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK/C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IAEpB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OA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MG;IACG,kBAAkB,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,SAAS,CAAC;IAiBrB;;;;;OAKG;IACG,iBAAiB,CACrB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,eAAe,CAAC;IAC3B;;;;;OAKG;IACG,iBAAiB,CACrB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAC3C,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC;IAmC3B;;;;;;OAMG;IACG,mBAAmB,CACvB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EAAE,EACnB,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,IAAI,CAAC;IAgBhB;;;;;;OAMG;IACG,QAAQ,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,IAAI,CAAC;IAChB;;;;;;;OAOG;IACG,QAAQ,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,eAAe,EACrB,eAAe,CAAC,EAAE,MAAM,EAAE,GACzB,OAAO,CAAC,IAAI,CAAC;CA2BjB"}
@@ -6,6 +6,7 @@ import {
6
6
  ListParticipantsResponse,
7
7
  ListRoomsRequest,
8
8
  ListRoomsResponse,
9
+ MoveParticipantRequest,
9
10
  MuteRoomTrackRequest,
10
11
  MuteRoomTrackResponse,
11
12
  ParticipantInfo,
@@ -137,6 +138,9 @@ class RoomServiceClient extends ServiceBase {
137
138
  * participant. When the source participant disconnects or the
138
139
  * `RemoveParticipant` method is called in the destination room, the
139
140
  * forwarding will be stopped.
141
+ * @param room -
142
+ * @param identity -
143
+ * @param destinationRoom - the room to forward the participant to
140
144
  */
141
145
  async forwardParticipant(room, identity, destinationRoom) {
142
146
  await this.rpc.request(
@@ -146,6 +150,22 @@ class RoomServiceClient extends ServiceBase {
146
150
  await this.authHeader({ roomAdmin: true, room, destinationRoom })
147
151
  );
148
152
  }
153
+ /**
154
+ * Move a connected participant to a different room. Requires `roomAdmin` and `destinationRoom`.
155
+ * The participant will be removed from the current room and added to the destination room.
156
+ * From the other observers' perspective, the participant would've disconnected from the previous room and joined the new one.
157
+ * @param room -
158
+ * @param identity -
159
+ * @param destinationRoom - the room to move the participant to
160
+ */
161
+ async moveParticipant(room, identity, destinationRoom) {
162
+ await this.rpc.request(
163
+ svc,
164
+ "MoveParticipant",
165
+ new MoveParticipantRequest({ room, identity, destinationRoom }).toJson(),
166
+ await this.authHeader({ roomAdmin: true, room, destinationRoom })
167
+ );
168
+ }
149
169
  /**
150
170
  * Mutes a track that the participant has published.
151
171
  * @param room -