Code Monkey home page Code Monkey logo

p2p-media-loader's Introduction

P2P Media Loader

GitHub ations workflow status npm version jsDelivr hits (npm)

P2P Media Loader is an open-source JavaScript library that leverages modern web browser features, such as HTML5 video and WebRTC, to enable media delivery over peer-to-peer (P2P) connections. It integrates smoothly with many popular HTML5 video players and works entirely without browser plugins or add-ons. Experience it in action with the demo.

By leveraging P2P technology, it greatly reduces reliance on traditional content delivery network (CDN) resources, lowers costs, and enhances the ability to deliver media streams to a larger audience.

This library enables the creation of a huge P2P mesh networks, also known as peer-to-peer content delivery network (P2P CDN), peer-to-peer television (P2PTV), and Enterprise Content Delivery Network (eCDN), which allows traffic sharing among users who are simultaneously viewing the same live or video on demand (VOD) stream via HLS or MPEG-DASH protocols.

Related software

Documentation and important links

Key features

Key components of the P2P network

All the components of the P2P network are free and open-source.

P2P Media Loader network

P2P Media Loader web browser requirements are:

  • WebRTC Data Channels support to exchange data between peers
  • Media Source Extensions are required by Hls.js and Shaka Player engines for media playback

STUN server is used by WebRTC to gather ICE candidates. There are many running public servers available on Public STUN server list.

A compatible WebTorrent tracker is required for WebRTC signaling and to create swarms of peers downloading the same media stream. A few running public trackers are available: https://tracker.novage.com.ua/, https://tracker.webtorrent.dev/, https://openwebtorrent.com/.

It is possible to run personal WebTorrent tracker using open-source implementations: wt-tracker, Aquatic, OpenWebtorrent Tracker, bittorrent-tracker.

P2P Media Loader is configured to use public STUN and WebTorrent servers by default. It means that it is not required to run any server-side software for the P2P network to function for simple use cases.

How It Works

A web browser runs a video player that integrates with the P2P Media Loader library. Each instance of the library is referred to as a peer, and collectively, many peers form the P2P network.

P2P Media Loader initially downloads media segments over HTTP(S) from a source server or CDN to start media playback quickly. If no peers are available, it continues to download segments over HTTP(S), similar to a traditional media stream.

Subsequently, P2P Media Loader transmits media stream details and connection information, such as ICE candidates, to WebTorrent trackers. These trackers provide a list of other peers who are accessing the same media stream.

P2P Media Loader then connects with these peers to download additional media segments and simultaneously shares segments that it has already downloaded.

Periodically, random peers in the P2P swarm download new segments over HTTP(S) and distribute them to others via P2P.

Web browsers support

P2P Media Loader required browser features

The features are fully supported across the most popular browsers

  • Chrome
  • Firefox
  • macOS Safari
  • iPadOS Safari (iPad)
  • iOS Safari (iPhone, iOS version 17.1+)
  • Edge

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.