Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/can-skip
Browse files Browse the repository at this point in the history
  • Loading branch information
mcintyrehh authored Apr 5, 2024
2 parents 7042db6 + 86d5267 commit f18bda1
Show file tree
Hide file tree
Showing 29 changed files with 98 additions and 524 deletions.
9 changes: 7 additions & 2 deletions src/controller/base-playlist-controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import type Hls from '../hls';
import type { NetworkComponentAPI } from '../types/component-api';
import { HlsSkip, HlsUrlParameters, Level, getSkipValue } from '../types/level';
import {
getSkipValue,
HlsSkip,
HlsUrlParameters,
type Level,
} from '../types/level';
import { computeReloadInterval, mergeDetails } from '../utils/level-helper';
import { ErrorData } from '../types/events';
import type { ErrorData } from '../types/events';
import { getRetryDelay, isTimeoutError } from '../utils/error-helper';
import { NetworkErrorAction } from './error-controller';
import { Logger } from '../utils/logger';
Expand Down
2 changes: 1 addition & 1 deletion src/controller/cmcd-controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Events } from '../events';
import Hls from '../hls';
import type Hls from '../hls';
import { Cmcd } from '@svta/common-media-library/cmcd/Cmcd';
import { CmcdObjectType } from '@svta/common-media-library/cmcd/CmcdObjectType';
import { CmcdStreamingFormat } from '@svta/common-media-library/cmcd/CmcdStreamingFormat';
Expand Down
2 changes: 1 addition & 1 deletion src/controller/eme-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
KeySystems,
requestMediaKeySystemAccess,
} from '../utils/mediakeys-helper';
import { strToUtf8array } from '../utils/keysystem-util';
import { strToUtf8array } from '../utils/utf8-utils';
import { base64Decode } from '../utils/numeric-encoding-utils';
import { DecryptData, LevelKey } from '../loader/level-key';
import Hex from '../utils/hex';
Expand Down
7 changes: 4 additions & 3 deletions src/controller/id3-track-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
clearCurrentCues,
removeCuesInRange,
} from '../utils/texttrack-utils';
import * as ID3 from '../demux/id3';
import {
DateRange,
isDateRangeCueAttribute,
Expand All @@ -19,6 +18,8 @@ import type {
} from '../types/events';
import type { ComponentAPI } from '../types/component-api';
import type Hls from '../hls';
import { getId3Frames } from '@svta/common-media-library/id3/getId3Frames';
import { isId3TimestampFrame } from '@svta/common-media-library/id3/isId3TimestampFrame';

declare global {
interface Window {
Expand Down Expand Up @@ -210,7 +211,7 @@ class ID3TrackController implements ComponentAPI {
continue;
}

const frames = ID3.getID3Frames(samples[i].data);
const frames = getId3Frames(samples[i].data);
if (frames) {
const startTime = samples[i].pts;
let endTime: number = startTime + samples[i].duration;
Expand All @@ -227,7 +228,7 @@ class ID3TrackController implements ComponentAPI {
for (let j = 0; j < frames.length; j++) {
const frame = frames[j];
// Safari doesn't put the timestamp frame in the TextTrack
if (!ID3.isTimeStampFrame(frame)) {
if (!isId3TimestampFrame(frame)) {
// add a bounds to any unbounded cues
this.updateId3CueEnds(startTime, type);
const cue = createCueWithDataFields(
Expand Down
2 changes: 1 addition & 1 deletion src/controller/level-controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
ManifestLoadedData,
ManifestParsedData,
LevelLoadedData,
Expand Down
4 changes: 2 additions & 2 deletions src/demux/audio/aacdemuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import BaseAudioDemuxer from './base-audio-demuxer';
import * as ADTS from './adts';
import * as MpegAudio from './mpegaudio';
import { logger } from '../../utils/logger';
import * as ID3 from '../id3';
import { getId3Data } from '@svta/common-media-library/id3/getId3Data';
import type { HlsEventEmitter } from '../../events';
import type { HlsConfig } from '../../config';

Expand Down Expand Up @@ -51,7 +51,7 @@ class AACDemuxer extends BaseAudioDemuxer {
// Look for ADTS header | 1111 1111 | 1111 X00X | where X can be either 0 or 1
// Layer bits (position 14 and 15) in header should be always 0 for ADTS
// More info https://wiki.multimedia.cx/index.php?title=ADTS
const id3Data = ID3.getID3Data(data, 0);
const id3Data = getId3Data(data, 0);
let offset = id3Data?.length || 0;

if (MpegAudio.probe(data, offset)) {
Expand Down
7 changes: 4 additions & 3 deletions src/demux/audio/ac3-demuxer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BaseAudioDemuxer from './base-audio-demuxer';
import { getID3Data, getTimeStamp } from '../id3';
import { getId3Data } from '@svta/common-media-library/id3/getId3Data';
import { getId3Timestamp } from '@svta/common-media-library/id3/getId3Timestamp';
import { getAudioBSID } from './dolby';
import type { HlsEventEmitter } from '../../events';
import type { AudioFrame, DemuxedAudioTrack } from '../../types/demuxer';
Expand Down Expand Up @@ -61,7 +62,7 @@ export class AC3Demuxer extends BaseAudioDemuxer {
return false;
}

const id3Data = getID3Data(data, 0);
const id3Data = getId3Data(data, 0);
if (!id3Data) {
return false;
}
Expand All @@ -71,7 +72,7 @@ export class AC3Demuxer extends BaseAudioDemuxer {
if (
data[offset] === 0x0b &&
data[offset + 1] === 0x77 &&
getTimeStamp(id3Data) !== undefined &&
getId3Timestamp(id3Data) !== undefined &&
// check the bsid to confirm ac-3
getAudioBSID(data, offset) < 16
) {
Expand Down
30 changes: 16 additions & 14 deletions src/demux/audio/base-audio-demuxer.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import * as ID3 from '../id3';
import {
DemuxerResult,
Demuxer,
DemuxedAudioTrack,
AudioFrame,
DemuxedMetadataTrack,
DemuxedVideoTrackBase,
DemuxedUserdataTrack,
KeyData,
type DemuxerResult,
type Demuxer,
type DemuxedAudioTrack,
type AudioFrame,
type DemuxedMetadataTrack,
type DemuxedVideoTrackBase,
type DemuxedUserdataTrack,
type KeyData,
MetadataSchema,
} from '../../types/demuxer';
import { dummyTrack } from '../dummy-demuxed-track';
import { appendUint8Array } from '../../utils/mp4-tools';
import { sliceUint8 } from '../../utils/typed-array';
import { RationalTimestamp } from '../../utils/timescale-conversion';
import { getId3Data } from '@svta/common-media-library/id3/getId3Data';
import { getId3Timestamp } from '@svta/common-media-library/id3/getId3Timestamp';
import { canParseId3 } from '@svta/common-media-library/id3/canParseId3';

class BaseAudioDemuxer implements Demuxer {
protected _audioTrack!: DemuxedAudioTrack;
Expand Down Expand Up @@ -69,12 +71,12 @@ class BaseAudioDemuxer implements Demuxer {
this.cachedData = null;
}

let id3Data: Uint8Array | undefined = ID3.getID3Data(data, 0);
let id3Data: Uint8Array | undefined = getId3Data(data, 0);
let offset = id3Data ? id3Data.length : 0;
let lastDataIndex;
const track = this._audioTrack;
const id3Track = this._id3Track;
const timestamp = id3Data ? ID3.getTimeStamp(id3Data) : undefined;
const timestamp = id3Data ? getId3Timestamp(id3Data) : undefined;
const length = data.length;

if (
Expand Down Expand Up @@ -111,9 +113,9 @@ class BaseAudioDemuxer implements Demuxer {
} else {
offset = length;
}
} else if (ID3.canParse(data, offset)) {
// after a ID3.canParse, a call to ID3.getID3Data *should* always returns some data
id3Data = ID3.getID3Data(data, offset)!;
} else if (canParseId3(data, offset)) {
// after a canParse, a call to getId3Data *should* always returns some data
id3Data = getId3Data(data, offset)!;
id3Track.samples.push({
pts: this.lastPTS,
dts: this.lastPTS,
Expand Down
7 changes: 4 additions & 3 deletions src/demux/audio/mp3demuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
* MP3 demuxer
*/
import BaseAudioDemuxer from './base-audio-demuxer';
import { getID3Data, getTimeStamp } from '../id3';
import { getAudioBSID } from './dolby';
import { logger } from '../../utils/logger';
import * as MpegAudio from './mpegaudio';
import { getId3Data } from '@svta/common-media-library/id3/getId3Data';
import { getId3Timestamp } from '@svta/common-media-library/id3/getId3Timestamp';

class MP3Demuxer extends BaseAudioDemuxer {
resetInitSegment(
Expand Down Expand Up @@ -39,15 +40,15 @@ class MP3Demuxer extends BaseAudioDemuxer {
// Look for MPEG header | 1111 1111 | 111X XYZX | where X can be either 0 or 1 and Y or Z should be 1
// Layer bits (position 14 and 15) in header should be always different from 0 (Layer I or Layer II or Layer III)
// More info http://www.mp3-tech.org/programmer/frame_header.html
const id3Data = getID3Data(data, 0);
const id3Data = getId3Data(data, 0);
let offset = id3Data?.length || 0;

// Check for ac-3|ec-3 sync bytes and return false if present
if (
id3Data &&
data[offset] === 0x0b &&
data[offset + 1] === 0x77 &&
getTimeStamp(id3Data) !== undefined &&
getId3Timestamp(id3Data) !== undefined &&
// check the bsid to confirm ac-3 or ec-3 (not mp3)
getAudioBSID(data, offset) <= 16
) {
Expand Down
2 changes: 1 addition & 1 deletion src/demux/audio/mpegaudio.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* MPEG parser helper
*/
import { DemuxedAudioTrack } from '../../types/demuxer';
import type { DemuxedAudioTrack } from '../../types/demuxer';

let chromeVersion: number | null = null;

Expand Down
Loading

0 comments on commit f18bda1

Please sign in to comment.