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

Remove OFF option from VideoQuality enum #985

Merged
merged 7 commits into from
Jan 10, 2024
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/poor-horses-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": major
---

Remote `OFF` option from VideoQuality enum
5 changes: 2 additions & 3 deletions example/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,8 @@ const appActions = {
if (textField.value) {
const msg = state.encoder.encode(textField.value);
currentRoom.localParticipant.publishData(msg, DataPacket_Kind.RELIABLE);
(<HTMLTextAreaElement>(
$('chat')
)).value += `${currentRoom.localParticipant.identity} (me): ${textField.value}\n`;
(<HTMLTextAreaElement>$('chat')).value +=
`${currentRoom.localParticipant.identity} (me): ${textField.value}\n`;
textField.value = '';
}
},
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -73,7 +73,6 @@ export {
RemoteVideoTrack,
RemoteTrackPublication,
TrackPublication,
VideoQuality,
ConnectionQuality,
DefaultReconnectPolicy,
CriticalTimers,
Expand Down
66 changes: 66 additions & 0 deletions src/proto/livekit_models_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ export class Room extends Message<Room> {
*/
activeRecording = false;

/**
* @generated from field: livekit.TimedVersion version = 13;
*/
version?: TimedVersion;

constructor(data?: PartialMessage<Room>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -456,6 +461,7 @@ export class Room extends Message<Room> {
{ 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<BinaryReadOptions>): Room {
Expand Down Expand Up @@ -726,6 +732,11 @@ export class ParticipantInfo extends Message<ParticipantInfo> {
*/
isPublisher = false;

/**
* @generated from field: livekit.ParticipantInfo.Kind kind = 14;
*/
kind = ParticipantInfo_Kind.STANDARD;

constructor(data?: PartialMessage<ParticipantInfo>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -745,6 +756,7 @@ export class ParticipantInfo extends Message<ParticipantInfo> {
{ 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<BinaryReadOptions>): ParticipantInfo {
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -1020,6 +1080,11 @@ export class TrackInfo extends Message<TrackInfo> {
*/
stream = "";

/**
* @generated from field: livekit.TimedVersion version = 18;
*/
version?: TimedVersion;

constructor(data?: PartialMessage<TrackInfo>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -1045,6 +1110,7 @@ export class TrackInfo extends Message<TrackInfo> {
{ 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<BinaryReadOptions>): TrackInfo {
Expand Down
2 changes: 1 addition & 1 deletion src/room/track/LocalVideoTrack.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
10 changes: 5 additions & 5 deletions src/room/track/LocalVideoTrack.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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';
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';
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 2 additions & 7 deletions src/room/track/RemoteTrackPublication.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
11 changes: 10 additions & 1 deletion src/room/track/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -15,6 +19,11 @@ const BACKGROUND_REACTION_DELAY = 5000;
// Safari tracks which audio elements have been "blessed" by the user.
const recycledElements: Array<HTMLAudioElement> = [];

export enum VideoQuality {
LOW = ProtoQuality.LOW,
MEDIUM = ProtoQuality.MEDIUM,
HIGH = ProtoQuality.HIGH,
}
export abstract class Track extends (EventEmitter as new () => TypedEventEmitter<TrackEventCallbacks>) {
kind: Track.Kind;

Expand Down
Loading