@@ -9,6 +9,7 @@ import type {
99 ImageOutput ,
1010 SegmentedFileOutput ,
1111 StreamOutput ,
12+ WebhookConfig ,
1213} from '@livekit/protocol' ;
1314import {
1415 AudioMixing ,
@@ -30,7 +31,14 @@ import { TwirpRpc, livekitPackage } from './TwirpRPC.js';
3031
3132const svc = 'Egress' ;
3233
33- export interface RoomCompositeOptions {
34+ export interface BaseOptions {
35+ /**
36+ * webhooks to call for this request, optional.
37+ */
38+ webhooks ?: WebhookConfig [ ] ;
39+ }
40+
41+ export interface RoomCompositeOptions extends BaseOptions {
3442 /**
3543 * egress layout. optional
3644 */
@@ -57,7 +65,7 @@ export interface RoomCompositeOptions {
5765 audioMixing ?: AudioMixing ;
5866}
5967
60- export interface WebOptions {
68+ export interface WebOptions extends BaseOptions {
6169 /**
6270 * encoding options or preset. optional
6371 */
@@ -76,7 +84,7 @@ export interface WebOptions {
7684 awaitStartSignal ?: boolean ;
7785}
7886
79- export interface ParticipantEgressOptions {
87+ export interface ParticipantEgressOptions extends BaseOptions {
8088 /**
8189 * true to capture source screenshare and screenshare_audio
8290 * false to capture camera and microphone
@@ -88,7 +96,7 @@ export interface ParticipantEgressOptions {
8896 encodingOptions ?: EncodingOptionsPreset | EncodingOptions ;
8997}
9098
91- export interface TrackCompositeOptions {
99+ export interface TrackCompositeOptions extends BaseOptions {
92100 /**
93101 * audio track ID
94102 */
@@ -169,6 +177,7 @@ export class EgressClient extends ServiceBase {
169177 audioMixing ?: AudioMixing ,
170178 ) : Promise < EgressInfo > {
171179 let layout : string | undefined ;
180+ let webhooks : WebhookConfig [ ] | undefined ;
172181 if ( optsOrLayout !== undefined ) {
173182 if ( typeof optsOrLayout === 'string' ) {
174183 layout = optsOrLayout ;
@@ -180,6 +189,7 @@ export class EgressClient extends ServiceBase {
180189 videoOnly = opts . videoOnly ;
181190 customBaseUrl = opts . customBaseUrl ;
182191 audioMixing = opts . audioMixing ;
192+ webhooks = opts . webhooks ;
183193 }
184194 }
185195
@@ -211,6 +221,7 @@ export class EgressClient extends ServiceBase {
211221 streamOutputs,
212222 segmentOutputs,
213223 imageOutputs,
224+ webhooks,
214225 } ) . toJson ( ) ;
215226
216227 const data = await this . rpc . request (
@@ -235,6 +246,7 @@ export class EgressClient extends ServiceBase {
235246 const audioOnly = opts ?. audioOnly || false ;
236247 const videoOnly = opts ?. videoOnly || false ;
237248 const awaitStartSignal = opts ?. awaitStartSignal || false ;
249+ const webhooks = opts ?. webhooks || [ ] ;
238250 const {
239251 output : legacyOutput ,
240252 options,
@@ -255,6 +267,7 @@ export class EgressClient extends ServiceBase {
255267 streamOutputs,
256268 segmentOutputs,
257269 imageOutputs,
270+ webhooks,
258271 } ) . toJson ( ) ;
259272
260273 const data = await this . rpc . request (
@@ -279,6 +292,7 @@ export class EgressClient extends ServiceBase {
279292 output : EncodedOutputs ,
280293 opts ?: ParticipantEgressOptions ,
281294 ) : Promise < EgressInfo > {
295+ const webhooks = opts ?. webhooks || [ ] ;
282296 const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } =
283297 this . getOutputParams ( output , opts ?. encodingOptions ) ;
284298 const req = new ParticipantEgressRequest ( {
@@ -290,6 +304,7 @@ export class EgressClient extends ServiceBase {
290304 streamOutputs,
291305 segmentOutputs,
292306 imageOutputs,
307+ webhooks,
293308 } ) . toJson ( ) ;
294309
295310 const data = await this . rpc . request (
@@ -329,6 +344,7 @@ export class EgressClient extends ServiceBase {
329344 options ?: EncodingOptionsPreset | EncodingOptions ,
330345 ) : Promise < EgressInfo > {
331346 let audioTrackId : string | undefined ;
347+ let webhooks : WebhookConfig [ ] | undefined ;
332348 if ( optsOrAudioTrackId !== undefined ) {
333349 if ( typeof optsOrAudioTrackId === 'string' ) {
334350 audioTrackId = optsOrAudioTrackId ;
@@ -337,6 +353,7 @@ export class EgressClient extends ServiceBase {
337353 audioTrackId = opts . audioTrackId ;
338354 videoTrackId = opts . videoTrackId ;
339355 options = opts . encodingOptions ;
356+ webhooks = opts . webhooks ;
340357 }
341358 }
342359
@@ -361,6 +378,7 @@ export class EgressClient extends ServiceBase {
361378 streamOutputs,
362379 segmentOutputs,
363380 imageOutputs,
381+ webhooks,
364382 } ) . toJson ( ) ;
365383
366384 const data = await this . rpc . request (
@@ -516,6 +534,7 @@ export class EgressClient extends ServiceBase {
516534 roomName : string ,
517535 output : DirectFileOutput | string ,
518536 trackId : string ,
537+ webhooks ?: WebhookConfig [ ] ,
519538 ) : Promise < EgressInfo > {
520539 let legacyOutput :
521540 | {
@@ -544,6 +563,7 @@ export class EgressClient extends ServiceBase {
544563 roomName,
545564 trackId,
546565 output : legacyOutput ,
566+ webhooks,
547567 } ) . toJson ( ) ;
548568
549569 const data = await this . rpc . request (
0 commit comments