Novage / p2p-media-loader

An open-source engine for P2P streaming of live and on demand video directly in a web browser HTML page
https://novage.com.ua/p2p-media-loader/demo.html
Apache License 2.0
1.43k stars 314 forks source link

Disallow selected peers to download from HTTP (force P2P) #231

Closed renatofrota closed 8 months ago

renatofrota commented 2 years ago

Hello,

Is there a way to disallow selected peers to download from HTTP (i.e., force them to always download the segments from other peers - or fail)?

Thanks.

ckcr4lyf commented 2 years ago

I think one challenge would be how to identify peers - your website probably serves the same JS file to all clients, but if on the client side you can find a way to figure out if they should be only P2P, you can initialize the loader with the HTTP probability set to zero

https://github.com/Novage/p2p-media-loader/blob/master/p2p-media-loader-core/README.md#loader--new-hybridloadersettings

renatofrota commented 2 years ago

Yes, I have other means to determine who should be capable of HTTP download and I am loading a "regular" JS script for them, while the others will receive the "P2P-only" version.

Thank you for your suggestion. Note: httpDownloadProbability: 0 did not work alone. I had to set requiredSegmentsPriority: -1 as well.

Now I just need to find a way to make the player stop/error/reload after a few seconds the next segment is unavailable, instead it just hanging and infinitely displaying the "loading" animation. Any tip?

renatofrota commented 2 years ago

I think it would be something along the lines of https://github.com/video-dev/hls.js/issues/1714, however I am not finding a way to implement this (I am using basically the same code of Novage's demo for Clappr Player, very slightly modified). JavaScript is not my native language 😅