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

Use deviceIds enum type where possible #645

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/components/castDevices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(): number {
export function getActiveDeviceId(): deviceIds {
if (deviceId !== null) {
return deviceId;
}
Expand Down
15 changes: 9 additions & 6 deletions src/components/codecSupportHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function hasH265Support(): boolean {
* @param deviceId - the device id
* @returns true if text tracks are supported
*/
export function hasTextTrackSupport(deviceId: number): boolean {
export function hasTextTrackSupport(deviceId: deviceIds): boolean {
return deviceId !== deviceIds.AUDIO;
}

Expand Down Expand Up @@ -96,7 +96,10 @@ export function getMaxBitrateSupport(): number {
* @param codec - Video codec.
* @returns Max supported width.
*/
export function getMaxWidthSupport(deviceId: number, codec?: string): number {
export function getMaxWidthSupport(
deviceId: deviceIds,
codec?: string
): number {
if (codec === 'h264') {
// with HLS, it will produce a manifest error if we
// send any stream larger than the screen size...
Expand Down Expand Up @@ -126,7 +129,7 @@ export function getMaxWidthSupport(deviceId: number, codec?: string): number {
* @param deviceId - Cast device id.
* @returns All supported H.264 profiles.
*/
export function getH264ProfileSupport(deviceId: number): 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';

Expand All @@ -142,7 +145,7 @@ export function getH264ProfileSupport(deviceId: number): string {
* @param deviceId - Cast device id.
* @returns The highest supported H.264 level.
*/
export function getH264LevelSupport(deviceId: number): number {
export function getH264LevelSupport(deviceId: deviceIds): number {
switch (deviceId) {
case deviceIds.NESTHUBANDMAX:
case deviceIds.GEN1AND2:
Expand All @@ -162,7 +165,7 @@ export function getH264LevelSupport(deviceId: number): number {
* @param deviceId - Cast device id.
* @returns All supported H.265 profiles.
*/
export function getH265ProfileSupport(deviceId: number): 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) {
return 'high|main|baseline|constrained baseline|high 10';
Expand All @@ -176,7 +179,7 @@ export function getH265ProfileSupport(deviceId: number): string {
* @param deviceId - Cast device id.
* @returns The highest supported H.265 level.
*/
export function getH265LevelSupport(deviceId: number): number {
export function getH265LevelSupport(deviceId: deviceIds): number {
if (deviceId == deviceIds.ULTRA || deviceId == deviceIds.CCGTV) {
return 52;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/deviceprofileBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface ProfileOptions {
}

let profileOptions: ProfileOptions;
let currentDeviceId: number;
let currentDeviceId: deviceIds;

/**
* Create and return a new ProfileCondition
Expand Down
Loading