WebRTC - scalable live stream broadcasting / multicasting
WebRTC - scalable live stream broadcasting / multicasting
[ ! ] Question is still open
PROBLEM:
WebRTC gives us peer-to-peer video/audio connections. It is perfect for p2p calls, hangouts. But what about broadcasting (one-to-many, for example, 1-to-10000)?
Lets say we have a broadcaster "B" and two attendees "A1", "A2". Of course it seems to be solvable: we just connect B with A1 and then B with A2. So B sends video/audio stream directly to A1 and another stream to A2. B sends streams twice.
Now lets imagine there are 10000 attendees: A1, A2, ..., A10000. It means B must send 10000 streams. Each stream is ~40KB/s which means B needs 400MB/s outgoing internet speed to maintain this broadcast. Unacceptable.
ORIGINAL QUESTION (OBSOLETE)
Is it possible somehow to solve this, so B sends only one stream on some server and attendees just pull this stream from this server? Yes, this means the outgoing speed on this server must be high, but I can maintain it.
Or maybe this means ruining WebRTC idea?
[ ! ] UP-TO-DATE QUESTION
- Solve CPU/Bandwidth - Is there server-less solution (aka multicasting or something similar)?
- Solve CPU - Is it possible to encode stream only once and send to peers?
- Solve CPU/Bandwidth - Multicasting is definitely possible, but does it actually work in real life (latency, network instability)?
NOTES
Flash is not working for my needs as per poor UX for end customers.
SOLUTION
26.05.2015 - There is no such a solution for scalable broadcasting for WebRTC at the moment, where you do not use media-servers at all. There are server-side solutions as well as hybrid (p2p + server-side depending on different conditions) on the market.
There are some promising techs though like https://github.com/muaz-khan/WebRTC-Scalable-Broadcast but they need to answer those possible issues: latency, overall network connection stability, scalability formula (they are not infinite-scalable probably).
Answer by Angel Genchev for WebRTC - scalable live stream broadcasting / multicasting
"Scalable" broadcasting is not possible on the Internet, because the IP UDP multicasting is not allowed there. But in theory it's possible on a LAN.
The problem with Websockets is that you don't have access to RAW UDP by design and it won't be allowed.
The problem with WebRTC is that it's data channels use a form of SRTP, where each session has own encryption key. So unless somebody "invents" or an API allows a way to share one session key between all clients, the multicast is useless.
Answer by igorpavlov for WebRTC - scalable live stream broadcasting / multicasting
The answer from Angel Genchev seems to be correct, however, there is a theoretical architecture, that allows low-latency broadcasting via WebRTC. Imagine B (broadcaster) streams to A1 (attendee 1). Then A2 (attendee 2) connects. Instead of streaming from B to A2, A1 starts streaming video being received from B to A2. If A1 disconnects then A2 starts receiving from B.
This architecture could work if there are no latencies and connection timeouts. So theoretically it is right, but not practically.
At the moment I am using server side solution.
Answer by shacharz for WebRTC - scalable live stream broadcasting / multicasting
There is the solution of peer-assisted delivery, meaning the approach is hybrid. Both server and peers help distribute the resource. That's the approach peer5.com and peercdn.com have taken.
If we're talking specifically about live broadcast it'll look something like this:
- Broadcaster sends the live video to a server.
- The server saves the video (usually also transcodes it to all the relevant formats).
- A metadata about this live stream is being created, compatible with HLS or HDS or MPEG_DASH
- Consumers browse to the relevant live stream there the player gets the metadata and knows which chunks of the video to get next.
- At the same time the consumer is being connected to other consumers (via WebRTC)
- Then the player downloads the relevant chunk either directly from the server or from peers.
Following such a model can save up to ~90% of the server's bandwidth depending on bitrate of the live stream and the collaborative uplink of the viewers.
disclaimer: the author is working at Peer5
Answer by flavioribeiro for WebRTC - scalable live stream broadcasting / multicasting
My masters is focused on the development of a hybrid cdn/p2p live streaming protocol using WebRTC. I've published my first results at http://bem.tv
Everything is open source and I'm seeking for contributors! :-)
Answer by Tom for WebRTC - scalable live stream broadcasting / multicasting
AFAIK the only current implementation of this that is relevant and mature is Adobe Flash Player, which has supported p2p multicast for peer to peer video broadcasting since version 10.1.
Answer by nschoe for WebRTC - scalable live stream broadcasting / multicasting
As it was pretty much covered here, what you are trying to do here is not possible with plain, old-fashionned WebRTC (strictly peer-to-peer). Because as it was said earlier, WebRTC connections renegociate encryption keys to encrypt data, for each session. So your broadcaster (B) will indeed need to upload its stream as many times as there are attendees.
However, there is a quite simple solution, which works very well: I have tested it, it is called a WebRTC gateway. Janus is a good example. It is completely open source (github repo here).
This works as follows: your broadcaster contacts the gateway (Janus) which speaks WebRTC. So there is a key negociation: B transmits securely (encrypted streams) to Janus.
Now, when attendees connects, they connect to Janus, again: WebRTC negociation, secured keys, etc. From now on, Janus will emit back the streams to each attendees.
This works well because the broadcaster (B) only uploads its stream once, to Janus. Now Janus decodes the data using its own key and have access to the raw data (that it, RTP packets) and can emit back those packets to each attendee (Janus takes care of encryption for you). And since you put Janus on a server, it has a great upload bandwidth, so you will be able to stream to many peer.
So yes, it does involve a server, but that server speaks WebRTC, and you "own" it: you implement the Janus part so you don't have to worry about data corruption or man in the middle. Well unless your server is compromised, of course. But there is so much you can do.
To show you how easy it is to use, in Janus, you have a function called incoming_rtp()
(and incoming_rtcp()
) that you can call, which gives you a pointer to the rt(c)p packets. You can then send it to each attendee (they are stored in sessions
that Janus makes very easy to use). Look here for one implementation of the incoming_rtp()
function, a couple of lines below you can see how to transmit the packets to all attendees and here you can see the actual function to relay a rtp packet.
It all works pretty well, the documentation is fairly easy to read and understand. I suggest you start with the "echotest" example, it is the simplest and you can understand the inner workings of Janus. I suggest you edit the echo test file to make your own, because there is a lot of redundant code to write, so you might as well start from a complete file.
Have fun! Hope I helped.
Answer by rubo77 for WebRTC - scalable live stream broadcasting / multicasting
As @MuazKhan noted above:
https://github.com/muaz-khan/WebRTC-Scalable-Broadcast
works in chrome, and no audio-broadcast yet, but it seems to be a 1st Solution.
A Scalable WebRTC peer-to-peer broadcasting demo.
This module simply initializes socket.io and configures it in a way that single broadcast can be relayed over unlimited users without any bandwidth/CPU usage issues. Everything happens peer-to-peer!
This should definitely be possible to complete.
Others are also able to achieve this: http://www.streamroot.io/
Answer by JAre for WebRTC - scalable live stream broadcasting / multicasting
I'm just starting to dig into WebRTC and I have a question(might be a stupid one):
Can we organize real-time P2P network as a shallow tree?
The way it works:
The initial seeder splits a data(audio/video in this case) segment into X small chunks and sends them to X leechers with WebRTC raw data streams. And then the leechers will exchange the chunks with each other and restore the original video segment. This way they will be forced to cooperate and the initial seeder won't need X * package_size bandwidth for the X leechers.
To address the reliability problem we can use the XOR trick for RAID data protection - i.e. add a little data overhead so the leechers will be able to restore data if some of them disconnected.
To improve the situation when a leecher asks for a missing chunk then opens WebRTC channel - we can map chunks(hash sums) to IPs (or other peer identifiers) so everyone in the P2P network will know who should store what and will know who to ask. Also the initial seeder can broadcast hashes of the next chunks(if it has a buffer) so the peers will be able to start establishing links ahead of time.
The chunk size can be adaptive or some peers can get more chunks - might be based on their performance.
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment