Remove dead code and some unused exports (#7882)

This commit is contained in:
Rob Walch
2026-05-29 12:46:03 -07:00
committed by GitHub
parent 4be073eb58
commit d0d7b1f08b
10 changed files with 16 additions and 125 deletions
+3 -6
View File
@@ -35,8 +35,8 @@ import {
requestMediaKeySystemAccess,
} from '../utils/mediakeys-helper';
import { KeySystemFormats } from '../utils/mediakeys-helper';
import { bin2str, parseMultiPssh, parseSinf } from '../utils/mp4-tools';
import { base64Decode } from '../utils/numeric-encoding-utils';
import { parseMultiPssh, parseSinf } from '../utils/mp4-tools';
import { base64Decode, bin2str } from '../utils/numeric-encoding-utils';
import { stringify } from '../utils/safe-json-stringify';
import { strToUtf8array } from '../utils/utf8-utils';
import type { EMEControllerConfig, HlsConfig, LoadPolicy } from '../config';
@@ -1440,10 +1440,7 @@ class EMEController extends Logger implements ComponentAPI {
// actual license request) and any HttpHeader elements (sent as request
// headers).
// For PlayReady CDMs, we need to dig the Challenge out of the XML.
const xmlString = String.fromCharCode.apply(
null,
new Uint16Array(licenseChallenge.buffer),
);
const xmlString = bin2str(new Uint16Array(licenseChallenge.buffer));
// eslint-disable-next-line no-restricted-syntax
if (!xmlString.includes('PlayReadyKeyMessage')) {
// This does not appear to be a wrapped message as on Edge. Some
-15
View File
@@ -205,21 +205,6 @@ export function pdtWithinToleranceTest(
return endProgramDateTime - candidateLookupTolerance > pdtBufferEnd;
}
export function findFragWithCC(
fragments: MediaFragment[],
cc: number,
): MediaFragment | null {
return BinarySearch.search(fragments, (candidate) => {
if (candidate.cc < cc) {
return 1;
} else if (candidate.cc > cc) {
return -1;
} else {
return 0;
}
});
}
export function findNearestWithCC(
details: LevelDetails | undefined,
cc: number,
-10
View File
@@ -138,16 +138,6 @@ class ExpGolomb {
readUByte(): number {
return this.readBits(8);
}
// ():int
readUShort(): number {
return this.readBits(16);
}
// ():int
readUInt(): number {
return this.readBits(32);
}
}
export default ExpGolomb;
+2 -4
View File
@@ -1,6 +1,7 @@
import BaseVideoParser from './base-video-parser';
import ExpGolomb from './exp-golomb';
import { parseSEIMessageFromNALu } from '../../utils/mp4-tools';
import { bin2str } from '../../utils/numeric-encoding-utils';
import type {
DemuxedUserdataTrack,
DemuxedVideoTrack,
@@ -764,10 +765,7 @@ class HevcVideoParser extends BaseVideoParser {
matchSPS(sps1: Uint8Array, sps2: Uint8Array): boolean {
// compare without headers and VPS related params
return (
String.fromCharCode.apply(null, sps1).substr(3) ===
String.fromCharCode.apply(null, sps2).substr(3)
);
return bin2str(sps1).substring(3) === bin2str(sps2).substring(3);
}
}
-41
View File
@@ -1,41 +0,0 @@
import { appendUint8Array } from './mp4-tools';
export default class Chunker {
private chunkSize: number;
public cache: Uint8Array | null = null;
constructor(chunkSize = Math.pow(2, 19)) {
this.chunkSize = chunkSize;
}
public push(data: Uint8Array): Array<Uint8Array> {
const { cache, chunkSize } = this;
const result: Array<Uint8Array> = [];
let temp: Uint8Array | null = null;
if (cache?.length) {
temp = appendUint8Array(cache, data);
this.cache = null;
} else {
temp = data;
}
if (temp.length < chunkSize) {
this.cache = temp;
return result;
}
if (temp.length > chunkSize) {
let offset = 0;
const len = temp.length;
while (offset < len - chunkSize) {
result.push(temp.slice(offset, offset + chunkSize));
offset += chunkSize;
}
this.cache = temp.slice(offset);
} else {
result.push(temp);
}
return result;
}
}
-6
View File
@@ -24,9 +24,3 @@ export function hexToArrayBuffer(str: string): ArrayBuffer {
.split(' '),
).buffer;
}
const Hex = {
hexDump: arrayToHex,
};
export default Hex;
-10
View File
@@ -19,16 +19,6 @@ type FragmentIntersection = (
) => void;
type PartIntersection = (oldPart: Part, newPart: Part) => void;
export function updatePTS(
fragments: MediaFragment[],
fromIdx: number,
toIdx: number,
): void {
const fragFrom = fragments[fromIdx];
const fragTo = fragments[toIdx];
updateFromToPTS(fragFrom, fragTo);
}
function updateFromToPTS(fragFrom: MediaFragment, fragTo: MediaFragment) {
const fragToPTS = fragTo.startPTS as number;
// if we know startPTS[toIdx]
+2 -2
View File
@@ -1,6 +1,6 @@
import { optionalSelf } from './global';
import { changeEndianness } from './keysystem-util';
import { base64Decode } from './numeric-encoding-utils';
import { base64Decode, bin2str } from './numeric-encoding-utils';
import type { DRMSystemOptions, EMEControllerConfig } from '../config';
/**
@@ -184,7 +184,7 @@ export function parsePlayReadyWRM(keyBytes: Uint8Array<ArrayBuffer>) {
keyBytes.byteOffset,
keyBytes.byteLength / 2,
);
const keyByteStr = String.fromCharCode.apply(null, Array.from(keyBytesUtf16));
const keyByteStr = bin2str(keyBytesUtf16);
// Parse Playready WRMHeader XML
const xmlKeyBytes = keyByteStr.substring(
+5 -8
View File
@@ -1,5 +1,6 @@
import { utf8ArrayToStr } from '@svta/cml-id3';
import { arrayToHex } from './hex';
import { bin2str } from './numeric-encoding-utils';
import { ElementaryStreamTypes } from '../loader/fragment';
import { logger } from '../utils/logger';
import type { ChunkMetadata } from '../hls';
@@ -72,28 +73,24 @@ export const RemuxerTrackIdConfig = {
text: 4,
};
export function bin2str(data: Uint8Array): string {
return String.fromCharCode.apply(null, data);
}
export function readUint16(buffer: Uint8Array, offset: number): number {
function readUint16(buffer: Uint8Array, offset: number): number {
const val = (buffer[offset] << 8) | buffer[offset + 1];
return val < 0 ? 65536 + val : val;
}
export function readUint32(buffer: Uint8Array, offset: number): number {
function readUint32(buffer: Uint8Array, offset: number): number {
const val = readSint32(buffer, offset);
return val < 0 ? 4294967296 + val : val;
}
export function readUint64(buffer: Uint8Array, offset: number) {
function readUint64(buffer: Uint8Array, offset: number) {
let result = readUint32(buffer, offset);
result *= Math.pow(2, 32);
result += readUint32(buffer, offset + 4);
return result;
}
export function readSint32(buffer: Uint8Array, offset: number): number {
function readSint32(buffer: Uint8Array, offset: number): number {
return (
(buffer[offset] << 24) |
(buffer[offset + 1] << 16) |
+4 -23
View File
@@ -1,26 +1,7 @@
export function base64ToBase64Url(base64encodedStr: string): string {
return base64encodedStr
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=+$/, '');
}
export function strToBase64Encode(str: string): string {
return btoa(str);
}
export function base64DecodeToStr(str: string): string {
return atob(str);
}
export function base64Encode(input: Uint8Array): string {
return btoa(String.fromCharCode(...input));
}
export function base64UrlEncode(input: Uint8Array): string {
return base64ToBase64Url(base64Encode(input));
}
export function base64Decode(base64encodedStr: string) {
return Uint8Array.from(atob(base64encodedStr), (c) => c.charCodeAt(0));
}
export function bin2str(data: number[] | Uint8Array | Uint16Array): string {
return String.fromCharCode.apply(null, data);
}