Home

Awesome

hls-p2p

Flash OSMF based hybrid cdn&p2p hls solution. Currently it support LIVE hls. Flash support rtmfp protocal, we use that to deliver video&audio data in p2p&cdn hybrid way.

NOTE: Please take some time to READ this file.

how it works

We use https://github.com/denivip/osmf-hls-plugin to enable hls support. Use that as a base, we developed the p2p part.

Normally, for hls protocal, client download m3u8 first, then download ts; In our p2p solution, client download m3u8 from server first, then download ts and m3u8 from server or other peers.

We developed a algorithm for LIVE hls P2P.

The algorithm is like this:

Server part:

Client part:

Install

Run and test

Server:

Client:

change the ip of your server in bin/index.html, such as "115.29.205.140"

some config value and their meanings are as follows:

# the url of LIVE hls stream, it MUST be live and single stream
# it should only contain ts file, and MUST NOT contain another m3u8 file
m3u8_url: "http://211.103.128.226:8080/live/tvie/xray/pad.m3u8",
# the rtmfp url
rtmfp_url: "rtmfp://115.29.205.140:19350/app",
# the url we will get peers information
http_tracker: "http://115.29.205.140:5000/get_peers",
# send log to that url
remote_log_base_url: "http://115.29.205.140:5000/remote_log",
# how many peers we will use to download data
rtmfp_url_peers: 2,
# leave it as it is
index_rtmfp_url: "",
# leave it as it is
index_rtmfp_url_peers: 1,
# the server ip and port from where we download m3u8 and ts.
# if you do not know how it works, set it as the same as `m3u8_url`
source_servers: ["211.103.128.226:8080"]

Data

In Cumulus, we will add peer informations to redis. You can get the peer informations in redis with following command

127.0.0.1:6379 > SMEMBERS cumulus_app
127.0.0.1:6379> LLEN app
(integer) 1
127.0.0.1:6379> LRANGE app 0 1
1) "c39e1de52e704279ecb6800bdb4c20006059d6b600b8abd08941a4119dc4250b"
127.0.0.1:6379> LTRIM app 0 0

peer - server protocal

peers protocal