diff --git a/.changeset/mighty-dingos-enjoy.md b/.changeset/mighty-dingos-enjoy.md new file mode 100644 index 00000000..f0c0b0fd --- /dev/null +++ b/.changeset/mighty-dingos-enjoy.md @@ -0,0 +1,5 @@ +--- +"@livekit/rtc-node": minor +--- + +feat(rtc): expose DisconnectReason diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 976d6b15..b81f94b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,7 +127,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: true + submodules: recursive - uses: pnpm/action-setup@v4 diff --git a/packages/livekit-rtc/generate_proto.sh b/packages/livekit-rtc/generate_proto.sh index e9a0cbb1..91e73ad6 100755 --- a/packages/livekit-rtc/generate_proto.sh +++ b/packages/livekit-rtc/generate_proto.sh @@ -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 \ diff --git a/packages/livekit-rtc/rust-sdks b/packages/livekit-rtc/rust-sdks index 06997356..cc889daa 160000 --- a/packages/livekit-rtc/rust-sdks +++ b/packages/livekit-rtc/rust-sdks @@ -1 +1 @@ -Subproject commit 06997356c083b01da766c4c93e8c4e8354d871ce +Subproject commit cc889daa26c2ea50258932708a24e095dcc850cc diff --git a/packages/livekit-rtc/src/participant.ts b/packages/livekit-rtc/src/participant.ts index 50083725..b7f1eb2d 100644 --- a/packages/livekit-rtc/src/participant.ts +++ b/packages/livekit-rtc/src/participant.ts @@ -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, @@ -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; + } } export type DataPublishOptions = { diff --git a/packages/livekit-rtc/src/proto/ffi_pb.ts b/packages/livekit-rtc/src/proto/ffi_pb.ts index f7083c55..f3c26f62 100644 --- a/packages/livekit-rtc/src/proto/ffi_pb.ts +++ b/packages/livekit-rtc/src/proto/ffi_pb.ts @@ -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 @@ -324,6 +325,20 @@ export class FfiRequest extends Message { */ 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) { @@ -374,6 +389,8 @@ export class FfiRequest extends Message { { 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): FfiRequest { @@ -646,6 +663,20 @@ export class FfiResponse extends Message { */ 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) { @@ -695,6 +726,8 @@ export class FfiResponse extends Message { { 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): FfiResponse { diff --git a/packages/livekit-rtc/src/proto/participant_pb.ts b/packages/livekit-rtc/src/proto/participant_pb.ts index d3c769e3..fa48904f 100644 --- a/packages/livekit-rtc/src/proto/participant_pb.ts +++ b/packages/livekit-rtc/src/proto/participant_pb.ts @@ -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 */ @@ -93,6 +211,11 @@ export class ParticipantInfo extends Message { */ kind?: ParticipantKind; + /** + * @generated from field: required livekit.proto.DisconnectReason disconnect_reason = 7; + */ + disconnectReason?: DisconnectReason; + constructor(data?: PartialMessage) { super(); proto2.util.initPartial(data, this); @@ -107,6 +230,7 @@ export class ParticipantInfo extends Message { { 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): ParticipantInfo { diff --git a/packages/livekit-rtc/src/proto/room_pb.ts b/packages/livekit-rtc/src/proto/room_pb.ts index 7109e71a..5eae7899 100644 --- a/packages/livekit-rtc/src/proto/room_pb.ts +++ b/packages/livekit-rtc/src/proto/room_pb.ts @@ -19,7 +19,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto2 } from "@bufbuild/protobuf"; -import { OwnedParticipant } from "./participant_pb.js"; +import { DisconnectReason, OwnedParticipant } from "./participant_pb.js"; import { OwnedTrack, OwnedTrackPublication, TrackSource } from "./track_pb.js"; import { RtcStats } from "./stats_pb.js"; import { VideoCodec } from "./video_frame_pb.js"; @@ -150,100 +150,6 @@ proto2.util.setEnumType(DataPacketKind, "livekit.proto.DataPacketKind", [ { no: 1, name: "KIND_RELIABLE" }, ]); -/** - * @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, -} -// 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" }, -]); - /** * Connect to a new LiveKit room * @@ -2844,6 +2750,18 @@ export class RoomEvent extends Message { */ value: ChatMessageReceived; case: "chatMessage"; + } | { + /** + * @generated from field: livekit.proto.DataStream.Header stream_header = 30; + */ + value: DataStream_Header; + case: "streamHeader"; + } | { + /** + * @generated from field: livekit.proto.DataStream.Chunk stream_chunk = 31; + */ + value: DataStream_Chunk; + case: "streamChunk"; } | { case: undefined; value?: undefined } = { case: undefined }; constructor(data?: PartialMessage) { @@ -2883,6 +2801,8 @@ export class RoomEvent extends Message { { no: 27, name: "data_packet_received", kind: "message", T: DataPacketReceived, oneof: "message" }, { no: 28, name: "transcription_received", kind: "message", T: TranscriptionReceived, oneof: "message" }, { no: 29, name: "chat_message", kind: "message", T: ChatMessageReceived, oneof: "message" }, + { no: 30, name: "stream_header", kind: "message", T: DataStream_Header, oneof: "message" }, + { no: 31, name: "stream_chunk", kind: "message", T: DataStream_Chunk, oneof: "message" }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): RoomEvent { @@ -4335,3 +4255,363 @@ export class RoomEOS extends Message { } } +/** + * @generated from message livekit.proto.DataStream + */ +export class DataStream extends Message { + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.DataStream"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DataStream { + return new DataStream().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DataStream { + return new DataStream().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DataStream { + return new DataStream().fromJsonString(jsonString, options); + } + + static equals(a: DataStream | PlainMessage | undefined, b: DataStream | PlainMessage | undefined): boolean { + return proto2.util.equals(DataStream, a, b); + } +} + +/** + * enum for operation types (specific to TextHeader) + * + * @generated from enum livekit.proto.DataStream.OperationType + */ +export enum DataStream_OperationType { + /** + * @generated from enum value: CREATE = 0; + */ + CREATE = 0, + + /** + * @generated from enum value: UPDATE = 1; + */ + UPDATE = 1, + + /** + * @generated from enum value: DELETE = 2; + */ + DELETE = 2, + + /** + * @generated from enum value: REACTION = 3; + */ + REACTION = 3, +} +// Retrieve enum metadata with: proto2.getEnumType(DataStream_OperationType) +proto2.util.setEnumType(DataStream_OperationType, "livekit.proto.DataStream.OperationType", [ + { no: 0, name: "CREATE" }, + { no: 1, name: "UPDATE" }, + { no: 2, name: "DELETE" }, + { no: 3, name: "REACTION" }, +]); + +/** + * header properties specific to text streams + * + * @generated from message livekit.proto.DataStream.TextHeader + */ +export class DataStream_TextHeader extends Message { + /** + * @generated from field: required livekit.proto.DataStream.OperationType operation_type = 1; + */ + operationType?: DataStream_OperationType; + + /** + * Optional: Version for updates/edits + * + * @generated from field: required int32 version = 2; + */ + version?: number; + + /** + * Optional: Reply to specific message + * + * @generated from field: required string reply_to_stream_id = 3; + */ + replyToStreamId?: string; + + /** + * file attachments for text streams + * + * @generated from field: repeated string attached_stream_ids = 4; + */ + attachedStreamIds: string[] = []; + + /** + * true if the text has been generated by an agent from a participant's audio transcription + * + * @generated from field: required bool generated = 5; + */ + generated?: boolean; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.DataStream.TextHeader"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 1, name: "operation_type", kind: "enum", T: proto2.getEnumType(DataStream_OperationType), req: true }, + { no: 2, name: "version", kind: "scalar", T: 5 /* ScalarType.INT32 */, req: true }, + { no: 3, name: "reply_to_stream_id", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true }, + { no: 4, name: "attached_stream_ids", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + { no: 5, name: "generated", kind: "scalar", T: 8 /* ScalarType.BOOL */, req: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DataStream_TextHeader { + return new DataStream_TextHeader().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DataStream_TextHeader { + return new DataStream_TextHeader().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DataStream_TextHeader { + return new DataStream_TextHeader().fromJsonString(jsonString, options); + } + + static equals(a: DataStream_TextHeader | PlainMessage | undefined, b: DataStream_TextHeader | PlainMessage | undefined): boolean { + return proto2.util.equals(DataStream_TextHeader, a, b); + } +} + +/** + * header properties specific to file or image streams + * + * @generated from message livekit.proto.DataStream.FileHeader + */ +export class DataStream_FileHeader extends Message { + /** + * name of the file + * + * @generated from field: required string file_name = 1; + */ + fileName?: string; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.DataStream.FileHeader"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 1, name: "file_name", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DataStream_FileHeader { + return new DataStream_FileHeader().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DataStream_FileHeader { + return new DataStream_FileHeader().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DataStream_FileHeader { + return new DataStream_FileHeader().fromJsonString(jsonString, options); + } + + static equals(a: DataStream_FileHeader | PlainMessage | undefined, b: DataStream_FileHeader | PlainMessage | undefined): boolean { + return proto2.util.equals(DataStream_FileHeader, a, b); + } +} + +/** + * main DataStream.Header that contains a oneof for specific headers + * + * @generated from message livekit.proto.DataStream.Header + */ +export class DataStream_Header extends Message { + /** + * unique identifier for this data stream + * + * @generated from field: required string stream_id = 1; + */ + streamId?: string; + + /** + * using int64 for Unix timestamp + * + * @generated from field: required int64 timestamp = 2; + */ + timestamp?: bigint; + + /** + * @generated from field: required string topic = 3; + */ + topic?: string; + + /** + * @generated from field: required string mime_type = 4; + */ + mimeType?: string; + + /** + * only populated for finite streams, if it's a stream of unknown size this stays empty + * + * @generated from field: optional uint64 total_length = 5; + */ + totalLength?: bigint; + + /** + * only populated for finite streams, if it's a stream of unknown size this stays empty + * + * @generated from field: optional uint64 total_chunks = 6; + */ + totalChunks?: bigint; + + /** + * user defined extensions map that can carry additional info + * + * @generated from field: map extensions = 7; + */ + extensions: { [key: string]: string } = {}; + + /** + * oneof to choose between specific header types + * + * @generated from oneof livekit.proto.DataStream.Header.content_header + */ + contentHeader: { + /** + * @generated from field: livekit.proto.DataStream.TextHeader text_header = 8; + */ + value: DataStream_TextHeader; + case: "textHeader"; + } | { + /** + * @generated from field: livekit.proto.DataStream.FileHeader file_header = 9; + */ + value: DataStream_FileHeader; + case: "fileHeader"; + } | { case: undefined; value?: undefined } = { case: undefined }; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.DataStream.Header"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 1, name: "stream_id", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true }, + { no: 2, name: "timestamp", kind: "scalar", T: 3 /* ScalarType.INT64 */, req: true }, + { no: 3, name: "topic", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true }, + { no: 4, name: "mime_type", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true }, + { no: 5, name: "total_length", kind: "scalar", T: 4 /* ScalarType.UINT64 */, opt: true }, + { no: 6, name: "total_chunks", kind: "scalar", T: 4 /* ScalarType.UINT64 */, opt: true }, + { no: 7, name: "extensions", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, + { no: 8, name: "text_header", kind: "message", T: DataStream_TextHeader, oneof: "content_header" }, + { no: 9, name: "file_header", kind: "message", T: DataStream_FileHeader, oneof: "content_header" }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DataStream_Header { + return new DataStream_Header().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DataStream_Header { + return new DataStream_Header().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DataStream_Header { + return new DataStream_Header().fromJsonString(jsonString, options); + } + + static equals(a: DataStream_Header | PlainMessage | undefined, b: DataStream_Header | PlainMessage | undefined): boolean { + return proto2.util.equals(DataStream_Header, a, b); + } +} + +/** + * @generated from message livekit.proto.DataStream.Chunk + */ +export class DataStream_Chunk extends Message { + /** + * unique identifier for this data stream to map it to the correct header + * + * @generated from field: required string stream_id = 1; + */ + streamId?: string; + + /** + * @generated from field: required uint64 chunk_index = 2; + */ + chunkIndex?: bigint; + + /** + * content as binary (bytes) + * + * @generated from field: required bytes content = 3; + */ + content?: Uint8Array; + + /** + * true only if this is the last chunk of this stream - can also be sent with empty content + * + * @generated from field: required bool complete = 4; + */ + complete?: boolean; + + /** + * a version indicating that this chunk_index has been retroactively modified and the original one needs to be replaced + * + * @generated from field: required int32 version = 5; + */ + version?: number; + + /** + * optional, initialization vector for AES-GCM encryption + * + * @generated from field: optional bytes iv = 6; + */ + iv?: Uint8Array; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.DataStream.Chunk"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 1, name: "stream_id", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true }, + { no: 2, name: "chunk_index", kind: "scalar", T: 4 /* ScalarType.UINT64 */, req: true }, + { no: 3, name: "content", kind: "scalar", T: 12 /* ScalarType.BYTES */, req: true }, + { no: 4, name: "complete", kind: "scalar", T: 8 /* ScalarType.BOOL */, req: true }, + { no: 5, name: "version", kind: "scalar", T: 5 /* ScalarType.INT32 */, req: true }, + { no: 6, name: "iv", kind: "scalar", T: 12 /* ScalarType.BYTES */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DataStream_Chunk { + return new DataStream_Chunk().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DataStream_Chunk { + return new DataStream_Chunk().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DataStream_Chunk { + return new DataStream_Chunk().fromJsonString(jsonString, options); + } + + static equals(a: DataStream_Chunk | PlainMessage | undefined, b: DataStream_Chunk | PlainMessage | undefined): boolean { + return proto2.util.equals(DataStream_Chunk, a, b); + } +} + diff --git a/packages/livekit-rtc/src/proto/stats_pb.ts b/packages/livekit-rtc/src/proto/stats_pb.ts index ea7d388f..7ca4d606 100644 --- a/packages/livekit-rtc/src/proto/stats_pb.ts +++ b/packages/livekit-rtc/src/proto/stats_pb.ts @@ -439,7 +439,13 @@ export class RtcStats extends Message { case: "certificate"; } | { /** - * @generated from field: livekit.proto.RtcStats.Track track = 17; + * @generated from field: livekit.proto.RtcStats.Stream stream = 17; + */ + value: RtcStats_Stream; + case: "stream"; + } | { + /** + * @generated from field: livekit.proto.RtcStats.Track track = 18; */ value: RtcStats_Track; case: "track"; @@ -467,7 +473,8 @@ export class RtcStats extends Message { { no: 14, name: "local_candidate", kind: "message", T: RtcStats_LocalCandidate, oneof: "stats" }, { no: 15, name: "remote_candidate", kind: "message", T: RtcStats_RemoteCandidate, oneof: "stats" }, { no: 16, name: "certificate", kind: "message", T: RtcStats_Certificate, oneof: "stats" }, - { no: 17, name: "track", kind: "message", T: RtcStats_Track, oneof: "stats" }, + { no: 17, name: "stream", kind: "message", T: RtcStats_Stream, oneof: "stats" }, + { no: 18, name: "track", kind: "message", T: RtcStats_Track, oneof: "stats" }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): RtcStats { @@ -1149,6 +1156,49 @@ export class RtcStats_Certificate extends Message { } } +/** + * @generated from message livekit.proto.RtcStats.Stream + */ +export class RtcStats_Stream extends Message { + /** + * @generated from field: required livekit.proto.RtcStatsData rtc = 1; + */ + rtc?: RtcStatsData; + + /** + * @generated from field: required livekit.proto.StreamStats stream = 2; + */ + stream?: StreamStats; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.RtcStats.Stream"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 1, name: "rtc", kind: "message", T: RtcStatsData, req: true }, + { no: 2, name: "stream", kind: "message", T: StreamStats, req: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): RtcStats_Stream { + return new RtcStats_Stream().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): RtcStats_Stream { + return new RtcStats_Stream().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): RtcStats_Stream { + return new RtcStats_Stream().fromJsonString(jsonString, options); + } + + static equals(a: RtcStats_Stream | PlainMessage | undefined, b: RtcStats_Stream | PlainMessage | undefined): boolean { + return proto2.util.equals(RtcStats_Stream, a, b); + } +} + /** * Deprecated * @@ -2953,3 +3003,48 @@ export class CertificateStats extends Message { } } +/** + * @generated from message livekit.proto.StreamStats + */ +export class StreamStats extends Message { + /** + * @generated from field: required string id = 1; + */ + id?: string; + + /** + * required int64 timestamp = 3; + * + * @generated from field: required string stream_identifier = 2; + */ + streamIdentifier?: string; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.StreamStats"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true }, + { no: 2, name: "stream_identifier", kind: "scalar", T: 9 /* ScalarType.STRING */, req: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): StreamStats { + return new StreamStats().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): StreamStats { + return new StreamStats().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): StreamStats { + return new StreamStats().fromJsonString(jsonString, options); + } + + static equals(a: StreamStats | PlainMessage | undefined, b: StreamStats | PlainMessage | undefined): boolean { + return proto2.util.equals(StreamStats, a, b); + } +} + diff --git a/packages/livekit-rtc/src/proto/track_publication_pb.ts b/packages/livekit-rtc/src/proto/track_publication_pb.ts new file mode 100644 index 00000000..e30d9d68 --- /dev/null +++ b/packages/livekit-rtc/src/proto/track_publication_pb.ts @@ -0,0 +1,180 @@ +// Copyright 2023 LiveKit, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// @generated by protoc-gen-es v1.10.0 with parameter "target=ts,import_extension=.js" +// @generated from file track_publication.proto (package livekit.proto, syntax proto2) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto2 } from "@bufbuild/protobuf"; + +/** + * Enable/Disable a remote track publication + * + * @generated from message livekit.proto.EnableRemoteTrackPublicationRequest + */ +export class EnableRemoteTrackPublicationRequest extends Message { + /** + * @generated from field: required uint64 track_publication_handle = 1; + */ + trackPublicationHandle?: bigint; + + /** + * @generated from field: required bool enabled = 2; + */ + enabled?: boolean; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.EnableRemoteTrackPublicationRequest"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 1, name: "track_publication_handle", kind: "scalar", T: 4 /* ScalarType.UINT64 */, req: true }, + { no: 2, name: "enabled", kind: "scalar", T: 8 /* ScalarType.BOOL */, req: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): EnableRemoteTrackPublicationRequest { + return new EnableRemoteTrackPublicationRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): EnableRemoteTrackPublicationRequest { + return new EnableRemoteTrackPublicationRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): EnableRemoteTrackPublicationRequest { + return new EnableRemoteTrackPublicationRequest().fromJsonString(jsonString, options); + } + + static equals(a: EnableRemoteTrackPublicationRequest | PlainMessage | undefined, b: EnableRemoteTrackPublicationRequest | PlainMessage | undefined): boolean { + return proto2.util.equals(EnableRemoteTrackPublicationRequest, a, b); + } +} + +/** + * @generated from message livekit.proto.EnableRemoteTrackPublicationResponse + */ +export class EnableRemoteTrackPublicationResponse extends Message { + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.EnableRemoteTrackPublicationResponse"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): EnableRemoteTrackPublicationResponse { + return new EnableRemoteTrackPublicationResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): EnableRemoteTrackPublicationResponse { + return new EnableRemoteTrackPublicationResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): EnableRemoteTrackPublicationResponse { + return new EnableRemoteTrackPublicationResponse().fromJsonString(jsonString, options); + } + + static equals(a: EnableRemoteTrackPublicationResponse | PlainMessage | undefined, b: EnableRemoteTrackPublicationResponse | PlainMessage | undefined): boolean { + return proto2.util.equals(EnableRemoteTrackPublicationResponse, a, b); + } +} + +/** + * update a remote track publication dimension + * + * @generated from message livekit.proto.UpdateRemoteTrackPublicationDimensionRequest + */ +export class UpdateRemoteTrackPublicationDimensionRequest extends Message { + /** + * @generated from field: required uint64 track_publication_handle = 1; + */ + trackPublicationHandle?: bigint; + + /** + * @generated from field: required uint32 width = 2; + */ + width?: number; + + /** + * @generated from field: required uint32 height = 3; + */ + height?: number; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.UpdateRemoteTrackPublicationDimensionRequest"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 1, name: "track_publication_handle", kind: "scalar", T: 4 /* ScalarType.UINT64 */, req: true }, + { no: 2, name: "width", kind: "scalar", T: 13 /* ScalarType.UINT32 */, req: true }, + { no: 3, name: "height", kind: "scalar", T: 13 /* ScalarType.UINT32 */, req: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdateRemoteTrackPublicationDimensionRequest { + return new UpdateRemoteTrackPublicationDimensionRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdateRemoteTrackPublicationDimensionRequest { + return new UpdateRemoteTrackPublicationDimensionRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdateRemoteTrackPublicationDimensionRequest { + return new UpdateRemoteTrackPublicationDimensionRequest().fromJsonString(jsonString, options); + } + + static equals(a: UpdateRemoteTrackPublicationDimensionRequest | PlainMessage | undefined, b: UpdateRemoteTrackPublicationDimensionRequest | PlainMessage | undefined): boolean { + return proto2.util.equals(UpdateRemoteTrackPublicationDimensionRequest, a, b); + } +} + +/** + * @generated from message livekit.proto.UpdateRemoteTrackPublicationDimensionResponse + */ +export class UpdateRemoteTrackPublicationDimensionResponse extends Message { + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "livekit.proto.UpdateRemoteTrackPublicationDimensionResponse"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): UpdateRemoteTrackPublicationDimensionResponse { + return new UpdateRemoteTrackPublicationDimensionResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): UpdateRemoteTrackPublicationDimensionResponse { + return new UpdateRemoteTrackPublicationDimensionResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): UpdateRemoteTrackPublicationDimensionResponse { + return new UpdateRemoteTrackPublicationDimensionResponse().fromJsonString(jsonString, options); + } + + static equals(a: UpdateRemoteTrackPublicationDimensionResponse | PlainMessage | undefined, b: UpdateRemoteTrackPublicationDimensionResponse | PlainMessage | undefined): boolean { + return proto2.util.equals(UpdateRemoteTrackPublicationDimensionResponse, a, b); + } +} + diff --git a/packages/livekit-rtc/src/room.ts b/packages/livekit-rtc/src/room.ts index 3fde5815..0d81f05b 100644 --- a/packages/livekit-rtc/src/room.ts +++ b/packages/livekit-rtc/src/room.ts @@ -10,8 +10,7 @@ import type { Participant } from './participant.js'; import { LocalParticipant, RemoteParticipant } from './participant.js'; import { EncryptionState } from './proto/e2ee_pb.js'; import type { FfiEvent } from './proto/ffi_pb.js'; -import type { OwnedParticipant } from './proto/participant_pb.js'; -import type { DisconnectReason } from './proto/room_pb.js'; +import type { DisconnectReason, OwnedParticipant } from './proto/participant_pb.js'; import { type ConnectCallback, type ConnectResponse,