Skip to content

Commit 94ef72e

Browse files
authored
fix: pass through correct disconnect reason (#428)
* fix: pass through correct disconnect reason * changeset * update submodule
1 parent 7661ca0 commit 94ef72e

File tree

8 files changed

+204
-45
lines changed

8 files changed

+204
-45
lines changed

.changeset/curly-rice-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@livekit/rtc-node': patch
3+
---
4+
5+
fix: pass through correct disconnect reason

packages/livekit-rtc/src/index.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
export { Room, RoomEvent, ConnectError, type RoomOptions, type RtcConfiguration } from './room.js';
6-
export { Participant, RemoteParticipant, LocalParticipant } from './participant.js';
7-
export {
8-
Track,
9-
type LocalTrack,
10-
type RemoteTrack,
11-
type VideoTrack,
12-
LocalAudioTrack,
13-
LocalVideoTrack,
14-
RemoteAudioTrack,
15-
RemoteVideoTrack,
16-
type AudioTrack,
17-
} from './track.js';
18-
export { VideoFrame } from './video_frame.js';
195
export { AudioFrame, combineAudioFrames } from './audio_frame.js';
20-
export { AudioStream } from './audio_stream.js';
216
export { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';
22-
export { VideoStream, type VideoFrameEvent } from './video_stream.js';
237
export { AudioSource } from './audio_source.js';
24-
export { VideoSource } from './video_source.js';
25-
export {
26-
TrackPublication,
27-
RemoteTrackPublication,
28-
LocalTrackPublication,
29-
} from './track_publication.js';
30-
export type { Transcription, TranscriptionSegment } from './transcription.js';
31-
export { E2EEManager, KeyProvider, FrameCryptor } from './e2ee.js';
32-
export type { E2EEOptions, KeyProviderOptions } from './e2ee.js';
8+
export { AudioStream } from './audio_stream.js';
339
export * from './data_streams/index.js';
10+
export { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';
11+
export type { E2EEOptions, KeyProviderOptions } from './e2ee.js';
12+
export { dispose } from './ffi_client.js';
13+
export { LocalParticipant, Participant, RemoteParticipant } from './participant.js';
14+
export { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';
15+
export { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';
3416
export {
3517
ConnectionQuality,
18+
ConnectionState,
19+
ContinualGatheringPolicy,
20+
DataPacketKind,
3621
IceServer,
3722
IceTransportType,
38-
DataPacketKind,
39-
ContinualGatheringPolicy,
4023
TrackPublishOptions,
41-
ConnectionState,
4224
} from './proto/room_pb.js';
43-
export { RpcError, type RpcInvocationData, type PerformRpcParams } from './rpc.js';
44-
export { EncryptionType, EncryptionState } from './proto/e2ee_pb.js';
4525
export { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';
46-
export { VideoBufferType, VideoRotation, VideoCodec } from './proto/video_frame_pb.js';
47-
export { ParticipantKind } from './proto/participant_pb.js';
48-
export { dispose } from './ffi_client.js';
26+
export { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';
27+
export { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';
28+
export { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';
29+
export {
30+
LocalAudioTrack,
31+
LocalVideoTrack,
32+
RemoteAudioTrack,
33+
RemoteVideoTrack,
34+
Track,
35+
type AudioTrack,
36+
type LocalTrack,
37+
type RemoteTrack,
38+
type VideoTrack,
39+
} from './track.js';
40+
export {
41+
LocalTrackPublication,
42+
RemoteTrackPublication,
43+
TrackPublication,
44+
} from './track_publication.js';
45+
export type { Transcription, TranscriptionSegment } from './transcription.js';
4946
export type { ChatMessage } from './types.js';
47+
export { VideoFrame } from './video_frame.js';
48+
export { VideoSource } from './video_source.js';
49+
export { VideoStream, type VideoFrameEvent } from './video_stream.js';

packages/livekit-rtc/src/proto/ffi_pb.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
2121
import { Message, proto2 } from "@bufbuild/protobuf";
2222
import { ConnectCallback, ConnectRequest, ConnectResponse, DisconnectCallback, DisconnectRequest, DisconnectResponse, EditChatMessageRequest, GetSessionStatsCallback, GetSessionStatsRequest, GetSessionStatsResponse, PublishDataCallback, PublishDataRequest, PublishDataResponse, PublishSipDtmfCallback, PublishSipDtmfRequest, PublishSipDtmfResponse, PublishTrackCallback, PublishTrackRequest, PublishTrackResponse, PublishTranscriptionCallback, PublishTranscriptionRequest, PublishTranscriptionResponse, RoomEvent, SendChatMessageCallback, SendChatMessageRequest, SendChatMessageResponse, SendStreamChunkCallback, SendStreamChunkRequest, SendStreamChunkResponse, SendStreamHeaderCallback, SendStreamHeaderRequest, SendStreamHeaderResponse, SendStreamTrailerCallback, SendStreamTrailerRequest, SendStreamTrailerResponse, SetDataChannelBufferedAmountLowThresholdRequest, SetDataChannelBufferedAmountLowThresholdResponse, SetLocalAttributesCallback, SetLocalAttributesRequest, SetLocalAttributesResponse, SetLocalMetadataCallback, SetLocalMetadataRequest, SetLocalMetadataResponse, SetLocalNameCallback, SetLocalNameRequest, SetLocalNameResponse, SetSubscribedRequest, SetSubscribedResponse, UnpublishTrackCallback, UnpublishTrackRequest, UnpublishTrackResponse } from "./room_pb.js";
23-
import { CreateAudioTrackRequest, CreateAudioTrackResponse, CreateVideoTrackRequest, CreateVideoTrackResponse, EnableRemoteTrackRequest, EnableRemoteTrackResponse, GetStatsCallback, GetStatsRequest, GetStatsResponse, LocalTrackMuteRequest, LocalTrackMuteResponse, TrackEvent } from "./track_pb.js";
23+
import { CreateAudioTrackRequest, CreateAudioTrackResponse, CreateVideoTrackRequest, CreateVideoTrackResponse, EnableRemoteTrackRequest, EnableRemoteTrackResponse, GetStatsCallback, GetStatsRequest, GetStatsResponse, LocalTrackMuteRequest, LocalTrackMuteResponse, SetTrackSubscriptionPermissionsRequest, SetTrackSubscriptionPermissionsResponse, TrackEvent } from "./track_pb.js";
2424
import { CaptureVideoFrameRequest, CaptureVideoFrameResponse, NewVideoSourceRequest, NewVideoSourceResponse, NewVideoStreamRequest, NewVideoStreamResponse, VideoConvertRequest, VideoConvertResponse, VideoStreamEvent, VideoStreamFromParticipantRequest, VideoStreamFromParticipantResponse } from "./video_frame_pb.js";
2525
import { AudioStreamEvent, AudioStreamFromParticipantRequest, AudioStreamFromParticipantResponse, CaptureAudioFrameCallback, CaptureAudioFrameRequest, CaptureAudioFrameResponse, ClearAudioBufferRequest, ClearAudioBufferResponse, FlushSoxResamplerRequest, FlushSoxResamplerResponse, NewAudioResamplerRequest, NewAudioResamplerResponse, NewAudioSourceRequest, NewAudioSourceResponse, NewAudioStreamRequest, NewAudioStreamResponse, NewSoxResamplerRequest, NewSoxResamplerResponse, PushSoxResamplerRequest, PushSoxResamplerResponse, RemixAndResampleRequest, RemixAndResampleResponse } from "./audio_frame_pb.js";
2626
import { E2eeRequest, E2eeResponse } from "./e2ee_pb.js";
@@ -187,6 +187,12 @@ export class FfiRequest extends Message<FfiRequest> {
187187
*/
188188
value: GetStatsRequest;
189189
case: "getStats";
190+
} | {
191+
/**
192+
* @generated from field: livekit.proto.SetTrackSubscriptionPermissionsRequest set_track_subscription_permissions = 48;
193+
*/
194+
value: SetTrackSubscriptionPermissionsRequest;
195+
case: "setTrackSubscriptionPermissions";
190196
} | {
191197
/**
192198
* Video
@@ -395,6 +401,7 @@ export class FfiRequest extends Message<FfiRequest> {
395401
{ no: 17, name: "local_track_mute", kind: "message", T: LocalTrackMuteRequest, oneof: "message" },
396402
{ no: 18, name: "enable_remote_track", kind: "message", T: EnableRemoteTrackRequest, oneof: "message" },
397403
{ no: 19, name: "get_stats", kind: "message", T: GetStatsRequest, oneof: "message" },
404+
{ no: 48, name: "set_track_subscription_permissions", kind: "message", T: SetTrackSubscriptionPermissionsRequest, oneof: "message" },
398405
{ no: 20, name: "new_video_stream", kind: "message", T: NewVideoStreamRequest, oneof: "message" },
399406
{ no: 21, name: "new_video_source", kind: "message", T: NewVideoSourceRequest, oneof: "message" },
400407
{ no: 22, name: "capture_video_frame", kind: "message", T: CaptureVideoFrameRequest, oneof: "message" },
@@ -563,6 +570,12 @@ export class FfiResponse extends Message<FfiResponse> {
563570
*/
564571
value: GetStatsResponse;
565572
case: "getStats";
573+
} | {
574+
/**
575+
* @generated from field: livekit.proto.SetTrackSubscriptionPermissionsResponse set_track_subscription_permissions = 47;
576+
*/
577+
value: SetTrackSubscriptionPermissionsResponse;
578+
case: "setTrackSubscriptionPermissions";
566579
} | {
567580
/**
568581
* Video
@@ -765,6 +778,7 @@ export class FfiResponse extends Message<FfiResponse> {
765778
{ no: 17, name: "local_track_mute", kind: "message", T: LocalTrackMuteResponse, oneof: "message" },
766779
{ no: 18, name: "enable_remote_track", kind: "message", T: EnableRemoteTrackResponse, oneof: "message" },
767780
{ no: 19, name: "get_stats", kind: "message", T: GetStatsResponse, oneof: "message" },
781+
{ no: 47, name: "set_track_subscription_permissions", kind: "message", T: SetTrackSubscriptionPermissionsResponse, oneof: "message" },
768782
{ no: 20, name: "new_video_stream", kind: "message", T: NewVideoStreamResponse, oneof: "message" },
769783
{ no: 21, name: "new_video_source", kind: "message", T: NewVideoSourceResponse, oneof: "message" },
770784
{ no: 22, name: "capture_video_frame", kind: "message", T: CaptureVideoFrameResponse, oneof: "message" },

packages/livekit-rtc/src/proto/room_pb.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,6 +2986,11 @@ export class ParticipantDisconnected extends Message<ParticipantDisconnected> {
29862986
*/
29872987
participantIdentity?: string;
29882988

2989+
/**
2990+
* @generated from field: required livekit.proto.DisconnectReason disconnect_reason = 2;
2991+
*/
2992+
disconnectReason?: DisconnectReason;
2993+
29892994
constructor(data?: PartialMessage<ParticipantDisconnected>) {
29902995
super();
29912996
proto2.util.initPartial(data, this);
@@ -2995,6 +3000,7 @@ export class ParticipantDisconnected extends Message<ParticipantDisconnected> {
29953000
static readonly typeName = "livekit.proto.ParticipantDisconnected";
29963001
static readonly fields: FieldList = proto2.util.newFieldList(() => [
29973002
{ no: 1, name: "participant_identity", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true },
3003+
{ no: 2, name: "disconnect_reason", kind: "enum", T: proto2.getEnumType(DisconnectReason), req: true },
29983004
]);
29993005

30003006
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ParticipantDisconnected {

packages/livekit-rtc/src/proto/track_pb.ts

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,3 +845,138 @@ export class EnableRemoteTrackResponse extends Message<EnableRemoteTrackResponse
845845
}
846846
}
847847

848+
/**
849+
* @generated from message livekit.proto.SetTrackSubscriptionPermissionsRequest
850+
*/
851+
export class SetTrackSubscriptionPermissionsRequest extends Message<SetTrackSubscriptionPermissionsRequest> {
852+
/**
853+
* @generated from field: required uint64 local_participant_handle = 1;
854+
*/
855+
localParticipantHandle?: bigint;
856+
857+
/**
858+
* @generated from field: required bool all_participants_allowed = 2;
859+
*/
860+
allParticipantsAllowed?: boolean;
861+
862+
/**
863+
* @generated from field: repeated livekit.proto.ParticipantTrackPermission permissions = 3;
864+
*/
865+
permissions: ParticipantTrackPermission[] = [];
866+
867+
constructor(data?: PartialMessage<SetTrackSubscriptionPermissionsRequest>) {
868+
super();
869+
proto2.util.initPartial(data, this);
870+
}
871+
872+
static readonly runtime: typeof proto2 = proto2;
873+
static readonly typeName = "livekit.proto.SetTrackSubscriptionPermissionsRequest";
874+
static readonly fields: FieldList = proto2.util.newFieldList(() => [
875+
{ no: 1, name: "local_participant_handle", kind: "scalar", T: 4 /* ScalarType.UINT64 */, req: true },
876+
{ no: 2, name: "all_participants_allowed", kind: "scalar", T: 8 /* ScalarType.BOOL */, req: true },
877+
{ no: 3, name: "permissions", kind: "message", T: ParticipantTrackPermission, repeated: true },
878+
]);
879+
880+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): SetTrackSubscriptionPermissionsRequest {
881+
return new SetTrackSubscriptionPermissionsRequest().fromBinary(bytes, options);
882+
}
883+
884+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): SetTrackSubscriptionPermissionsRequest {
885+
return new SetTrackSubscriptionPermissionsRequest().fromJson(jsonValue, options);
886+
}
887+
888+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): SetTrackSubscriptionPermissionsRequest {
889+
return new SetTrackSubscriptionPermissionsRequest().fromJsonString(jsonString, options);
890+
}
891+
892+
static equals(a: SetTrackSubscriptionPermissionsRequest | PlainMessage<SetTrackSubscriptionPermissionsRequest> | undefined, b: SetTrackSubscriptionPermissionsRequest | PlainMessage<SetTrackSubscriptionPermissionsRequest> | undefined): boolean {
893+
return proto2.util.equals(SetTrackSubscriptionPermissionsRequest, a, b);
894+
}
895+
}
896+
897+
/**
898+
* @generated from message livekit.proto.ParticipantTrackPermission
899+
*/
900+
export class ParticipantTrackPermission extends Message<ParticipantTrackPermission> {
901+
/**
902+
* The participant identity this permission applies to.
903+
*
904+
* @generated from field: required string participant_identity = 1;
905+
*/
906+
participantIdentity?: string;
907+
908+
/**
909+
* Grant permission to all all tracks. Takes precedence over allowedTrackSids.
910+
*
911+
* @generated from field: optional bool allow_all = 2;
912+
*/
913+
allowAll?: boolean;
914+
915+
/**
916+
* List of track sids to grant permission to.
917+
*
918+
* @generated from field: repeated string allowed_track_sids = 3;
919+
*/
920+
allowedTrackSids: string[] = [];
921+
922+
constructor(data?: PartialMessage<ParticipantTrackPermission>) {
923+
super();
924+
proto2.util.initPartial(data, this);
925+
}
926+
927+
static readonly runtime: typeof proto2 = proto2;
928+
static readonly typeName = "livekit.proto.ParticipantTrackPermission";
929+
static readonly fields: FieldList = proto2.util.newFieldList(() => [
930+
{ no: 1, name: "participant_identity", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true },
931+
{ no: 2, name: "allow_all", kind: "scalar", T: 8 /* ScalarType.BOOL */, opt: true },
932+
{ no: 3, name: "allowed_track_sids", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
933+
]);
934+
935+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ParticipantTrackPermission {
936+
return new ParticipantTrackPermission().fromBinary(bytes, options);
937+
}
938+
939+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ParticipantTrackPermission {
940+
return new ParticipantTrackPermission().fromJson(jsonValue, options);
941+
}
942+
943+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ParticipantTrackPermission {
944+
return new ParticipantTrackPermission().fromJsonString(jsonString, options);
945+
}
946+
947+
static equals(a: ParticipantTrackPermission | PlainMessage<ParticipantTrackPermission> | undefined, b: ParticipantTrackPermission | PlainMessage<ParticipantTrackPermission> | undefined): boolean {
948+
return proto2.util.equals(ParticipantTrackPermission, a, b);
949+
}
950+
}
951+
952+
/**
953+
* @generated from message livekit.proto.SetTrackSubscriptionPermissionsResponse
954+
*/
955+
export class SetTrackSubscriptionPermissionsResponse extends Message<SetTrackSubscriptionPermissionsResponse> {
956+
constructor(data?: PartialMessage<SetTrackSubscriptionPermissionsResponse>) {
957+
super();
958+
proto2.util.initPartial(data, this);
959+
}
960+
961+
static readonly runtime: typeof proto2 = proto2;
962+
static readonly typeName = "livekit.proto.SetTrackSubscriptionPermissionsResponse";
963+
static readonly fields: FieldList = proto2.util.newFieldList(() => [
964+
]);
965+
966+
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): SetTrackSubscriptionPermissionsResponse {
967+
return new SetTrackSubscriptionPermissionsResponse().fromBinary(bytes, options);
968+
}
969+
970+
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): SetTrackSubscriptionPermissionsResponse {
971+
return new SetTrackSubscriptionPermissionsResponse().fromJson(jsonValue, options);
972+
}
973+
974+
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): SetTrackSubscriptionPermissionsResponse {
975+
return new SetTrackSubscriptionPermissionsResponse().fromJsonString(jsonString, options);
976+
}
977+
978+
static equals(a: SetTrackSubscriptionPermissionsResponse | PlainMessage<SetTrackSubscriptionPermissionsResponse> | undefined, b: SetTrackSubscriptionPermissionsResponse | PlainMessage<SetTrackSubscriptionPermissionsResponse> | undefined): boolean {
979+
return proto2.util.equals(SetTrackSubscriptionPermissionsResponse, a, b);
980+
}
981+
}
982+

packages/livekit-rtc/src/proto/video_frame_pb.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ export class VideoBufferInfo extends Message<VideoBufferInfo> {
753753
/**
754754
* only for packed formats
755755
*
756-
* @generated from field: required uint32 stride = 6;
756+
* @generated from field: optional uint32 stride = 6;
757757
*/
758758
stride?: number;
759759

@@ -774,7 +774,7 @@ export class VideoBufferInfo extends Message<VideoBufferInfo> {
774774
{ no: 2, name: "width", kind: "scalar", T: 13 /* ScalarType.UINT32 */, req: true },
775775
{ no: 3, name: "height", kind: "scalar", T: 13 /* ScalarType.UINT32 */, req: true },
776776
{ no: 4, name: "data_ptr", kind: "scalar", T: 4 /* ScalarType.UINT64 */, req: true },
777-
{ no: 6, name: "stride", kind: "scalar", T: 13 /* ScalarType.UINT32 */, req: true },
777+
{ no: 6, name: "stride", kind: "scalar", T: 13 /* ScalarType.UINT32 */, opt: true },
778778
{ no: 7, name: "components", kind: "message", T: VideoBufferInfo_ComponentInfo, repeated: true },
779779
]);
780780

packages/livekit-rtc/src/room.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,22 @@ import { LocalParticipant, RemoteParticipant } from './participant.js';
2121
import { EncryptionState } from './proto/e2ee_pb.js';
2222
import type { FfiEvent } from './proto/ffi_pb.js';
2323
import type { DisconnectReason, OwnedParticipant } from './proto/participant_pb.js';
24+
import type { DataStream_Trailer } from './proto/room_pb.js';
2425
import {
2526
type ConnectCallback,
27+
ConnectRequest,
2628
type ConnectResponse,
2729
type ConnectionQuality,
30+
ConnectionState,
31+
ContinualGatheringPolicy,
2832
type DataPacketKind,
2933
type DataStream_Chunk,
3034
type DataStream_Header,
31-
DataStream_Trailer,
3235
type DisconnectResponse,
3336
RoomOptions as FfiRoomOptions,
3437
type IceServer,
35-
type RoomInfo,
36-
} from './proto/room_pb.js';
37-
import {
38-
ConnectRequest,
39-
ConnectionState,
40-
ContinualGatheringPolicy,
4138
IceTransportType,
39+
type RoomInfo,
4240
} from './proto/room_pb.js';
4341
import { TrackKind } from './proto/track_pb.js';
4442
import type { LocalTrack, RemoteTrack } from './track.js';
@@ -249,7 +247,8 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
249247
this.emit(RoomEvent.ParticipantConnected, participant);
250248
} else if (ev.case == 'participantDisconnected') {
251249
const participant = this.remoteParticipants.get(ev.value.participantIdentity!);
252-
this.remoteParticipants.delete(participant!.identity!);
250+
this.remoteParticipants.delete(participant!.identity);
251+
participant!.info.disconnectReason = ev.value.disconnectReason;
253252
this.emit(RoomEvent.ParticipantDisconnected, participant!);
254253
} else if (ev.case == 'localTrackPublished') {
255254
const publication = this.localParticipant!.trackPublications.get(ev.value.trackSid!);

0 commit comments

Comments
 (0)