Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rtc): expose DisconnectReason #372

Merged
merged 7 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mighty-dingos-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/rtc-node": minor
---

feat(rtc): expose DisconnectReason
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: true
submodules: recursive

- uses: pnpm/action-setup@v4

Expand Down
1 change: 1 addition & 0 deletions packages/livekit-rtc/generate_proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ PATH=$PATH:$(pwd)/node_modules/.bin \
$FFI_PROTOCOL/participant.proto \
$FFI_PROTOCOL/room.proto \
$FFI_PROTOCOL/track.proto \
$FFI_PROTOCOL/track_publication.proto \
$FFI_PROTOCOL/video_frame.proto \
$FFI_PROTOCOL/e2ee.proto \
$FFI_PROTOCOL/stats.proto \
Expand Down
2 changes: 1 addition & 1 deletion packages/livekit-rtc/rust-sdks
Submodule rust-sdks updated 106 files
14 changes: 13 additions & 1 deletion packages/livekit-rtc/src/participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
//
// SPDX-License-Identifier: Apache-2.0
import { FfiClient, FfiHandle } from './ffi_client.js';
import type { OwnedParticipant, ParticipantInfo, ParticipantKind } from './proto/participant_pb.js';
import {
DisconnectReason,
type OwnedParticipant,
type ParticipantInfo,
type ParticipantKind,
} from './proto/participant_pb.js';
import type {
PublishDataCallback,
PublishDataResponse,
Expand Down Expand Up @@ -95,6 +100,13 @@ export abstract class Participant {
get kind(): ParticipantKind | undefined {
return this.info.kind;
}

get disconnectReason(): DisconnectReason | undefined {
if (this.info.disconnectReason === DisconnectReason.UNKNOWN_REASON) {
return undefined;
}
return this.info.disconnectReason;
nbsp marked this conversation as resolved.
Show resolved Hide resolved
}
}

export type DataPublishOptions = {
Expand Down
33 changes: 33 additions & 0 deletions packages/livekit-rtc/src/proto/ffi_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { CaptureVideoFrameRequest, CaptureVideoFrameResponse, NewVideoSourceRequ
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";
import { E2eeRequest, E2eeResponse } from "./e2ee_pb.js";
import { PerformRpcCallback, PerformRpcRequest, PerformRpcResponse, RegisterRpcMethodRequest, RegisterRpcMethodResponse, RpcMethodInvocationEvent, RpcMethodInvocationResponseRequest, RpcMethodInvocationResponseResponse, UnregisterRpcMethodRequest, UnregisterRpcMethodResponse } from "./rpc_pb.js";
import { EnableRemoteTrackPublicationRequest, EnableRemoteTrackPublicationResponse, UpdateRemoteTrackPublicationDimensionRequest, UpdateRemoteTrackPublicationDimensionResponse } from "./track_publication_pb.js";

/**
* @generated from enum livekit.proto.LogLevel
Expand Down Expand Up @@ -324,6 +325,20 @@ export class FfiRequest extends Message<FfiRequest> {
*/
value: RpcMethodInvocationResponseRequest;
case: "rpcMethodInvocationResponse";
} | {
/**
* Track Publication
*
* @generated from field: livekit.proto.EnableRemoteTrackPublicationRequest enable_remote_track_publication = 42;
*/
value: EnableRemoteTrackPublicationRequest;
case: "enableRemoteTrackPublication";
} | {
/**
* @generated from field: livekit.proto.UpdateRemoteTrackPublicationDimensionRequest update_remote_track_publication_dimension = 43;
*/
value: UpdateRemoteTrackPublicationDimensionRequest;
case: "updateRemoteTrackPublicationDimension";
} | { case: undefined; value?: undefined } = { case: undefined };

constructor(data?: PartialMessage<FfiRequest>) {
Expand Down Expand Up @@ -374,6 +389,8 @@ export class FfiRequest extends Message<FfiRequest> {
{ no: 39, name: "register_rpc_method", kind: "message", T: RegisterRpcMethodRequest, oneof: "message" },
{ no: 40, name: "unregister_rpc_method", kind: "message", T: UnregisterRpcMethodRequest, oneof: "message" },
{ no: 41, name: "rpc_method_invocation_response", kind: "message", T: RpcMethodInvocationResponseRequest, oneof: "message" },
{ no: 42, name: "enable_remote_track_publication", kind: "message", T: EnableRemoteTrackPublicationRequest, oneof: "message" },
{ no: 43, name: "update_remote_track_publication_dimension", kind: "message", T: UpdateRemoteTrackPublicationDimensionRequest, oneof: "message" },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FfiRequest {
Expand Down Expand Up @@ -646,6 +663,20 @@ export class FfiResponse extends Message<FfiResponse> {
*/
value: RpcMethodInvocationResponseResponse;
case: "rpcMethodInvocationResponse";
} | {
/**
* Track Publication
*
* @generated from field: livekit.proto.EnableRemoteTrackPublicationResponse enable_remote_track_publication = 41;
*/
value: EnableRemoteTrackPublicationResponse;
case: "enableRemoteTrackPublication";
} | {
/**
* @generated from field: livekit.proto.UpdateRemoteTrackPublicationDimensionResponse update_remote_track_publication_dimension = 42;
*/
value: UpdateRemoteTrackPublicationDimensionResponse;
case: "updateRemoteTrackPublicationDimension";
} | { case: undefined; value?: undefined } = { case: undefined };

constructor(data?: PartialMessage<FfiResponse>) {
Expand Down Expand Up @@ -695,6 +726,8 @@ export class FfiResponse extends Message<FfiResponse> {
{ no: 38, name: "register_rpc_method", kind: "message", T: RegisterRpcMethodResponse, oneof: "message" },
{ no: 39, name: "unregister_rpc_method", kind: "message", T: UnregisterRpcMethodResponse, oneof: "message" },
{ no: 40, name: "rpc_method_invocation_response", kind: "message", T: RpcMethodInvocationResponseResponse, oneof: "message" },
{ no: 41, name: "enable_remote_track_publication", kind: "message", T: EnableRemoteTrackPublicationResponse, oneof: "message" },
{ no: 42, name: "update_remote_track_publication_dimension", kind: "message", T: UpdateRemoteTrackPublicationDimensionResponse, oneof: "message" },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): FfiResponse {
Expand Down
124 changes: 124 additions & 0 deletions packages/livekit-rtc/src/proto/participant_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,124 @@ proto2.util.setEnumType(ParticipantKind, "livekit.proto.ParticipantKind", [
{ no: 4, name: "PARTICIPANT_KIND_AGENT" },
]);

/**
* @generated from enum livekit.proto.DisconnectReason
*/
export enum DisconnectReason {
/**
* @generated from enum value: UNKNOWN_REASON = 0;
*/
UNKNOWN_REASON = 0,

/**
* the client initiated the disconnect
*
* @generated from enum value: CLIENT_INITIATED = 1;
*/
CLIENT_INITIATED = 1,

/**
* another participant with the same identity has joined the room
*
* @generated from enum value: DUPLICATE_IDENTITY = 2;
*/
DUPLICATE_IDENTITY = 2,

/**
* the server instance is shutting down
*
* @generated from enum value: SERVER_SHUTDOWN = 3;
*/
SERVER_SHUTDOWN = 3,

/**
* RoomService.RemoveParticipant was called
*
* @generated from enum value: PARTICIPANT_REMOVED = 4;
*/
PARTICIPANT_REMOVED = 4,

/**
* RoomService.DeleteRoom was called
*
* @generated from enum value: ROOM_DELETED = 5;
*/
ROOM_DELETED = 5,

/**
* the client is attempting to resume a session, but server is not aware of it
*
* @generated from enum value: STATE_MISMATCH = 6;
*/
STATE_MISMATCH = 6,

/**
* client was unable to connect fully
*
* @generated from enum value: JOIN_FAILURE = 7;
*/
JOIN_FAILURE = 7,

/**
* Cloud-only, the server requested Participant to migrate the connection elsewhere
*
* @generated from enum value: MIGRATION = 8;
*/
MIGRATION = 8,

/**
* the signal websocket was closed unexpectedly
*
* @generated from enum value: SIGNAL_CLOSE = 9;
*/
SIGNAL_CLOSE = 9,

/**
* the room was closed, due to all Standard and Ingress participants having left
*
* @generated from enum value: ROOM_CLOSED = 10;
*/
ROOM_CLOSED = 10,

/**
* SIP callee did not respond in time
*
* @generated from enum value: USER_UNAVAILABLE = 11;
*/
USER_UNAVAILABLE = 11,

/**
* SIP callee rejected the call (busy)
*
* @generated from enum value: USER_REJECTED = 12;
*/
USER_REJECTED = 12,

/**
* SIP protocol failure or unexpected response
*
* @generated from enum value: SIP_TRUNK_FAILURE = 13;
*/
SIP_TRUNK_FAILURE = 13,
}
// Retrieve enum metadata with: proto2.getEnumType(DisconnectReason)
proto2.util.setEnumType(DisconnectReason, "livekit.proto.DisconnectReason", [
{ no: 0, name: "UNKNOWN_REASON" },
{ no: 1, name: "CLIENT_INITIATED" },
{ no: 2, name: "DUPLICATE_IDENTITY" },
{ no: 3, name: "SERVER_SHUTDOWN" },
{ no: 4, name: "PARTICIPANT_REMOVED" },
{ no: 5, name: "ROOM_DELETED" },
{ no: 6, name: "STATE_MISMATCH" },
{ no: 7, name: "JOIN_FAILURE" },
{ no: 8, name: "MIGRATION" },
{ no: 9, name: "SIGNAL_CLOSE" },
{ no: 10, name: "ROOM_CLOSED" },
{ no: 11, name: "USER_UNAVAILABLE" },
{ no: 12, name: "USER_REJECTED" },
{ no: 13, name: "SIP_TRUNK_FAILURE" },
]);

/**
* @generated from message livekit.proto.ParticipantInfo
*/
Expand Down Expand Up @@ -93,6 +211,11 @@ export class ParticipantInfo extends Message<ParticipantInfo> {
*/
kind?: ParticipantKind;

/**
* @generated from field: required livekit.proto.DisconnectReason disconnect_reason = 7;
*/
disconnectReason?: DisconnectReason;

constructor(data?: PartialMessage<ParticipantInfo>) {
super();
proto2.util.initPartial(data, this);
Expand All @@ -107,6 +230,7 @@ export class ParticipantInfo extends Message<ParticipantInfo> {
{ no: 4, name: "metadata", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true },
{ no: 5, name: "attributes", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} },
{ no: 6, name: "kind", kind: "enum", T: proto2.getEnumType(ParticipantKind), req: true },
{ no: 7, name: "disconnect_reason", kind: "enum", T: proto2.getEnumType(DisconnectReason), req: true },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ParticipantInfo {
Expand Down
Loading
Loading