diff --git a/.changeset/poor-horses-grow.md b/.changeset/poor-horses-grow.md new file mode 100644 index 0000000000..c41f17aaa6 --- /dev/null +++ b/.changeset/poor-horses-grow.md @@ -0,0 +1,5 @@ +--- +"livekit-client": major +--- + +Remote `OFF` option from VideoQuality enum diff --git a/example/sample.ts b/example/sample.ts index 7a45186fd0..5277b879b0 100644 --- a/example/sample.ts +++ b/example/sample.ts @@ -345,9 +345,8 @@ const appActions = { if (textField.value) { const msg = state.encoder.encode(textField.value); currentRoom.localParticipant.publishData(msg, DataPacket_Kind.RELIABLE); - (( - $('chat') - )).value += `${currentRoom.localParticipant.identity} (me): ${textField.value}\n`; + ($('chat')).value += + `${currentRoom.localParticipant.identity} (me): ${textField.value}\n`; textField.value = ''; } }, diff --git a/src/index.ts b/src/index.ts index df439c0a8a..8d6831b0ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import { LogLevel, getLogger, setLogExtension, setLogLevel } from './logger'; -import { DataPacket_Kind, DisconnectReason, VideoQuality } from './proto/livekit_models_pb'; +import { DataPacket_Kind, DisconnectReason } from './proto/livekit_models_pb'; import DefaultReconnectPolicy from './room/DefaultReconnectPolicy'; import Room, { ConnectionState, RoomState } from './room/Room'; import LocalParticipant from './room/participant/LocalParticipant'; @@ -73,7 +73,6 @@ export { RemoteVideoTrack, RemoteTrackPublication, TrackPublication, - VideoQuality, ConnectionQuality, DefaultReconnectPolicy, CriticalTimers, diff --git a/src/proto/livekit_models_pb.ts b/src/proto/livekit_models_pb.ts index def9fd4c45..a769879b88 100644 --- a/src/proto/livekit_models_pb.ts +++ b/src/proto/livekit_models_pb.ts @@ -437,6 +437,11 @@ export class Room extends Message { */ activeRecording = false; + /** + * @generated from field: livekit.TimedVersion version = 13; + */ + version?: TimedVersion; + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); @@ -456,6 +461,7 @@ export class Room extends Message { { no: 9, name: "num_participants", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, { no: 11, name: "num_publishers", kind: "scalar", T: 13 /* ScalarType.UINT32 */ }, { no: 10, name: "active_recording", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 13, name: "version", kind: "message", T: TimedVersion }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): Room { @@ -726,6 +732,11 @@ export class ParticipantInfo extends Message { */ isPublisher = false; + /** + * @generated from field: livekit.ParticipantInfo.Kind kind = 14; + */ + kind = ParticipantInfo_Kind.STANDARD; + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); @@ -745,6 +756,7 @@ export class ParticipantInfo extends Message { { no: 11, name: "permission", kind: "message", T: ParticipantPermission }, { no: 12, name: "region", kind: "scalar", T: 9 /* ScalarType.STRING */ }, { no: 13, name: "is_publisher", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 14, name: "kind", kind: "enum", T: proto3.getEnumType(ParticipantInfo_Kind) }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): ParticipantInfo { @@ -804,6 +816,54 @@ proto3.util.setEnumType(ParticipantInfo_State, "livekit.ParticipantInfo.State", { no: 3, name: "DISCONNECTED" }, ]); +/** + * @generated from enum livekit.ParticipantInfo.Kind + */ +export enum ParticipantInfo_Kind { + /** + * standard participants, e.g. web clients + * + * @generated from enum value: STANDARD = 0; + */ + STANDARD = 0, + + /** + * only ingests streams + * + * @generated from enum value: INGRESS = 1; + */ + INGRESS = 1, + + /** + * only consumes streams + * + * @generated from enum value: EGRESS = 2; + */ + EGRESS = 2, + + /** + * SIP participants + * + * @generated from enum value: SIP = 3; + */ + SIP = 3, + + /** + * LiveKit agents + * + * @generated from enum value: AGENT = 4; + */ + AGENT = 4, +} +// Retrieve enum metadata with: proto3.getEnumType(ParticipantInfo_Kind) +proto3.util.setEnumType(ParticipantInfo_Kind, "livekit.ParticipantInfo.Kind", [ + { no: 0, name: "STANDARD" }, + { no: 1, name: "INGRESS" }, + { no: 2, name: "EGRESS" }, + { no: 3, name: "SIP" }, + { no: 4, name: "AGENT" }, +]); + /** * @generated from message livekit.Encryption */ @@ -1020,6 +1080,11 @@ export class TrackInfo extends Message { */ stream = ""; + /** + * @generated from field: livekit.TimedVersion version = 18; + */ + version?: TimedVersion; + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); @@ -1045,6 +1110,7 @@ export class TrackInfo extends Message { { no: 15, name: "disable_red", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, { no: 16, name: "encryption", kind: "enum", T: proto3.getEnumType(Encryption_Type) }, { no: 17, name: "stream", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 18, name: "version", kind: "message", T: TimedVersion }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): TrackInfo { diff --git a/src/room/track/LocalVideoTrack.test.ts b/src/room/track/LocalVideoTrack.test.ts index b879d1b1f4..3ebc9baac5 100644 --- a/src/room/track/LocalVideoTrack.test.ts +++ b/src/room/track/LocalVideoTrack.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; -import { VideoQuality } from '../../proto/livekit_models_pb'; import { videoLayersFromEncodings } from './LocalVideoTrack'; +import { VideoQuality } from './Track'; describe('videoLayersFromEncodings', () => { it('returns single layer for no encoding', () => { diff --git a/src/room/track/LocalVideoTrack.ts b/src/room/track/LocalVideoTrack.ts index 227330c269..74849922cc 100644 --- a/src/room/track/LocalVideoTrack.ts +++ b/src/room/track/LocalVideoTrack.ts @@ -1,6 +1,6 @@ import type { SignalClient } from '../../api/SignalClient'; import type { StructuredLogger } from '../../logger'; -import { VideoLayer, VideoQuality } from '../../proto/livekit_models_pb'; +import { VideoQuality as ProtoVideoQuality, VideoLayer } from '../../proto/livekit_models_pb'; import { SubscribedCodec, SubscribedQuality } from '../../proto/livekit_rtc_pb'; import { ScalabilityMode } from '../participant/publishUtils'; import type { VideoSenderStats } from '../stats'; @@ -8,7 +8,7 @@ import { computeBitrate, monitorFrequency } from '../stats'; import type { LoggerOptions } from '../types'; import { Mutex, isFireFox, isMobile, isWeb, unwrapConstraint } from '../utils'; import LocalTrack from './LocalTrack'; -import { Track } from './Track'; +import { Track, VideoQuality } from './Track'; import type { VideoCaptureOptions, VideoCodec } from './options'; import type { TrackProcessor } from './processor/types'; import { constraintsForOptions } from './utils'; @@ -427,14 +427,14 @@ async function setPublishingLayersForSender( const encoding = encodings[0]; /* @ts-ignore */ // const mode = new ScalabilityMode(encoding.scalabilityMode); - let maxQuality = VideoQuality.OFF; + let maxQuality = ProtoVideoQuality.OFF; qualities.forEach((q) => { - if (q.enabled && (maxQuality === VideoQuality.OFF || q.quality > maxQuality)) { + if (q.enabled && (maxQuality === ProtoVideoQuality.OFF || q.quality > maxQuality)) { maxQuality = q.quality; } }); - if (maxQuality === VideoQuality.OFF) { + if (maxQuality === ProtoVideoQuality.OFF) { if (encoding.active) { encoding.active = false; hasChanged = true; diff --git a/src/room/track/RemoteTrackPublication.ts b/src/room/track/RemoteTrackPublication.ts index 719977dcb2..d5c1912353 100644 --- a/src/room/track/RemoteTrackPublication.ts +++ b/src/room/track/RemoteTrackPublication.ts @@ -1,15 +1,10 @@ -import { - ParticipantTracks, - SubscriptionError, - TrackInfo, - VideoQuality, -} from '../../proto/livekit_models_pb'; +import { ParticipantTracks, SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb'; import { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb'; import { TrackEvent } from '../events'; import type { LoggerOptions } from '../types'; import type RemoteTrack from './RemoteTrack'; import RemoteVideoTrack from './RemoteVideoTrack'; -import { Track } from './Track'; +import { Track, VideoQuality } from './Track'; import { TrackPublication } from './TrackPublication'; export default class RemoteTrackPublication extends TrackPublication { diff --git a/src/room/track/Track.ts b/src/room/track/Track.ts index 0648736b5a..70b36cb68d 100644 --- a/src/room/track/Track.ts +++ b/src/room/track/Track.ts @@ -2,7 +2,11 @@ import { EventEmitter } from 'events'; import type TypedEventEmitter from 'typed-emitter'; import type { SignalClient } from '../../api/SignalClient'; import log, { LoggerNames, StructuredLogger, getLogger } from '../../logger'; -import { TrackSource, TrackType } from '../../proto/livekit_models_pb'; +import { + VideoQuality as ProtoQuality, + TrackSource, + TrackType, +} from '../../proto/livekit_models_pb'; import { StreamState as ProtoStreamState } from '../../proto/livekit_rtc_pb'; import { TrackEvent } from '../events'; import type { LoggerOptions } from '../types'; @@ -15,6 +19,11 @@ const BACKGROUND_REACTION_DELAY = 5000; // Safari tracks which audio elements have been "blessed" by the user. const recycledElements: Array = []; +export enum VideoQuality { + LOW = ProtoQuality.LOW, + MEDIUM = ProtoQuality.MEDIUM, + HIGH = ProtoQuality.HIGH, +} export abstract class Track extends (EventEmitter as new () => TypedEventEmitter) { kind: Track.Kind;