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

fix: move CMAF HAS dependencies from lib to samples #109

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a8aacb9
fix: refactor enums to const
littlespex Oct 26, 2024
b260648
chore: update api docs
littlespex Oct 26, 2024
5e9e244
no message
littlespex Oct 26, 2024
db7b120
fix: move CMAF HAS dependencies from lib to samples
littlespex Oct 28, 2024
6a11490
fix: move CMAF HAS dependencies from lib to samples
littlespex Oct 28, 2024
55ffcb0
Merge branch 'task/remove-sax-parser' of https://github.com/streaming…
littlespex Oct 28, 2024
4b81b7b
no message
littlespex Oct 28, 2024
78e3e50
Merge branch 'issue/enum-to-const' into task/remove-sax-parser
littlespex Oct 29, 2024
3b5617b
chore: remove redundant `as const`
littlespex Oct 28, 2024
8cc561c
chore: add ValueOf helper type
littlespex Oct 28, 2024
ee062e4
no message
littlespex Oct 28, 2024
e5d5769
chore: add Thanks section to README (#106)
littlespex Oct 28, 2024
409268b
chore: include full license text in notice file (#105)
littlespex Oct 28, 2024
3bdbac0
chore: update eslint deps and rules (#107)
littlespex Oct 28, 2024
d311dbe
fix: move CMAF HAS dependencies from lib to samples
littlespex Oct 28, 2024
3711234
fix: refactor enums to const
littlespex Oct 26, 2024
75cd447
chore: update api docs
littlespex Oct 26, 2024
7a67d55
Merge branch 'task/remove-sax-parser' of https://github.com/streaming…
littlespex Oct 29, 2024
2df9944
fix: replace ts-node (#102)
littlespex Aug 30, 2024
563d9f2
chore: prep for isolatedDeclarations
littlespex Sep 6, 2024
6fd3b40
chore: update eslint
littlespex Oct 26, 2024
ee34615
- rename IMapper
littlespex Oct 26, 2024
71507d3
fix: refactor enums to const
littlespex Oct 26, 2024
dea4177
chore: update api docs
littlespex Oct 26, 2024
5030e62
no message
littlespex Oct 26, 2024
366156e
chore: add comment to tsconfig isolatedDeclarations property
littlespex Oct 28, 2024
4b2db93
chore: remove redundant `as const`
littlespex Oct 28, 2024
1d78388
chore: add ValueOf helper type
littlespex Oct 28, 2024
58e58ca
no message
littlespex Oct 28, 2024
7985fa7
chore: add Thanks section to README (#106)
littlespex Oct 28, 2024
7d001c8
chore: include full license text in notice file (#105)
littlespex Oct 28, 2024
cc80a3a
chore: update eslint deps and rules (#107)
littlespex Oct 28, 2024
498d28b
fix: move CMAF HAS dependencies from lib to samples
littlespex Oct 28, 2024
294f412
fix: refactor enums to const
littlespex Oct 26, 2024
b1dbeda
chore: update api docs
littlespex Oct 26, 2024
38dd162
chore: remove redundant `as const`
littlespex Oct 28, 2024
ec0bfbe
chore: add ValueOf helper type
littlespex Oct 28, 2024
2c50b2a
no message
littlespex Oct 28, 2024
43446dc
no message
littlespex Oct 28, 2024
aedf802
Merge branch 'task/remove-sax-parser' of https://github.com/streaming…
littlespex Oct 29, 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
48 changes: 48 additions & 0 deletions lib/config/common-media-library.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,21 @@ export type CueHandler = {
dispatchCue?(): void;
};

// @alpha
export type DashManifest = {
MPD: {
$?: {
maxSegmentDuration?: string;
mediaPresentationDuration?: string;
minBufferTime?: string;
profiles?: string;
type?: string;
xmlns?: string;
};
Period: Period[];
};
};

// @alpha
export function dashToHam(manifest: string): Presentation[];

Expand Down Expand Up @@ -483,6 +498,14 @@ export function hamToDash(presentation: Presentation[]): Manifest;
// @alpha
export function hamToHls(presentation: Presentation[]): Manifest;

// @alpha
export type HlsManifest = {
playlists: PlayList[];
mediaGroups: MediaGroups;
segments: SegmentHls[];
targetDuration?: number;
};

// @alpha
export function hlsToHam(manifest: string, ancillaryManifests: string[]): Presentation[];

Expand Down Expand Up @@ -639,6 +662,24 @@ export type SelectionSet = Ham & {
alignedSwitchingSets?: AlignedSwitchingSet[];
};

// Warning: (ae-forgotten-export) The symbol "DashParser" needs to be exported by the entry point index.d.ts
// Warning: (ae-internal-missing-underscore) The name "setDashParser" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export function setDashParser(parser: DashParser): void;

// Warning: (ae-forgotten-export) The symbol "DashSerializer" needs to be exported by the entry point index.d.ts
// Warning: (ae-internal-missing-underscore) The name "setDashSerializer" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export function setDashSerializer(serializer: DashSerializer): void;

// Warning: (ae-forgotten-export) The symbol "HlsParser" needs to be exported by the entry point index.d.ts
// Warning: (ae-internal-missing-underscore) The name "setHlsParser" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export function setHlsParser(parser: HlsParser): void;

// @beta
export type SfBareItem = string | Uint8Array | boolean | number | symbol | Date | SfToken;

Expand Down Expand Up @@ -805,4 +846,11 @@ export type VideoTrack = Track & {
scanType: string;
};

// Warnings were encountered during analysis:
//
// src/cmaf/ham/types/mapper/dash/DashManifest.ts:19:3 - (ae-forgotten-export) The symbol "Period" needs to be exported by the entry point index.d.ts
// src/cmaf/ham/types/mapper/hls/HlsManifest.ts:12:2 - (ae-forgotten-export) The symbol "PlayList" needs to be exported by the entry point index.d.ts
// src/cmaf/ham/types/mapper/hls/HlsManifest.ts:13:2 - (ae-forgotten-export) The symbol "MediaGroups" needs to be exported by the entry point index.d.ts
// src/cmaf/ham/types/mapper/hls/HlsManifest.ts:14:2 - (ae-forgotten-export) The symbol "SegmentHls" needs to be exported by the entry point index.d.ts

```
5 changes: 0 additions & 5 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,5 @@
"build:cjs": "tsc --module commonjs --outDir dist/cjs",
"test": "tsx --test ./test/**/*.test.ts",
"prepublishOnly": "npm run build"
},
"dependencies": {
"@types/xml2js": "0.4.14",
"m3u8-parser": "7.1.0",
"xml2js": "0.6.2"
}
}
8 changes: 7 additions & 1 deletion lib/src/cmaf-ham.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ export type { Track } from './cmaf/ham/types/model/Track.js';
export type { TrackType } from './cmaf/ham/types/model/TrackType.js';
export type { VideoTrack } from './cmaf/ham/types/model/VideoTrack.js';

export type { Validation } from './cmaf/ham/types/Validation.js';
export type { Manifest } from './cmaf/ham/types/manifest/Manifest.js';
export type { ManifestFormat } from './cmaf/ham/types/manifest/ManifestFormat.js';
export type { DashManifest } from './cmaf/ham/types/mapper/dash/DashManifest.js';
export type { HlsManifest } from './cmaf/ham/types/mapper/hls/HlsManifest.js';
export type { Validation } from './cmaf/ham/types/Validation.js';

export { setDashParser } from './cmaf/ham/utils/dash/parseDashManifest.js';
export { setDashSerializer } from './cmaf/ham/utils/dash/serializeDashManifest.js';
export { setHlsParser } from './cmaf/ham/utils/hls/parseHlsManifest.js';

export { dashToHam } from './cmaf/ham/services/converters/dashToHam.js';
export { hamToDash } from './cmaf/ham/services/converters/hamToDash.js';
Expand Down
4 changes: 2 additions & 2 deletions lib/src/cmaf/ham/mapper/dash/DashMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Presentation } from '../../types/model/Presentation.js';
import { mapDashToHam } from './mapDashToHam/mapDashToHam.js';
import { mapHamToDash } from './mapHamToDash/mapHamToDash.js';

import { xmlToJson } from '../../utils/dash/xmlToJson.js';
import { parseDashManifest } from '../../utils/dash/parseDashManifest.js';
import { addMetadataToDash } from '../../utils/manifest/addMetadataToDash.js';
import { getMetadata } from '../../utils/manifest/getMetadata.js';

Expand All @@ -19,7 +19,7 @@ export class DashMapper implements Mapper {
}

toHam(manifest: Manifest): Presentation[] {
const dashManifest: DashManifest | undefined = xmlToJson(
const dashManifest: DashManifest | undefined = parseDashManifest(
manifest.manifest,
);

Expand Down
4 changes: 2 additions & 2 deletions lib/src/cmaf/ham/mapper/dash/mapHamToDash/mapHamToDash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Period } from '../../../types/mapper/dash/Period.js';

import { presentationsToPeriods } from './presentationsToPeriods.js';

import { jsonToXml } from '../../../utils/dash/jsonToXml.js';
import { serializeDashManifest } from '../../../utils/dash/serializeDashManifest.js';

export function mapHamToDash(hamManifests: Presentation[]): string {
const periods: Period[] = presentationsToPeriods(hamManifests);
Expand All @@ -20,5 +20,5 @@ export function mapHamToDash(hamManifests: Presentation[]): string {
},
};

return jsonToXml(manifest);
return serializeDashManifest(manifest);
}
6 changes: 0 additions & 6 deletions lib/src/cmaf/ham/utils/dash/jsonToXml.ts

This file was deleted.

30 changes: 30 additions & 0 deletions lib/src/cmaf/ham/utils/dash/parseDashManifest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { DashManifest } from '../../types/mapper/dash/DashManifest.js';

export type DashParser = (raw: string) => DashManifest;

let dashParser: DashParser;

/**
* @internal
*/
export function setDashParser(parser: DashParser): void {
dashParser = parser;
}

/**
* @internal
*/
export function getDashParser(): DashParser {
return dashParser;
}

/**
* @internal
* Parse XML to Json
*
* @param raw - Raw string containing the xml from the Dash Manifest
* @returns json with the Dash Manifest structure
*/
export function parseDashManifest(raw: string): DashManifest {
return dashParser(raw);
}
23 changes: 23 additions & 0 deletions lib/src/cmaf/ham/utils/dash/serializeDashManifest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { DashManifest } from '../../types/mapper/dash/DashManifest';

export type DashSerializer = (json: DashManifest) => string;

let xmlSerializer: DashSerializer;

/**
* @internal
*/
export function setDashSerializer(serializer: DashSerializer): void {
xmlSerializer = serializer;
}

/**
* @internal
*/
export function getDashSerializer(): DashSerializer {
return xmlSerializer;
}

export function serializeDashManifest(json: DashManifest): string {
return xmlSerializer(json);
}
20 changes: 0 additions & 20 deletions lib/src/cmaf/ham/utils/dash/xmlToJson.ts

This file was deleted.

32 changes: 20 additions & 12 deletions lib/src/cmaf/ham/utils/hls/parseHlsManifest.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
// @ts-ignore
import { Parser } from 'm3u8-parser';
import type { HlsManifest } from '../../types/mapper/hls/HlsManifest.js';

export function parseHlsManifest(text: string | undefined): HlsManifest {
export type HlsParser = (text: string) => HlsManifest;

let hlsParser: HlsParser;

/**
* @internal
*/
export function setHlsParser(parser: HlsParser): void {
hlsParser = parser;
}

/**
* @internal
*/
export function getHlsParser(): HlsParser {
return hlsParser;
}

export function parseHlsManifest(text?: string): HlsManifest {
if (!text) {
console.error("Can't parse empty HLS Manifest");
return {} as HlsManifest;
}

const parser = new Parser();

parser.push(text);
parser.end();
const parsedHlsManifest = parser.manifest;
if (!parsedHlsManifest) {
throw new Error();
}

return parsedHlsManifest;
return hlsParser(text);
}
Loading
Loading