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.4k stars 310 forks source link

Refactor: commands #392

Closed DimaDemchenko closed 1 month ago

Chocobozzz commented 1 month ago

Hi,

Can you detail this protocol change? Is the purpose to resend a P2P request to the same peer for the same segment?

mrlika commented 1 month ago

Hi, @Chocobozzz,

There were issues handling segment requests via P2P when a segment download was canceled and restarted immediately. To address this, a randomly generated request ID has been added to the segment request command.

Fortunately, the library is designed so that P2P protocol version changes are minor because the protocol version is added to the WebTorrent info hash: https://github.com/Novage/p2p-media-loader/blob/0972c005958df549f3b27b8da0b6bf721450969c/packages/p2p-media-loader-core/src/utils/stream.ts#L23

This means that swarms consist of peers of the same protocol version. If peers of different protocol versions download the same stream, they will be in separate swarms, eliminating the ability for non-compatible communications.

Chocobozzz commented 1 month ago

Thank you for your answer @mrlika :pray:

Yes I was aware about the protocol version, we correctly handle it :) https://github.com/Chocobozzz/PeerTube/blob/fbee171a0bea725e74ddc9ca4a00875c2250afd4/server/core/lib/hls.ts#L27