@livepeer-frameworks/player-core 0.0.3
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/dist/cjs/index.js +19493 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.js +19398 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/player.css +2140 -0
- package/dist/types/core/ABRController.d.ts +164 -0
- package/dist/types/core/CodecUtils.d.ts +54 -0
- package/dist/types/core/Disposable.d.ts +61 -0
- package/dist/types/core/EventEmitter.d.ts +73 -0
- package/dist/types/core/GatewayClient.d.ts +144 -0
- package/dist/types/core/InteractionController.d.ts +121 -0
- package/dist/types/core/LiveDurationProxy.d.ts +102 -0
- package/dist/types/core/MetaTrackManager.d.ts +220 -0
- package/dist/types/core/MistReporter.d.ts +163 -0
- package/dist/types/core/MistSignaling.d.ts +148 -0
- package/dist/types/core/PlayerController.d.ts +665 -0
- package/dist/types/core/PlayerInterface.d.ts +230 -0
- package/dist/types/core/PlayerManager.d.ts +182 -0
- package/dist/types/core/PlayerRegistry.d.ts +27 -0
- package/dist/types/core/QualityMonitor.d.ts +184 -0
- package/dist/types/core/ScreenWakeLockManager.d.ts +70 -0
- package/dist/types/core/SeekingUtils.d.ts +142 -0
- package/dist/types/core/StreamStateClient.d.ts +108 -0
- package/dist/types/core/SubtitleManager.d.ts +111 -0
- package/dist/types/core/TelemetryReporter.d.ts +79 -0
- package/dist/types/core/TimeFormat.d.ts +97 -0
- package/dist/types/core/TimerManager.d.ts +83 -0
- package/dist/types/core/UrlUtils.d.ts +81 -0
- package/dist/types/core/detector.d.ts +149 -0
- package/dist/types/core/index.d.ts +49 -0
- package/dist/types/core/scorer.d.ts +167 -0
- package/dist/types/core/selector.d.ts +9 -0
- package/dist/types/index.d.ts +45 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/players/DashJsPlayer.d.ts +102 -0
- package/dist/types/players/HlsJsPlayer.d.ts +70 -0
- package/dist/types/players/MewsWsPlayer/SourceBufferManager.d.ts +119 -0
- package/dist/types/players/MewsWsPlayer/WebSocketManager.d.ts +60 -0
- package/dist/types/players/MewsWsPlayer/index.d.ts +220 -0
- package/dist/types/players/MewsWsPlayer/types.d.ts +89 -0
- package/dist/types/players/MistPlayer.d.ts +25 -0
- package/dist/types/players/MistWebRTCPlayer/index.d.ts +133 -0
- package/dist/types/players/NativePlayer.d.ts +143 -0
- package/dist/types/players/VideoJsPlayer.d.ts +59 -0
- package/dist/types/players/WebCodecsPlayer/JitterBuffer.d.ts +118 -0
- package/dist/types/players/WebCodecsPlayer/LatencyProfiles.d.ts +64 -0
- package/dist/types/players/WebCodecsPlayer/RawChunkParser.d.ts +63 -0
- package/dist/types/players/WebCodecsPlayer/SyncController.d.ts +174 -0
- package/dist/types/players/WebCodecsPlayer/WebSocketController.d.ts +164 -0
- package/dist/types/players/WebCodecsPlayer/index.d.ts +149 -0
- package/dist/types/players/WebCodecsPlayer/polyfills/MediaStreamTrackGenerator.d.ts +105 -0
- package/dist/types/players/WebCodecsPlayer/types.d.ts +395 -0
- package/dist/types/players/WebCodecsPlayer/worker/decoder.worker.d.ts +13 -0
- package/dist/types/players/WebCodecsPlayer/worker/types.d.ts +197 -0
- package/dist/types/players/index.d.ts +14 -0
- package/dist/types/styles/index.d.ts +11 -0
- package/dist/types/types.d.ts +363 -0
- package/dist/types/vanilla/FrameWorksPlayer.d.ts +143 -0
- package/dist/types/vanilla/index.d.ts +19 -0
- package/dist/workers/decoder.worker.js +989 -0
- package/dist/workers/decoder.worker.js.map +1 -0
- package/package.json +80 -0
- package/src/core/ABRController.ts +550 -0
- package/src/core/CodecUtils.ts +257 -0
- package/src/core/Disposable.ts +120 -0
- package/src/core/EventEmitter.ts +113 -0
- package/src/core/GatewayClient.ts +439 -0
- package/src/core/InteractionController.ts +712 -0
- package/src/core/LiveDurationProxy.ts +270 -0
- package/src/core/MetaTrackManager.ts +753 -0
- package/src/core/MistReporter.ts +543 -0
- package/src/core/MistSignaling.ts +346 -0
- package/src/core/PlayerController.ts +2829 -0
- package/src/core/PlayerInterface.ts +432 -0
- package/src/core/PlayerManager.ts +900 -0
- package/src/core/PlayerRegistry.ts +149 -0
- package/src/core/QualityMonitor.ts +597 -0
- package/src/core/ScreenWakeLockManager.ts +163 -0
- package/src/core/SeekingUtils.ts +364 -0
- package/src/core/StreamStateClient.ts +457 -0
- package/src/core/SubtitleManager.ts +297 -0
- package/src/core/TelemetryReporter.ts +308 -0
- package/src/core/TimeFormat.ts +205 -0
- package/src/core/TimerManager.ts +209 -0
- package/src/core/UrlUtils.ts +179 -0
- package/src/core/detector.ts +382 -0
- package/src/core/index.ts +140 -0
- package/src/core/scorer.ts +553 -0
- package/src/core/selector.ts +16 -0
- package/src/global.d.ts +11 -0
- package/src/index.ts +75 -0
- package/src/lib/utils.ts +6 -0
- package/src/players/DashJsPlayer.ts +642 -0
- package/src/players/HlsJsPlayer.ts +483 -0
- package/src/players/MewsWsPlayer/SourceBufferManager.ts +572 -0
- package/src/players/MewsWsPlayer/WebSocketManager.ts +241 -0
- package/src/players/MewsWsPlayer/index.ts +1065 -0
- package/src/players/MewsWsPlayer/types.ts +106 -0
- package/src/players/MistPlayer.ts +188 -0
- package/src/players/MistWebRTCPlayer/index.ts +703 -0
- package/src/players/NativePlayer.ts +820 -0
- package/src/players/VideoJsPlayer.ts +643 -0
- package/src/players/WebCodecsPlayer/JitterBuffer.ts +299 -0
- package/src/players/WebCodecsPlayer/LatencyProfiles.ts +151 -0
- package/src/players/WebCodecsPlayer/RawChunkParser.ts +151 -0
- package/src/players/WebCodecsPlayer/SyncController.ts +456 -0
- package/src/players/WebCodecsPlayer/WebSocketController.ts +564 -0
- package/src/players/WebCodecsPlayer/index.ts +1650 -0
- package/src/players/WebCodecsPlayer/polyfills/MediaStreamTrackGenerator.ts +379 -0
- package/src/players/WebCodecsPlayer/types.ts +542 -0
- package/src/players/WebCodecsPlayer/worker/decoder.worker.ts +1360 -0
- package/src/players/WebCodecsPlayer/worker/types.ts +276 -0
- package/src/players/index.ts +22 -0
- package/src/styles/animations.css +21 -0
- package/src/styles/index.ts +52 -0
- package/src/styles/player.css +2126 -0
- package/src/styles/tailwind.css +1015 -0
- package/src/types.ts +421 -0
- package/src/vanilla/FrameWorksPlayer.ts +367 -0
- package/src/vanilla/index.ts +22 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser and Codec Detection
|
|
3
|
+
* Ported from MistMetaPlayer v3.1.0
|
|
4
|
+
*
|
|
5
|
+
* Detects browser capabilities and codec support
|
|
6
|
+
* Removes legacy IE/Flash detection code
|
|
7
|
+
*/
|
|
8
|
+
import { translateCodec } from './CodecUtils';
|
|
9
|
+
export interface BrowserInfo {
|
|
10
|
+
isChrome: boolean;
|
|
11
|
+
isFirefox: boolean;
|
|
12
|
+
isSafari: boolean;
|
|
13
|
+
isEdge: boolean;
|
|
14
|
+
isAndroid: boolean;
|
|
15
|
+
isIOS: boolean;
|
|
16
|
+
isMobile: boolean;
|
|
17
|
+
supportsMediaSource: boolean;
|
|
18
|
+
supportsWebRTC: boolean;
|
|
19
|
+
supportsWebSocket: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface CodecSupport {
|
|
22
|
+
h264: boolean;
|
|
23
|
+
h265: boolean;
|
|
24
|
+
vp8: boolean;
|
|
25
|
+
vp9: boolean;
|
|
26
|
+
av1: boolean;
|
|
27
|
+
aac: boolean;
|
|
28
|
+
mp3: boolean;
|
|
29
|
+
opus: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Detect browser information
|
|
33
|
+
*/
|
|
34
|
+
export declare function getBrowserInfo(): BrowserInfo;
|
|
35
|
+
export { translateCodec };
|
|
36
|
+
/**
|
|
37
|
+
* Test codec support using MediaSource API
|
|
38
|
+
*/
|
|
39
|
+
export declare function testCodecSupport(mimeType: string, codec: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Get comprehensive codec support info
|
|
42
|
+
*/
|
|
43
|
+
export declare function getCodecSupport(): CodecSupport;
|
|
44
|
+
/**
|
|
45
|
+
* Check if tracks are playable by testing codecs
|
|
46
|
+
*/
|
|
47
|
+
export declare function checkTrackPlayability(tracks: Array<{
|
|
48
|
+
type: string;
|
|
49
|
+
codec: string;
|
|
50
|
+
codecstring?: string;
|
|
51
|
+
init?: string;
|
|
52
|
+
}>, containerType: string): {
|
|
53
|
+
playable: string[];
|
|
54
|
+
supported: string[];
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Check protocol/scheme mismatch (http/https)
|
|
58
|
+
*/
|
|
59
|
+
export declare function checkProtocolMismatch(sourceUrl: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Check if current page is loaded over file://
|
|
62
|
+
*/
|
|
63
|
+
export declare function isFileProtocol(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Get Android version (returns null if not Android)
|
|
66
|
+
*/
|
|
67
|
+
export declare function getAndroidVersion(): number | null;
|
|
68
|
+
/**
|
|
69
|
+
* Browser-specific compatibility checks
|
|
70
|
+
*/
|
|
71
|
+
export declare function getBrowserCompatibility(): {
|
|
72
|
+
supportsNativeHLS: boolean | 0 | null;
|
|
73
|
+
supportsMSE: boolean;
|
|
74
|
+
supportsWebSocket: boolean;
|
|
75
|
+
supportsWebRTC: boolean;
|
|
76
|
+
preferVideoJs: boolean | 0 | null;
|
|
77
|
+
avoidMEWSOnMac: boolean;
|
|
78
|
+
fileProtocolLimitations: boolean;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Codecs that are compatible with WebRTC (WHEP/MistServer native)
|
|
82
|
+
* These are the only codecs that can be used in RTP streams
|
|
83
|
+
*/
|
|
84
|
+
export declare const WEBRTC_COMPATIBLE_CODECS: {
|
|
85
|
+
readonly video: readonly ["H264", "VP8", "VP9", "AV1"];
|
|
86
|
+
readonly audio: readonly ["OPUS", "PCMU", "PCMA", "G711", "G722"];
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Codecs that are explicitly incompatible with WebRTC
|
|
90
|
+
*/
|
|
91
|
+
export declare const WEBRTC_INCOMPATIBLE_CODECS: {
|
|
92
|
+
readonly video: readonly ["HEVC", "H265", "THEORA", "MPEG2"];
|
|
93
|
+
readonly audio: readonly ["AC3", "EAC3", "EC3", "MP3", "FLAC", "VORBIS", "DTS"];
|
|
94
|
+
};
|
|
95
|
+
export interface WebRTCCodecCompatibility {
|
|
96
|
+
/** Whether at least one video track is WebRTC-compatible */
|
|
97
|
+
videoCompatible: boolean;
|
|
98
|
+
/** Whether at least one audio track is WebRTC-compatible (or no audio tracks) */
|
|
99
|
+
audioCompatible: boolean;
|
|
100
|
+
/** Overall compatibility - both video and audio must be compatible */
|
|
101
|
+
compatible: boolean;
|
|
102
|
+
/** List of incompatible codecs found */
|
|
103
|
+
incompatibleCodecs: string[];
|
|
104
|
+
/** Detailed breakdown per track type */
|
|
105
|
+
details: {
|
|
106
|
+
videoTracks: number;
|
|
107
|
+
audioTracks: number;
|
|
108
|
+
compatibleVideoCodecs: string[];
|
|
109
|
+
compatibleAudioCodecs: string[];
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Check if stream tracks are compatible with WebRTC playback
|
|
114
|
+
*
|
|
115
|
+
* Uses RTCRtpReceiver.getCapabilities() to dynamically query browser support,
|
|
116
|
+
* matching the reference MistServer implementation (webrtc.js:38-46).
|
|
117
|
+
*
|
|
118
|
+
* @param tracks - Array of track metadata from MistServer
|
|
119
|
+
* @returns Compatibility assessment
|
|
120
|
+
*/
|
|
121
|
+
export declare function checkWebRTCCodecCompatibility(tracks: Array<{
|
|
122
|
+
type: string;
|
|
123
|
+
codec: string;
|
|
124
|
+
}>): WebRTCCodecCompatibility;
|
|
125
|
+
export interface MSECodecCompatibility {
|
|
126
|
+
/** Whether at least one video track is MSE-compatible in this browser */
|
|
127
|
+
videoCompatible: boolean;
|
|
128
|
+
/** Whether at least one audio track is MSE-compatible in this browser */
|
|
129
|
+
audioCompatible: boolean;
|
|
130
|
+
/** Overall compatibility */
|
|
131
|
+
compatible: boolean;
|
|
132
|
+
/** Codecs that failed browser support test */
|
|
133
|
+
unsupportedCodecs: string[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Check if stream tracks are compatible with MSE playback in this browser
|
|
137
|
+
*
|
|
138
|
+
* Unlike WebRTC, MSE compatibility varies by browser. HEVC works in Safari
|
|
139
|
+
* but not Firefox. This function actually tests MediaSource.isTypeSupported().
|
|
140
|
+
*
|
|
141
|
+
* @param tracks - Array of track metadata
|
|
142
|
+
* @param containerType - MIME type (e.g., 'video/mp4')
|
|
143
|
+
*/
|
|
144
|
+
export declare function checkMSECodecCompatibility(tracks: Array<{
|
|
145
|
+
type: string;
|
|
146
|
+
codec: string;
|
|
147
|
+
codecstring?: string;
|
|
148
|
+
init?: string;
|
|
149
|
+
}>, containerType?: string): MSECodecCompatibility;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Player Management System
|
|
3
|
+
*
|
|
4
|
+
* Exports all core functionality for the FrameWorks player system
|
|
5
|
+
*/
|
|
6
|
+
export * from './detector';
|
|
7
|
+
export * from './scorer';
|
|
8
|
+
export * from './PlayerInterface';
|
|
9
|
+
export { PlayerManager, type PlayerSelection, type PlayerCombination, type PlayerManagerOptions, type PlayerManagerEvents, } from './PlayerManager';
|
|
10
|
+
export * from './PlayerRegistry';
|
|
11
|
+
export { globalPlayerManager, createPlayerManager, ensurePlayersRegistered } from './PlayerRegistry';
|
|
12
|
+
export type { IPlayer, PlayerOptions } from './PlayerInterface';
|
|
13
|
+
export { QualityMonitor, PROTOCOL_THRESHOLDS } from './QualityMonitor';
|
|
14
|
+
export type { QualityMonitorOptions, QualityMonitorState, PlayerProtocol } from './QualityMonitor';
|
|
15
|
+
export { TelemetryReporter } from './TelemetryReporter';
|
|
16
|
+
export type { TelemetryReporterConfig } from './TelemetryReporter';
|
|
17
|
+
export { ABRController } from './ABRController';
|
|
18
|
+
export type { ABRControllerConfig, ABRDecision } from './ABRController';
|
|
19
|
+
export { MetaTrackManager } from './MetaTrackManager';
|
|
20
|
+
export type { MetaTrackManagerConfig, MetaTrackSubscription } from './MetaTrackManager';
|
|
21
|
+
export { TypedEventEmitter } from './EventEmitter';
|
|
22
|
+
export { GatewayClient } from './GatewayClient';
|
|
23
|
+
export type { GatewayClientConfig, GatewayClientEvents, GatewayStatus } from './GatewayClient';
|
|
24
|
+
export { StreamStateClient } from './StreamStateClient';
|
|
25
|
+
export type { StreamStateClientConfig, StreamStateClientEvents } from './StreamStateClient';
|
|
26
|
+
export { PlayerController, buildStreamInfoFromEndpoints, MIST_SOURCE_TYPES, PROTOCOL_TO_MIME, getMimeTypeForProtocol, getSourceTypeInfo, } from './PlayerController';
|
|
27
|
+
export type { PlayerControllerConfig, PlayerControllerEvents } from './PlayerController';
|
|
28
|
+
export { MistReporter } from './MistReporter';
|
|
29
|
+
export type { MistReporterStats, MistReporterOptions, MistReporterInitialReport } from './MistReporter';
|
|
30
|
+
export { MistSignaling } from './MistSignaling';
|
|
31
|
+
export type { MistSignalingConfig, MistSignalingEvents, MistTimeUpdate, MistSignalingState } from './MistSignaling';
|
|
32
|
+
export { LiveDurationProxy, createLiveVideoProxy } from './LiveDurationProxy';
|
|
33
|
+
export type { LiveDurationProxyOptions, LiveDurationState } from './LiveDurationProxy';
|
|
34
|
+
export { TimerManager } from './TimerManager';
|
|
35
|
+
export { BaseDisposable, disposeAll, createCompositeDisposable } from './Disposable';
|
|
36
|
+
export type { Disposable } from './Disposable';
|
|
37
|
+
export { appendUrlParams, parseUrlParams, stripUrlParams, buildUrl, isSecureUrl, httpToWs, wsToHttp, matchPageProtocol, } from './UrlUtils';
|
|
38
|
+
export { translateCodec, isCodecSupported, getBestSupportedTrack, } from './CodecUtils';
|
|
39
|
+
export type { TrackInfo } from './CodecUtils';
|
|
40
|
+
export { SubtitleManager } from './SubtitleManager';
|
|
41
|
+
export type { SubtitleTrackInfo, SubtitleManagerConfig } from './SubtitleManager';
|
|
42
|
+
export { InteractionController } from './InteractionController';
|
|
43
|
+
export type { InteractionControllerConfig, InteractionState } from './InteractionController';
|
|
44
|
+
export { ScreenWakeLockManager } from './ScreenWakeLockManager';
|
|
45
|
+
export type { ScreenWakeLockConfig } from './ScreenWakeLockManager';
|
|
46
|
+
export { LATENCY_TIERS, SPEED_PRESETS, DEFAULT_BUFFER_WINDOW_SEC, getLatencyTier, isMediaStreamSource, supportsPlaybackRate, calculateSeekableRange, canSeekStream, calculateLiveThresholds, calculateIsNearLive, isLiveContent, } from './SeekingUtils';
|
|
47
|
+
export type { LatencyTier, LiveThresholds, SeekableRange, SeekableRangeParams, CanSeekParams, } from './SeekingUtils';
|
|
48
|
+
export { formatTime, formatClockTime, formatTimeDisplay, formatTooltipTime, formatDuration, parseTime, } from './TimeFormat';
|
|
49
|
+
export type { TimeDisplayParams } from './TimeFormat';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Player Scoring System
|
|
3
|
+
* Enhanced from MistMetaPlayer v3.1.0 with reliability and mode-aware scoring
|
|
4
|
+
*
|
|
5
|
+
* Implements the scoring algorithm for player selection with:
|
|
6
|
+
* - Track type scoring
|
|
7
|
+
* - Player priority scoring
|
|
8
|
+
* - Source order scoring
|
|
9
|
+
* - Player reliability scoring (new)
|
|
10
|
+
* - Playback mode bonuses (new)
|
|
11
|
+
* - Protocol-specific routing (new)
|
|
12
|
+
*/
|
|
13
|
+
import type { PlaybackMode } from '../types';
|
|
14
|
+
export interface TrackScore {
|
|
15
|
+
video: number;
|
|
16
|
+
audio: number;
|
|
17
|
+
subtitle: number;
|
|
18
|
+
}
|
|
19
|
+
export interface PlayerScore {
|
|
20
|
+
base: number;
|
|
21
|
+
trackTypes: string[];
|
|
22
|
+
total: number;
|
|
23
|
+
breakdown?: {
|
|
24
|
+
trackScore: number;
|
|
25
|
+
priorityScore: number;
|
|
26
|
+
sourceScore: number;
|
|
27
|
+
reliabilityScore: number;
|
|
28
|
+
modeBonus: number;
|
|
29
|
+
routingBonus: number;
|
|
30
|
+
protocolPenalty: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Default track type scores
|
|
35
|
+
*/
|
|
36
|
+
export declare const DEFAULT_TRACK_SCORES: TrackScore;
|
|
37
|
+
/**
|
|
38
|
+
* Calculate score for supported track types
|
|
39
|
+
*/
|
|
40
|
+
export declare function calculateTrackScore(supportedTracks: string[] | boolean, scores?: TrackScore): number;
|
|
41
|
+
/**
|
|
42
|
+
* Calculate maximum possible score for a stream
|
|
43
|
+
*/
|
|
44
|
+
export declare function calculateMaxScore(availableTracks: string[], scores?: TrackScore): number;
|
|
45
|
+
/**
|
|
46
|
+
* Player priority scoring
|
|
47
|
+
*/
|
|
48
|
+
export declare function calculatePriorityScore(priority: number, maxPriority: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* Source preference scoring based on MistServer ordering
|
|
51
|
+
*/
|
|
52
|
+
export declare function calculateSourceScore(sourceIndex: number, totalSources: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Bandwidth/quality scoring
|
|
55
|
+
*/
|
|
56
|
+
export declare function calculateQualityScore(bandwidth?: number, targetBandwidth?: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* Protocol blacklist - completely excluded from selection
|
|
59
|
+
* These protocols are truly broken and should never be considered.
|
|
60
|
+
*
|
|
61
|
+
* NOTE: Protocols that ARE supported by reference implementation but unreliable
|
|
62
|
+
* should be in PROTOCOL_PENALTIES instead (heavily penalized but still selectable).
|
|
63
|
+
*/
|
|
64
|
+
export declare const PROTOCOL_BLACKLIST: Set<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Check if a protocol is blacklisted
|
|
67
|
+
*/
|
|
68
|
+
export declare function isProtocolBlacklisted(mimeType: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Protocol penalties for problematic protocols (not blacklisted, but deprioritized)
|
|
71
|
+
* These get subtracted from the total score to deprioritize certain protocols.
|
|
72
|
+
*
|
|
73
|
+
* Heavy penalties (0.50+): Reference-supported but consistently unreliable
|
|
74
|
+
* Medium penalties (0.20): Experimental or spotty support
|
|
75
|
+
*/
|
|
76
|
+
export declare const PROTOCOL_PENALTIES: Record<string, number>;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate protocol penalty based on known problematic protocols
|
|
79
|
+
*/
|
|
80
|
+
export declare function calculateProtocolPenalty(mimeType: string): number;
|
|
81
|
+
/**
|
|
82
|
+
* Player reliability scores
|
|
83
|
+
* Based on library maturity, error recovery, and overall stability
|
|
84
|
+
*/
|
|
85
|
+
export declare const PLAYER_RELIABILITY: Record<string, number>;
|
|
86
|
+
/**
|
|
87
|
+
* Calculate player reliability score
|
|
88
|
+
*/
|
|
89
|
+
export declare function calculateReliabilityScore(playerShortname: string): number;
|
|
90
|
+
/**
|
|
91
|
+
* Protocol bonuses for each playback mode
|
|
92
|
+
*
|
|
93
|
+
* IMPORTANT: Track compatibility is enforced by trackScore (50% weight).
|
|
94
|
+
* Mode bonuses (12% weight) only affect ordering among compatible options.
|
|
95
|
+
* A protocol missing required tracks will never be selected regardless of mode bonus.
|
|
96
|
+
*
|
|
97
|
+
* Priority rationale:
|
|
98
|
+
* - Low-latency: WHEP/WebRTC first (<1s), then MP4/WS (2-5s), HLS last (10-30s)
|
|
99
|
+
* - Quality: MP4/WS first (stable + low latency), HLS fallback, WHEP minimal
|
|
100
|
+
* - VOD: MP4/HLS first (seekable), WHEP hard penalty (no seek support)
|
|
101
|
+
* - Auto: MP4/WS balanced choice, WHEP for low latency, HLS last resort
|
|
102
|
+
*/
|
|
103
|
+
export declare const MODE_PROTOCOL_BONUSES: Record<PlaybackMode, Record<string, number>>;
|
|
104
|
+
/**
|
|
105
|
+
* Calculate mode-specific bonus for a protocol
|
|
106
|
+
*/
|
|
107
|
+
export declare function calculateModeBonus(mimeType: string, mode: PlaybackMode): number;
|
|
108
|
+
/**
|
|
109
|
+
* Protocol routing rules - certain players are preferred for certain protocols
|
|
110
|
+
*/
|
|
111
|
+
export declare const PROTOCOL_ROUTING: Record<string, {
|
|
112
|
+
prefer: string[];
|
|
113
|
+
avoid?: string[];
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Calculate routing bonus based on protocol+player pairing
|
|
117
|
+
*/
|
|
118
|
+
export declare function calculateRoutingBonus(mimeType: string, playerShortname: string): number;
|
|
119
|
+
/**
|
|
120
|
+
* Comprehensive player scoring with enhanced factors
|
|
121
|
+
*/
|
|
122
|
+
export declare function scorePlayer(supportedTracks: string[] | boolean, priority: number, sourceIndex: number, options?: {
|
|
123
|
+
maxPriority?: number;
|
|
124
|
+
totalSources?: number;
|
|
125
|
+
trackScores?: Partial<TrackScore>;
|
|
126
|
+
bandwidth?: number;
|
|
127
|
+
targetBandwidth?: number;
|
|
128
|
+
playerShortname?: string;
|
|
129
|
+
mimeType?: string;
|
|
130
|
+
playbackMode?: PlaybackMode;
|
|
131
|
+
weights?: {
|
|
132
|
+
tracks: number;
|
|
133
|
+
priority: number;
|
|
134
|
+
source: number;
|
|
135
|
+
quality: number;
|
|
136
|
+
reliability?: number;
|
|
137
|
+
mode?: number;
|
|
138
|
+
routing?: number;
|
|
139
|
+
protocolPenalty?: number;
|
|
140
|
+
};
|
|
141
|
+
}): PlayerScore;
|
|
142
|
+
/**
|
|
143
|
+
* Compare two player scores
|
|
144
|
+
*/
|
|
145
|
+
export declare function compareScores(a: PlayerScore, b: PlayerScore): number;
|
|
146
|
+
/**
|
|
147
|
+
* Batch score multiple players and return sorted by best score
|
|
148
|
+
*/
|
|
149
|
+
export declare function scoreAndRankPlayers<T extends {
|
|
150
|
+
priority: number;
|
|
151
|
+
}>(players: Array<{
|
|
152
|
+
player: T;
|
|
153
|
+
supportedTracks: string[] | boolean;
|
|
154
|
+
sourceIndex: number;
|
|
155
|
+
}>, options?: Parameters<typeof scorePlayer>[3]): Array<{
|
|
156
|
+
player: T;
|
|
157
|
+
score: PlayerScore;
|
|
158
|
+
}>;
|
|
159
|
+
/**
|
|
160
|
+
* Utility to check if a score meets minimum thresholds
|
|
161
|
+
*/
|
|
162
|
+
export declare function meetsMinimumScore(score: PlayerScore, requirements: {
|
|
163
|
+
minTotal?: number;
|
|
164
|
+
requireVideo?: boolean;
|
|
165
|
+
requireAudio?: boolean;
|
|
166
|
+
minTrackTypes?: number;
|
|
167
|
+
}): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Player Selection Types
|
|
3
|
+
*
|
|
4
|
+
* Re-exports from PlayerManager for backwards compatibility.
|
|
5
|
+
* All selection logic is now consolidated in PlayerManager.
|
|
6
|
+
*/
|
|
7
|
+
export type { PlayerSelection, PlayerCombination, PlayerManagerOptions, } from './PlayerManager';
|
|
8
|
+
import type { PlayerManagerOptions } from './PlayerManager';
|
|
9
|
+
export type SelectionOptions = PlayerManagerOptions;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @livepeer-frameworks/player-core
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic core player logic for FrameWorks streaming.
|
|
5
|
+
* This package provides:
|
|
6
|
+
* - PlayerManager: Intelligent player/protocol selection
|
|
7
|
+
* - PlayerController: High-level player orchestration
|
|
8
|
+
* - GatewayClient: Gateway endpoint resolution
|
|
9
|
+
* - StreamStateClient: MistServer WebSocket/HTTP polling
|
|
10
|
+
* - Quality monitoring, ABR control, interaction handling
|
|
11
|
+
*/
|
|
12
|
+
export { PlayerManager } from './core/PlayerManager';
|
|
13
|
+
export type { PlayerSelection, PlayerCombination, PlayerManagerOptions, PlayerManagerEvents, } from './core/PlayerManager';
|
|
14
|
+
export { PlayerController, buildStreamInfoFromEndpoints } from './core/PlayerController';
|
|
15
|
+
export type { PlayerControllerConfig, PlayerControllerEvents } from './core/PlayerController';
|
|
16
|
+
export { ensurePlayersRegistered, registerAllPlayers, createPlayerManager, globalPlayerManager, globalPlayerManager as globalRegistry } from './core/PlayerRegistry';
|
|
17
|
+
export { GatewayClient } from './core/GatewayClient';
|
|
18
|
+
export * from './players';
|
|
19
|
+
export { StreamStateClient } from './core/StreamStateClient';
|
|
20
|
+
export { QualityMonitor } from './core/QualityMonitor';
|
|
21
|
+
export { ABRController } from './core/ABRController';
|
|
22
|
+
export { InteractionController } from './core/InteractionController';
|
|
23
|
+
export { MistSignaling } from './core/MistSignaling';
|
|
24
|
+
export { MistReporter } from './core/MistReporter';
|
|
25
|
+
export { MetaTrackManager } from './core/MetaTrackManager';
|
|
26
|
+
export type { MetaTrackSubscription } from './core/MetaTrackManager';
|
|
27
|
+
export { SubtitleManager } from './core/SubtitleManager';
|
|
28
|
+
export { LiveDurationProxy } from './core/LiveDurationProxy';
|
|
29
|
+
export { TimerManager } from './core/TimerManager';
|
|
30
|
+
export { TypedEventEmitter, TypedEventEmitter as EventEmitter } from './core/EventEmitter';
|
|
31
|
+
export { TelemetryReporter } from './core/TelemetryReporter';
|
|
32
|
+
export type { IPlayer, PlayerCapability, PlayerEvents } from './core/PlayerInterface';
|
|
33
|
+
export { BasePlayer } from './core/PlayerInterface';
|
|
34
|
+
export type { StreamSource, StreamTrack, StreamInfo, PlayerOptions as CorePlayerOptions } from './core/PlayerInterface';
|
|
35
|
+
export * from './core/scorer';
|
|
36
|
+
export * from './core/selector';
|
|
37
|
+
export * from './core/detector';
|
|
38
|
+
export * from './core/UrlUtils';
|
|
39
|
+
export * from './core/SeekingUtils';
|
|
40
|
+
export type { LatencyTier, LiveThresholds, SeekableRange, SeekableRangeParams, CanSeekParams } from './core/SeekingUtils';
|
|
41
|
+
export * from './core/TimeFormat';
|
|
42
|
+
export type { TimeDisplayParams } from './core/TimeFormat';
|
|
43
|
+
export { ensurePlayerStyles, injectPlayerStyles } from './styles';
|
|
44
|
+
export { cn } from './lib/utils';
|
|
45
|
+
export * from './types';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { BasePlayer } from '../core/PlayerInterface';
|
|
2
|
+
import type { StreamSource, StreamInfo, PlayerOptions, PlayerCapability } from '../core/PlayerInterface';
|
|
3
|
+
export declare class DashJsPlayerImpl extends BasePlayer {
|
|
4
|
+
readonly capability: PlayerCapability;
|
|
5
|
+
private dashPlayer;
|
|
6
|
+
private container;
|
|
7
|
+
private destroyed;
|
|
8
|
+
private debugging;
|
|
9
|
+
private lastProgress;
|
|
10
|
+
private videoProxy;
|
|
11
|
+
private streamType;
|
|
12
|
+
private subsLoaded;
|
|
13
|
+
private pendingSubtitleId;
|
|
14
|
+
isMimeSupported(mimetype: string): boolean;
|
|
15
|
+
isBrowserSupported(mimetype: string, source: StreamSource, streamInfo: StreamInfo): boolean | string[];
|
|
16
|
+
/**
|
|
17
|
+
* Check if current stream is live.
|
|
18
|
+
* Ported from reference dashjs.js live detection.
|
|
19
|
+
*/
|
|
20
|
+
private isLiveStream;
|
|
21
|
+
/**
|
|
22
|
+
* Create a Proxy wrapper for the video element that intercepts duration for live streams.
|
|
23
|
+
* Ported from reference dashjs.js:81-122.
|
|
24
|
+
*
|
|
25
|
+
* For live streams, returns synthetic duration = buffer_end + time_since_last_progress
|
|
26
|
+
* This makes the seek bar usable for live content.
|
|
27
|
+
*/
|
|
28
|
+
private createVideoProxy;
|
|
29
|
+
/**
|
|
30
|
+
* Set up comprehensive event logging.
|
|
31
|
+
* Ported from reference dashjs.js:152-160.
|
|
32
|
+
*/
|
|
33
|
+
private setupEventLogging;
|
|
34
|
+
/**
|
|
35
|
+
* Set up subtitle deferred loading.
|
|
36
|
+
* Ported from reference dashjs.js:173-197.
|
|
37
|
+
*/
|
|
38
|
+
private setupSubtitleHandling;
|
|
39
|
+
/**
|
|
40
|
+
* Set up stalled indicator handling.
|
|
41
|
+
* Ported from reference dashjs.js:207-211.
|
|
42
|
+
*/
|
|
43
|
+
private setupStalledHandling;
|
|
44
|
+
initialize(container: HTMLElement, source: StreamSource, options: PlayerOptions): Promise<HTMLVideoElement>;
|
|
45
|
+
/**
|
|
46
|
+
* Get DASH.js-specific stats for ABR and playback monitoring
|
|
47
|
+
* Updated for dashjs v5 API
|
|
48
|
+
*/
|
|
49
|
+
getStats(): Promise<{
|
|
50
|
+
type: 'dash';
|
|
51
|
+
currentQuality: number;
|
|
52
|
+
bufferLevel: number;
|
|
53
|
+
bitrateInfoList: Array<{
|
|
54
|
+
bitrate: number;
|
|
55
|
+
width: number;
|
|
56
|
+
height: number;
|
|
57
|
+
}>;
|
|
58
|
+
currentBitrate: number;
|
|
59
|
+
playbackRate: number;
|
|
60
|
+
} | undefined>;
|
|
61
|
+
/**
|
|
62
|
+
* Set playback rate
|
|
63
|
+
*/
|
|
64
|
+
setPlaybackRate(rate: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Set source URL for seamless source switching.
|
|
67
|
+
* Ported from reference dashjs.js:166-168.
|
|
68
|
+
*/
|
|
69
|
+
setSource(url: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Get duration using proxy for live streams.
|
|
72
|
+
* Returns synthetic growing duration for live content.
|
|
73
|
+
*/
|
|
74
|
+
getDuration(): number;
|
|
75
|
+
/**
|
|
76
|
+
* Jump to live edge for live streams.
|
|
77
|
+
* Uses DASH.js seekToLive API when available.
|
|
78
|
+
*/
|
|
79
|
+
jumpToLive(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Get latency from live edge (for live streams)
|
|
82
|
+
*/
|
|
83
|
+
getLiveLatency(): number;
|
|
84
|
+
destroy(): Promise<void>;
|
|
85
|
+
getQualities(): Array<{
|
|
86
|
+
id: string;
|
|
87
|
+
label: string;
|
|
88
|
+
bitrate?: number;
|
|
89
|
+
width?: number;
|
|
90
|
+
height?: number;
|
|
91
|
+
isAuto?: boolean;
|
|
92
|
+
active?: boolean;
|
|
93
|
+
}>;
|
|
94
|
+
selectQuality(id: string): void;
|
|
95
|
+
getTextTracks(): Array<{
|
|
96
|
+
id: string;
|
|
97
|
+
label: string;
|
|
98
|
+
lang?: string;
|
|
99
|
+
active: boolean;
|
|
100
|
+
}>;
|
|
101
|
+
selectTextTrack(id: string | null): void;
|
|
102
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BasePlayer } from '../core/PlayerInterface';
|
|
2
|
+
import type { StreamSource, StreamInfo, PlayerOptions, PlayerCapability } from '../core/PlayerInterface';
|
|
3
|
+
export declare class HlsJsPlayerImpl extends BasePlayer {
|
|
4
|
+
readonly capability: PlayerCapability;
|
|
5
|
+
private hls;
|
|
6
|
+
private container;
|
|
7
|
+
private failureCount;
|
|
8
|
+
private destroyed;
|
|
9
|
+
private liveDurationProxy;
|
|
10
|
+
isMimeSupported(mimetype: string): boolean;
|
|
11
|
+
isBrowserSupported(mimetype: string, source: StreamSource, streamInfo: StreamInfo): boolean | string[];
|
|
12
|
+
initialize(container: HTMLElement, source: StreamSource, options: PlayerOptions): Promise<HTMLVideoElement>;
|
|
13
|
+
destroy(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the calculated duration for live streams
|
|
16
|
+
* Falls back to native duration for VOD
|
|
17
|
+
*/
|
|
18
|
+
getDuration(): number;
|
|
19
|
+
/**
|
|
20
|
+
* Check if the stream is live
|
|
21
|
+
*/
|
|
22
|
+
isLiveStream(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Seek to a position with live-aware constraints
|
|
25
|
+
*/
|
|
26
|
+
seek(time: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Jump to live edge
|
|
29
|
+
* Uses HLS.js liveSyncPosition when available (more accurate)
|
|
30
|
+
*/
|
|
31
|
+
jumpToLive(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get latency from live edge (for live streams)
|
|
34
|
+
*/
|
|
35
|
+
getLiveLatency(): number;
|
|
36
|
+
getQualities(): Array<{
|
|
37
|
+
id: string;
|
|
38
|
+
label: string;
|
|
39
|
+
bitrate?: number;
|
|
40
|
+
width?: number;
|
|
41
|
+
height?: number;
|
|
42
|
+
isAuto?: boolean;
|
|
43
|
+
active?: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
selectQuality(id: string): void;
|
|
46
|
+
getTextTracks(): Array<{
|
|
47
|
+
id: string;
|
|
48
|
+
label: string;
|
|
49
|
+
lang?: string;
|
|
50
|
+
active: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
selectTextTrack(id: string | null): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get HLS.js-specific stats for accurate bitrate and bandwidth
|
|
55
|
+
*/
|
|
56
|
+
getStats(): Promise<{
|
|
57
|
+
type: 'hls';
|
|
58
|
+
bandwidthEstimate: number;
|
|
59
|
+
currentLevel: number;
|
|
60
|
+
currentBitrate: number;
|
|
61
|
+
loadLevel: number;
|
|
62
|
+
levels: Array<{
|
|
63
|
+
bitrate: number;
|
|
64
|
+
width: number;
|
|
65
|
+
height: number;
|
|
66
|
+
}>;
|
|
67
|
+
buffered: number;
|
|
68
|
+
latency?: number;
|
|
69
|
+
} | undefined>;
|
|
70
|
+
}
|