googlevideo 2.0.0 → 4.0.0
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/LICENSE +9 -9
- package/README.md +127 -66
- package/dist/protos/generated/misc/common.d.ts +180 -21
- package/dist/protos/generated/misc/common.js +277 -147
- package/dist/protos/generated/misc/common.js.map +1 -0
- package/dist/protos/generated/video_streaming/buffered_range.d.ts +10 -25
- package/dist/protos/generated/video_streaming/buffered_range.js +21 -166
- package/dist/protos/generated/video_streaming/buffered_range.js.map +1 -0
- package/dist/protos/generated/video_streaming/client_abr_state.d.ts +34 -45
- package/dist/protos/generated/video_streaming/client_abr_state.js +209 -350
- package/dist/protos/generated/video_streaming/client_abr_state.js.map +1 -0
- package/dist/protos/generated/video_streaming/crypto_params.d.ts +2 -24
- package/dist/protos/generated/video_streaming/crypto_params.js +2 -86
- package/dist/protos/generated/video_streaming/crypto_params.js.map +1 -0
- package/dist/protos/generated/video_streaming/format_initialization_metadata.d.ts +6 -21
- package/dist/protos/generated/video_streaming/format_initialization_metadata.js +32 -95
- package/dist/protos/generated/video_streaming/format_initialization_metadata.js.map +1 -0
- package/dist/protos/generated/video_streaming/format_selection_config.d.ts +12 -0
- package/dist/protos/generated/video_streaming/format_selection_config.js +68 -0
- package/dist/protos/generated/video_streaming/format_selection_config.js.map +1 -0
- package/dist/protos/generated/video_streaming/innertube_request.d.ts +25 -0
- package/dist/protos/generated/video_streaming/innertube_request.js +186 -0
- package/dist/protos/generated/video_streaming/innertube_request.js.map +1 -0
- package/dist/protos/generated/video_streaming/live_metadata.d.ts +20 -0
- package/dist/protos/generated/video_streaming/live_metadata.js +153 -0
- package/dist/protos/generated/video_streaming/live_metadata.js.map +1 -0
- package/dist/protos/generated/video_streaming/media_capabilities.d.ts +0 -15
- package/dist/protos/generated/video_streaming/media_capabilities.js +2 -122
- package/dist/protos/generated/video_streaming/media_capabilities.js.map +1 -0
- package/dist/protos/generated/video_streaming/media_header.d.ts +5 -27
- package/dist/protos/generated/video_streaming/media_header.js +28 -151
- package/dist/protos/generated/video_streaming/media_header.js.map +1 -0
- package/dist/protos/generated/video_streaming/next_request_policy.d.ts +3 -15
- package/dist/protos/generated/video_streaming/next_request_policy.js +32 -50
- package/dist/protos/generated/video_streaming/next_request_policy.js.map +1 -0
- package/dist/protos/generated/video_streaming/onesie_header.d.ts +7 -22
- package/dist/protos/generated/video_streaming/onesie_header.js +16 -137
- package/dist/protos/generated/video_streaming/onesie_header.js.map +1 -0
- package/dist/protos/generated/video_streaming/onesie_header_type.d.ts +9 -25
- package/dist/protos/generated/video_streaming/onesie_header_type.js +17 -176
- package/dist/protos/generated/video_streaming/onesie_header_type.js.map +1 -0
- package/dist/protos/generated/video_streaming/onesie_innertube_request.d.ts +15 -0
- package/dist/protos/generated/video_streaming/{onesie_player_request.js → onesie_innertube_request.js} +10 -54
- package/dist/protos/generated/video_streaming/onesie_innertube_request.js.map +1 -0
- package/dist/protos/generated/video_streaming/onesie_innertube_response.d.ts +15 -0
- package/dist/protos/generated/video_streaming/{onesie_player_response.js → onesie_innertube_response.js} +6 -58
- package/dist/protos/generated/video_streaming/onesie_innertube_response.js.map +1 -0
- package/dist/protos/generated/video_streaming/onesie_proxy_status.d.ts +18 -0
- package/dist/protos/generated/video_streaming/onesie_proxy_status.js +25 -0
- package/dist/protos/generated/video_streaming/onesie_proxy_status.js.map +1 -0
- package/dist/protos/generated/video_streaming/onesie_request.d.ts +7 -17
- package/dist/protos/generated/video_streaming/onesie_request.js +28 -89
- package/dist/protos/generated/video_streaming/onesie_request.js.map +1 -0
- package/dist/protos/generated/video_streaming/playback_cookie.d.ts +2 -17
- package/dist/protos/generated/video_streaming/playback_cookie.js +6 -47
- package/dist/protos/generated/video_streaming/playback_cookie.js.map +1 -0
- package/dist/protos/generated/video_streaming/playback_start_policy.d.ts +0 -15
- package/dist/protos/generated/video_streaming/playback_start_policy.js +2 -66
- package/dist/protos/generated/video_streaming/playback_start_policy.js.map +1 -0
- package/dist/protos/generated/video_streaming/reload_player_response.d.ts +14 -0
- package/dist/protos/generated/video_streaming/reload_player_response.js +73 -0
- package/dist/protos/generated/video_streaming/reload_player_response.js.map +1 -0
- package/dist/protos/generated/video_streaming/request_cancellation_policy.d.ts +0 -15
- package/dist/protos/generated/video_streaming/request_cancellation_policy.js +2 -66
- package/dist/protos/generated/video_streaming/request_cancellation_policy.js.map +1 -0
- package/dist/protos/generated/video_streaming/request_identifier.d.ts +10 -0
- package/dist/protos/generated/video_streaming/request_identifier.js +41 -0
- package/dist/protos/generated/video_streaming/request_identifier.js.map +1 -0
- package/dist/protos/generated/video_streaming/sabr_context_sending_policy.d.ts +12 -0
- package/dist/protos/generated/video_streaming/sabr_context_sending_policy.js +86 -0
- package/dist/protos/generated/video_streaming/sabr_context_sending_policy.js.map +1 -0
- package/dist/protos/generated/video_streaming/sabr_context_update.d.ts +48 -0
- package/dist/protos/generated/video_streaming/sabr_context_update.js +242 -0
- package/dist/protos/generated/video_streaming/sabr_context_update.js.map +1 -0
- package/dist/protos/generated/video_streaming/sabr_error.d.ts +0 -15
- package/dist/protos/generated/video_streaming/sabr_error.js +2 -29
- package/dist/protos/generated/video_streaming/sabr_error.js.map +1 -0
- package/dist/protos/generated/video_streaming/sabr_redirect.d.ts +0 -15
- package/dist/protos/generated/video_streaming/sabr_redirect.js +2 -22
- package/dist/protos/generated/video_streaming/sabr_redirect.js.map +1 -0
- package/dist/protos/generated/video_streaming/snackbar_message.d.ts +10 -0
- package/dist/protos/generated/video_streaming/snackbar_message.js +41 -0
- package/dist/protos/generated/video_streaming/snackbar_message.js.map +1 -0
- package/dist/protos/generated/video_streaming/stream_protection_status.d.ts +1 -16
- package/dist/protos/generated/video_streaming/stream_protection_status.js +6 -33
- package/dist/protos/generated/video_streaming/stream_protection_status.js.map +1 -0
- package/dist/protos/generated/video_streaming/streamer_context.d.ts +11 -28
- package/dist/protos/generated/video_streaming/streamer_context.js +33 -383
- package/dist/protos/generated/video_streaming/streamer_context.js.map +1 -0
- package/dist/protos/generated/video_streaming/time_range.d.ts +2 -17
- package/dist/protos/generated/video_streaming/time_range.js +9 -41
- package/dist/protos/generated/video_streaming/time_range.js.map +1 -0
- package/dist/protos/generated/video_streaming/ump_part_id.d.ts +58 -0
- package/dist/protos/generated/video_streaming/ump_part_id.js +89 -0
- package/dist/protos/generated/video_streaming/ump_part_id.js.map +1 -0
- package/dist/protos/generated/video_streaming/video_playback_abr_request.d.ts +21 -36
- package/dist/protos/generated/video_streaming/video_playback_abr_request.js +67 -343
- package/dist/protos/generated/video_streaming/video_playback_abr_request.js.map +1 -0
- package/dist/src/core/{ChunkedDataBuffer.d.ts → CompositeBuffer.d.ts} +8 -8
- package/dist/src/core/{ChunkedDataBuffer.js → CompositeBuffer.js} +32 -27
- package/dist/src/core/CompositeBuffer.js.map +1 -0
- package/dist/src/core/SabrStream.d.ts +356 -0
- package/dist/src/core/SabrStream.js +958 -0
- package/dist/src/core/SabrStream.js.map +1 -0
- package/dist/src/core/SabrStreamingAdapter.d.ts +158 -0
- package/dist/src/core/SabrStreamingAdapter.js +496 -0
- package/dist/src/core/SabrStreamingAdapter.js.map +1 -0
- package/dist/src/core/SabrUmpProcessor.d.ts +53 -0
- package/dist/src/core/SabrUmpProcessor.js +234 -0
- package/dist/src/core/SabrUmpProcessor.js.map +1 -0
- package/dist/src/core/UmpReader.d.ts +30 -0
- package/dist/src/core/UmpReader.js +122 -0
- package/dist/src/core/UmpReader.js.map +1 -0
- package/dist/src/core/UmpWriter.d.ts +16 -0
- package/dist/src/core/UmpWriter.js +56 -0
- package/dist/src/core/UmpWriter.js.map +1 -0
- package/dist/src/exports/protos.d.ts +1 -0
- package/dist/src/exports/protos.js +2 -0
- package/dist/src/exports/protos.js.map +1 -0
- package/dist/src/exports/sabr-stream.d.ts +2 -0
- package/dist/src/exports/sabr-stream.js +2 -0
- package/dist/src/exports/sabr-stream.js.map +1 -0
- package/dist/src/exports/sabr-streaming-adapter.d.ts +3 -0
- package/dist/src/exports/sabr-streaming-adapter.js +3 -0
- package/dist/src/exports/sabr-streaming-adapter.js.map +1 -0
- package/dist/src/exports/ump.d.ts +3 -0
- package/dist/src/exports/ump.js +4 -0
- package/dist/src/exports/ump.js.map +1 -0
- package/dist/src/exports/utils.d.ts +1 -0
- package/dist/src/exports/utils.js +2 -0
- package/dist/src/exports/utils.js.map +1 -0
- package/dist/src/types/sabrStreamTypes.d.ts +102 -0
- package/dist/src/types/sabrStreamTypes.js +2 -0
- package/dist/src/types/sabrStreamTypes.js.map +1 -0
- package/dist/src/types/sabrStreamingAdapterTypes.d.ts +93 -0
- package/dist/src/types/sabrStreamingAdapterTypes.js +2 -0
- package/dist/src/types/sabrStreamingAdapterTypes.js.map +1 -0
- package/dist/src/types/shared.d.ts +64 -0
- package/dist/src/types/shared.js +2 -0
- package/dist/src/types/shared.js.map +1 -0
- package/dist/src/utils/CacheManager.d.ts +32 -0
- package/dist/src/utils/CacheManager.js +131 -0
- package/dist/src/utils/CacheManager.js.map +1 -0
- package/dist/src/utils/EventEmitterLike.d.ts +5 -0
- package/dist/src/utils/EventEmitterLike.js +51 -10
- package/dist/src/utils/EventEmitterLike.js.map +1 -0
- package/dist/src/utils/Logger.d.ts +30 -0
- package/dist/src/utils/Logger.js +80 -0
- package/dist/src/utils/Logger.js.map +1 -0
- package/dist/src/utils/Protos.d.ts +21 -13
- package/dist/src/utils/Protos.js +22 -13
- package/dist/src/utils/Protos.js.map +1 -0
- package/dist/src/utils/RequestMetadataManager.d.ts +15 -0
- package/dist/src/utils/RequestMetadataManager.js +48 -0
- package/dist/src/utils/RequestMetadataManager.js.map +1 -0
- package/dist/src/utils/formatKeyUtils.d.ts +45 -0
- package/dist/src/utils/formatKeyUtils.js +77 -0
- package/dist/src/utils/formatKeyUtils.js.map +1 -0
- package/dist/src/utils/index.d.ts +5 -3
- package/dist/src/utils/index.js +6 -2
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/sabrStreamUtils.d.ts +28 -0
- package/dist/src/utils/sabrStreamUtils.js +76 -0
- package/dist/src/utils/sabrStreamUtils.js.map +1 -0
- package/dist/src/utils/shared.d.ts +43 -0
- package/dist/src/utils/shared.js +108 -0
- package/dist/src/utils/shared.js.map +1 -0
- package/package.json +88 -61
- package/dist/protos/generated/video_streaming/encrypted_player_request.d.ts +0 -37
- package/dist/protos/generated/video_streaming/encrypted_player_request.js +0 -239
- package/dist/protos/generated/video_streaming/onesie_player_request.d.ts +0 -31
- package/dist/protos/generated/video_streaming/onesie_player_response.d.ts +0 -29
- package/dist/protos/generated/video_streaming/proxy_status.d.ts +0 -16
- package/dist/protos/generated/video_streaming/proxy_status.js +0 -86
- package/dist/src/core/ServerAbrStream.d.ts +0 -38
- package/dist/src/core/ServerAbrStream.js +0 -272
- package/dist/src/core/UMP.d.ts +0 -10
- package/dist/src/core/UMP.js +0 -109
- package/dist/src/core/index.d.ts +0 -3
- package/dist/src/core/index.js +0 -3
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +0 -4
- package/dist/src/utils/helpers.d.ts +0 -63
- package/dist/src/utils/helpers.js +0 -101
- package/dist/src/utils/types.d.ts +0 -65
- package/dist/src/utils/types.js +0 -1
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { concatenateChunks } from '../utils/index.js';
|
|
2
|
+
import { createSegmentCacheKey, fromFormat, fromMediaHeader } from '../utils/formatKeyUtils.js';
|
|
3
|
+
import { CompositeBuffer } from './CompositeBuffer.js';
|
|
4
|
+
import { UmpReader } from './UmpReader.js';
|
|
5
|
+
import { FormatInitializationMetadata, MediaHeader, NextRequestPolicy, ReloadPlaybackContext, SabrContextSendingPolicy, SabrContextUpdate, SabrError, SabrRedirect, SnackbarMessage, StreamProtectionStatus, UMPPartId } from '../utils/Protos.js';
|
|
6
|
+
/**
|
|
7
|
+
* This class is responsible for reading a UMP stream, handling different part types
|
|
8
|
+
* (like media headers, media data, and server directives), and populating a
|
|
9
|
+
* metadata object with the extracted information. It is supposed to be used
|
|
10
|
+
* in conjunction with a {@linkcode SabrPlayerAdapter} in video player
|
|
11
|
+
* implementations.
|
|
12
|
+
*/
|
|
13
|
+
export class SabrUmpProcessor {
|
|
14
|
+
constructor(requestMetadata, cacheManager) {
|
|
15
|
+
this.requestMetadata = requestMetadata;
|
|
16
|
+
this.cacheManager = cacheManager;
|
|
17
|
+
this.formatInitMetadata = [];
|
|
18
|
+
this.partialSegments = new Map();
|
|
19
|
+
this.umpPartHandlers = new Map([
|
|
20
|
+
[UMPPartId.FORMAT_INITIALIZATION_METADATA, this.handleFormatInitMetadata.bind(this)],
|
|
21
|
+
[UMPPartId.NEXT_REQUEST_POLICY, this.handleNextRequestPolicy.bind(this)],
|
|
22
|
+
[UMPPartId.SABR_ERROR, this.handleSabrError.bind(this)],
|
|
23
|
+
[UMPPartId.SABR_REDIRECT, this.handleSabrRedirect.bind(this)],
|
|
24
|
+
[UMPPartId.SABR_CONTEXT_UPDATE, this.handleSabrContextUpdate.bind(this)],
|
|
25
|
+
[UMPPartId.SABR_CONTEXT_SENDING_POLICY, this.handleSabrContextSendingPolicy.bind(this)],
|
|
26
|
+
[UMPPartId.SNACKBAR_MESSAGE, this.handleSnackbarMessage.bind(this)],
|
|
27
|
+
[UMPPartId.STREAM_PROTECTION_STATUS, this.handleStreamProtectionStatus.bind(this)],
|
|
28
|
+
[UMPPartId.RELOAD_PLAYER_RESPONSE, this.handleReloadPlayerResponse.bind(this)],
|
|
29
|
+
[UMPPartId.MEDIA_HEADER, this.handleMediaHeader.bind(this)],
|
|
30
|
+
[UMPPartId.MEDIA, this.handleMedia.bind(this)],
|
|
31
|
+
[UMPPartId.MEDIA_END, this.handleMediaEnd.bind(this)]
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Processes a chunk of data from a UMP stream and updates the request context.
|
|
36
|
+
* @returns A promise that resolves with a processing result if a terminal part is found (e.g., MediaEnd), or undefined otherwise.
|
|
37
|
+
* @param value
|
|
38
|
+
*/
|
|
39
|
+
processChunk(value) {
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
let chunk;
|
|
42
|
+
if (this.partialPart) {
|
|
43
|
+
chunk = this.partialPart.data;
|
|
44
|
+
chunk.append(value);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
chunk = new CompositeBuffer([value]);
|
|
48
|
+
}
|
|
49
|
+
const ump = new UmpReader(chunk);
|
|
50
|
+
this.partialPart = ump.read((part) => {
|
|
51
|
+
const handler = this.umpPartHandlers.get(part.type);
|
|
52
|
+
const result = handler?.(part);
|
|
53
|
+
if (result) {
|
|
54
|
+
this.partialPart = undefined;
|
|
55
|
+
this.desiredHeaderId = undefined;
|
|
56
|
+
this.partialSegments.clear();
|
|
57
|
+
resolve(result);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
resolve(undefined);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getSegmentInfo() {
|
|
64
|
+
return this.partialSegments.get(this.desiredHeaderId || 0);
|
|
65
|
+
}
|
|
66
|
+
decodePart(part, decoder) {
|
|
67
|
+
if (!part.data.chunks.length)
|
|
68
|
+
return undefined;
|
|
69
|
+
try {
|
|
70
|
+
return decoder.decode(concatenateChunks(part.data.chunks));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
handleFormatInitMetadata(part) {
|
|
77
|
+
const formatInitMetadata = this.decodePart(part, FormatInitializationMetadata);
|
|
78
|
+
if (formatInitMetadata) {
|
|
79
|
+
this.formatInitMetadata.push(formatInitMetadata);
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
handleNextRequestPolicy(part) {
|
|
84
|
+
const nextRequestPolicy = this.decodePart(part, NextRequestPolicy);
|
|
85
|
+
if (nextRequestPolicy) {
|
|
86
|
+
this.requestMetadata.streamInfo = {
|
|
87
|
+
...this.requestMetadata.streamInfo,
|
|
88
|
+
nextRequestPolicy
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
handleMediaHeader(part) {
|
|
94
|
+
const mediaHeader = this.decodePart(part, MediaHeader);
|
|
95
|
+
if (!mediaHeader) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
const targetFormatKey = fromFormat(this.requestMetadata.format);
|
|
99
|
+
const segmentFormatKey = fromMediaHeader(mediaHeader);
|
|
100
|
+
if (!this.requestMetadata.isSABR || segmentFormatKey === targetFormatKey) {
|
|
101
|
+
const segmentObj = {
|
|
102
|
+
headerId: mediaHeader.headerId,
|
|
103
|
+
mediaHeader: mediaHeader,
|
|
104
|
+
bufferedChunks: [],
|
|
105
|
+
lastChunkSize: 0
|
|
106
|
+
};
|
|
107
|
+
if (this.desiredHeaderId === undefined) {
|
|
108
|
+
this.desiredHeaderId = mediaHeader.headerId;
|
|
109
|
+
}
|
|
110
|
+
this.partialSegments.set(mediaHeader.headerId, segmentObj);
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
handleMedia(part) {
|
|
115
|
+
const headerId = part.data.getUint8(0);
|
|
116
|
+
const buffer = part.data.split(1).remainingBuffer;
|
|
117
|
+
const segment = this.partialSegments.get(headerId);
|
|
118
|
+
if (segment) {
|
|
119
|
+
segment.lastChunkSize = buffer.getLength();
|
|
120
|
+
for (const chunk of buffer.chunks) {
|
|
121
|
+
segment.bufferedChunks.push(chunk);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
handleMediaEnd(part) {
|
|
127
|
+
const headerId = part.data.getUint8(0);
|
|
128
|
+
const segment = this.partialSegments.get(headerId);
|
|
129
|
+
if (segment && segment.headerId === this.desiredHeaderId) {
|
|
130
|
+
const segmentData = concatenateChunks(segment.bufferedChunks);
|
|
131
|
+
this.requestMetadata.streamInfo = {
|
|
132
|
+
...this.requestMetadata.streamInfo,
|
|
133
|
+
formatInitMetadata: this.formatInitMetadata,
|
|
134
|
+
mediaHeader: segment.mediaHeader
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Cache initialization segments to optimize performance. SABR responses contain larger payloads,
|
|
138
|
+
* and caching the init segment reduces latency when switching between different quality levels
|
|
139
|
+
* or initializing new streams.
|
|
140
|
+
*/
|
|
141
|
+
if (this.cacheManager && this.requestMetadata.isInit && this.requestMetadata.byteRange && this.requestMetadata.format) {
|
|
142
|
+
this.cacheManager.setInitSegment(createSegmentCacheKey(segment.mediaHeader, this.requestMetadata.format), segmentData);
|
|
143
|
+
return {
|
|
144
|
+
data: segmentData.slice(this.requestMetadata.byteRange.start, this.requestMetadata.byteRange.end + 1),
|
|
145
|
+
done: true
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
data: segmentData,
|
|
150
|
+
done: true
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
handleSnackbarMessage(part) {
|
|
155
|
+
const snackbarMessage = this.decodePart(part, SnackbarMessage);
|
|
156
|
+
if (snackbarMessage) {
|
|
157
|
+
this.requestMetadata.streamInfo = {
|
|
158
|
+
...this.requestMetadata.streamInfo,
|
|
159
|
+
snackbarMessage
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
handleSabrError(part) {
|
|
165
|
+
const sabrError = this.decodePart(part, SabrError);
|
|
166
|
+
this.requestMetadata.error = { sabrError };
|
|
167
|
+
return { done: true };
|
|
168
|
+
}
|
|
169
|
+
handleStreamProtectionStatus(part) {
|
|
170
|
+
const streamProtectionStatus = this.decodePart(part, StreamProtectionStatus);
|
|
171
|
+
if (!streamProtectionStatus) {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
this.requestMetadata.streamInfo = {
|
|
175
|
+
...this.requestMetadata.streamInfo,
|
|
176
|
+
streamProtectionStatus
|
|
177
|
+
};
|
|
178
|
+
if (streamProtectionStatus.status === 3) {
|
|
179
|
+
return {
|
|
180
|
+
done: true
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
handleReloadPlayerResponse(part) {
|
|
186
|
+
const reloadPlaybackContext = this.decodePart(part, ReloadPlaybackContext);
|
|
187
|
+
if (!reloadPlaybackContext) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
this.requestMetadata.streamInfo = {
|
|
191
|
+
...this.requestMetadata.streamInfo,
|
|
192
|
+
reloadPlaybackContext
|
|
193
|
+
};
|
|
194
|
+
return {
|
|
195
|
+
done: true
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
handleSabrRedirect(part) {
|
|
199
|
+
const redirect = this.decodePart(part, SabrRedirect);
|
|
200
|
+
if (!redirect) {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
this.requestMetadata.streamInfo = {
|
|
204
|
+
...this.requestMetadata.streamInfo,
|
|
205
|
+
redirect
|
|
206
|
+
};
|
|
207
|
+
// With just UMP, redirects should be followed immediately.
|
|
208
|
+
if (this.requestMetadata.isUMP && !this.requestMetadata.isSABR) {
|
|
209
|
+
return { done: true };
|
|
210
|
+
}
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
handleSabrContextUpdate(part) {
|
|
214
|
+
const sabrContextUpdate = this.decodePart(part, SabrContextUpdate);
|
|
215
|
+
if (sabrContextUpdate) {
|
|
216
|
+
this.requestMetadata.streamInfo = {
|
|
217
|
+
...this.requestMetadata.streamInfo,
|
|
218
|
+
sabrContextUpdate
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
handleSabrContextSendingPolicy(part) {
|
|
224
|
+
const sabrContextSendingPolicy = this.decodePart(part, SabrContextSendingPolicy);
|
|
225
|
+
if (sabrContextSendingPolicy) {
|
|
226
|
+
this.requestMetadata.streamInfo = {
|
|
227
|
+
...this.requestMetadata.streamInfo,
|
|
228
|
+
sabrContextSendingPolicy
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=SabrUmpProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SabrUmpProcessor.js","sourceRoot":"","sources":["../../../src/core/SabrUmpProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,4BAA4B,EAC5B,WAAW,EACX,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,SAAS,EACV,MAAM,oBAAoB,CAAC;AAoB5B;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAqB3B,YACU,eAAoC,EACpC,YAA2B;QAD3B,oBAAe,GAAf,eAAe,CAAqB;QACpC,iBAAY,GAAZ,YAAY,CAAe;QArBpB,uBAAkB,GAAmC,EAAE,CAAC;QAEjE,oBAAe,GAAG,IAAI,GAAG,EAAmB,CAAC;QAEpC,oBAAe,GAAG,IAAI,GAAG,CAA4B;YACpE,CAAE,SAAS,CAAC,8BAA8B,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE;YACtF,CAAE,SAAS,CAAC,mBAAmB,EAAE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE;YAC1E,CAAE,SAAS,CAAC,UAAU,EAAE,I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IAAI,CAAC,eAAe,CAAC,UAAU;gBAClC,iBAAiB;aAClB,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,8BAA8B,CAAC,IAAU;QAC/C,MAAM,wBAAwB,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;QACjF,IAAI,wBAAwB,EAAE,CAAC;YAC7B,IAAI,CAAC,eAAe,CAAC,UAAU,GAAG;gBAChC,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU;gBAClC,wBAAwB;aACzB,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CompositeBuffer } from './CompositeBuffer.js';
|
|
2
|
+
import type { Part } from '../types/shared.js';
|
|
3
|
+
export declare class UmpReader {
|
|
4
|
+
private compositeBuffer;
|
|
5
|
+
constructor(compositeBuffer: CompositeBuffer);
|
|
6
|
+
/**
|
|
7
|
+
* Parses parts from the buffer and calls the handler for each complete part.
|
|
8
|
+
* @param handlePart - Function called with each complete part.
|
|
9
|
+
* @returns Partial part if parsing is incomplete, undefined otherwise.
|
|
10
|
+
*/
|
|
11
|
+
read(handlePart: (part: Part) => void): Part | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Reads a variable-length integer from the buffer.
|
|
14
|
+
* @param offset - Position to start reading from.
|
|
15
|
+
* @returns Tuple of [value, new offset] or [-1, offset] if incomplete.
|
|
16
|
+
*/
|
|
17
|
+
readVarInt(offset: number): [number, number];
|
|
18
|
+
/**
|
|
19
|
+
* Checks if the specified bytes can be read from the current chunk.
|
|
20
|
+
* @param offset - Position to start reading from.
|
|
21
|
+
* @param length - Number of bytes to read.
|
|
22
|
+
* @returns True if bytes can be read from current chunk, false otherwise.
|
|
23
|
+
*/
|
|
24
|
+
canReadFromCurrentChunk(offset: number, length: number): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Gets a DataView of the current chunk, creating it if necessary.
|
|
27
|
+
* @returns DataView for the current chunk.
|
|
28
|
+
*/
|
|
29
|
+
getCurrentDataView(): DataView;
|
|
30
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export class UmpReader {
|
|
2
|
+
constructor(compositeBuffer) {
|
|
3
|
+
this.compositeBuffer = compositeBuffer;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parses parts from the buffer and calls the handler for each complete part.
|
|
7
|
+
* @param handlePart - Function called with each complete part.
|
|
8
|
+
* @returns Partial part if parsing is incomplete, undefined otherwise.
|
|
9
|
+
*/
|
|
10
|
+
read(handlePart) {
|
|
11
|
+
while (true) {
|
|
12
|
+
let offset = 0;
|
|
13
|
+
const [partType, newOffset] = this.readVarInt(offset);
|
|
14
|
+
offset = newOffset;
|
|
15
|
+
const [partSize, finalOffset] = this.readVarInt(offset);
|
|
16
|
+
offset = finalOffset;
|
|
17
|
+
if (partType < 0 || partSize < 0)
|
|
18
|
+
break;
|
|
19
|
+
if (!this.compositeBuffer.canReadBytes(offset, partSize)) {
|
|
20
|
+
if (!this.compositeBuffer.canReadBytes(offset, 1))
|
|
21
|
+
break;
|
|
22
|
+
return {
|
|
23
|
+
type: partType,
|
|
24
|
+
size: partSize,
|
|
25
|
+
data: this.compositeBuffer
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const splitResult = this.compositeBuffer.split(offset).remainingBuffer.split(partSize);
|
|
29
|
+
offset = 0;
|
|
30
|
+
handlePart({
|
|
31
|
+
type: partType,
|
|
32
|
+
size: partSize,
|
|
33
|
+
data: splitResult.extractedBuffer
|
|
34
|
+
});
|
|
35
|
+
this.compositeBuffer = splitResult.remainingBuffer;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reads a variable-length integer from the buffer.
|
|
40
|
+
* @param offset - Position to start reading from.
|
|
41
|
+
* @returns Tuple of [value, new offset] or [-1, offset] if incomplete.
|
|
42
|
+
*/
|
|
43
|
+
readVarInt(offset) {
|
|
44
|
+
let byteLength;
|
|
45
|
+
// Determine the length of the val
|
|
46
|
+
if (this.compositeBuffer.canReadBytes(offset, 1)) {
|
|
47
|
+
const firstByte = this.compositeBuffer.getUint8(offset);
|
|
48
|
+
byteLength = firstByte < 128 ? 1 : firstByte < 192 ? 2 : firstByte < 224 ? 3 : firstByte < 240 ? 4 : 5;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
byteLength = 0;
|
|
52
|
+
}
|
|
53
|
+
if (byteLength < 1 || !this.compositeBuffer.canReadBytes(offset, byteLength)) {
|
|
54
|
+
return [-1, offset];
|
|
55
|
+
}
|
|
56
|
+
let value;
|
|
57
|
+
// Now read it based on the length
|
|
58
|
+
switch (byteLength) {
|
|
59
|
+
case 1:
|
|
60
|
+
value = this.compositeBuffer.getUint8(offset++);
|
|
61
|
+
break;
|
|
62
|
+
case 2: {
|
|
63
|
+
const byte1 = this.compositeBuffer.getUint8(offset++);
|
|
64
|
+
const byte2 = this.compositeBuffer.getUint8(offset++);
|
|
65
|
+
value = (byte1 & 0x3f) + 64 * byte2;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case 3: {
|
|
69
|
+
const byte1 = this.compositeBuffer.getUint8(offset++);
|
|
70
|
+
const byte2 = this.compositeBuffer.getUint8(offset++);
|
|
71
|
+
const byte3 = this.compositeBuffer.getUint8(offset++);
|
|
72
|
+
value = (byte1 & 0x1f) + 32 * (byte2 + 256 * byte3);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case 4: {
|
|
76
|
+
const byte1 = this.compositeBuffer.getUint8(offset++);
|
|
77
|
+
const byte2 = this.compositeBuffer.getUint8(offset++);
|
|
78
|
+
const byte3 = this.compositeBuffer.getUint8(offset++);
|
|
79
|
+
const byte4 = this.compositeBuffer.getUint8(offset++);
|
|
80
|
+
value = (byte1 & 0x0f) + 16 * (byte2 + 256 * (byte3 + 256 * byte4));
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
default: {
|
|
84
|
+
const tempOffset = offset + 1;
|
|
85
|
+
this.compositeBuffer.focus(tempOffset);
|
|
86
|
+
if (this.canReadFromCurrentChunk(tempOffset, 4)) {
|
|
87
|
+
value = this.getCurrentDataView().getUint32(tempOffset - this.compositeBuffer.currentChunkOffset, true);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const byte3 = this.compositeBuffer.getUint8(tempOffset + 2) + 256 * this.compositeBuffer.getUint8(tempOffset + 3);
|
|
91
|
+
value =
|
|
92
|
+
this.compositeBuffer.getUint8(tempOffset) +
|
|
93
|
+
256 * (this.compositeBuffer.getUint8(tempOffset + 1) + 256 * byte3);
|
|
94
|
+
}
|
|
95
|
+
offset += 5;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return [value, offset];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Checks if the specified bytes can be read from the current chunk.
|
|
103
|
+
* @param offset - Position to start reading from.
|
|
104
|
+
* @param length - Number of bytes to read.
|
|
105
|
+
* @returns True if bytes can be read from current chunk, false otherwise.
|
|
106
|
+
*/
|
|
107
|
+
canReadFromCurrentChunk(offset, length) {
|
|
108
|
+
return offset - this.compositeBuffer.currentChunkOffset + length <= this.compositeBuffer.chunks[this.compositeBuffer.currentChunkIndex].length;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Gets a DataView of the current chunk, creating it if necessary.
|
|
112
|
+
* @returns DataView for the current chunk.
|
|
113
|
+
*/
|
|
114
|
+
getCurrentDataView() {
|
|
115
|
+
if (!this.compositeBuffer.currentDataView) {
|
|
116
|
+
const currentChunk = this.compositeBuffer.chunks[this.compositeBuffer.currentChunkIndex];
|
|
117
|
+
this.compositeBuffer.currentDataView = new DataView(currentChunk.buffer, currentChunk.byteOffset, currentChunk.length);
|
|
118
|
+
}
|
|
119
|
+
return this.compositeBuffer.currentDataView;
|
|
120
|
+
}
|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,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;QACzH,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CompositeBuffer } from './CompositeBuffer.js';
|
|
2
|
+
export declare class UmpWriter {
|
|
3
|
+
private compositeBuffer;
|
|
4
|
+
constructor(compositeBuffer: CompositeBuffer);
|
|
5
|
+
/**
|
|
6
|
+
* Writes a part to the buffer.
|
|
7
|
+
* @param partType - The type of the part.
|
|
8
|
+
* @param partData - The data of the part.
|
|
9
|
+
*/
|
|
10
|
+
write(partType: number, partData: Uint8Array): void;
|
|
11
|
+
/**
|
|
12
|
+
* Writes a variable-length integer to the buffer.
|
|
13
|
+
* @param value - The integer to write.
|
|
14
|
+
*/
|
|
15
|
+
private writeVarInt;
|
|
16
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export class UmpWriter {
|
|
2
|
+
constructor(compositeBuffer) {
|
|
3
|
+
this.compositeBuffer = compositeBuffer;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Writes a part to the buffer.
|
|
7
|
+
* @param partType - The type of the part.
|
|
8
|
+
* @param partData - The data of the part.
|
|
9
|
+
*/
|
|
10
|
+
write(partType, partData) {
|
|
11
|
+
const partSize = partData.length;
|
|
12
|
+
this.writeVarInt(partType);
|
|
13
|
+
this.writeVarInt(partSize);
|
|
14
|
+
this.compositeBuffer.append(partData);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Writes a variable-length integer to the buffer.
|
|
18
|
+
* @param value - The integer to write.
|
|
19
|
+
*/
|
|
20
|
+
writeVarInt(value) {
|
|
21
|
+
if (value < 0)
|
|
22
|
+
throw new Error('VarInt value cannot be negative.');
|
|
23
|
+
if (value < 128) {
|
|
24
|
+
this.compositeBuffer.append(new Uint8Array([value]));
|
|
25
|
+
}
|
|
26
|
+
else if (value < 16384) {
|
|
27
|
+
this.compositeBuffer.append(new Uint8Array([
|
|
28
|
+
(value & 0x3F) | 0x80,
|
|
29
|
+
value >> 6
|
|
30
|
+
]));
|
|
31
|
+
}
|
|
32
|
+
else if (value < 2097152) {
|
|
33
|
+
this.compositeBuffer.append(new Uint8Array([
|
|
34
|
+
(value & 0x1F) | 0xC0,
|
|
35
|
+
(value >> 5) & 0xFF,
|
|
36
|
+
value >> 13
|
|
37
|
+
]));
|
|
38
|
+
}
|
|
39
|
+
else if (value < 268435456) {
|
|
40
|
+
this.compositeBuffer.append(new Uint8Array([
|
|
41
|
+
(value & 0x0F) | 0xE0,
|
|
42
|
+
(value >> 4) & 0xFF,
|
|
43
|
+
(value >> 12) & 0xFF,
|
|
44
|
+
value >> 20
|
|
45
|
+
]));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const data = new Uint8Array(5);
|
|
49
|
+
const view = new DataView(data.buffer);
|
|
50
|
+
data[0] = 0xF0;
|
|
51
|
+
view.setUint32(1, value, true);
|
|
52
|
+
this.compositeBuffer.append(data);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=UmpWriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UmpWriter.js","sourceRoot":"","sources":["../../../src/core/UmpWriter.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,SAAS;IACpB,YACU,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IACtC,CAAC;IAEL;;;;OAIG;IACI,KAAK,CAAC,QAAgB,EAAE,QAAoB;QACjD,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC3B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC3B,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,QA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,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;YACf,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC/B,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../utils/Protos.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protos.js","sourceRoot":"","sources":["../../../src/exports/protos.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sabr-stream.js","sourceRoot":"","sources":["../../../src/exports/sabr-stream.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sabr-streaming-adapter.js","sourceRoot":"","sources":["../../../src/exports/sabr-streaming-adapter.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ump.js","sourceRoot":"","sources":["../../../src/exports/ump.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../utils/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/exports/utils.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { SabrStreamState } from '../core/SabrStream.js';
|
|
2
|
+
import type { FetchFunction, SabrFormat } from './shared.js';
|
|
3
|
+
import type { EnabledTrackTypes } from '../utils/index.js';
|
|
4
|
+
import type { ClientInfo } from '../utils/Protos.js';
|
|
5
|
+
export interface SabrStreamConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Custom fetch implementation to use for HTTP requests.
|
|
8
|
+
* If not provided, the global `fetch` function will be used.
|
|
9
|
+
*/
|
|
10
|
+
fetch?: FetchFunction;
|
|
11
|
+
/**
|
|
12
|
+
* The URL endpoint for server-side ABR streaming requests.
|
|
13
|
+
* This is typically obtained from the initial player response.
|
|
14
|
+
*/
|
|
15
|
+
serverAbrStreamingUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Base64-encoded Ustreamer configuration obtained from the player response.
|
|
18
|
+
* Required for authorizing and configuring the streaming session.
|
|
19
|
+
*/
|
|
20
|
+
videoPlaybackUstreamerConfig?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Client information used to identify the requesting device/app.
|
|
23
|
+
* Contains details like client name, version, and capabilities.
|
|
24
|
+
*/
|
|
25
|
+
clientInfo?: ClientInfo;
|
|
26
|
+
/**
|
|
27
|
+
* Proof of Origin token for content protection verification.
|
|
28
|
+
*/
|
|
29
|
+
poToken?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Total duration of the media content in milliseconds.
|
|
32
|
+
* If not provided, will be determined from format metadata.
|
|
33
|
+
*/
|
|
34
|
+
durationMs?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Array of available streaming formats obtained from the player response.
|
|
37
|
+
*/
|
|
38
|
+
formats?: SabrFormat[];
|
|
39
|
+
}
|
|
40
|
+
export interface SabrPlaybackOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Video format selection, can be a format ID number, a SabrFormat object,
|
|
43
|
+
* or a function that selects a format from the available formats array.
|
|
44
|
+
*/
|
|
45
|
+
videoFormat?: number | SabrFormat | ((formats: SabrFormat[]) => SabrFormat | undefined);
|
|
46
|
+
/**
|
|
47
|
+
* Audio format selection, can be a format ID number, a SabrFormat object,
|
|
48
|
+
* or a function that selects a format from the available formats array.
|
|
49
|
+
*/
|
|
50
|
+
audioFormat?: number | SabrFormat | ((formats: SabrFormat[]) => SabrFormat | undefined);
|
|
51
|
+
/**
|
|
52
|
+
* Preferred video quality (e.g., "1080p", "720p").
|
|
53
|
+
*/
|
|
54
|
+
videoQuality?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Preferred audio quality (e.g., "high", "medium").
|
|
57
|
+
*/
|
|
58
|
+
audioQuality?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Preferred video language code.
|
|
61
|
+
*/
|
|
62
|
+
videoLanguage?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Preferred audio language code.
|
|
65
|
+
*/
|
|
66
|
+
audioLanguage?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to prefer WebM container format.
|
|
69
|
+
*/
|
|
70
|
+
preferWebM?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether to prefer MP4 container format.
|
|
73
|
+
*/
|
|
74
|
+
preferMP4?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Whether to prefer H.264 video codec.
|
|
77
|
+
*/
|
|
78
|
+
preferH264?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Whether to prefer Opus audio codec.
|
|
81
|
+
*/
|
|
82
|
+
preferOpus?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Maximum number of retry attempts when fetching segments.
|
|
85
|
+
* Default is 10.
|
|
86
|
+
*/
|
|
87
|
+
maxRetries?: number;
|
|
88
|
+
/**
|
|
89
|
+
* Duration in milliseconds after which a stall is detected if no progress is made.
|
|
90
|
+
* Default is 30000 (30 seconds).
|
|
91
|
+
*/
|
|
92
|
+
stallDetectionMs?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Enabled track types for streaming (audio only, video only, or both).
|
|
95
|
+
* @see EnabledTrackTypes
|
|
96
|
+
*/
|
|
97
|
+
enabledTrackTypes?: EnabledTrackTypes;
|
|
98
|
+
/**
|
|
99
|
+
* Previously saved state to resume a download.
|
|
100
|
+
*/
|
|
101
|
+
state?: SabrStreamState;
|
|
102
|
+
}
|