WebRTC - create a connection client-client from the server - javascript

I'm trying to code a Voice-Call application using WebRTC. I know that I have to create the peer-to-peer connection to connect the two clients in order to start seeing each other in a webcam conference, BUT:
Is there any way to let the server create and maintain the connection?
Following this guide I know that one client has to offer and create a connection and the other has to "reply" in order the start a conversation.
Thank you

You will have to create socket events to send call accept/reject requests.
But first you need to setup server and client side p2p communication.
For webRTC server: Licode webRTC Server
And for ios cleint for Licode :
Visit: Licode Erizo Client iOS
This solution is the only ope source solution available on web.
Best of luck.

Related

How can I have a server stream a video with WebRTC?

My current use case is that I'm trying to mock a system that uses WebRTC for live video streaming (for a robot). This way, I don't have to be connected to the robot to develop the client.
My issue as of now is that I have no idea how to stream a video using WebRTC to connected peers. I've seen many examples of how to do this from client to client using a signaling server, but other than directly sending the video buffer using socket.io, I haven't seen an example of server -> client WebRTC streaming.
I'm planning to use Node.JS for mocking the video stream as I've been using it for the rest of the robot's systems.
It really isn't that different though client to client or server to client. You want to stream/broadcast a video to all the connected peers. Think of your server will be a client in the setup.
You can also use a WebRTC solution like Janus Repo it is a simple gateway and completely open source. Refer to - WebRTC & Dev API's for more info.
If you find latency issues after peers have increased in number you can check - Mesh, Routing, Multi peer architecture for some solutions for it.
Hope it helps.

How To Configure webRTC And Express.js To Run In Same Domain

I'm looking to have a video conference website running on node.js + express.js instead of regular apache and I'm having trouble deciding on a solution.
I need the server to send the website to the user through express.js, plus, connect people in a queue so they can enter a video conference with strangers.
Should I build two different server applications, one for the express.js and one for the webRTC server, listening on different ports?
If so, how can I make the user interact with the different aplications? They will need to be able to login, be placed in the queue and be able to see the strangers once the connection is established.
WebRTC and Express.js is differ ExpressJS (Web frame work mapping your request)
but WebRTC is differ(Peer-to-Peer) communication with the help of signalling means exchange information about two browser so you can use Socket.IO or any other websocket framework
Every thing depend of signalling you want to connect particular person send signalling that particular person its not possible in Express.js so use any websocket framework like socket.io

what can Socket.io connect to?

I'm playing around with an open source project that uses Socket.IO to connect to the website chat.meatspac.es which is hosted on a different server. It connects like this
var socket = socketClient.connect('https://chat.meatspac.es');
And then it listens for the data that is also published on chat.meatspac.es. Does this only work because the chat.meatspac.es is also a Socket.IO application and it's emitting signals that can be picked up by this other open sourced project?
For example, I naively tried to connect to my Twitter stream
var socket = socketClient.connect('https://twitter.com/username');
but it wouldn't listen for messages published in my Twitter feed.
So, my question is, can Socket.IO only connect to servers that are emitting Socket.IO messages?
socket.io allows simulation of socket API (used in traditional desktop apps) for access with javascript (web).
But this is will not behave exactly as traditional sockets behave. It uses HTML5 websockets for sockets simulation
Sockets.io needs to have a compatible server app, that is shown here by deploying a server app using nodejs
Take a look at server side implementations of websockets today, socket.io with nodejs being one of them.
http://www.html5rocks.com/en/tutorials/websockets/basics/
So for your question using socket.io to create a socket connection to twitter:
var socket = socketClient.connect('https://twitter.com/username');
This is not possible because socket.io is not a real socket API, its just a simulation of sockets api using HTML5 websocket api and maybe other fallbacks (long polling, comet, etc). So the server should be compatible to handle the ws(websocket protocol) request and in case of twitter here to get feed stream, this is not the case so this can not be done like that.
See the twitter api to programmatically get access to twitter resources
https://dev.twitter.com/docs/api/1.1

WebRTC - help me understand a few concepts

