Jan Lelis (@janlelis) | Paris to Berlin Hackathon | October 18, 2013
Free browser-to-browser video communication
We are open sourcing our stack: github.com/palavatv
Brings real-time communications to the web!
Already supported in Chromes & Firefoxes out there -- pluginfree
Theoretical endpoints: Uncountable!
getUserMedia
<video id="gum-video" autoplay="autoplay">
<script>
navigator.webkitGetUserMedia(
{video: true, audio: false},
function(stream) {
document.getElementById('gum-video').src =
webkitURL.createObjectURL(stream);
}
);
</script>
Developer implements how to establish a PeerConnection
palava-machine (ruby)
signalmaster (node.js)
webrtc.io (node.js)
together.js hub (node.js)
peerjs server (node.js)
We are working on a webrtc signaling service. You might want to check it out if you consider using webrtc in a future project.
PeerConnection
// already got localStream via getUserMedia
var pc = new webkitRTCPeerConnection(
{iceServers: [{url: "stun:93.186.193.18"}]},
{optional: [{DtlsSrtpKeyAgreement: true}]}
);
pc.addStream(localStream);
pc.onaddstream = function(event) {
console.log("adding remote stream");
$('#video-tag')[0].src =
webkitURL.createObjectURL(event.stream);
};
PeerConnection
// connect to signaling provider
var server = new WebSocket('wss:palava.tv:4233');
// ...
pc.createOffer(function(sdp) {
// register local sdp in our new connection
pc.setLocalDescription(sdp);
// send the "sdp" to other peer
server.send(JSON.stringify({peer_id: 42, event: 'offer', sdp: sdp}));
// ...
// other peer receives 'offer' and sends an 'answer' via server
server.onmessage = function(msg) {
payload = JSON.parse(msg.data);
if(payload.event === 'answer') {
pc.setRemoteDescription(
new RTCSessionDescription(payload.sdp)
);
// exchange ice candidates... when finished:
// pc.onaddstream callback will be called by WebRTC
Allows for a new generation of real-time applications
Provides a simple JavaScript APIs for doing so
It is a standard:
It is designed to be compatible with the rest of the world
blog.palava.tv | twitter.com/palavatv | github.com/palavatv
Feel free to contact me for questions @janlelis | jan@signaling.io