dasha 3.1.5 → 4.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/dist/dasha.cjs +1048 -0
- package/dist/dasha.d.cts +160 -0
- package/dist/dasha.d.ts +160 -0
- package/dist/dasha.js +1019 -0
- package/package.json +37 -21
- package/dasha.js +0 -29
- package/lib/audio.js +0 -148
- package/lib/dash.js +0 -516
- package/lib/hls.js +0 -234
- package/lib/subtitle.js +0 -137
- package/lib/track.js +0 -127
- package/lib/util.js +0 -98
- package/lib/video.js +0 -200
- package/lib/xml.js +0 -310
- package/types/dasha.d.ts +0 -161
package/dist/dasha.d.cts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
//#region lib/shared/media-type.d.ts
|
|
2
|
+
declare const MEDIA_TYPES: {
|
|
3
|
+
readonly VIDEO: "video";
|
|
4
|
+
readonly AUDIO: "audio";
|
|
5
|
+
readonly SUBTITLES: "subtitle";
|
|
6
|
+
readonly CLOSED_CAPTIONS: "closed-captions";
|
|
7
|
+
};
|
|
8
|
+
type MediaType = (typeof MEDIA_TYPES)[keyof typeof MEDIA_TYPES];
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region lib/shared/encrypt-method.d.ts
|
|
12
|
+
declare const ENCRYPT_METHODS: {
|
|
13
|
+
NONE: number;
|
|
14
|
+
AES_128: number;
|
|
15
|
+
AES_128_ECB: number;
|
|
16
|
+
SAMPLE_AES: number;
|
|
17
|
+
SAMPLE_AES_CTR: number;
|
|
18
|
+
CENC: number;
|
|
19
|
+
CHACHA20: number;
|
|
20
|
+
UNKNOWN: number;
|
|
21
|
+
};
|
|
22
|
+
type EncryptMethod = (typeof ENCRYPT_METHODS)[keyof typeof ENCRYPT_METHODS];
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region lib/shared/extractor-type.d.ts
|
|
26
|
+
declare const EXTRACTOR_TYPES: {
|
|
27
|
+
readonly MPEG_DASH: "MPEG_DASH";
|
|
28
|
+
readonly HLS: "HLS";
|
|
29
|
+
readonly HTTP_LIVE: "HTTP_LIVE";
|
|
30
|
+
readonly MSS: "MSS";
|
|
31
|
+
};
|
|
32
|
+
type ExtractorType = (typeof EXTRACTOR_TYPES)[keyof typeof EXTRACTOR_TYPES];
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region lib/shared/role-type.d.ts
|
|
36
|
+
declare const ROLE_TYPE: {
|
|
37
|
+
Subtitle: number;
|
|
38
|
+
Main: number;
|
|
39
|
+
Alternate: number;
|
|
40
|
+
Supplementary: number;
|
|
41
|
+
Commentary: number;
|
|
42
|
+
Dub: number;
|
|
43
|
+
Description: number;
|
|
44
|
+
Sign: number;
|
|
45
|
+
Metadata: number;
|
|
46
|
+
ForcedSubtitle: number;
|
|
47
|
+
};
|
|
48
|
+
type RoleType = (typeof ROLE_TYPE)[keyof typeof ROLE_TYPE];
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region lib/parser-config.d.ts
|
|
52
|
+
declare class ParserConfig {
|
|
53
|
+
url: string;
|
|
54
|
+
originalUrl: string;
|
|
55
|
+
baseUrl?: string;
|
|
56
|
+
customParserArgs: Record<string, string>;
|
|
57
|
+
headers: Record<string, string>;
|
|
58
|
+
contentProcessors: any[];
|
|
59
|
+
urlProcessors: any[];
|
|
60
|
+
keyProcessors: any[];
|
|
61
|
+
customMethod?: EncryptMethod;
|
|
62
|
+
customKey?: Buffer;
|
|
63
|
+
customIv?: Buffer;
|
|
64
|
+
urlProcessorArgs?: string;
|
|
65
|
+
appendUrlParams: boolean;
|
|
66
|
+
keyRetryCount: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region lib/shared/encrypt-info.d.ts
|
|
71
|
+
declare class EncryptInfo {
|
|
72
|
+
method: EncryptMethod;
|
|
73
|
+
key?: Buffer;
|
|
74
|
+
iv?: Buffer;
|
|
75
|
+
constructor(method?: string);
|
|
76
|
+
parseMethod(method?: string): EncryptMethod;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region lib/shared/media-segment.d.ts
|
|
81
|
+
declare class MediaSegment {
|
|
82
|
+
index: number;
|
|
83
|
+
duration: number;
|
|
84
|
+
title?: string;
|
|
85
|
+
dateTime?: Date;
|
|
86
|
+
startRange?: number;
|
|
87
|
+
get stopRange(): number | undefined;
|
|
88
|
+
expectLength?: number;
|
|
89
|
+
encryptInfo: EncryptInfo;
|
|
90
|
+
get isEncrypted(): boolean;
|
|
91
|
+
url: string;
|
|
92
|
+
nameFromVar?: string;
|
|
93
|
+
equals(segment: unknown): boolean;
|
|
94
|
+
getHashCode(): string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region lib/shared/media-part.d.ts
|
|
99
|
+
declare class MediaPart {
|
|
100
|
+
mediaSegments: MediaSegment[];
|
|
101
|
+
constructor(segments?: MediaSegment[]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region lib/shared/playlist.d.ts
|
|
106
|
+
declare class Playlist {
|
|
107
|
+
url: string;
|
|
108
|
+
isLive: boolean;
|
|
109
|
+
refreshIntervalMs: number;
|
|
110
|
+
get totalDuration(): number;
|
|
111
|
+
targetDuration?: number;
|
|
112
|
+
mediaInit?: MediaSegment;
|
|
113
|
+
mediaParts: MediaPart[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region lib/shared/stream-spec.d.ts
|
|
118
|
+
declare class StreamSpec {
|
|
119
|
+
mediaType?: MediaType;
|
|
120
|
+
groupId: string | null;
|
|
121
|
+
language?: string;
|
|
122
|
+
name?: string;
|
|
123
|
+
default?: boolean;
|
|
124
|
+
skippedDuration?: number;
|
|
125
|
+
bandwidth?: number;
|
|
126
|
+
codecs: string | null;
|
|
127
|
+
resolution?: string;
|
|
128
|
+
frameRate?: number;
|
|
129
|
+
channels: string | null;
|
|
130
|
+
extension: string | null;
|
|
131
|
+
role?: RoleType;
|
|
132
|
+
videoRange?: string;
|
|
133
|
+
characteristics?: string;
|
|
134
|
+
publishTime?: Date;
|
|
135
|
+
audioId?: string;
|
|
136
|
+
videoId?: string;
|
|
137
|
+
subtitleId?: string;
|
|
138
|
+
periodId: string | null;
|
|
139
|
+
url: string;
|
|
140
|
+
originalUrl: string;
|
|
141
|
+
playlist?: Playlist;
|
|
142
|
+
get segmentsCount(): number;
|
|
143
|
+
toShortString(): string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region lib/stream-extractor.d.ts
|
|
148
|
+
declare class StreamExtractor {
|
|
149
|
+
#private;
|
|
150
|
+
constructor(parserConfig?: ParserConfig);
|
|
151
|
+
get extractorType(): ExtractorType;
|
|
152
|
+
loadSourceFromUrl(url: string): Promise<void>;
|
|
153
|
+
loadSourceFromText(rawText: string, url?: string): void;
|
|
154
|
+
extractStreams(): Promise<StreamSpec[]>;
|
|
155
|
+
fetchPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
156
|
+
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
export { ENCRYPT_METHODS, EXTRACTOR_TYPES, EncryptMethod, ExtractorType, MEDIA_TYPES, MediaType, ParserConfig, ROLE_TYPE, RoleType, StreamExtractor };
|
package/dist/dasha.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
//#region lib/shared/media-type.d.ts
|
|
2
|
+
declare const MEDIA_TYPES: {
|
|
3
|
+
readonly VIDEO: "video";
|
|
4
|
+
readonly AUDIO: "audio";
|
|
5
|
+
readonly SUBTITLES: "subtitle";
|
|
6
|
+
readonly CLOSED_CAPTIONS: "closed-captions";
|
|
7
|
+
};
|
|
8
|
+
type MediaType = (typeof MEDIA_TYPES)[keyof typeof MEDIA_TYPES];
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region lib/shared/encrypt-method.d.ts
|
|
12
|
+
declare const ENCRYPT_METHODS: {
|
|
13
|
+
NONE: number;
|
|
14
|
+
AES_128: number;
|
|
15
|
+
AES_128_ECB: number;
|
|
16
|
+
SAMPLE_AES: number;
|
|
17
|
+
SAMPLE_AES_CTR: number;
|
|
18
|
+
CENC: number;
|
|
19
|
+
CHACHA20: number;
|
|
20
|
+
UNKNOWN: number;
|
|
21
|
+
};
|
|
22
|
+
type EncryptMethod = (typeof ENCRYPT_METHODS)[keyof typeof ENCRYPT_METHODS];
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region lib/shared/extractor-type.d.ts
|
|
26
|
+
declare const EXTRACTOR_TYPES: {
|
|
27
|
+
readonly MPEG_DASH: "MPEG_DASH";
|
|
28
|
+
readonly HLS: "HLS";
|
|
29
|
+
readonly HTTP_LIVE: "HTTP_LIVE";
|
|
30
|
+
readonly MSS: "MSS";
|
|
31
|
+
};
|
|
32
|
+
type ExtractorType = (typeof EXTRACTOR_TYPES)[keyof typeof EXTRACTOR_TYPES];
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region lib/shared/role-type.d.ts
|
|
36
|
+
declare const ROLE_TYPE: {
|
|
37
|
+
Subtitle: number;
|
|
38
|
+
Main: number;
|
|
39
|
+
Alternate: number;
|
|
40
|
+
Supplementary: number;
|
|
41
|
+
Commentary: number;
|
|
42
|
+
Dub: number;
|
|
43
|
+
Description: number;
|
|
44
|
+
Sign: number;
|
|
45
|
+
Metadata: number;
|
|
46
|
+
ForcedSubtitle: number;
|
|
47
|
+
};
|
|
48
|
+
type RoleType = (typeof ROLE_TYPE)[keyof typeof ROLE_TYPE];
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region lib/parser-config.d.ts
|
|
52
|
+
declare class ParserConfig {
|
|
53
|
+
url: string;
|
|
54
|
+
originalUrl: string;
|
|
55
|
+
baseUrl?: string;
|
|
56
|
+
customParserArgs: Record<string, string>;
|
|
57
|
+
headers: Record<string, string>;
|
|
58
|
+
contentProcessors: any[];
|
|
59
|
+
urlProcessors: any[];
|
|
60
|
+
keyProcessors: any[];
|
|
61
|
+
customMethod?: EncryptMethod;
|
|
62
|
+
customKey?: Buffer;
|
|
63
|
+
customIv?: Buffer;
|
|
64
|
+
urlProcessorArgs?: string;
|
|
65
|
+
appendUrlParams: boolean;
|
|
66
|
+
keyRetryCount: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region lib/shared/encrypt-info.d.ts
|
|
71
|
+
declare class EncryptInfo {
|
|
72
|
+
method: EncryptMethod;
|
|
73
|
+
key?: Buffer;
|
|
74
|
+
iv?: Buffer;
|
|
75
|
+
constructor(method?: string);
|
|
76
|
+
parseMethod(method?: string): EncryptMethod;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region lib/shared/media-segment.d.ts
|
|
81
|
+
declare class MediaSegment {
|
|
82
|
+
index: number;
|
|
83
|
+
duration: number;
|
|
84
|
+
title?: string;
|
|
85
|
+
dateTime?: Date;
|
|
86
|
+
startRange?: number;
|
|
87
|
+
get stopRange(): number | undefined;
|
|
88
|
+
expectLength?: number;
|
|
89
|
+
encryptInfo: EncryptInfo;
|
|
90
|
+
get isEncrypted(): boolean;
|
|
91
|
+
url: string;
|
|
92
|
+
nameFromVar?: string;
|
|
93
|
+
equals(segment: unknown): boolean;
|
|
94
|
+
getHashCode(): string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region lib/shared/media-part.d.ts
|
|
99
|
+
declare class MediaPart {
|
|
100
|
+
mediaSegments: MediaSegment[];
|
|
101
|
+
constructor(segments?: MediaSegment[]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region lib/shared/playlist.d.ts
|
|
106
|
+
declare class Playlist {
|
|
107
|
+
url: string;
|
|
108
|
+
isLive: boolean;
|
|
109
|
+
refreshIntervalMs: number;
|
|
110
|
+
get totalDuration(): number;
|
|
111
|
+
targetDuration?: number;
|
|
112
|
+
mediaInit?: MediaSegment;
|
|
113
|
+
mediaParts: MediaPart[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region lib/shared/stream-spec.d.ts
|
|
118
|
+
declare class StreamSpec {
|
|
119
|
+
mediaType?: MediaType;
|
|
120
|
+
groupId: string | null;
|
|
121
|
+
language?: string;
|
|
122
|
+
name?: string;
|
|
123
|
+
default?: boolean;
|
|
124
|
+
skippedDuration?: number;
|
|
125
|
+
bandwidth?: number;
|
|
126
|
+
codecs: string | null;
|
|
127
|
+
resolution?: string;
|
|
128
|
+
frameRate?: number;
|
|
129
|
+
channels: string | null;
|
|
130
|
+
extension: string | null;
|
|
131
|
+
role?: RoleType;
|
|
132
|
+
videoRange?: string;
|
|
133
|
+
characteristics?: string;
|
|
134
|
+
publishTime?: Date;
|
|
135
|
+
audioId?: string;
|
|
136
|
+
videoId?: string;
|
|
137
|
+
subtitleId?: string;
|
|
138
|
+
periodId: string | null;
|
|
139
|
+
url: string;
|
|
140
|
+
originalUrl: string;
|
|
141
|
+
playlist?: Playlist;
|
|
142
|
+
get segmentsCount(): number;
|
|
143
|
+
toShortString(): string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region lib/stream-extractor.d.ts
|
|
148
|
+
declare class StreamExtractor {
|
|
149
|
+
#private;
|
|
150
|
+
constructor(parserConfig?: ParserConfig);
|
|
151
|
+
get extractorType(): ExtractorType;
|
|
152
|
+
loadSourceFromUrl(url: string): Promise<void>;
|
|
153
|
+
loadSourceFromText(rawText: string, url?: string): void;
|
|
154
|
+
extractStreams(): Promise<StreamSpec[]>;
|
|
155
|
+
fetchPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
156
|
+
refreshPlayList(streamSpecs: StreamSpec[]): Promise<void>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
export { ENCRYPT_METHODS, EXTRACTOR_TYPES, EncryptMethod, ExtractorType, MEDIA_TYPES, MediaType, ParserConfig, ROLE_TYPE, RoleType, StreamExtractor };
|