Skip to content

Commit 509d481

Browse files
committed
Improved core config jsdoc
1 parent 898bd05 commit 509d481

File tree

1 file changed

+161
-0
lines changed
  • packages/p2p-media-loader-core/src

1 file changed

+161
-0
lines changed

packages/p2p-media-loader-core/src/types.ts

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,185 @@ export type DynamicCoreConfig = Partial<
6161
* Configuration options for the Core functionality, including network and processing parameters.
6262
*/
6363
export type CoreConfig = {
64+
/** Time window to consider for high demand scenarios, in milliseconds.
65+
*
66+
* @default
67+
* ```typescript
68+
* highDemandTimeWindow: 15
69+
* ```
70+
*/
6471
highDemandTimeWindow: number;
72+
73+
/** Time window for HTTP downloads, in milliseconds.
74+
*
75+
* @default
76+
* ```typescript
77+
* httpDownloadTimeWindow: 45
78+
* ```
79+
*/
6580
httpDownloadTimeWindow: number;
81+
82+
/** Time window for P2P downloads, in milliseconds.
83+
*
84+
* @default
85+
* ```typescript
86+
* p2pDownloadTimeWindow: 45
87+
* ```
88+
*/
6689
p2pDownloadTimeWindow: number;
90+
91+
/** Maximum number of simultaneous HTTP downloads allowed.
92+
*
93+
* @default
94+
* ```typescript
95+
* simultaneousHttpDownloads: 3
96+
* ```
97+
*/
6798
simultaneousHttpDownloads: number;
99+
100+
/** Maximum number of simultaneous P2P downloads allowed.
101+
*
102+
* @default
103+
* ```typescript
104+
* simultaneousP2PDownloads: 3
105+
* ```
106+
*/
68107
simultaneousP2PDownloads: number;
108+
109+
/** Time after which a cached segment expires, in milliseconds.
110+
*
111+
* @default
112+
* ```typescript
113+
* cachedSegmentExpiration: 120 * 1000
114+
* ```
115+
*/
69116
cachedSegmentExpiration: number;
117+
118+
/** Maximum number of segments to store in the cache.
119+
*
120+
* @default
121+
* ```typescript
122+
* cachedSegmentsCount: 50
123+
* ```
124+
*/
70125
cachedSegmentsCount: number;
126+
127+
/** Maximum message size for WebRTC communications, in bytes.
128+
*
129+
* @default
130+
* ```typescript
131+
* webRtcMaxMessageSize: 64 * 1024 - 1
132+
* ```
133+
*/
71134
webRtcMaxMessageSize: number;
135+
136+
/** Timeout for not receiving bytes from P2P, in milliseconds.
137+
*
138+
* @default
139+
* ```typescript
140+
* p2pNotReceivingBytesTimeoutMs: 1000
141+
* ```
142+
*/
72143
p2pNotReceivingBytesTimeoutMs: number;
144+
145+
/** Timeout for destroying the P2P loader if inactive, in milliseconds.
146+
*
147+
* @default
148+
* ```typescript
149+
* p2pLoaderDestroyTimeoutMs: 30 * 1000
150+
* ```
151+
*/
73152
p2pLoaderDestroyTimeoutMs: number;
153+
154+
/** Timeout for not receiving bytes from HTTP downloads, in milliseconds.
155+
*
156+
* @default
157+
* ```typescript
158+
* httpNotReceivingBytesTimeoutMs: 1000
159+
* ```
160+
*/
74161
httpNotReceivingBytesTimeoutMs: number;
162+
163+
/** Number of retries allowed after an HTTP error.
164+
*
165+
* @default
166+
* ```typescript
167+
* httpErrorRetries: 3
168+
* ```
169+
*/
75170
httpErrorRetries: number;
171+
172+
/** Number of retries allowed after a P2P error.
173+
*
174+
* @default
175+
* ```typescript
176+
* p2pErrorRetries: 3
177+
* ```
178+
*/
76179
p2pErrorRetries: number;
180+
181+
/**
182+
* List of URLs to the trackers used for announcing and discovering peers.
183+
*
184+
* @default
185+
* The default trackers used are:
186+
* ```typescript
187+
* [
188+
* "wss://tracker.openwebtorrent.com",
189+
* "wss://tracker.novage.com.ua",
190+
* ]
191+
* ```
192+
*/
77193
announceTrackers: string[];
194+
195+
/**
196+
* Configuration for the RTC layer, used in WebRTC communication.
197+
* This configuration specifies the STUN/TURN servers used by WebRTC to establish connections through NATs and firewalls.
198+
*
199+
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration
200+
*
201+
* @default
202+
* ```json
203+
* {
204+
* "rtcConfig": {
205+
* "iceServers": [
206+
* { "urls": "stun:stun.l.google.com:19302" },
207+
* { "urls": "stun:global.stun.twilio.com:3478" }
208+
* ]
209+
* }
210+
* }
211+
* ```
212+
*/
78213
rtcConfig: RTCConfiguration;
214+
215+
/** Prefix to use for the client version in tracker communications.
216+
*
217+
* @default
218+
* ```typescript
219+
* trackerClientVersionPrefix: "PM0100" // PM + VERSION
220+
* ```
221+
*/
79222
trackerClientVersionPrefix: string;
223+
224+
/** Optional unique identifier for the swarm, used to isolate peer pools. */
80225
swarmId?: string;
226+
227+
/**
228+
* Optional function to validate a P2P segment before fully integrating it into the playback buffer.
229+
* @param url URL of the segment to validate.
230+
* @param byteRange Optional range of bytes to validate within the segment.
231+
* @returns A promise that resolves with a boolean indicating if the segment is valid.
232+
*/
81233
validateP2PSegment?: (url: string, byteRange?: ByteRange) => Promise<boolean>;
234+
235+
/**
236+
* Optional function to customize the setup of HTTP requests for segment downloads.
237+
* @param segmentUrl URL of the segment.
238+
* @param segmentByteRange The range of bytes requested for the segment.
239+
* @param requestAbortSignal An abort signal to cancel the request if needed.
240+
* @param requestByteRange Additional byte range for partial requests, if required.
241+
* @returns A promise that resolves with the configured request, or undefined if no request should be made.
242+
*/
82243
httpRequestSetup?: (
83244
segmentUrl: string,
84245
segmentByteRange: ByteRange | undefined,

0 commit comments

Comments
 (0)