Skip to content

Commit

Permalink
P2P Media Loader v1 (#373)
Browse files Browse the repository at this point in the history
* Use only callbacks instead of promise creation in hls engine.

* Add segment storage initialization.

* Add peer settings options.

* Move storage cleanup logic into storage class.

* Add p2p loaders container.

* Add p2p loaders destroy logic.

* Remove unnecessary toString on string variable.

* Don't use response.arrayBuffer() if getting data from stream.

* Change peer announcement type and corresponding logic.

* Use single PeerRequestError with different types instead of lot of Error classes.

* Change peer announcement type and corresponding logic.

* Remove memory request container counters.

* Remove unnecessary segmentsToDelete from memory segment storage.

* Specific configuration for each separate shaka player instance. (#307)

* Add ability to create multiple shaka p2p-players despite the global shared library configuration.

* Remove unnecessary p2pml assignment.

* Fix issue with typo in "chunk"

* Add ability to subscribe to segments store update.

* Add stale p2p loader destroy timeout.

* Add request container http requests subscriptions.

* Add vite-plugin-node-polyfills to demo.

* Move utils to separate folder.

* Fix issues with abort looping, not handling requests in container.

* Force queue process if playback position was significantly changed.

* Add stream property to segment type.

* Fix issue with fetch result data wrong promise error handling.

* Fix issue with not clearing aborted engine request.

* Add random http loading.

* Change JsonSegmentAnnouncement type.

* Add loading through p2p to process queue.

* Change load method parameter to queue item.

* Add loggers to hybrid loader, p2p-manager.

* Add load probability to http random load.

* Show stat in Demo. Destroy p2p manager if there is no uploadable data.

* Refactor code related to stat components.

* Add loggers select to demo.

* And onPeerClose event to Peer class.

* Fix issue with wrong array buffer slicing. Modify choosing peer connection logic.

* Add peer logger. Use utf-8 string for peer ids instead of hashes.

* Remove ripemd160 package.

* Install node types. Patch bittorrent-tracker. Remove modules ignoring for browsers in bittorrent-tracker package.json.

* Sent ArrayBuffer to peer instead of Buffer. Use custom function to change string from utf-8 to hex.

* Add remain time predicting logic.

* Create universal bandwidth-approximator.

* Add bitrate adaptation logic.

* Rename p2p-loader logger.

* Use simple number variable instead of object creation.

* Modify uploading cancellation logic.

* Broadcast announcement not more than 1 time for macrotask.

* Generate user-friendly stream hash.

* Configure tsconfig module, target options.

* Change event handler name to onSegmentLoaded.

* Add core event handlers to shaka.

* Fix issues with shaka streams playback.

* Revise and refactor code.

* Move p2p files to separate p2p directory.

* Rename request container file and p2p loader and container files.

* Add request-container, storage loggers. Use queueMicrotask instead of setTimeout.

* Fix issue with skipping first segment in queue generation function.

* Add binary serialization functions.

* Remove bits file.

* P2P loader. (#305)

* Fix issue with wrong segment endTime.

* Fix issue with hls wrong segment local id.

* Add linked-map, load queue and http-loader.

* Add load queue class.

* Add segments storage.

* Add segments load logic.

* Add plugin requests promises map.

* Rewrite load queue.

* Move segment queue status determination to queue class.

* Separate main and secondary stream to different contexts.

* Remove unnecessary loader layer.

* Fix issue with not loading after moving playhead to random position.

* Rename hybrid loader file.

* Initialize playback on first segment request by plugin.

* Make storage async. Add core destroy logic.

* Use StreamWithReadonlySegments type in plugins.

* Add bandwidth approximator.

* Refactor load queue code.

* Load controlling: pure functions style. (#302)

* Refactor code, use functional style.

* Add shaka playback update handling.

* Set playback after first segment is requested.

* Remove unnecessary linked map methods.

* Use is loaded callback in queue generating function instead of segment storage instance.

* Install bittorrent-tracker and ripemd160 to core.

* Create type declaration for bittorrent tracker.

* Create P2PLoader and Peer classes.

* Move enums to separate file.

* Remove unused position core property.

* Create secondary hybrid loader only if necessary.

* Add force parameter to process queue hybrid loader method.

* Add sendCommand method to Peer.

* Add request type.

* Create and apply RequestContainer class.

* Rename settings time window properties.

* Add AbortError.

* Add streams map to hybrid loader.

* Add peer self segments map generation logic.

* Notify peers on segment loadings update.

* Fix types issues.

* Add peer events.

* Add downloadSegment method to p2p-loader. Use p2p request type in Peer class.

* Use request container in p2p-loader.

* Add receiving segment chunks logic.

* Reject promise with errors in peer class.

* Rewrite fetch segment with async await.

* Use object with booleans instead of set for segment queue statuses.

* Rename fetch segment function.

* Rename hybrid loader public method.

* Use engine callbacks instead of promise creation in core.

* Remove unnecessary getControlledPromise function from engines.

* Create hybrid loaders when necessary data is already set.

* Add progress to http loading.

* Add progress functionality to Peer class.

* Fix type issues.

* Use only callbacks instead of promise creation in hls engine.

* Add segment storage initialization.

* Add peer settings options.

* Move storage cleanup logic into storage class.

* Add p2p loaders container.

* Add p2p loaders destroy logic.

* Remove unnecessary toString on string variable.

* Don't use response.arrayBuffer() if getting data from stream.

* Change peer announcement type and corresponding logic.

* Use single PeerRequestError with different types instead of lot of Error classes.

* Change peer announcement type and corresponding logic.

* Remove memory request container counters.

* Remove unnecessary segmentsToDelete from memory segment storage.

* Fix issue with typo in "chunk"

* Add ability to subscribe to segments store update.

* Add stale p2p loader destroy timeout.

* Add request container http requests subscriptions.

* Add vite-plugin-node-polyfills to demo.

* Move utils to separate folder.

* Fix issues with abort looping, not handling requests in container.

* Force queue process if playback position was significantly changed.

* Add stream property to segment type.

* Fix issue with fetch result data wrong promise error handling.

* Fix issue with not clearing aborted engine request.

* Add random http loading.

* Change JsonSegmentAnnouncement type.

* Add loading through p2p to process queue.

* Change load method parameter to queue item.

* Add loggers to hybrid loader, p2p-manager.

* Add load probability to http random load.

* Show stat in Demo. Destroy p2p manager if there is no uploadable data.

* Refactor code related to stat components.

* Add loggers select to demo.

* And onPeerClose event to Peer class.

* Fix issue with wrong array buffer slicing. Modify choosing peer connection logic.

* Add peer logger. Use utf-8 string for peer ids instead of hashes.

* Remove ripemd160 package.

* Install node types. Patch bittorrent-tracker. Remove modules ignoring for browsers in bittorrent-tracker package.json.

* Sent ArrayBuffer to peer instead of Buffer. Use custom function to change string from utf-8 to hex.

* Add remain time predicting logic.

* Create universal bandwidth-approximator.

* Add bitrate adaptation logic.

* Rename p2p-loader logger.

* Use simple number variable instead of object creation.

* Modify uploading cancellation logic.

* Broadcast announcement not more than 1 time for macrotask.

* Generate user-friendly stream hash.

* Configure tsconfig module, target options.

* Change event handler name to onSegmentLoaded.

* Add core event handlers to shaka.

* Fix issues with shaka streams playback.

* Revise and refactor code.

* Move p2p files to separate p2p directory.

* Rename request container file and p2p loader and container files.

* Add request-container, storage loggers. Use queueMicrotask instead of setTimeout.

* Fix issue with skipping first segment in queue generation function.

* Add binary serialization functions.

* Remove bits file.

---------

Co-authored-by: Igor Zolotarenko <[email protected]>
Co-authored-by: Andriy Lysnevych <[email protected]>

* Add number and array binary serialization functions.

* Add array compression function.

* Rewrite using bigint.

* Fix issue with wrong bitwise operation.

* Change similar int serialization algorithm.

* Complete similar int array serialization algorithm.

* Refactor code and apply serialization.

* Fix errors.

* Change removing/creating new p2p loader order.

* Add clappr player.

* Add hls.js clappr player.

* Fix eslint warnings.

* Add shaka clappr player.

* Fix lint warnings.

* Disable no explicit any rule for demo.

* Refactor code.

* Change comment.

* Use common approach for hls and dash in shaka.

* Refactor, simplify and optimize getting segment references in shaka-player.

* Safe hls subscription/unsubscription to/from events.

* Clearing and disposing for shaka engine.

* Destroy hls instance.

* Fix type errors.

* Fix bug.

* Delegate control to process queue. (#313)

* Reduce LoadProgress object type.

* Create microtask for process queue.

* Add event dispatcher class.

* Create Request class.

* Move Request file to separate file.

* Change style of bittorrent-tracker declarations event handlers types.

* Create P2PTrackerClient class to encapsulate peer connection logic.

* Add TODO task.

* Add requests error handling.

* Fix types errors.

* P2P announce segments on http requests state change.

* Fix bugs.

* Make broadcastAnnouncement method as function expression.

* Refactor Request code. Create separate flows for each type of abort.

* Remove event subscriptions to request instance.

* Fix type errors.

* Fix bugs.

* Fix lint warnings.

* Move P2P tracker client to separate file.

* Fix more bugs. Rewrite loggers.

* Remove unused code.

* Use function declaration instead of expression.

---------

Co-authored-by: Igor Zolotarenko <[email protected]>

* Compare hls instances on each manifest loading in hls js integration.

* Remove decoration utils.

* Use md5 algorithm. Generate 15 bytes hash (1 byte truncate).

* Use one decimal in segment id. Other truncate.

* Structure binary commands code. Fix bugs.

* Add PeerRequestSegmentCommand.

* Don't add empty arrays to binary command representation.

* Remove inner types file.

* Split too large command buffer into chunks.

* Send split command.

* Receive splited to chunks command.

* Add string serialization.

* Fix bug.

* Cancel last commit changes.

* Fix prettier warnings.

* Add ability to resume segment downloading starting from certain byte.

* Rename file.

* Add peer destroy logger. Fix type error.

* Add errors handling.

* Update dependencies. (#321)

* Update dependencies.

* Check hls.js versions.

---------

Co-authored-by: Igor Zolotarenko <[email protected]>

* Live stream delay. (#318)

* Fix issue with segment index.

* Add try catch block to hook segment index method.

* Fix bug.

* Fix bug.

* Multiply to 2 to get segment id from start time.

* Substitute segment index get method immediately if it already exists.

* Set live edge delay.

* Use more common configuration approach for shaka-player.

* Rename method.

---------

Co-authored-by: Igor Zolotarenko <[email protected]>

* Rename file.

* Refactor http loader. Throw error and clear already loaded data on bytes mismatch.

* Add SegmentDataSendingCompleted command.

* Failed attempts clear interval.

* Throw http unexpected status code error.

* Clear failed attempts list after 60 seconds after last error.

* Fix type error.

* Bandwidth calculator. (#323)

* Rename file.

* Add bandwidth calculator.

* Add bandwidth calculator.

* Git use another approach. Suppress loading intervals together.

* Use time shift instead of loading intervals.

---------

Co-authored-by: Igor Zolotarenko <[email protected]>

* Playhead position change bug. (#324)

* Fix issue with not loading requested by engine segment.

* Fix types error.

* Bandwidth algorithm. (#325)

* Add ability to get bandwidth for last N not spliced seconds.

* Get from engines additional stream info (is live, active stream bandwidth)

* Pass multiple bandwidth calculators of different types to hybrid loader and requests.

* Return generator from generateQueue function.

* Add shaka segment index reading optimisation.

* Revise queue generation algorithm.

* Fix issue with load stalling after abrupt position changing.

* Fix issue with engine request has been already settled.

* Enhance bandwidth algorithm.

* Fix lint errors.

* Make CLEAR_THRESHOLD_MS a class field

* Rename methods

* Remove LinkedMap class

* Remove redundant comment

* Rename downloadProgressRatio

* Rename to queueDownloadRatio

* Move demo to shorter folder

* Open browser on demo start

* Update dependencies

* Fix GitHub Actions

---------

Co-authored-by: Igor Zolotarenko <[email protected]>
Co-authored-by: Andriy Lysnevych <[email protected]>

* Fix DPlayer not playing in Safari

* ShakaPlayer on macOS fixes

* Fix issues

* Use the latest Clappr player for the demo

* Improve Prettier and ESLint configuration

* Update packages

* pnpm: run demo from root

* Add favicon to the demo

* Update dependencies

* Small refactoring

* Improve enum usage

* Refactoring

* Refactoring of peer protocol handling

* Reset downloading error on successful download

* peerId generation (#327)

* peerId generation

* improvements

* vite-env

* pnpm-lock

* vite-env in demo

* improvements

* Typed linter (#330)

* WIP: fixing linter issues

* WIP: fix hls.js types

* WIP: hls.js types fixes

* WIP: shaka types

* Finish with types

* Update CodeQL action

* Configuration update

* Improve

* Fix/console-warnings (#331)

* console-warnings

* Simplify types

* Test CodeQL

* Update actions

* Delete test file

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* refactored naming (#333)

* Hls.js live eadge delay autodetection (#334)

* userConfig

* added type check

* Fix types

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* Fix: limit versions in demo (#335)

* fix/limit-versions

* stick-to-major-version

* stick-to-major-version

* Refactor: umd bundle to esm bundle (#338)

* esm bundle

* nodePolyfills

* modules-demo

* Update demo.js

* Update index.html

* Update dependencies

* Add link to ES modules demo page

* Fix demo

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* dash-shaka-playback from npm

* Feat: Segment validation (#336)

* segment validation

* improvements

* test func

* error type

* fixed p2p segment validation

* Revert abort callback type

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* FIX: "debug" dependency (#339)

* dependencies update

* Fix debug module import style

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* Feat: event emitter (#340)

* event emitter

* Fix types

* Fix file name

* Add event dispatcher optimization

* Create listeners once

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* Fix: dev server & pnpm scripts improved (#342)

* fix-dev-server&pnpm-clean-improved

* clean scripts

* Make pnpm calls consistent across projects

* Fix json syntax

* Refactor linter and type check configuration

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* Fix tsconfig.node.json (#345)

* Feat: setup http request callback (#344)

* setup http request callback

* improvements

* async func

* abort signal

* Refactor: event dispatcher (#343)

* improved event dispatcher

* refactored segment-storage

* fixed mistake in dispatchEvent

* fixed type

* Feat: core events (#346)

* segment events

* peer events

* chunk events

* types refactored

* Updated core events

* Chunk events

* RequestError moved to public type

* peer protocol

* added documentation for core events

* added type DownloadSource

* changed type to downloadSource

* significantly reduced description of events

* Removed interface extension

* onSegmentLoaded moved to request.ts

* refactor naming

* removed unsuded var from demo

* Feat: Config (#347)

* core config

* shaka

* hls

* removed hls userconfig from engine

* fixed demo

* dynamic config change

* changed config type to omit

* zero config

* deep merge

* Dynamic config for core

* refactored tracker-client config

* get core config

* removed readonly from settings

* refactored deep merge

* refactored core config & naming

* simplified deepConfigMerge

* added shaka & hls engine config

* export types

* Small refactoring (#348)

* internal-types (#349)

* Refactoring

* Fix naming

* Refactor index.ts

* Refactoring

* Improve core configuration

* swarmId & trackerClientVersionPrefix core config fields

* Update dependencies

* Refactor config to be readonly

* Rename Hlsjs to HlsJs

* Update dependencies recursively

* Better logging

* Feat: npm autodeploy (#350)

* npm-publish workflow

* Update .github/workflows/npm-publish.yml

* improvements

* publish on tags

* removed deprecated command

* Rewrited npm-publish action

* added support for different versions

* removed redundant func since it doesn't affect logic

* removed auto commit

* updated packages.json for npm publish

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* deleted unused scripts from packages

* API changes (#351)

* WIP: better API

* injectP2PMixin

* Make callbacks private

* Improve P2P mixin types

* Validate shaka

* Rename Hls.js Engine class

* Rename Shaka P2P engine class

* Final fixes and renaming

* added package p2p-demo

* updated pnpm-lock

* added peerDependencies

* updated build config

* Fix Clappr player stats

* simplified config

* added main file in package.json

* Update demo/package.json

* improvements

* update pnpm-lock

* removed vite from demo package

* removed vite from demo devDependencies

* added version support for demo package

* deleted tsconfig.node.json

* playback options

* added cleanupfunc & removed stream select

* hls player

* fixed videocontainer ref

* removed unused code

* defaultValue for input

* useQueryParams

* player components

* deleted App.tsx to prevent merge conflict

* Revert "Fix Clappr player stats"

This reverts commit 8ff5c40.

* Graph network

* core version from packageJson

* improved graph options

* revised & improved code

* refactor

* pnpm-lock

* Feat/demo (#352)

* deleted unused scripts from packages

* added package p2p-demo

* updated pnpm-lock

* added peerDependencies

* updated build config

* simplified config

* added main file in package.json

* Update demo/package.json

* improvements

* update pnpm-lock

* removed vite from demo package

* removed vite from demo devDependencies

* added version support for demo package

* deleted tsconfig.node.json

* playback options

* added cleanupfunc & removed stream select

* hls player

* fixed videocontainer ref

* removed unused code

* defaultValue for input

* useQueryParams

* player components

* Graph network

* core version from packageJson

* improved graph options

* revised & improved code

* refactor

* pnpm-lock

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* FEAT: Download stats chart (#353)

* simplified jsx

* chart draft with 1 value

* chart draft

* draft stacked area chart

* draft of chart with fake data

* implemented chart with fake data

* chart with real stat

* added legend with stored data

* colors moved to constants

* added percentage calculation

* Chart legend moved to separate component

* implemented chart legends

* refactored naming

* resolved all TS-type-errors

* spacing for readability

* renamed chart component

* fixed margin of svg container

* d3 types moved to dev deps

* improvements

* mbit/s

* removed unused deps

* resolved merge conflicts

* Refactor: network graph (#357)

* simplified jsx

* chart draft with 1 value

* chart draft

* draft stacked area chart

* draft of chart with fake data

* implemented chart with fake data

* chart with real stat

* added legend with stored data

* colors moved to constants

* added percentage calculation

* Chart legend moved to separate component

* implemented chart legends

* refactored naming

* resolved all TS-type-errors

* spacing for readability

* renamed chart component

* fixed margin of svg container

* d3 types moved to dev deps

* improvements

* mbit/s

* removed unused deps

* button to create new peer

* draft of graph network

* draft of graph

* GraphNetwork with fake data

* NetworkGraph with real data

* types

* component moved to folder

* removed custom data generation

* changed transition time on exit

* pnpm-lock

* pnpm

* improvements

* type improvements

* changed link type

* Feat: responsive layout (#359)

* simplified jsx

* chart draft with 1 value

* chart draft

* draft stacked area chart

* draft of chart with fake data

* implemented chart with fake data

* chart with real stat

* added legend with stored data

* colors moved to constants

* added percentage calculation

* Chart legend moved to separate component

* implemented chart legends

* refactored naming

* resolved all TS-type-errors

* spacing for readability

* renamed chart component

* fixed margin of svg container

* d3 types moved to dev deps

* improvements

* mbit/s

* removed unused deps

* button to create new peer

* draft of graph network

* draft of graph

* GraphNetwork with fake data

* NetworkGraph with real data

* types

* component moved to folder

* removed custom data generation

* changed transition time on exit

* pnpm-lock

* pnpm

* improvements

* type improvements

* changed link type

* implemented responsive layout

* implemented debug options

* fixed debugger

* dimensions improvements

* custom trackers

* small improvements

* removed refs from d3 files

* vite bundler

* tsc compile improvements

* fixed default trackers

* Fixes

* refactored responsive layout

* layout css

* updated css imports

* refactored useQueryParams hook

* implemented resize with ResizeObserver

* separated types

* pnpm updated to 9.0.0

* separated logic for a better readability

* improvements

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* Feat: players (#361)

* hls clappr & dplayer

* vime player

* plyr player

* plyr instance

* openPlayer

* added opt groups in playback options

* shaka player

* separated player's props

* shaka DPlayer

* Shaka Clappr

* Clappr declaration

* Add PlayerEvents type

* Plyr imporvements

* OpenPlayer improvements

* Simplified hls configuration with getConfiguredHlsInstance

* simplified shakaP2PEngine configuration

* mediaelement test

* simplified render func

* shaka import improvements

* fixed playback options

* Clappr shakaP2PEngine

* shaka Plyr

* p2p engine destroy

* refactored HLS integration in players

* hls mediaElement player container

* configure shaka events

* Plyr improvements

* remove window.Hls on cleanup

* refactored cleanup logic for openPlayer

* small adjustments

* small adjustments

* MediaElement bug fixed

* shaka improvements

* clappr styles

* shaka clappr

* type declaration

* global declaration

* fixed type errors

* Add HLS & shaka support check and error message for unsupported browsers

* Refactor useQueryParams hook to improve readability and performance

* add custom quality selector for hlsjs player

* Fix select-container alignment issue in Hlsjs.css

* removed redundant code

* Add playsInline attribute to video elements in players

* test vime with mp4

* Add vidstack player

* Update HLS provider library

* Improve types

* simplified vidstack player setup

* p2p config improvements

* fix type error

* changed default player

* added debug mode from query params

* Removed Vime player since it will be deprecated

* fixed naming

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* Feat/docs (#362)

* hls clappr & dplayer

* vime player

* plyr player

* plyr instance

* openPlayer

* added opt groups in playback options

* shaka player

* separated player's props

* shaka DPlayer

* Shaka Clappr

* Clappr declaration

* Add PlayerEvents type

* Plyr imporvements

* OpenPlayer improvements

* Simplified hls configuration with getConfiguredHlsInstance

* simplified shakaP2PEngine configuration

* mediaelement test

* simplified render func

* shaka import improvements

* fixed playback options

* Clappr shakaP2PEngine

* shaka Plyr

* p2p engine destroy

* refactored HLS integration in players

* hls mediaElement player container

* configure shaka events

* Plyr improvements

* remove window.Hls on cleanup

* refactored cleanup logic for openPlayer

* small adjustments

* small adjustments

* MediaElement bug fixed

* shaka improvements

* clappr styles

* shaka clappr

* type declaration

* global declaration

* fixed type errors

* Add HLS & shaka support check and error message for unsupported browsers

* Refactor useQueryParams hook to improve readability and performance

* add custom quality selector for hlsjs player

* Fix select-container alignment issue in Hlsjs.css

* removed redundant code

* Add playsInline attribute to video elements in players

* test vime with mp4

* Add vidstack player

* Update HLS provider library

* Improve types

* simplified vidstack player setup

* p2p config improvements

* fix type error

* changed default player

* added debug mode from query params

* Removed Vime player since it will be deprecated

* fixed naming

* jsdoc

* refactor types

* add typedoc configuration for p2p-media-loader packages

* add typedoc configuration for p2p-media-loader packages

* added plugin for typedoc

* updated main README file

* Improved core config jsdoc

* main readme files improvements

* typedoc config

* add docs to gitignore

* jsdoc improvements

* updated applyDynamicConfig method parameter types in HlsJsP2PEngine and ShakaP2PEngine

* updated video players to autoplay and mute by default

* updated video player styles for better aspect ratio control

* updated HlsjsClapprPlayer initialization in engine.ts

* removed member visibility section

* api doc

* refactor:  Shaka player initialization and video container handling

* updated with new player examples

* refactored video player initialization and container handling

* improved readability

* updated API documentation link in README.md

* small fix in api docs

* api docs improvements

* improved scrollbar styling in typedoc

* Improve video player initialization and container handling

* Add error logging for player initialization in HlsjsOpenPlayer and ShakaPlyr

* Removed categorizeByGroup from typedoc.json

* Updated import URLs for p2p-media-loader-core and p2p-media-loader-hlsjs

* Updated event names and parameters for peer events

* Removed DeepReadOnly type

* Refactored naming

* Improved api docs

* Improve types

* Fix linter issues

* Updated README in packages

* Updated FAQ.md

* Improved FAQ.md

* Updated FAQ.md

---------

Co-authored-by: Andriy Lysnevych <[email protected]>

* Fixed httpwindow download

* Refactored proccess queue

* Updated httpDownloadTimeWindow and p2pDownloadTimeWindow in CoreConfig

* Naming and documentation fixes

* Updated openplayerjs

* Refactored randomTimeout

* fixed timewindow naming

* Refactored loadRandomThroughHttp  logic

* Removed statuses in requests

* randomized segmentsToDownload

* Updated values in CoreConfig

* Refactored segment loading logic for hybrid loader

* Small improvements to loadRandomThroughHttp

* Improvements

* Improved config

* Updated CoreConfig values and apply dynamic configuration changes

* Updated dynamic configuration example in Hls.js engine

* Fix: segment abort issue &  added requestProcessQueueCallback in peer (#365)

* improvements

* Fix segment abort issue

* Refactor requestProcessQueueCallback

* Refactor segment event details types

* Small improvements

* Fixed onSegmentAnnouncement

* Update hybrid-loader.ts

* Refactor: docs (#366)

* improvements

* Fix segment abort issue

* Refactor requestProcessQueueCallback

* Refactor segment event details types

* Small improvements

* Fixed onSegmentAnnouncement

* Refactor core types docs

* Refactor engine types

* Revert "Refactor engine types"

This reverts commit e7cda7c.

* Refactor engine types

* Removed question in FAQ

* Removed "ts-essentials" from dependencies

* Refactor segment storage expiration logic

* Fix typedoc props sorting

* Updated cachedSegmentExpiration to undefined for VOD streams and use default value for live streams

* Small adjustments

* Feat: Extended config (#368)

* Add main & secondary stream configs

* Refactor dynamic configuration handling in Core.applyDynamicConfig

* Refactored types

* Fix jsdoc in types

* Refactor mergeConfigs function to use Object.create(null)

* Refactor mergeConfigs function to handle restricted properties

* Fix types

* Refactor core to use StreamConfig instead of CoreConfig

* Refactor core configuration to use partial updates in HlsJsP2PEngine and ShakaP2PEngine

* Refactor core configuration to use partial updates in HlsJsP2PEngine and ShakaP2PEngine

* Refactor core configuration to use StreamConfig instead of CoreConfig

* Add tests for core utils

* Update eslint config to ignore test folder

* Refactor core configuration to use DefinedCoreConfig

* Refactor overrideConfig

* Small improvements

* Small improvements

* Feat: isP2PDisabled (#369)

* Add main & secondary stream configs

* Refactor dynamic configuration handling in Core.applyDynamicConfig

* Refactored types

* Fix jsdoc in types

* Refactor mergeConfigs function to use Object.create(null)

* Refactor mergeConfigs function to handle restricted properties

* Fix types

* Refactor core to use StreamConfig instead of CoreConfig

* Refactor core configuration to use partial updates in HlsJsP2PEngine and ShakaP2PEngine

* Refactor core configuration to use partial updates in HlsJsP2PEngine and ShakaP2PEngine

* Refactor core configuration to use StreamConfig instead of CoreConfig

* Add tests for core utils

* Update eslint config to ignore test folder

* Refactor core configuration to use DefinedCoreConfig

* Refactor overrideConfig

* Small improvements

* Small improvements

* Add isP2PDisabled in static stream configuration

* Refactor applyDynamicConfig method to handle changes in isP2PDisabled and stream configurations

* Refactor Peer class connection event handling

* Refactor segment loading logic to improve P2P functionality

* Refactor stream configuration handling in Core.applyDynamicConfig

* Simplified dynamic configuration handling

* Improved CoreConfig description in documentation

* Remove redundant comments from codebase

* Refactor segment loading logic to improve P2P functionality

* Refactor naming for enhanced readability

* Refactor segment loading logic to handle P2P functionality

* Refactor error handling in RequestsContainer.destroy method

* Improved naming

* Improvements in Core and RequestsContainer

* Refactor Peer class connection event listeners

* Refactor error handling in catch block

* Refactor Peer class connection event listeners and add missing event handlers

* Refactor peer-connection (#370)

* Add main & secondary stream configs

* Refactor dynamic configuration handling in Core.applyDynamicConfig

* Refactored types

* Fix jsdoc in types

* Refactor mergeConfigs function to use Object.create(null)

* Refactor mergeConfigs function to handle restricted properties

* Fix types

* Refactor core to use StreamConfig instead of CoreConfig

* Refactor core configuration to use partial updates in HlsJsP2PEngine and ShakaP2PEngine

* Refactor core configuration to use partial updates in HlsJsP2PEngine and ShakaP2PEngine

* Refactor core configuration to use StreamConfig instead of CoreConfig

* Add tests for core utils

* Update eslint config to ignore test folder

* Refactor core configuration to use DefinedCoreConfig

* Refactor overrideConfig

* Small improvements

* Small improvements

* Add isP2PDisabled in static stream configuration

* Refactor applyDynamicConfig method to handle changes in isP2PDisabled and stream configurations

* Refactor Peer class connection event handling

* Refactor segment loading logic to improve P2P functionality

* Refactor stream configuration handling in Core.applyDynamicConfig

* Simplified dynamic configuration handling

* Improved CoreConfig description in documentation

* Remove redundant comments from codebase

* Refactor segment loading logic to improve P2P functionality

* Refactor naming for enhanced readability

* Refactor segment loading logic to handle P2P functionality

* Refactor error handling in RequestsContainer.destroy method

* Improved naming

* Improvements in Core and RequestsContainer

* Refactor Peer class connection event listeners

* Refactor error handling in catch block

* Refactor Peer class connection event listeners and add missing event handlers

* Refactor peer-connection

* Resolved type error

* Rename master to main

* Fix docs and terminology

* Use default swarm ID in the demo

* Move vitest to dev dependencies

* Fix dependencies

* Fixes

* Rename local to runtime

* Update documentation

* NPM version badge

* Add build badge

---------

Co-authored-by: Igor Zolotarenko <[email protected]>
Co-authored-by: Igor Zolotarenko <[email protected]>
Co-authored-by: i-zolotarenko <[email protected]>
Co-authored-by: igor <[email protected]>
Co-authored-by: Dmytro Demchenko <[email protected]>
Co-authored-by: DimaDemchenko <[email protected]>
Co-authored-by: DimaDemchenko <[email protected]>
  • Loading branch information
8 people authored Jun 25, 2024
1 parent 65bfee0 commit e33b483
Show file tree
Hide file tree
Showing 233 changed files with 17,595 additions and 26,398 deletions.
8 changes: 3 additions & 5 deletions p2p-media-loader-core/.editorconfig → .editorconfig
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120

[*.md]
trim_trailing_whitespace = false
[*.json]
indent_size = 2
20 changes: 20 additions & 0 deletions .eslintrc.common.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
env: {
es2021: true,
},
extends: [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended-type-checked",
],
plugins: ["@typescript-eslint"],
ignorePatterns: ["/.eslintrc.cjs", "/lib", "/dist"],
rules: {
"no-console": "warn",
"@typescript-eslint/prefer-nullish-coalescing": "error",
curly: ["warn", "multi-line", "consistent"],
"spaced-comment": ["warn", "always", { markers: ["/"] }],
"no-debugger": "warn",
"@typescript-eslint/no-non-null-assertion": "error",
},
};
32 changes: 32 additions & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build & Lint

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: latest

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- run: pnpm i
- run: pnpm lint
- run: pnpm build
- run: npx tsc
working-directory: ./demo
71 changes: 20 additions & 51 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,40 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"

on:
push:
branches: [master]
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 17 * * 2'
- cron: "0 17 * * 2"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
timeout-minutes: 360
permissions:
security-events: write
actions: read
contents: read

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['javascript']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
language: ["javascript-typescript"]

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
- name: Checkout repository
uses: actions/checkout@v4

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
50 changes: 50 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
on:
push:
tags:
- "*"

jobs:
setup_and_build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org/"

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Install Dependencies
run: pnpm install

- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Update package.json version
run: |
export TAG=$VERSION
node update-versions.js
working-directory: ./scripts

- name: Build
run: pnpm run build

- name: Pack Packages
run: pnpm run pack-packages

- name: NPM Publish Packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for package in p2p-media-loader-core p2p-media-loader-hlsjs p2p-media-loader-shaka p2p-media-loader-demo; do
pnpm publish ./packages/$package/$package-$VERSION.tgz --access public
done
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

docs
node_modules
/demo/dist
/packages/*/dist
/packages/*/lib
/packages/*/build
/packages/*/dist-ssr
*.local
*.tgz

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
3 changes: 3 additions & 0 deletions .prettierrc.common.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
editorconfig: true,
};
Loading

0 comments on commit e33b483

Please sign in to comment.