Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jinxkitt's avatar

Laravel-Websockets and WebRTC RTCPeerConnection

I am building an app to broadcast a live video to be watch by multiple users. I am trying to use this technology WebRTC and laravel websockets. None of the senior laravel programers seems to have done this. Does anyone of you knows a better reference to do this. Thank you.

0 likes
9 replies
Tippin's avatar

@jinxkitt What exactly are you trying to accomplish? A webinar, (one to many), or one to one, many to many streams? WebRTC alone is not too hard to get one to one or many to many working, however if you want more of a webinar, then a media server such as janus is a good option. I have a demo messenger app that has video calls using WebRTC you can checkout here https://github.com/RTippin/messenger-demo

I will say with a base WebRTC setup, you will probably need to setup your own TURN/STUN servers and your own signaling server (pusher/socketio). In one of my projects, I am currently working on using Janus as the media server to handle video calls/webinars. You can check out their documentation as well here https://janus.conf.meetecho.com/docs/

In general I would suggest heavily looking over the examples from the WebRTC project to get a better understanding of how they setup streams in each module. https://webrtc.github.io/samples/

roelmagdaleno's avatar

Hi, I'm in the same situation as @jinxkitt due to coronavirus there's this school where they want to teach using streaming to its students.

In my case the teacher is the only broadcaster using video and audio, and the students are only the viewers, the students won't be able to broadcast. I guess @jinxkitt wants that as well.

Do you think I should setup my own TURN/STUN servers for my case?

I'm gonna try your project, looks promising. Thank you.

Tippin's avatar

If you go the WebRTC route and run no media server as the middleman, I would still setup TURN/STUN, however you can find public ones with a google search. But if you choose to use a public one, know it can go down at anytime or they can kick you off if you abuse it.

I will say in my own experience (not the best on WebRTC advanced methods), in my demo app above I am using adapter.js and my own WebRTC javascript, but I have a few issues

https://github.com/RTippin/messenger-demo/blob/master/resources/js/managers/WebRTCManager.js

I was unable to figure out how to "subscribe" to a single stream without publishing my own by creating offers. So in your case that would not work. If I did not get my own media first I was unable to see anyone else basically.

Now on the other project I am working on (Remote teaching whiteboard/streaming/recording) I am using Janus server. Janus has many advantages as it handles so much for you. It allows me to easily have publishers and/or subscribers, so webinars are easy. On top of that, I can record the streams for playback after.

1 like
roelmagdaleno's avatar

I just read some stuff about Janus and looks pretty easy for me using its JS plugins. Have you achieved something with it yet that you can share?

Looks like the plugin I have to use is the "videoroom" or use the "screen sharing" demo.

But I have two questions:

  1. With this I don't have to setup any TURN/STUN servers, right?
  2. I wonder about the server requirements or resources, for example, CPU or RAM. Do you recommend some minimum requirements?

Thanks!

Tippin's avatar

Right now I do not have any public code I can link to from myself, as it is all local testing, but if you did choose to go that route I could show you how my backend handles it. I am working on it with someone else and it is alot to digest for sure. Janus server config itself is alot, but like anything, once it works it becomes easy.

Locally I have Janus server setup inside portainer through docker. I did have to write my own service class to handle talking to janus through the backend, as you lock certain things out like creating a room from the frontend, or having the backend clear out empty calls. Since I run everything through a firewall, I let janus use my already existing STUN/TURN servers, but it is capable of handling that itself.

My plan will be to start it on our deployment on azure, probably giving it 4 cores and 6gb ram to start, but that will end up being scaled and we will deploy more janus servers if we see limits being met. There is no real "best" way to gauge how intensive it can be, but I can link you to an article I found interesting when looking into this months back. And definitely be sure to checkout the janus FAQs as well on their site.

https://webrtchacks.com/sfu-load-testing/

https://www.slideshare.net/LorenzoMiniero/scaling-webrtc-applications-with-janus

roelmagdaleno's avatar

Thanks for the article, it has been difficult to find any (updated) guide to follow step by step. It would be awesome if you could write a guide with all your knowledge, I would do the same but in spanish. :D

Thanks a lot!

snigdho991's avatar

Hello brother. I have integrated the video conference/group chat with twilio sdk. I think, in your application's group option there's the feature. And I want to integrate it by WebRTC with your way. How I can achieve this ? N.B: I don't need the full application of you. I just want to know about the video group chat feature. Can you please help me to give me some guideline for making this ? I will be very grateful to you then. Thanks in advance.

saeed410's avatar

jauns server is very hard to install especially for us who rarely work with command-line servers. Isn't there a simpler server or step-by-step installation doc to install media and signaling servers? @Tippin , it's too much to ask. I would be very grateful if you could publish a video tutorial to install janus server integrated with your project RTippin messenger.I tried but I could'nt.

Tippin's avatar

I do not make videos, sorry. I would say most media servers will require a bit of setup, and if that does not sound like something you want to manage, you can always use a 3rd party provider like Twillio, BigBlueButton, and more. Have you tried looking up other youtube videos for how to install and setup janus?

Currently my buddy keeps a docker image updated and all I have to do is deploy the image, but it requires you know a bit about docker. Example (not up to date but works): https://github.com/ajnozari/janus-gateway

In my demo, I just have a janus docker node setup from within portainer https://www.portainer.io/

Backend wise for how I create and destroy rooms through the janus API, you can find my PHP wrapper here: https://github.com/RTippin/messenger/tree/master/src/Services/Janus

Please or to participate in this conversation.