I'm new to WebRTC, actually just heard about it a few days ago and I've read a lot about it. However, I still have a few questions.
What do I need to explore the usage of WebRTC? E.g.: do I need a server, any libraries etc.? I'm aware that new version of Chrome and Firefox support WebRTC, but besides these two browsers, is there anything else that is necessary?
What is the main purpose of WebRTC when addressing practical usage? To video chat? Audio chat? What about text-chatting?
Does WebRTC need a server for any kind of browser-to-browser interaction? I've seen some libraries, such as PeerJS that don't explicitly mention any kind of server... so is it possible to connect two clients directly? There's also a PeerServer, which supposedly helps broker connections between PeerJS clients. Can I use WebRTC without such a server?
What are the most commonly used libraries for WebRTC?
What's a good starting point for someone who's totally new in WebRTC? I'd like to setup a basic google-talk kind of service, to chat with one person.
Thank you so much guys.
You can find many docs here E.g. this one, this one and this one!
You can find a few libraries here.
A simple multi-user WebRTC app needs following things:
Signalling server to exchange sdp/ice/etc. ---- e.g. socket.io/websockets/xmpp/sip/XHR/etc.
ICE server i.e. STUN and/or TURN; to make sure Firewalls doesn't block UDP/TCP ports
JavaScript app to access/invoke RTCWeb JavaScript API i.e. RTCPeerConnection.
It just takes a few minutes to setup WebRTC peer-to-peer connection. You can setup peer-to-server connections as well where media-servers can be used to transcode/record/merge streams; or to relay to PSTN networks.
WebRTC DataChannels can be used for gaming, webpage synchronizing; fetching static contents, peer-to-peer or peer-to-server data transmission, etc.
What do I need to explore the usage of WebRTC? E.g.: do I need a
server, any libraries etc.? I'm aware that new version of Chrome and
Firefox support WebRTC, but besides these two browsers, is there
anything else that is necessary?
WebRTC it is JavaScript API for web developers which can be used for audio and video streaming.
But there are 2 notices:
You need a signaling path.
For example, if your first user is Alice using Firefox and second user is Bob using Chrome,
they should negotiate used codecs and streams.
WebRTC does not offer the signalling implementation. So you need to implement the signaling yourself. It is quite simple. You need to send SDP(stream config) to participant and receive an SDP answer. You can use plain HTTP via apahe server or use Websockets or any other transport to negotiate SDP.
So, it seems you need an intermediary signaling server workning with websockets or HTTP/HTTPS.
Once you negotiated the streams you are sending your audio or video stream, but the distanation user might have a simmetric NAT. It means that you stream will not be delivered to the target user. In such situation you need a TURN server to traverse the NAT.
Finally you will need 2 server-side logic items:
1) Signaling server
2) TURN or proxy server
To start, take a look Web Call Server.
The server implements HTML5 Websocket signaling and SRTP proxying as a TURN server.
You can also learn the webrtc application open source code.
First steps:
1. Download the signaling and streaming server.
2. Download and unzip web client.
3. Start the web client and debug javascript code to learn more how webrtc works.

WebRTC and Websockets. Is there a difference

I'm assuming that WebRTC is an API that decodes/encodes audio and video, although the communication between the server and the clients is done via web sockets, or some other network protocol? I'm a bit confused. Does WebRTC have its own communications protocol?
There's two sides to WebRTC.
JavaScript APIs (getUserMedia) that allow an app to access camera and microphone hardware. You can use this access to simply display the stream locally (perhaps applying effects), or send the stream over the network. You could send the data to your server, or you could use...
PeerConnection, an API that allows browsers to establish direct peer-to-peer socket connections. You can establish a connection directly to someone else's browser and exchange data directly. This is very useful for high-bandwidth data like video, where you don't want your server to have to deal with relaying large amounts of data.
Take a look at the demos to see both parts of WebRTC in action.
So in a nutshell:
WebSockets allow full-duplex communication between a browser and a web server.
WebRTC's PeerConnection allows full-duplex communication between two browsers.
WebRTC uses RTP (a UDP based protocol) for the media transport, but requires an out-of-band signaling channel to setup the communication. One option for the signaling channel is WebSocket.
Instead of peerConnection you can also look at the WebRTC data channel draft: https://datatracker.ietf.org/doc/html/draft-jesup-rtcweb-data-protocol-00 which is basically bidirectional udp. Which can be a really valuable alternative to WebSockets as doesn't have the "negative" sides of a tcp connection.
No, Signaling is not defined by WebRTC.
Here is an post by the IETF which explains it pretty good why it is not:
http://www.ietf.org/mail-archive/web/rtcweb/current/msg01143.html
This means that you are free to choose how you exchange network information. I.e. you could use websockets, HTTP and even Email, but that would be a bit of a struggle :)

Categories