====== Audio/Video Calls over XMPP ====== To be able to make audio/video calls using XMPP with ejabberd server ===== Requirements ===== For this we are using **giggle.js** (URL - [[https://github.com/valeriansaliou/giggle]]). While this works fine with Chrome, as Chrome has WebRTC support which is required for the connection, we have faced issues with browsers like Safari and IE. For these browsers to enable calling we use external plugins. (See Plugins) ===== Implementation ===== There are two ways we can achieve this - a) XMPP over websocket. b) XMPP over BOSH. ==== a) XMPP over websocket (Currently Used) ==== We can create a new JSJaCWebSocketConnection. Eg URL- [[https://devtalent01.exphosted.com:5280/websocket]] ==== b) XMPP over BOSH ==== We can create a new JSJaCHttpBindingConnection. Eg URL- [[https://devtalent01.exphosted.com:5280/http-bind]] ===== Code ===== Following are the code changes that needs to be done for Audio/Video calling in Safari and IE while using the plugin:- The plugin basically provides the missing methods required for a browser to support calling over WebRTC. a) **getUserMedia()** - Used to get access to the media streams (video, audio or both). It takes in 3 parameters: 1> constraints (video, audio or both) 2> success_callback (is fired when getting user media is a "success") 3> failure_callback (is fired when getting user media is a "failure") Used as: Plugin.getUserMedia(constraints, success_callback, failure_callback); b) **attachMediaStream()** - Used to attach a media stream to a video element. (Basically sets the src of video element). It takes 2 parameters: 1> video element (to which stream would be attached) 2> stream (received from success block of getUserMedia) Used as: Eg:- Plugin.attachMediaStream(param1, param 2); c) **RTCSessionDescription** - The process of negotiating a connection between two peers involves exchanging RTCSessionDescription objects back and forth until the two peers agree upon a configuration for the connection. d) **RTCIceCandidate** - Typically ICE (Interactive Connectivity Establishment) candidate provides the information about the ip-address and port from where the data is going to be exchanged. Normally, it takes 2 params, but 3rd parameter **sdpMid** is only needed if we are using the plugin: 1> sdpMLineIndex 2> candidate 3> sdpMid e) **RTCPeerConnection()** - This interface represents a WebRTC connection between the local computer and a remote peer. It is used to handle efficient streaming of data between the two peers. It takes in 2 parameters: 1> configuration - holds ice server configs 2> constraints - holds stun server configs The steps and usage of this plugin is take from [[https://github.com/muaz-khan/PluginRTC]] ===== Plugins ===== [[ https://github.com/sarandogou/webrtc-everywhere#downloads ]] [[ https://temasys.atlassian.net/wiki/display/TWPP/Downloading+and+Installing ]] (Currently Being Used For Safari and IE)