How to decentralize
Live Video Streaming 

CASTO

@acidsound

Zero-Latency Decentralized
Broadcasting Web

PUMP UP THE VOLUME (1990)

VIDEO

Legacy Video Streaming

streamer

transcoding

Content Delivery Network

viewer

Huge computation cost/time

RTMP

HLS

HLS

CASTO

streamer

viewer

webRTC

VP8
H264

VP8
H264

SFU

* SFU: selective forwarding unit

SFU

SFU

SFU

SFU

SFU

webRTC

Traditional CASTO
Transcoding SAAS Transcoding
Media Server
x
Storage AWS, Azure, GCP x
(delivery only)
Delivery CDN P2P

webRTC

webRTC + ?

IPFS(Interplanetary File System)

Decentralized

But ...

Is it suitable for live streaming ?

Distributed

File 

System

 

What if the file gets bigger?

$ ipfs object get QmR45FmbVVrixReBwJkhEKde2qwHYaQzGxu4ZoDeswuF9w
{“Links”: [{
“Name”: “”,
“Hash”: “QmYSK2JyM3RyDyB52caZCTKFR3HKniEcMnNJYdk8DQ6KKB”,
“Size”: 262158},
{“Name”: “”,
“Hash”: “QmQeUqdjFmaxuJewStqCLUoKrR9khqb4Edw9TfRQQdfWz3”,
“Size”: 262158},
{“Name”: “”,
“Hash”: “Qma98bk1hjiRZDTmYmfiUXDj8hXXt7uGA5roU5mfUb3sVG”,
“Size”: 178947}],
“Data”: “\u0008\u0002\u0018* \u0010 \u0010 \n”}

Can't guarantee discover & broadcasting time

The solution is ??

IPFS Stack

IPFS Stack

What we really need

Modular Network Stack

We got them ALL

you pick what YOU want

Ethereum <3 libp2p

Polkadot <3 libp2p

and CASTO <3 libp2p !!

CodeLab 

PeerInfo: Identification

/* peer의 생성 */
peerInfo = await new Promise((resolve, reject)=>PeerInfo.create((err,peerInfo)=>err && reject(err) || resolve(peerInfo)));

/* peer가 가질 수 있는 복수의 multiaddr 추가 */
peerInfo.multiaddrs.add(multiaddr(`/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star/ipfs/${peerInfo.id.toB58String()}`));

Transport

Discover

Dial/Handle

Summary

1. Create PeerInfo (A & B)

2. Create a Node (A & B)

3. Run a Node (A & B)

4. Discover a Node (A -> B)

5. Dial the discovered Node (A -> B)

6. If successfully dialed, create a connection (A -> B)

 

5-1. Handle the dial (B -> A)

6-1. If successfully handled,

create a connection (B -> A)

And then

Peers exchange

webRTC connection info

for live streaming

Streamer

Relay

Viewer

Star (libp2p)

STUN/TURN (webRTC)

discover

streaming

CASTO Architecture

dial

dial

peerConnection

peerConnection

what libp2p does

1. Discover a Peer

2. Identify the Peer
3. When disconnected,

go back to #1 

what webRTC does  

1. Create a PeerConnection based on the identified Peer

2. Start live streaming 

streamer

viewer

webRTC

VP8
H264

VP8
H264

SFU

* SFU: selective forwarding unit

SFU

SFU

SFU

SFU

SFU

webRTC

peer

* libp2p   POV

peer

peer

peer

peer

peer

peer

peer

discovery

Why not use libp2p

for live streaming?

It's possible 

BUT 

webRTC is better at 

Codec, Simulcast and Statistics

for media streaming 

webRTC Protocol

webRTC Implementation

CASTO SDK

const casto = new CASTO();
media.srcObject = await casto.start();

Let's start with just 2 lines :D

ISSUES

NAT Traverse

Issues

What if they are under the same Public IP, but different router? (NAT-NAT)

What is one is on WIFI, but the other is using LTE?

What if the router bans UDP port for webRTC?

STUN/TURN server gets centralized!

Compatibility

Issues

Time solves the problem most of the time (Safari sucks..)

Safari started supporting webRTC Video just a year ago

New SDP Format - Possibility of flexible effective relay  

Audio compatibility issues  different browsers 

Performance

Issues

Various Peer Discovery methods

Apply mDNS in a private Network

Peer/Content Routing using kadDHT

 Performance tuning for different browsers 

What's next ?

Multiple Depth Nodes

Next CASTO

Simulcast

Token Incentives

Web Client SDK

More docs

Cool tutorials & sample

Partners

STAY TUNED!

Made with Slides.com