@meshstream/p2p-web 0.0.0-stage → 0.2.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/README.md +497 -2
- package/dist/adapters.d.ts +140 -0
- package/dist/adapters.js +1 -0
- package/dist/advanced.d.ts +1 -0
- package/dist/advanced.js +1 -0
- package/dist/capabilities.d.ts +27 -0
- package/dist/config.d.ts +100 -0
- package/dist/dash-p2p.d.ts +116 -0
- package/dist/dash.d.ts +110 -0
- package/dist/dashjs-p2p.d.ts +222 -0
- package/dist/direct-file.d.ts +8 -0
- package/dist/fallback.d.ts +35 -0
- package/dist/hls.d.ts +157 -0
- package/dist/ice.d.ts +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -0
- package/dist/meshstream-sw.d.ts +0 -0
- package/dist/meshstream-sw.js +1 -0
- package/dist/origin-headers.d.ts +36 -0
- package/dist/playback-auth.d.ts +14 -0
- package/dist/playback-lifecycle.d.ts +11 -0
- package/dist/player.d.ts +160 -0
- package/dist/public-capabilities.d.ts +11 -0
- package/dist/qoe.d.ts +25 -0
- package/dist/report.d.ts +140 -0
- package/dist/rx-player.d.ts +163 -0
- package/dist/segment-storage.d.ts +31 -0
- package/dist/service-worker-p2p.d.ts +166 -0
- package/dist/service-worker.d.ts +113 -0
- package/dist/service-worker.js +1 -0
- package/dist/session-token.d.ts +47 -0
- package/dist/url.d.ts +38 -0
- package/dist/vendor/meshstream-p2p-core.d.ts +536 -0
- package/dist/version.d.ts +2 -0
- package/package.json +53 -6
- package/src/vendor/MESHSTREAM_CORE_LICENSE.txt +202 -0
package/dist/hls.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type Hls from "hls.js";
|
|
2
|
+
import { HlsJsP2PEngine } from "p2p-media-loader-hlsjs";
|
|
3
|
+
import type { WebP2pCapabilityResult } from "./capabilities.js";
|
|
4
|
+
import type { SdkConfigResponse } from "./config.js";
|
|
5
|
+
import { type P2pDiagnostics, type P2pStats } from "./report.js";
|
|
6
|
+
import type { MeshStreamPlaybackState } from "./qoe.js";
|
|
7
|
+
import { type OriginHeaders, type OriginHeadersProvider } from "./origin-headers.js";
|
|
8
|
+
export declare const DEFAULT_P2P_STRATEGY: Readonly<{
|
|
9
|
+
uploadSlots: 4;
|
|
10
|
+
downloadSlots: 5;
|
|
11
|
+
simultaneousP2PDownloads: 3;
|
|
12
|
+
httpDownloadInitialTimeoutMs: 0;
|
|
13
|
+
highDemandTimeWindow: 15;
|
|
14
|
+
httpDownloadTimeWindow: 3000;
|
|
15
|
+
p2pDownloadTimeWindow: 6000;
|
|
16
|
+
peerHighDemandTimeWindow: 6;
|
|
17
|
+
peerHttpDownloadTimeWindow: 3000;
|
|
18
|
+
peerP2pDownloadTimeWindow: 12000;
|
|
19
|
+
livePeerHighDemandTimeWindow: 2;
|
|
20
|
+
livePeerHttpDownloadTimeWindow: 4;
|
|
21
|
+
liveSeedCohortCount: 4;
|
|
22
|
+
liveSeedHttpDownloadTimeWindow: 6;
|
|
23
|
+
maxMessageSizeBytes: number;
|
|
24
|
+
p2pNotReceivingBytesTimeoutMs: 2000;
|
|
25
|
+
webRtcConnectionTimeoutMs: 15000;
|
|
26
|
+
}>;
|
|
27
|
+
export interface HlsP2pConfig {
|
|
28
|
+
hlsjsInstance: Hls;
|
|
29
|
+
streamUrl: string;
|
|
30
|
+
contentId?: string;
|
|
31
|
+
originHeaders?: OriginHeaders;
|
|
32
|
+
originHeadersProvider?: OriginHeadersProvider;
|
|
33
|
+
sdkConfig?: Pick<SdkConfigResponse, "applicationId" | "keyId" | "reportUrl" | "trackerUrls" | "primaryTrackerUrl" | "iceServers" | "playbackAuth" | "defaults">;
|
|
34
|
+
trackerUrl?: string;
|
|
35
|
+
trackerUrls?: string[];
|
|
36
|
+
appId?: string;
|
|
37
|
+
sessionId?: string;
|
|
38
|
+
iceServers?: RTCIceServer[];
|
|
39
|
+
p2pEnabled?: boolean;
|
|
40
|
+
httpDownloadInitialTimeoutMs?: number;
|
|
41
|
+
uploadSlots?: number;
|
|
42
|
+
downloadSlots?: number;
|
|
43
|
+
networkType?: string;
|
|
44
|
+
liveWindowBucket?: string;
|
|
45
|
+
capability?: WebP2pCapabilityResult;
|
|
46
|
+
logLevel?: "none" | "error" | "warn" | "info" | "debug";
|
|
47
|
+
sessionTokenManager?: {
|
|
48
|
+
getAuthorizationHeader(): Promise<string | undefined>;
|
|
49
|
+
diagnostics?(): {
|
|
50
|
+
attempts: number;
|
|
51
|
+
successes: number;
|
|
52
|
+
failures: number;
|
|
53
|
+
durationMs: number;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export type P2pUnavailableReason = "NO_PEERS" | "TRACKER_ERROR" | "DISABLED" | "UNSUPPORTED" | "CONFIG_UNAVAILABLE" | "INITIALIZATION_FAILED" | "KEY_P2P_DISABLED" | "QUOTA_EXHAUSTED" | "QUOTA_DISABLED";
|
|
58
|
+
export interface P2pEventListener {
|
|
59
|
+
onStatistics?(stats: P2pStats): void;
|
|
60
|
+
onPlaybackStateChanged?(state: MeshStreamPlaybackState): void;
|
|
61
|
+
onPeerCountChanged?(peerCount: number): void;
|
|
62
|
+
onP2pReady?(): void;
|
|
63
|
+
onP2pUnavailable?(reason: P2pUnavailableReason): void;
|
|
64
|
+
onTrackerError?(totalErrors: number): void;
|
|
65
|
+
onPeerConnectError?(totalErrors: number): void;
|
|
66
|
+
onCdnFallback?(bytes: number): void;
|
|
67
|
+
}
|
|
68
|
+
type PublicEvent = "peer-connect" | "peer-close" | "p2p-download" | "p2p-upload" | "http-download" | "tracker-error" | "segment-error";
|
|
69
|
+
type Listener = (payload: unknown) => void;
|
|
70
|
+
export interface LivePeerHttpSchedulingInput {
|
|
71
|
+
livePeerSchedulingActive: boolean;
|
|
72
|
+
peerHasSegment: boolean;
|
|
73
|
+
p2pSlotsAvailable: boolean;
|
|
74
|
+
previousP2pFailures: number;
|
|
75
|
+
}
|
|
76
|
+
export declare class HlsP2pClient {
|
|
77
|
+
private engine;
|
|
78
|
+
private readonly hlsjsInstance;
|
|
79
|
+
private readonly engineConfig;
|
|
80
|
+
private readonly trackerCandidates;
|
|
81
|
+
private activeTrackerIndex;
|
|
82
|
+
private failoverInFlight;
|
|
83
|
+
private disposed;
|
|
84
|
+
private engineGeneration;
|
|
85
|
+
readonly swarmId: string;
|
|
86
|
+
private readonly streamUrl;
|
|
87
|
+
private readonly contentId?;
|
|
88
|
+
private readonly appId?;
|
|
89
|
+
private readonly keyId?;
|
|
90
|
+
private readonly uploadSlots;
|
|
91
|
+
private readonly downloadSlots;
|
|
92
|
+
private readonly reportIntervalMs;
|
|
93
|
+
private readonly capability?;
|
|
94
|
+
private readonly reportUrl?;
|
|
95
|
+
private readonly sessionId;
|
|
96
|
+
private readonly sessionTokenManager?;
|
|
97
|
+
private readonly startedAtMs;
|
|
98
|
+
private readonly listeners;
|
|
99
|
+
private readonly eventListeners;
|
|
100
|
+
private readonly activePeers;
|
|
101
|
+
private readonly pagehideHandler;
|
|
102
|
+
private reportTimer;
|
|
103
|
+
private reportInFlight;
|
|
104
|
+
private pendingFinalReport;
|
|
105
|
+
private hasReportedContext;
|
|
106
|
+
private eventTimer;
|
|
107
|
+
private p2pEnabled;
|
|
108
|
+
private p2pReady;
|
|
109
|
+
private peerWindowProfile;
|
|
110
|
+
/** Remains unknown until hls.js parses the first media playlist. */
|
|
111
|
+
private playbackIsLive;
|
|
112
|
+
private readonly liveSeedCohort;
|
|
113
|
+
private readonly hlsLivePlaylistHandler;
|
|
114
|
+
private readonly stats;
|
|
115
|
+
private readonly diagnosticState;
|
|
116
|
+
static isSupported(): boolean;
|
|
117
|
+
constructor(config: HlsP2pConfig);
|
|
118
|
+
on(event: PublicEvent, listener: Listener): void;
|
|
119
|
+
off(event: PublicEvent, listener: Listener): void;
|
|
120
|
+
addEventListener(listener: P2pEventListener): void;
|
|
121
|
+
removeEventListener(listener: P2pEventListener): void;
|
|
122
|
+
setP2pEnabled(enabled: boolean): void;
|
|
123
|
+
statistics(): P2pStats;
|
|
124
|
+
diagnostics(): P2pDiagnostics;
|
|
125
|
+
dispose(): void;
|
|
126
|
+
getHlsConfig(): ReturnType<HlsJsP2PEngine["getConfigForHlsJs"]>;
|
|
127
|
+
private emit;
|
|
128
|
+
private bindEvents;
|
|
129
|
+
private createEngine;
|
|
130
|
+
private failoverTracker;
|
|
131
|
+
private notify;
|
|
132
|
+
private notifyPlaybackState;
|
|
133
|
+
private startStatsReporting;
|
|
134
|
+
private applyPeerOptimizedWindows;
|
|
135
|
+
private reportStats;
|
|
136
|
+
private currentLiveLatency;
|
|
137
|
+
private recordLiveLatency;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Restores hls.js's low-latency-safe defaults after the upstream P2P engine
|
|
141
|
+
* expands live sync to the full playlist. Explicit customer hls.js settings
|
|
142
|
+
* remain authoritative, as do server-provided HLS hold-back values.
|
|
143
|
+
*/
|
|
144
|
+
export declare function applyDefaultHlsLiveLatencyPolicy(hls: Pick<Hls, "config" | "userConfig">, isLive: boolean): void;
|
|
145
|
+
/**
|
|
146
|
+
* Elects a stable subset of viewers to retain one additional live fragment.
|
|
147
|
+
* Session-local election avoids a coordination request and never affects VOD.
|
|
148
|
+
*/
|
|
149
|
+
export declare function isLiveSeedCohort(sessionId: string, swarmId: string, cohortCount?: 4): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Keep the CDN as the fallback for an urgent live fragment, but do not race it
|
|
152
|
+
* against a peer that has already announced the fragment. A prior P2P failure
|
|
153
|
+
* is deliberately terminal for this decision so the retry immediately uses
|
|
154
|
+
* HTTP rather than extending a playback stall.
|
|
155
|
+
*/
|
|
156
|
+
export declare function shouldUsePeerForLiveHttpRequest({ livePeerSchedulingActive, peerHasSegment, p2pSlotsAvailable, previousP2pFailures, }: LivePeerHttpSchedulingInput): boolean;
|
|
157
|
+
export {};
|
package/dist/ice.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { attach, attachToHls, attachToRxPlayer, attachToVhs, type MeshStreamAttachOptions, type MeshStreamAttachToHlsOptions, type MeshStreamAttachToRxPlayerOptions, type MeshStreamAttachToVhsOptions, type MeshStreamMediaPlayer, type MeshStreamP2pEventListener, type MeshStreamP2pFallbackReason, type MeshStreamPlaybackStartResult, } from "./adapters.js";
|
|
2
|
+
export { type P2pStats } from "./report.js";
|
|
3
|
+
export { type OriginHeaders, type OriginHeadersProvider, type OriginRequestKind, } from "./origin-headers.js";
|
|
4
|
+
export { MeshStreamDirectFilePlayer } from "./direct-file.js";
|
|
5
|
+
export { getCapability, type MeshStreamCapability } from "./public-capabilities.js";
|
|
6
|
+
export { type MeshStreamPlaybackState, type MeshStreamQoeSnapshot } from "./qoe.js";
|