mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Create type definitions for hls-parser (#40600)
This commit is contained in:
parent
db30eb1819
commit
8d57d313be
24
types/hls-parser/hls-parser-tests.ts
Normal file
24
types/hls-parser/hls-parser-tests.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import HLS = require('hls-parser');
|
||||
|
||||
const playlist = HLS.parse('');
|
||||
|
||||
if (playlist.isMasterPlaylist) {
|
||||
// Master playlist
|
||||
} else {
|
||||
// Media playlist
|
||||
}
|
||||
|
||||
const { MediaPlaylist, Segment } = HLS.types;
|
||||
|
||||
new MediaPlaylist({
|
||||
targetDuration: 9,
|
||||
playlistType: 'VOD',
|
||||
segments: [
|
||||
new Segment({
|
||||
uri: 'low/1.m3u8',
|
||||
duration: 9,
|
||||
mediaSequenceNumber: 0,
|
||||
discontinuitySequence: 0,
|
||||
}),
|
||||
],
|
||||
});
|
||||
284
types/hls-parser/index.d.ts
vendored
Normal file
284
types/hls-parser/index.d.ts
vendored
Normal file
@ -0,0 +1,284 @@
|
||||
// Type definitions for hls-parser 0.5
|
||||
// Project: https://github.com/kuu/hls-parser#readme
|
||||
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.4
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface Byterange {
|
||||
length: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
strictMode: boolean;
|
||||
}
|
||||
|
||||
export class Data {
|
||||
type: 'playlist' | 'segment';
|
||||
}
|
||||
|
||||
export namespace types {
|
||||
class Playlist extends Data {
|
||||
isMasterPlaylist: boolean;
|
||||
|
||||
uri?: string;
|
||||
|
||||
version?: number;
|
||||
|
||||
independentSegments: boolean;
|
||||
|
||||
start?: { offset: number; precise: boolean };
|
||||
|
||||
source?: string;
|
||||
|
||||
constructor(properties: {
|
||||
isMasterPlaylist: boolean;
|
||||
uri?: string;
|
||||
version?: number;
|
||||
independentSegments: boolean;
|
||||
start?: { offset: number; precise: boolean };
|
||||
source?: string;
|
||||
});
|
||||
}
|
||||
|
||||
class MasterPlaylist extends Playlist {
|
||||
variants: readonly Variant[];
|
||||
|
||||
currentVariant?: number;
|
||||
|
||||
sessionDataList: readonly SessionData[];
|
||||
|
||||
sessionKeyList: readonly Key[];
|
||||
|
||||
constructor(properties: {
|
||||
variants?: readonly Variant[];
|
||||
currentVariant?: number;
|
||||
sessionDataList?: readonly SessionData[];
|
||||
sessionKeyList?: readonly Key[];
|
||||
source?: string;
|
||||
});
|
||||
}
|
||||
|
||||
class MediaPlaylist extends Playlist {
|
||||
targetDuration: number;
|
||||
|
||||
mediaSequenceBase?: number;
|
||||
|
||||
discontinuitySequenceBase?: number;
|
||||
|
||||
endlist: boolean;
|
||||
|
||||
playlistType?: 'EVENT' | 'VOD';
|
||||
|
||||
isIFrame: boolean;
|
||||
|
||||
segments: readonly Segment[];
|
||||
|
||||
constructor(properties: {
|
||||
targetDuration: number;
|
||||
mediaSequenceBase?: number;
|
||||
discontinuitySequenceBase?: number;
|
||||
endlist?: boolean;
|
||||
playlistType?: 'EVENT' | 'VOD';
|
||||
isIFrame?: boolean;
|
||||
segments?: readonly Segment[];
|
||||
source?: string;
|
||||
});
|
||||
}
|
||||
|
||||
class Variant {
|
||||
uri: string;
|
||||
|
||||
isIFrameOnly?: boolean;
|
||||
|
||||
bandwidth: number;
|
||||
|
||||
averageBandwidth?: number;
|
||||
|
||||
codecs?: string;
|
||||
|
||||
resolution?: { width: number; height: number };
|
||||
|
||||
frameRate?: number;
|
||||
|
||||
hdcpLevel?: string;
|
||||
|
||||
audio: ReadonlyArray<Rendition<'AUDIO'>>;
|
||||
|
||||
video: ReadonlyArray<Rendition<'VIDEO'>>;
|
||||
|
||||
subtitles: ReadonlyArray<Rendition<'SUBTITLES'>>;
|
||||
|
||||
closedCaptions: ReadonlyArray<Rendition<'CLOSED-CAPTIONS'>>;
|
||||
|
||||
currentRenditions: { audio?: number; video?: number; subtitles?: number; closedCaptions?: number };
|
||||
|
||||
constructor(properties: {
|
||||
uri: string;
|
||||
isIFrameOnly?: boolean;
|
||||
bandwidth: number;
|
||||
averageBandwidth?: number;
|
||||
codecs?: string;
|
||||
resolution?: { width: number; height: number };
|
||||
frameRate?: number;
|
||||
hdcpLevel?: string;
|
||||
audio?: ReadonlyArray<Rendition<'AUDIO'>>;
|
||||
video?: ReadonlyArray<Rendition<'VIDEO'>>;
|
||||
subtitles?: ReadonlyArray<Rendition<'SUBTITLES'>>;
|
||||
closedCaptions?: ReadonlyArray<Rendition<'CLOSED-CAPTIONS'>>;
|
||||
currentRenditions?: { audio?: number; video?: number; subtitles?: number; closedCaptions?: number };
|
||||
});
|
||||
}
|
||||
|
||||
class Rendition<T> {
|
||||
type: T;
|
||||
|
||||
uri?: string;
|
||||
|
||||
groupId: string;
|
||||
|
||||
language?: string;
|
||||
|
||||
assocLanguage?: string;
|
||||
|
||||
name: string;
|
||||
|
||||
isDefault: boolean;
|
||||
|
||||
autoselect: boolean;
|
||||
|
||||
forced: boolean;
|
||||
|
||||
instreamId?: string;
|
||||
|
||||
characteristics?: string;
|
||||
|
||||
channels?: string;
|
||||
|
||||
constructor(properties: {
|
||||
type: T;
|
||||
uri?: string;
|
||||
groupId: string;
|
||||
language?: string;
|
||||
assocLanguage?: string;
|
||||
name: string;
|
||||
isDefault?: boolean;
|
||||
autoselect?: boolean;
|
||||
forced?: boolean;
|
||||
instreamId?: string;
|
||||
characteristics?: string;
|
||||
channels?: string;
|
||||
});
|
||||
}
|
||||
|
||||
class SessionData {
|
||||
id: string;
|
||||
|
||||
value?: string;
|
||||
|
||||
uri?: string;
|
||||
|
||||
language?: string;
|
||||
|
||||
constructor(properties: { id: string; value?: string; uri?: string; language?: string });
|
||||
}
|
||||
|
||||
class Segment extends Data {
|
||||
uri: string;
|
||||
|
||||
duration: number;
|
||||
|
||||
title?: string;
|
||||
|
||||
byterange?: Byterange;
|
||||
|
||||
discontinuity?: boolean;
|
||||
|
||||
mediaSequenceNumber: number;
|
||||
|
||||
discontinuitySequence: number;
|
||||
|
||||
key?: Key;
|
||||
|
||||
map?: MediaInitializationSection;
|
||||
|
||||
programDateTime?: Date;
|
||||
|
||||
dateRange: DateRange;
|
||||
|
||||
constructor(properties: {
|
||||
uri: string;
|
||||
duration: number;
|
||||
title?: string;
|
||||
byterange?: Byterange;
|
||||
discontinuity?: boolean;
|
||||
mediaSequenceNumber: number;
|
||||
discontinuitySequence: number;
|
||||
key?: Key;
|
||||
map?: MediaInitializationSection;
|
||||
programDateTime?: Date;
|
||||
dateRange?: DateRange;
|
||||
});
|
||||
}
|
||||
|
||||
class Key {
|
||||
method: string;
|
||||
|
||||
uri?: string;
|
||||
|
||||
iv?: Buffer;
|
||||
|
||||
format?: string;
|
||||
|
||||
formatVersion?: string;
|
||||
|
||||
constructor(properties: { method: string; uri?: string; iv?: Buffer; format?: string; formatVersion?: string });
|
||||
}
|
||||
|
||||
class MediaInitializationSection {
|
||||
uri: string;
|
||||
|
||||
byterange?: Byterange;
|
||||
|
||||
constructor(properties: { uri: string; byterange?: Byterange });
|
||||
}
|
||||
|
||||
class DateRange {
|
||||
id: string;
|
||||
|
||||
classId?: string;
|
||||
|
||||
start: Date;
|
||||
|
||||
end?: Date;
|
||||
|
||||
duration?: number;
|
||||
|
||||
plannedDuration?: number;
|
||||
|
||||
endOnNext?: boolean;
|
||||
|
||||
attributes?: object;
|
||||
|
||||
constructor(properties: {
|
||||
id: string;
|
||||
classId?: string;
|
||||
start: Date;
|
||||
end?: Date;
|
||||
duration?: number;
|
||||
plannedDuration?: number;
|
||||
endOnNext?: boolean;
|
||||
attributes?: object;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function parse(manifest: string): types.MasterPlaylist | types.MediaPlaylist;
|
||||
|
||||
export function stringify(playlist: types.MasterPlaylist | types.MediaPlaylist): string;
|
||||
|
||||
export function setOptions(overrides: Partial<Options>): void;
|
||||
|
||||
export function getOptions(): Options;
|
||||
23
types/hls-parser/tsconfig.json
Normal file
23
types/hls-parser/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hls-parser-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/hls-parser/tslint.json
Normal file
1
types/hls-parser/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user