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

Refactor/switch id3 functions with cml id3 functions #1

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
6432b5b
replace id3 functions with cml
Jan 31, 2024
9e89a20
upodated imports to use CML functions
fernandocQualabs Feb 1, 2024
1424fc7
removed unused functions
fernandocQualabs Feb 1, 2024
02e148c
removed unused unit tests
fernandocQualabs Feb 1, 2024
fc0484b
optimize imports to make the build lighter
Feb 5, 2024
57203a7
Reintroduced id3 tests but using common media library
coatesjuan Feb 27, 2024
629bd99
Revert "Reintroduced id3 tests but using common media library"
coatesjuan Feb 28, 2024
eeac5bf
Update common-media-library version
Feb 29, 2024
c201ea7
Add exact CML version
Feb 29, 2024
7e71685
Moved utf8 utils and tests
hernanr99 Mar 1, 2024
7d01e18
Update CML's version
Mar 4, 2024
d6c0b37
Merge branch 'master' into refactor/switch-id3-functions-with-cml-id3…
felipeYoungi Mar 4, 2024
6983e55
removed utf8ArrayToStr and imported it from CML
fernandocQualabs Mar 5, 2024
f04756a
removed unwanted changes from package-lock.json
fernandocQualabs Mar 5, 2024
1dd0625
Update package.json and others fixes
hernanr99 Mar 14, 2024
5c0ea54
Add line break to package-lock.json
hernanr99 Mar 14, 2024
5c42c69
chore(deps): update dependency wrangler to v3.32.0
renovate[bot] Mar 14, 2024
994f825
Merge pull request #6287 from video-dev/renovate/wrangler-3.x
hlsjs-ci Mar 14, 2024
97441e6
chore(deps): update dependency wrangler to v3.34.2
renovate[bot] Mar 14, 2024
fdd5398
Merge pull request #6288 from video-dev/renovate/wrangler-3.x
hlsjs-ci Mar 14, 2024
2babd0e
chore(deps): update dependency chromedriver to v122.0.5
renovate[bot] Mar 18, 2024
22a9ab0
Merge pull request #6292 from video-dev/renovate/chromedriver-122.x
hlsjs-ci Mar 18, 2024
2d2433d
chore(deps): update dependency chromedriver to v122.0.6
renovate[bot] Mar 18, 2024
b618814
Merge pull request #6293 from video-dev/renovate/chromedriver-122.x
hlsjs-ci Mar 18, 2024
977c603
API.md update removeLevel
Mar 6, 2024
dd47b84
chore(deps): update dependency @microsoft/api-documenter to v7.23.38
renovate[bot] Mar 22, 2024
386ac7b
Merge pull request #6298 from video-dev/renovate/microsoft-api-docume…
hlsjs-ci Mar 22, 2024
c9a8f5e
chore(deps): update dependency @microsoft/api-documenter to v7.24.1
renovate[bot] Mar 22, 2024
e884841
Merge pull request #6299 from video-dev/renovate/microsoft-api-docume…
hlsjs-ci Mar 22, 2024
8d89a11
chore(deps): update typescript-eslint monorepo to v7.3.0
renovate[bot] Mar 25, 2024
cde82fb
Merge pull request #6303 from video-dev/renovate/typescript-eslint-mo…
hlsjs-ci Mar 25, 2024
2ba90f6
chore(deps): update typescript-eslint monorepo to v7.3.1
renovate[bot] Mar 26, 2024
2564563
Merge pull request #6304 from video-dev/renovate/typescript-eslint-mo…
hlsjs-ci Mar 26, 2024
04071d6
chore(deps): update babel monorepo to v7.24.1
renovate[bot] Mar 26, 2024
5375dc7
Merge pull request #6308 from video-dev/renovate/babel-monorepo
hlsjs-ci Mar 26, 2024
d8a86b0
chore(deps): update babel monorepo to v7.24.3
renovate[bot] Mar 26, 2024
ae1364a
Merge pull request #6310 from video-dev/renovate/babel-monorepo
hlsjs-ci Mar 26, 2024
ff6d64a
chore(deps): update dependency @types/chai to v4.3.13
renovate[bot] Mar 26, 2024
94af8e2
Merge pull request #6309 from video-dev/renovate/chai-4.x
hlsjs-ci Mar 26, 2024
bd151a7
chore(deps): update dependency @types/chai to v4.3.14
renovate[bot] Mar 26, 2024
176c4e6
Merge pull request #6311 from video-dev/renovate/chai-4.x
hlsjs-ci Mar 26, 2024
113b0fb
chore(deps): update dependency @microsoft/api-extractor to v7.43.0
renovate[bot] Mar 26, 2024
62703ee
Merge pull request #6312 from video-dev/renovate/microsoft-api-extrac…
hlsjs-ci Mar 26, 2024
6a16062
chore(deps): update dependency wrangler to v3.35.0
renovate[bot] Mar 26, 2024
f3a1afc
Merge pull request #6313 from video-dev/renovate/wrangler-3.x
hlsjs-ci Mar 26, 2024
8b49200
chore(deps): update dependency wrangler to v3.38.0
renovate[bot] Mar 26, 2024
0216391
Merge pull request #6314 from video-dev/renovate/wrangler-3.x
hlsjs-ci Mar 26, 2024
0a632d3
chore(deps): update dependency typescript to v5.4.3
renovate[bot] Mar 27, 2024
4cd7347
Merge pull request #6318 from video-dev/renovate/typescript-5.x
hlsjs-ci Mar 27, 2024
80c8b01
Merge branch 'master' into refactor/switch-id3-functions-with-cml-id3…
fernandocQualabs Mar 28, 2024
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
21 changes: 20 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@rollup/plugin-replace": "5.0.5",
"@rollup/plugin-terser": "0.4.4",
"@rollup/plugin-typescript": "11.1.6",
"@svta/common-media-library": "0.6.2",
"@svta/common-media-library": "^0.6.2",
felipeYoungi marked this conversation as resolved.
Show resolved Hide resolved
"@types/chai": "4.3.11",
"@types/chart.js": "2.9.41",
"@types/mocha": "10.0.6",
Expand Down Expand Up @@ -129,5 +129,8 @@
"typescript": "5.3.3",
"url-toolkit": "2.2.5",
"wrangler": "3.24.0"
},
"dependencies": {
"ci": "^2.3.0"
}
}
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 @@ -211,7 +212,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 @@ -228,7 +229,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
4 changes: 2 additions & 2 deletions src/demux/audio/aacdemuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ 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 type { HlsEventEmitter } from '../../events';
import type { HlsConfig } from '../../config';
import { getId3Data } from '@svta/common-media-library/id3/getId3Data';

class AACDemuxer extends BaseAudioDemuxer {
private readonly observer: HlsEventEmitter;
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
14 changes: 8 additions & 6 deletions src/demux/audio/base-audio-demuxer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as ID3 from '../id3';
import {
DemuxerResult,
Demuxer,
Expand All @@ -14,6 +13,9 @@ 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
Loading