Update DeviceIds name to pascal case

This commit is contained in:
Matthew Haughton 2024-10-25 23:19:05 +11:00
parent 8d0a8dc72d
commit ab21ba3236
4 changed files with 39 additions and 39 deletions

View File

@ -1,7 +1,7 @@
const castContext = cast.framework.CastReceiverContext.getInstance();
// Device Ids
export enum deviceIds {
export enum DeviceIds {
GEN1AND2,
AUDIO,
GEN3,
@ -18,7 +18,7 @@ let deviceId: number | null = null;
* Tries to identify the active Cast device by testing support for different codecs.
* @returns Active Cast device Id.
*/
export function getActiveDeviceId(): deviceIds {
export function getActiveDeviceId(): DeviceIds {
if (deviceId !== null) {
return deviceId;
}
@ -27,15 +27,15 @@ export function getActiveDeviceId(): deviceIds {
castContext.canDisplayType('video/mp4', 'hev1.1.6.L153.B0') &&
castContext.canDisplayType('video/webm', 'vp9')
) {
deviceId = deviceIds.ULTRA;
deviceId = DeviceIds.ULTRA;
} else if (castContext.canDisplayType('video/webm', 'vp9')) {
deviceId = deviceIds.NESTHUBANDMAX;
deviceId = DeviceIds.NESTHUBANDMAX;
} else if (castContext.canDisplayType('video/mp4', 'avc1.64002A')) {
deviceId = deviceIds.GEN3;
deviceId = DeviceIds.GEN3;
} else if (castContext.canDisplayType('video/mp4', 'avc1.640029')) {
deviceId = deviceIds.GEN1AND2;
deviceId = DeviceIds.GEN1AND2;
} else {
deviceId = deviceIds.AUDIO;
deviceId = DeviceIds.AUDIO;
}
return deviceId;

View File

@ -1,4 +1,4 @@
import { deviceIds } from './castDevices';
import { DeviceIds } from './castDevices';
const castContext = cast.framework.CastReceiverContext.getInstance();
@ -59,8 +59,8 @@ export function hasH265Support(): boolean {
* @param deviceId - the device id
* @returns true if text tracks are supported
*/
export function hasTextTrackSupport(deviceId: deviceIds): boolean {
return deviceId !== deviceIds.AUDIO;
export function hasTextTrackSupport(deviceId: DeviceIds): boolean {
return deviceId !== DeviceIds.AUDIO;
}
/**
@ -97,7 +97,7 @@ export function getMaxBitrateSupport(): number {
* @returns Max supported width.
*/
export function getMaxWidthSupport(
deviceId: deviceIds,
deviceId: DeviceIds,
codec?: string
): number {
if (codec === 'h264') {
@ -111,13 +111,13 @@ export function getMaxWidthSupport(
// they just refuse to do it with HLS. This increases
// the rate of direct playback.
switch (deviceId) {
case deviceIds.ULTRA:
case deviceIds.CCGTV:
case DeviceIds.ULTRA:
case DeviceIds.CCGTV:
return 3840;
case deviceIds.GEN1AND2:
case deviceIds.GEN3:
case DeviceIds.GEN1AND2:
case DeviceIds.GEN3:
return 1920;
case deviceIds.NESTHUBANDMAX:
case DeviceIds.NESTHUBANDMAX:
return 1280;
}
@ -129,11 +129,11 @@ export function getMaxWidthSupport(
* @param deviceId - Cast device id.
* @returns All supported H.264 profiles.
*/
export function getH264ProfileSupport(deviceId: deviceIds): string {
export function getH264ProfileSupport(deviceId: DeviceIds): string {
// These are supported by all Cast devices, excluding audio only devices.
let h264Profiles = 'high|main|baseline|constrained baseline';
if (deviceId === deviceIds.ULTRA || deviceId === deviceIds.CCGTV) {
if (deviceId === DeviceIds.ULTRA || deviceId === DeviceIds.CCGTV) {
h264Profiles += '|high 10';
}
@ -145,15 +145,15 @@ export function getH264ProfileSupport(deviceId: deviceIds): string {
* @param deviceId - Cast device id.
* @returns The highest supported H.264 level.
*/
export function getH264LevelSupport(deviceId: deviceIds): number {
export function getH264LevelSupport(deviceId: DeviceIds): number {
switch (deviceId) {
case deviceIds.NESTHUBANDMAX:
case deviceIds.GEN1AND2:
case DeviceIds.NESTHUBANDMAX:
case DeviceIds.GEN1AND2:
return 41;
case deviceIds.GEN3:
case deviceIds.ULTRA:
case DeviceIds.GEN3:
case DeviceIds.ULTRA:
return 42;
case deviceIds.CCGTV:
case DeviceIds.CCGTV:
return 51;
}
@ -165,9 +165,9 @@ export function getH264LevelSupport(deviceId: deviceIds): number {
* @param deviceId - Cast device id.
* @returns All supported H.265 profiles.
*/
export function getH265ProfileSupport(deviceId: deviceIds): string {
export function getH265ProfileSupport(deviceId: DeviceIds): string {
// These are supported by all Cast devices, excluding audio only devices.
if (deviceId === deviceIds.ULTRA || deviceId === deviceIds.CCGTV) {
if (deviceId === DeviceIds.ULTRA || deviceId === DeviceIds.CCGTV) {
return 'high|main|baseline|constrained baseline|high 10';
}
@ -179,8 +179,8 @@ export function getH265ProfileSupport(deviceId: deviceIds): string {
* @param deviceId - Cast device id.
* @returns The highest supported H.265 level.
*/
export function getH265LevelSupport(deviceId: deviceIds): number {
if (deviceId == deviceIds.ULTRA || deviceId == deviceIds.CCGTV) {
export function getH265LevelSupport(deviceId: DeviceIds): number {
if (deviceId == DeviceIds.ULTRA || deviceId == DeviceIds.CCGTV) {
return 52;
}

View File

@ -13,7 +13,7 @@ import { EncodingContext } from '@jellyfin/sdk/lib/generated-client/models/encod
import { ProfileConditionType } from '@jellyfin/sdk/lib/generated-client/models/profile-condition-type';
import { ProfileConditionValue } from '@jellyfin/sdk/lib/generated-client/models/profile-condition-value';
import { SubtitleDeliveryMethod } from '@jellyfin/sdk/lib/generated-client/models/subtitle-delivery-method';
import { deviceIds, getActiveDeviceId } from './castDevices';
import { DeviceIds, getActiveDeviceId } from './castDevices';
import {
hasSurroundSupport,
hasTextTrackSupport,
@ -39,7 +39,7 @@ interface ProfileOptions {
}
let profileOptions: ProfileOptions;
let currentDeviceId: deviceIds;
let currentDeviceId: DeviceIds;
/**
* Create and return a new ProfileCondition
@ -79,7 +79,7 @@ function getContainerProfiles(): Array<ContainerProfile> {
function getDirectPlayProfiles(): Array<DirectPlayProfile> {
const DirectPlayProfiles: Array<DirectPlayProfile> = [];
if (currentDeviceId !== deviceIds.AUDIO) {
if (currentDeviceId !== DeviceIds.AUDIO) {
const mp4VideoCodecs = getSupportedMP4VideoCodecs();
const mp4AudioCodecs = getSupportedMP4AudioCodecs();
const vpxVideoCodecs = getSupportedVPXVideoCodecs();
@ -163,7 +163,7 @@ function getCodecProfiles(): Array<CodecProfile> {
CodecProfiles.push(audioConditions);
// If device is audio only, don't add all the video related stuff
if (currentDeviceId == deviceIds.AUDIO) {
if (currentDeviceId == DeviceIds.AUDIO) {
return CodecProfiles;
}
@ -319,7 +319,7 @@ function getTranscodingProfiles(): Array<TranscodingProfile> {
}
// If device is audio only, don't add all the video related stuff
if (currentDeviceId == deviceIds.AUDIO) {
if (currentDeviceId == DeviceIds.AUDIO) {
return TranscodingProfiles;
}

View File

@ -2,7 +2,7 @@ import type { BaseItemDto } from '@jellyfin/sdk/lib/generated-client';
import { AppStatus } from '../types/appStatus';
import { parseISO8601Date, TicksPerSecond, ticksToSeconds } from '../helpers';
import { JellyfinApi } from './jellyfinApi';
import { deviceIds, getActiveDeviceId } from './castDevices';
import { DeviceIds, getActiveDeviceId } from './castDevices';
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export abstract class DocumentManager {
@ -17,7 +17,7 @@ export abstract class DocumentManager {
* Hide the document body on chromecast audio to save resources
*/
public static initialize(): void {
if (getActiveDeviceId() === deviceIds.AUDIO) {
if (getActiveDeviceId() === DeviceIds.AUDIO) {
document.body.style.display = 'none';
}
}
@ -133,7 +133,7 @@ export abstract class DocumentManager {
*/
public static async showItem(item: BaseItemDto): Promise<void> {
// no showItem for cc audio
if (getActiveDeviceId() === deviceIds.AUDIO) {
if (getActiveDeviceId() === DeviceIds.AUDIO) {
return;
}
@ -219,7 +219,7 @@ export abstract class DocumentManager {
*/
public static async showItemId(itemId: string): Promise<void> {
// no showItemId for cc audio
if (getActiveDeviceId() === deviceIds.AUDIO) {
if (getActiveDeviceId() === DeviceIds.AUDIO) {
return;
}
@ -402,7 +402,7 @@ export abstract class DocumentManager {
*/
public static async startBackdropInterval(): Promise<void> {
// no backdrop rotation for cc audio
if (getActiveDeviceId() === deviceIds.AUDIO) {
if (getActiveDeviceId() === DeviceIds.AUDIO) {
return;
}
@ -453,7 +453,7 @@ export abstract class DocumentManager {
*/
public static setPlayerBackdrop(item: BaseItemDto): void {
// no backdrop rotation for cc audio
if (getActiveDeviceId() === deviceIds.AUDIO) {
if (getActiveDeviceId() === DeviceIds.AUDIO) {
return;
}