Skip to content

Commit 6b4e470

Browse files
authored
Ensure encryption transforms are set up as soon as sender is created (livekit#1561)
1 parent c7e4f7f commit 6b4e470

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

.changeset/sixty-pianos-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"livekit-client": patch
3+
---
4+
5+
Ensure encryption transforms are set up as soon as sender is created

src/e2ee/E2eeManager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ export class E2EEManager
221221
this.room.localParticipant.identity,
222222
);
223223
});
224-
room.localParticipant.on(ParticipantEvent.LocalTrackPublished, async (publication) => {
225-
this.setupE2EESender(publication.track!, publication.track!.sender!);
224+
225+
room.localParticipant.on(ParticipantEvent.LocalSenderCreated, async (sender, track) => {
226+
this.setupE2EESender(track, sender);
226227
});
227228

228229
keyProvider

src/room/events.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ export enum ParticipantEvent {
429429
*/
430430
LocalTrackUnpublished = 'localTrackUnpublished',
431431

432+
/**
433+
* @internal
434+
*/
435+
LocalSenderCreated = 'localSenderCreated',
436+
432437
/**
433438
* Participant metadata is a simple way for app-specific state to be pushed to
434439
* all users.

src/room/participant/LocalParticipant.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,7 @@ export default class LocalParticipant extends Participant {
11691169
}
11701170

11711171
track.sender = await this.engine.createSender(track, opts, encodings);
1172+
this.emit(ParticipantEvent.LocalSenderCreated, track.sender, track);
11721173

11731174
if (isLocalVideoTrack(track)) {
11741175
opts.degradationPreference ??= getDefaultDegradationPreference(track);

src/room/participant/Participant.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ export type ParticipantEventCallbacks = {
403403
trackUnmuted: (publication: TrackPublication) => void;
404404
localTrackPublished: (publication: LocalTrackPublication) => void;
405405
localTrackUnpublished: (publication: LocalTrackPublication) => void;
406+
localSenderCreated: (sender: RTCRtpSender, track: Track) => void;
406407
participantMetadataChanged: (prevMetadata: string | undefined, participant?: any) => void;
407408
participantNameChanged: (name: string) => void;
408409
dataReceived: (payload: Uint8Array, kind: DataPacket_Kind) => void;

0 commit comments

Comments
 (0)