Skip to content

Commit

Permalink
Add support for Egress Image Output (livekit#143)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: lukasIO <[email protected]>
  • Loading branch information
biglittlebigben and lukasIO authored Feb 27, 2024
1 parent b88dae0 commit ca1fb83
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-peaches-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-server-sdk": patch
---

Add support for Egress Image Output
2 changes: 1 addition & 1 deletion protocol
Submodule protocol updated 112 files
20 changes: 16 additions & 4 deletions src/EgressClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
EncodedFileOutput,
EncodingOptions,
EncodingOptionsPreset,
ImageOutput,
ListEgressRequest,
ListEgressResponse,
ParticipantEgressRequest,
Expand Down Expand Up @@ -98,6 +99,7 @@ export interface EncodedOutputs {
file?: EncodedFileOutput | undefined;
stream?: StreamOutput | undefined;
segments?: SegmentedFileOutput | undefined;
images?: ImageOutput | undefined;
}

export interface ListEgressOptions {
Expand Down Expand Up @@ -178,6 +180,7 @@ export class EgressClient extends ServiceBase {
fileOutputs,
streamOutputs,
segmentOutputs,
imageOutputs,
} = this.getOutputParams(output, options);

const req = new RoomCompositeEgressRequest({
Expand All @@ -191,6 +194,7 @@ export class EgressClient extends ServiceBase {
fileOutputs,
streamOutputs,
segmentOutputs,
imageOutputs,
}).toJson();

const data = await this.rpc.request(
Expand Down Expand Up @@ -221,6 +225,7 @@ export class EgressClient extends ServiceBase {
fileOutputs,
streamOutputs,
segmentOutputs,
imageOutputs,
} = this.getOutputParams(output, opts?.encodingOptions);

const req = new WebEgressRequest({
Expand All @@ -233,6 +238,7 @@ export class EgressClient extends ServiceBase {
fileOutputs,
streamOutputs,
segmentOutputs,
imageOutputs,
}).toJson();

const data = await this.rpc.request(
Expand All @@ -257,17 +263,16 @@ export class EgressClient extends ServiceBase {
output: EncodedOutputs,
opts?: ParticipantEgressOptions,
): Promise<EgressInfo> {
const { options, fileOutputs, streamOutputs, segmentOutputs } = this.getOutputParams(
output,
opts?.encodingOptions,
);
const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } =
this.getOutputParams(output, opts?.encodingOptions);
const req = new ParticipantEgressRequest({
roomName,
identity,
options,
fileOutputs,
streamOutputs,
segmentOutputs,
imageOutputs,
}).toJson();

const data = await this.rpc.request(
Expand Down Expand Up @@ -327,6 +332,7 @@ export class EgressClient extends ServiceBase {
fileOutputs,
streamOutputs,
segmentOutputs,
imageOutputs,
} = this.getOutputParams(output, options);
const req = new TrackCompositeEgressRequest({
roomName,
Expand All @@ -337,6 +343,7 @@ export class EgressClient extends ServiceBase {
fileOutputs,
streamOutputs,
segmentOutputs,
imageOutputs,
}).toJson();

const data = await this.rpc.request(
Expand Down Expand Up @@ -387,6 +394,7 @@ export class EgressClient extends ServiceBase {
let streamOutputs: Array<StreamOutput> | undefined;
let segments: SegmentedFileOutput | undefined;
let segmentOutputs: Array<SegmentedFileOutput> | undefined;
let imageOutputs: Array<ImageOutput> | undefined;

if (this.isEncodedOutputs(output)) {
if (output.file !== undefined) {
Expand All @@ -398,6 +406,9 @@ export class EgressClient extends ServiceBase {
if (output.segments !== undefined) {
segmentOutputs = [output.segments];
}
if (output.images !== undefined) {
imageOutputs = [output.images];
}
} else if (this.isEncodedFileOutput(output)) {
file = output;
fileOutputs = [file];
Expand Down Expand Up @@ -470,6 +481,7 @@ export class EgressClient extends ServiceBase {
fileOutputs,
streamOutputs,
segmentOutputs,
imageOutputs,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
EncodingOptions,
EncodingOptionsPreset,
GCPUpload,
ImageOutput,
ParticipantEgressRequest,
RoomCompositeEgressRequest,
S3Upload,
Expand Down

0 comments on commit ca1fb83

Please sign in to comment.