3

Peers must be able to forward data in order to broadcast in a peer-to-peer overlay (such as Chord). When each node (peer) receives data it will then forward the data to all other nodes in their routing table, who will then forward the same data again until all nodes in the ring receives the data. eg, structured p2p WebRTC broadcasting requires a means of forwarding WebRTC video streams.

In my understanding, the javascript WebRTC API is designed to allow the developer to setup connections but not handle media streams directly. That a high-level video object is 'plugged' into the connection object to consume the video stream with no lower level access to the video data.

The questions

  1. Is there any way to reach raw video streams within a WebRTC client?
  2. Is there any form of raw consumer objects or forwarding/relay objects in WebRTC?
JSON
  • 1,819
  • 20
  • 27

3 Answers3

5

It's certainly possible to forward an incoming stream from one RTCPeerConnection to another. Here's an example: https://github.com/git-matrix/webrtc/tree/master/samples/web/content/peerconnection/multiple-relay However, you don't get low-level access to the frames in this scenario, and the content will be decoded and re-encoded instead of being passed through as-is.

oxygen
  • 5,891
  • 6
  • 37
  • 69
Joel Dice
  • 226
  • 3
  • 2
  • 1
    link is dead, I'm not sure if this is (still) possible with chrome. the following would suggest it is not: https://github.com/muaz-khan/WebRTC-Scalable-Broadcast the following would suggest it is: https://github.com/webrtc/samples/tree/gh-pages/src/content/peerconnection/multiple-relay maybe the second one just has better code. – HMR Jun 25 '16 at 03:52
2

Well first of all, I think I have managed to relay A's video to C. Since I am testing with only one PC (laptop) and two different camera's I am not 100% certain, but I think I have done it, it seems RTCPeerconnection is able to take a remote stream.

Btw, I am using the easyrtc library since I can't find any workable simple codes to test with.

So the basic idea should be,

A grabs the event video. B connects to A,

B saves the remote stream reference received from A;

C connects to B,

B instead of passing local media stream, hands the remote media stream to C;

C would save that remote media stream;

When D connects to C, C would hand the remote media stream received from B (which actually has been received originally from A) to D

and like wise, the flow continues... i.e A's media stream passes like a Wave through B, C, D , E....

Notice that the connection flow should look like this: A<-->B<-->C<-->D<-->E... every node has only two connection.. with the previous node and the next node.

However, long story short - Yes, you can access the media stream and hand it to another remote connection

I just need an expert who can give me a working raw JS based webrtc code where A connects with B and vice versa.. and I would try to write C connecting with B and D connecting with C codes for proper testing.

lucpattyn
  • 51
  • 2
  • Thank you, this seems logical. Let me look into this and if it's right I'll post the code in my question above and give you the answer. – JSON Feb 08 '14 at 21:11
1
  1. No, there isn't on the client side. You have to send it to the server and there you can do pretty much whatever you want.
  2. You have to open a separate peer connection for each peer you want to forward to.

Source: http://www.youtube.com/watch?v=E8C8ouiXHHk

Svetlin Mladenov
  • 4,307
  • 24
  • 31
  • this doesn't seem to answer my question. as for part 1 of your answer, peer to peer video will not send video to a server. this is client/server not peer to peer, even if the video originated from a different client. additionally, in peer to peer broadcast it will specifically get 'bounced' from client to client even if the original video sorce is a server such as a news broadcast. – JSON Nov 07 '13 at 14:10
  • as for part 2, you used the word 'forward' which is specifically what I'm looking for, ie video comes into javascript over the network from one peer and is then sent to a list of different peers. if the video originates on a peer that is directly connected than it's not forwarded but sent directly. are you saying that you can literally forward to different peer connections? How if so? – JSON Nov 07 '13 at 14:19
  • 1
    Regarding your first question: Currently there is no way to get to the raw video stream when you are on the client side (i.e. limited to the WebRTC javascript API). If you want access to the raw stream then you have to send the stream to a server (something that runs natively on the platform for example a C++ server that uses the web-RTC C++ library) and do the processing there. By the end of the video a person in the audience asks the very same question so I thought that this video may be useful to you. – Svetlin Mladenov Nov 07 '13 at 15:05