Repository navigation
v4.0.0
#573
Replies: 1 comment
|
🙏 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary of Major Updates
properties(bitrate, codecs, width, height, ...) to the core, which computes each stream's full identity —identityHash(replacesStream.index),swarmId,streamSwarmId,infoHash— once at registration and freezes it on theStreamobject. Fully wire-compatible with v3: the default derivation is bit-identical (enforced by golden-vector tests), so default-config v4 peers keep sharing swarms with v3 peers.StreamConfig.streamSwarmIdBuildercallback and the Node-safep2p-media-loader-core/serversubpath let a server reproduce the exact infohash every client announces — e.g., to allowlist swarms on a private tracker.Core.addStreamIfNoneExistsnever throws; registration failures (includingstreamSwarmIdBuildercollisions) are reported via the newonStreamRegistrationErrorevent. TheswarmId-only configuration (no manifest URL) now works end to end.StreamWithSegments/SegmentWithStreamare internal; newCore.getStreams()andCore.getStreamSegmentRuntimeIds()cover enumeration and manifest diffing.trackerUrlthe peer was discovered from; the deprecatedSegmentLoadDetails.segmentUrlis removed.^1.7.0(runtime-compatible down to hls.js 1.3, verified by source inspection);wss://tracker.webtorrent.devadded to default trackers; a latent legacy-WebView crash in manifest URL handling fixed.Detailed Changes
1. Core-Owned Stream Identity
Core.addStreamIfNoneExiststakes{ runtimeId, type, properties }(StreamRegistration); the identity fields are computed by the core:Streamtype:Stream.indexis replaced byStream.identityHash; streams also carryproperties(frozen at registration),swarmId,streamSwarmId, andinfoHash— all computed once and immutable.stream-propertiesextractor modules in the hls.js and Shaka integrations, pinned by parity test suites asserting both players derive the sameidentityHashfor equivalent manifest metadata.generateStreamShortId/getStreamSwarmId/getStreamHashand assert the newcomputeStreamIdentityHash/computeStreamSwarmId/computeInfoHashproduce the same literals. No infohash changes unless a customstreamSwarmIdBuilderis configured.2. Predictable Swarm Infohashes (Server-Side)
StreamConfig.streamSwarmIdBuilder: builds a custom stream swarm ID per stream from a rich context (swarmId,streamType, rawproperties,identityHash,defaultStreamSwarmId,peerProtocolVersion). The returned string is hashed into the announced infohash, so it fully defines which swarm the stream's peers join. Validated at registration: must be a non-empty string, and two different stream identities may never collide onto one ID (the guard compares the full(swarmId, type, identityHash)tuple).p2p-media-loader-core/serversubpath (Node.js 16+, ESM — CommonJS projects use dynamicimport()): exportscomputeStreamIdentityHash,computeStreamSwarmId,buildStreamSwarmId,computeInfoHash, andPEER_PROTOCOL_VERSIONso a server can reproduce the exact client-side derivation — with or without a custom builder. See "Predicting swarm infohashes on a server" in the API documentation.swarmIdandstreamSwarmIdBuilderare static-only: identity is derived once at registration, so dynamic configuration updates strip them instead of silently desynchronizing announced swarms.3. Robust, Observable Stream Registration
addStreamIfNoneExistsnever throws: a stream that fails to register (unresolvable swarm ID, invalid or colliding builder output) stays unknown to the core — its segments play through the player's default loader without P2P, other streams are unaffected — and the failure is dispatched via the newonStreamRegistrationErrorevent. A misconfiguredstreamSwarmIdBuilderis now observable in production instead of only in debug logs, and custom integrations can no longer crash their player's manifest parsing on a registration error.swarmId-only configuration: vestigial guards requiringsetManifestResponseUrl()after registration were removed fromloadSegment/isSegmentLoadable, sonew Core({ swarmId })works end to end as documented.MANIFEST_LOADEDURL (post-redirect for any loader honoring theresponse.urlcontract; verified identical in hls.js 1.3.5, 1.6.16, and 1.7.0). This also fixes a latent crash on legacy WebViews withoutxhr.responseURL.4. Public API Sweep
Core.getStreams(): lists all registered streams with their computed identities — e.g., every announced infohash — at any time, not just at registration.Core.getStreamSegmentRuntimeIds(streamRuntimeId): a snapshotReadonlySetof the segment runtime IDs registered for a stream, in registration order — the manifest-diffing workflow that previously required reading the segments map.getStream()/getStreams()results and theonStreamAddedpayload are snapshots without the internal segments registry; streampropertiesare frozen. No core output shares live internal state, so consumers can neither corrupt the registry nor retain the per-stream segment graph in memory.StreamWithSegmentsandSegmentWithStreamare internal types now —Core.getStream()returns the plain stream.TypedErroris documented public API: the base class of all library errors and warnings;err instanceof TypedErrorcatches any of them, with the machine-readabletypediscriminator.5. Consistent Event Payloads
SegmentEventDetails, peer events extendPeerDetails, tracker events extend the newTrackerEventDetails— adding a correlation field to an event family is now a one-line change.PeerDetails.trackerUrl:onPeerConnect,onPeerClose,onPeerError,onPeerWarning, andonPeerConnectErrorall report which tracker the peer was discovered from.onStreamAdded(fired once per registered stream with its computed identity, includinginfoHash) andonStreamRegistrationError(see above).SegmentLoadDetails.segmentUrl— usesegment.url.ByteRange.start/endarereadonly;SegmentResponse.datadocuments that it may alias the P2P-upload cache buffer (copy withdata.slice(0)before transferring to a worker).6. Compatibility & Housekeeping
^1.7.0: adapted to the newly typedNullableNetworkDetailsloader callbacks (nullinstead ofundefined/{}for P2P-served fragments — hls.js's own convention). Verified runtime-compatible with hls.js 1.3.x and 1.6.x by source inspection.wss://tracker.webtorrent.dev.PartialShakaEngineConfig→PartialShakaP2PEngineConfig(Shaka package, matches sibling type names); theSegmentStorageinterface'sstreamIdparameter is renamed tostreamSwarmId(the passed value is unchanged — custom storage implementations keep working).Breaking Changes
Stream.indexStream.identityHashgenerateStreamShortId(props)computeStreamIdentityHash(properties)GenerateStreamShortIdPropsStreamPropertiesStreamWithSegments,SegmentWithStreamCore.getStreamSegmentRuntimeIds()SegmentLoadDetails.segmentUrl(deprecated)segment.urlPartialShakaEngineConfig(shaka package)PartialShakaP2PEngineConfigaddStreamIfNoneExiststhrows on failureonStreamRegistrationError, never throwsswarmIdchangeable via dynamic configDespite the API changes, the wire format is unchanged: v4 clients with default configuration join the same swarms as v3 clients.
Full Changelog: v3.0.1...v4.0.0
This discussion was created from the release v4.0.0.
All reactions