user7885198
user7885198

Reputation:

webrtc - signaling server with php or node.js

I'm trying to build a simple video streaming web application where one user (chatroom owner) broadcasts video from his webcam and the other users (chatroom members) are able to see it in real time

i have done tons of researches on google so i found out that what i need is :

      - get the adapter.js file for compatibility ( no clue where to get it )

      - get video stream from the webcam

      - send it to a server

      - have the server send it to certain users

      - clients receive that video stream and displays it inside a < video > tag

i was only able to do the first step, the examples i found on the web are clear and simple

for the other steps, all examples i found on the web explains how to do this locally on a single page but i want to do it remotly, even followed the guides in O'reilly WebRTC book

i have no clue what i should write in the server side code or how to send the received video stream ( i have some examples but i didn't understand the code )

i have no clue how the clients will receive that stream ( no examples found for this one, all examples out there send and receive video on the same page )

can anyone help, my server side langages is PHP but i can switch to Node.js if that's a must

Upvotes: 5

Views: 8141

Answers (2)

Niels
Niels

Reputation: 155

So, it seems you ask for help and you have tons of questions.

Regarding local or remotely: there is no difference whether it only works on your computer or at a server. Usually you test things locally on your computer, and then you put it online. You usually do not need to change your code (except settings like URLs) to get it working on a server.

You say you have no idea what you should write at the server code. Well, it is just for signalling, so any two browsers should be able to communicate. Usually it is done with websockets and coded with less than 10 lines of code for node.js; there are plenty of small examples of that, like here . You say your main server language is PHP; that is challenging because PHP can not use websockets without commandline access. If you have regular shared-hosted PHP access, you can use my example at http://github.com/nielsbaloe/webrtc-php which uses ServerSideEvents.

You want to know how clients will receive the stream. Well, the browser takes care of the streams. You only have to take care of the handshakes. So when you have code for two browsers running (like in my example), it is exactly the same code for more clients, you can extend it so that there is one sender and multiple viewers.

Upvotes: 4

Ajay
Ajay

Reputation: 2643

Am answering your questions inline

  1. You can get adapter.js file from https://github.com/webrtc/adapter/tree/master/release
  2. To get video stream from the webcam, use getUserMedia API, see the demo

  3. To Stream video to viewers, use PeerConnection,

    • WebRTC has no specific signalling defined, you can use any signalling to exchange offer/answer/candidates between publisher and viewer using any server(node/php) in p2p. See official complex demo and get the source.

    • If you want to stream to multiple viewers, then you need a media server, see demos Janus & Jitsi

You can find more resources here

Upvotes: 4

Related Questions