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 HAM dependencies from lib to samples #120

Merged
merged 15 commits into from
Oct 29, 2024
Merged
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- Replace Typescript enums with constants [#103](https://github.com/streaming-video-technology-alliance/common-media-library/issues/103)
- Remove CMAF HAM dependencies [#119](https://github.com/streaming-video-technology-alliance/common-media-library/issues/119)


## [0.7.3] - 2024-08-30

Expand Down
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import tsdoc from 'eslint-plugin-tsdoc';
import typescriptEnum from 'eslint-plugin-typescript-enum';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
Expand All @@ -20,10 +21,12 @@ export default [{
}, ...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:typescript-enum/recommended',
), {
plugins: {
'@typescript-eslint': typescriptEslint,
tsdoc,
'typescript-enum': typescriptEnum,
},

files: ['**/*.js', '**/*.ts'],
Expand Down
214 changes: 138 additions & 76 deletions lib/config/common-media-library.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,30 @@ export type Cmcd = {
rtp?: number;
};

// @beta
export const CMCD_HEADERS = "headers";

// @beta
export const CMCD_JSON = "json";

// @beta
export const CMCD_OBJECT = "CMCD-Object";

// @beta
export const CMCD_PARAM = "CMCD";

// @beta
export const CMCD_QUERY = "query";

// @beta
export const CMCD_REQUEST = "CMCD-Request";

// @beta
export const CMCD_SESSION = "CMCD-Session";

// @beta
export const CMCD_STATUS = "CMCD-Status";

// @beta
export const CMCD_V1 = 1;

Expand All @@ -118,11 +139,16 @@ export type CmcdEncodeOptions = {
};

// @beta
export enum CmcdEncoding {
HEADERS = "headers",
JSON = "json",
QUERY = "query"
}
export const CmcdEncoding: {
readonly JSON: typeof CMCD_JSON;
readonly QUERY: typeof CMCD_QUERY;
readonly HEADERS: typeof CMCD_HEADERS;
};

// Warning: (ae-forgotten-export) The symbol "ValueOf" needs to be exported by the entry point index.d.ts
//
// @beta (undocumented)
export type CmcdEncoding = ValueOf<typeof CmcdEncoding>;

// @beta
export type CmcdFormatter = (value: CmcdValue, options?: CmcdEncodeOptions) => string | number;
Expand All @@ -131,45 +157,45 @@ export type CmcdFormatter = (value: CmcdValue, options?: CmcdEncodeOptions) => s
export const CmcdFormatters: Record<string, CmcdFormatter>;

// @beta
export enum CmcdHeaderField {
OBJECT = "CMCD-Object",
REQUEST = "CMCD-Request",
SESSION = "CMCD-Session",
STATUS = "CMCD-Status"
}
export const CmcdHeaderField: {
readonly OBJECT: typeof CMCD_OBJECT;
readonly REQUEST: typeof CMCD_REQUEST;
readonly SESSION: typeof CMCD_SESSION;
readonly STATUS: typeof CMCD_STATUS;
};

// @beta (undocumented)
export type CmcdHeaderField = ValueOf<typeof CmcdHeaderField>;

// @beta
export type CmcdHeadersMap = Record<CmcdHeaderField, CmcdKey[]>;

// @beta
export type CmcdKey = keyof Cmcd;

// Warning: (ae-forgotten-export) The symbol "CmObjectType" needs to be exported by the entry point index.d.ts
//
// @beta
export enum CmcdObjectType {
AUDIO = "a",
CAPTION = "c",
INIT = "i",
KEY = "k",
MANIFEST = "m",
MUXED = "av",
OTHER = "o",
TIMED_TEXT = "tt",
VIDEO = "v"
}
export const CmcdObjectType: typeof CmObjectType;

// @beta (undocumented)
export type CmcdObjectType = CmObjectType;

// Warning: (ae-forgotten-export) The symbol "CmStreamingFormat" needs to be exported by the entry point index.d.ts
//
// @beta
export enum CmcdStreamingFormat {
DASH = "d",
HLS = "h",
OTHER = "o",
SMOOTH = "s"
}
export const CmcdStreamingFormat: typeof CmStreamingFormat;

// @beta (undocumented)
export type CmcdStreamingFormat = CmStreamingFormat;

// Warning: (ae-forgotten-export) The symbol "CmStreamType" needs to be exported by the entry point index.d.ts
//
// @beta
export enum CmcdStreamType {
LIVE = "l",
VOD = "v"
}
export const CmcdStreamType: typeof CmStreamType;

// @beta (undocumented)
export type CmcdStreamType = CmStreamType;

// @beta
export type CmcdValue = CmcdObjectType | CmcdStreamingFormat | CmcdStreamType | string | number | boolean | symbol | SfToken;
Expand All @@ -180,10 +206,10 @@ export type CmcdValue = CmcdObjectType | CmcdStreamingFormat | CmcdStreamType |
export type CmCustomKey = `${string}-${string}`;

// @beta
export const CMSD_DYNAMIC: string;
export const CMSD_DYNAMIC = "CMSD-Dynamic";

// @beta
export const CMSD_STATIC: string;
export const CMSD_STATIC = "CMSD-Static";

// @beta
export const CMSD_V1 = 1;
Expand Down Expand Up @@ -213,23 +239,19 @@ export type CmsdEncodeOptions = {
};

// @beta
export enum CmsdHeaderField {
DYNAMIC = "CMSD-Dynamic",
STATIC = "CMSD-Static"
}
export const CmsdHeaderField: {
readonly STATIC: typeof CMSD_STATIC;
readonly DYNAMIC: typeof CMSD_DYNAMIC;
};

// @beta (undocumented)
export type CmsdHeaderField = ValueOf<typeof CmsdHeaderField>;

// @beta
export enum CmsdObjectType {
AUDIO = "a",
CAPTION = "c",
INIT = "i",
KEY = "k",
MANIFEST = "m",
MUXED = "av",
OTHER = "o",
TIMED_TEXT = "tt",
VIDEO = "v"
}
export const CmsdObjectType: typeof CmObjectType;

// @beta (undocumented)
export type CmsdObjectType = CmObjectType;

// @beta
export type CmsdStatic = {
Expand All @@ -249,25 +271,20 @@ export type CmsdStatic = {
};

// @beta
export enum CmsdStreamingFormat {
DASH = "d",
HLS = "h",
OTHER = "o",
SMOOTH = "s"
}
export const CmsdStreamingFormat: typeof CmStreamingFormat;

// @beta (undocumented)
export type CmsdStreamingFormat = CmStreamingFormat;

// @beta
export enum CmsdStreamType {
LIVE = "l",
VOD = "v"
}
export const CmsdStreamType: typeof CmStreamType;

// @beta (undocumented)
export type CmsdStreamType = CmStreamType;

// @beta
export type CmsdValue = CmsdObjectType | CmsdStreamingFormat | CmsdStreamType | string | number | boolean | symbol | SfToken;

// Warning: (ae-forgotten-export) The symbol "CmObjectType" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "CmStreamingFormat" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "CmStreamType" needs to be exported by the entry point index.d.ts
// Warning: (ae-internal-missing-underscore) The name "CmValue" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
Expand Down Expand Up @@ -365,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 @@ -466,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 @@ -622,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 @@ -766,20 +824,17 @@ export type Validation = {
};

// @beta
export const enum VerboseLevel {
// (undocumented)
DATA = 3,
// (undocumented)
DEBUG = 3,
// (undocumented)
ERROR = 0,
// (undocumented)
INFO = 2,
// (undocumented)
TEXT = 1,
// (undocumented)
WARNING = 2
}
export const VerboseLevel: {
readonly ERROR: 0;
readonly TEXT: 1;
readonly WARNING: 2;
readonly INFO: 2;
readonly DEBUG: 3;
readonly DATA: 3;
};

// @beta (undocumented)
export type VerboseLevel = ValueOf<typeof VerboseLevel>;

// @alpha
export type VideoTrack = Track & {
Expand All @@ -791,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
Loading
Loading