diff --git a/examples/media-player/media-player.ts b/examples/media-player/media-player.ts index b4116fa..10c8175 100644 --- a/examples/media-player/media-player.ts +++ b/examples/media-player/media-player.ts @@ -109,7 +109,7 @@ const initMediaPlayer = async (resource: File | string) => { ); endTimestamp = await input.getDurationFromMetadata(tracks, { skipLiveWait: true }) ?? await input.computeDuration(tracks, { skipLiveWait: true }); - isRelativeToUnixEpoch = (await Promise.all(tracks.map(t => t.getIsRelativeToUnixEpoch()))).some(Boolean); + isRelativeToUnixEpoch = (await Promise.all(tracks.map(t => t.isRelativeToUnixEpoch()))).some(Boolean); playbackTimeAtStart = firstTimestamp; // Configure the time display elements accordingly diff --git a/src/input-track.ts b/src/input-track.ts index bf14088..9857a1e 100644 --- a/src/input-track.ts +++ b/src/input-track.ts @@ -98,13 +98,7 @@ export abstract class InputTrack { * Returns whether the track metadata says that this track only contains key packets. The actual packets may * differ. */ - abstract getHasOnlyKeyPackets(): Promise; - /** - * Whether the track metadata says that this track only contains key packets. The actual packets may differ. - * @deprecated Use {@link InputTrack.getHasOnlyKeyPackets} instead. - */ - // eslint-disable-next-line @typescript-eslint/no-deprecated - abstract get hasOnlyKeyPackets(): boolean; + abstract hasOnlyKeyPackets(): Promise; /** Returns true if and only if this track is a video track. */ isVideoTrack(): this is InputVideoTrack { @@ -205,23 +199,10 @@ export abstract class InputTrack { * Returns whether the timestamps of this track are relative to the Unix epoch (January 1, 1970 00:00:00 UTC). * When `true`, each timestamp maps to a definitive point in time. */ - async getIsRelativeToUnixEpoch() { + async isRelativeToUnixEpoch() { return this._backing.isRelativeToUnixEpoch(); } - /** - * Whether the timestamps of this track are relative to the Unix epoch (January 1, 1970 00:00:00 UTC). When `true`, - * each timestamp maps to a definitive point in time. - * @deprecated Use {@link InputTrack.getIsRelativeToUnixEpoch} instead. - */ - get isRelativeToUnixEpoch() { - return requireSync( - this._backing.isRelativeToUnixEpoch(), - 'isRelativeToUnixEpoch', - 'getIsRelativeToUnixEpoch', - ); - } - /** Returns the track's disposition, i.e. information about its intended usage. */ async getDisposition() { return this._backing.getDisposition(); @@ -243,15 +224,6 @@ export abstract class InputTrack { return this._backing.getBitrate(); } - /** - * The peak bitrate of the track, in bits per second, as specified in the track's metadata. This might not match the - * actual media data's bitrate. - * @deprecated Use {@link InputTrack.getBitrate} instead. - */ - get bitrate() { - return requireSync(this._backing.getBitrate(), 'bitrate', 'getBitrate'); - } - /** * Returns the average bitrate of the track in bits per second, as specified in the track's metadata. This might * not match the actual media data's bitrate. @@ -260,15 +232,6 @@ export abstract class InputTrack { return this._backing.getAverageBitrate(); } - /** - * The average bitrate of the track, in bits per second, as specified in the track's metadata. This might not match - * the actual media data's bitrate. - * @deprecated Use {@link InputTrack.getAverageBitrate} instead. - */ - get averageBitrate() { - return requireSync(this._backing.getAverageBitrate(), 'averageBitrate', 'getAverageBitrate'); - } - /** * Returns the start timestamp of the first packet of this track, in seconds. While often near zero, this value * may be positive or even negative. A negative starting timestamp means the track's timing has been offset. Samples @@ -556,26 +519,10 @@ export class InputVideoTrack extends InputTrack { return requireSync(this._backing.getCodec(), 'codec', 'getCodec'); } - /** - * Returns whether the track metadata says that this track only contains key packets. The actual packets may - * differ. - */ - async getHasOnlyKeyPackets() { + async hasOnlyKeyPackets() { return (await this._backing.getHasOnlyKeyPackets?.()) ?? false; } - /** - * Whether the track metadata says that this track only contains key packets. The actual packets may differ. - * @deprecated Use {@link InputVideoTrack.getHasOnlyKeyPackets} instead. - */ - get hasOnlyKeyPackets() { - const raw = this._backing.getHasOnlyKeyPackets?.(); - if (raw === undefined) { - return false; - } - return requireSync(raw, 'hasOnlyKeyPackets', 'getHasOnlyKeyPackets') ?? false; - } - /** Returns the width in pixels of the track's coded samples, before any transformations or rotations. */ async getCodedWidth() { return this._backing.getCodedWidth(); @@ -859,26 +806,10 @@ export class InputAudioTrack extends InputTrack { return requireSync(this._backing.getCodec(), 'codec', 'getCodec'); } - /** - * Returns whether the track metadata says that this track only contains key packets. The actual packets may - * differ. - */ - async getHasOnlyKeyPackets() { + async hasOnlyKeyPackets() { return (await this._backing.getHasOnlyKeyPackets?.()) ?? true; } - /** - * Whether the track metadata says that this track only contains key packets. The actual packets may differ. - * @deprecated Use {@link InputAudioTrack.getHasOnlyKeyPackets} instead. - */ - get hasOnlyKeyPackets() { - const raw = this._backing.getHasOnlyKeyPackets?.(); - if (raw === undefined) { - return true; - } - return requireSync(raw, 'hasOnlyKeyPackets', 'getHasOnlyKeyPackets') ?? true; - } - /** Returns the number of audio channels in the track. */ async getNumberOfChannels() { return this._backing.getNumberOfChannels(); diff --git a/src/input.ts b/src/input.ts index d161dca..6cc6444 100644 --- a/src/input.ts +++ b/src/input.ts @@ -543,7 +543,7 @@ export class Input extends EventEmitter sortBy: async t => [ prefer((await t.getDisposition()).default), prefer(await t.hasPairableAudioTrack()), - prefer(!(await t.getHasOnlyKeyPackets())), + prefer(!(await t.hasOnlyKeyPackets())), desc(await t.getBitrate()), ], }); diff --git a/test/node/hls-input.test.ts b/test/node/hls-input.test.ts index d4a2631..c9fbfb7 100644 --- a/test/node/hls-input.test.ts +++ b/test/node/hls-input.test.ts @@ -106,7 +106,7 @@ test.concurrent('Big Buck Bunny', { timeout: 15_000 }, async () => { // Force hydration of all tracks by loading actual media data for (const track of tracks) { - expect(await track.getIsRelativeToUnixEpoch()).toBe(false); + expect(await track.isRelativeToUnixEpoch()).toBe(false); } expect(sourceCount).toBe(1 + 5 + 5); @@ -342,18 +342,18 @@ test.concurrent('Out-of-band audio track via ADTS', { timeout: 15_000 }, async ( const tracks = await input.getTracks(); const videoOnlyKeyPacketsFlags = await Promise.all( - tracks.filter((x): x is InputVideoTrack => x.isVideoTrack()).map(x => x.getHasOnlyKeyPackets()), + tracks.filter((x): x is InputVideoTrack => x.isVideoTrack()).map(x => x.hasOnlyKeyPackets()), ); expect(videoOnlyKeyPacketsFlags.some(x => x)).toBe(true); const audioTrack = tracks.find((x): x is InputAudioTrack => x.isAudioTrack()); assert(audioTrack); - expect(await audioTrack.getHasOnlyKeyPackets()).toBe(true); + expect(await audioTrack.hasOnlyKeyPackets()).toBe(true); expect(await audioTrack.getPairableVideoTracks()).toHaveLength(1); // Since the I-frame one isn't pairable const videoTrack = (await audioTrack.getPairableVideoTracks())[0]!; assert(videoTrack); - expect(await videoTrack.getHasOnlyKeyPackets()).toBe(false); + expect(await videoTrack.hasOnlyKeyPackets()).toBe(false); let lastTimestamp = -Infinity; const sink = new EncodedPacketSink(audioTrack); @@ -482,7 +482,7 @@ test.concurrent('Single-value PDT', { timeout: 15_000 }, async () => { using input = createInputFrom('https://playertest.longtailvideo.com/adaptive/aviion/manifest.m3u8', ALL_FORMATS); const tracks = await input.getTracks(); - expect((await Promise.all(tracks.map(x => x.getIsRelativeToUnixEpoch()))).every(x => x)).toBe(true); + expect((await Promise.all(tracks.map(x => x.isRelativeToUnixEpoch()))).every(x => x)).toBe(true); const track = tracks[0]!; const firstTimestamp = await track.getFirstTimestamp(); @@ -545,7 +545,7 @@ test.concurrent('PDT with bad values', { timeout: 15_000 }, async () => { const audioTrack = await input.getPrimaryAudioTrack(); assert(audioTrack); - expect(await audioTrack.getIsRelativeToUnixEpoch()).toBe(false); + expect(await audioTrack.isRelativeToUnixEpoch()).toBe(false); }); test.concurrent('Alternative audio only', { timeout: 15_000 }, async () => { @@ -578,7 +578,7 @@ test.concurrent('Advanced Apple HLS', { timeout: 30_000 }, async () => { displayWidth: await t.getDisplayWidth(), displayHeight: await t.getDisplayHeight(), bitrate: await t.getBitrate(), - hasOnlyKeyPackets: await t.getHasOnlyKeyPackets(), + hasOnlyKeyPackets: await t.hasOnlyKeyPackets(), codecParameterString: await t.getCodecParameterString(), }); const snapshotAudioTrack = async (t: InputAudioTrack) => ({