summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2017-01-03 12:08:21 -0300
committerCorey Hulen <corey@hulen.com>2017-01-03 10:08:21 -0500
commit144219964742c35eebf6d75ae27ad17732c89dae (patch)
tree499275f4079369e2e3da037926f5a841cd33961c /webapp/components
parent7cdfba62ef991f36363592a70f08db6a88b3c332 (diff)
downloadchat-144219964742c35eebf6d75ae27ad17732c89dae.tar.gz
chat-144219964742c35eebf6d75ae27ad17732c89dae.tar.bz2
chat-144219964742c35eebf6d75ae27ad17732c89dae.zip
PLT-4644 Update webrtc client (#4922)
* PLT-4644 Update webrtc client * update webrtc-adapter * Use default ice server if none is provided
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/webrtc/webrtc_controller.jsx37
1 files changed, 31 insertions, 6 deletions
diff --git a/webapp/components/webrtc/webrtc_controller.jsx b/webapp/components/webrtc/webrtc_controller.jsx
index 7e0cdb098..36278b3f4 100644
--- a/webapp/components/webrtc/webrtc_controller.jsx
+++ b/webapp/components/webrtc/webrtc_controller.jsx
@@ -7,7 +7,7 @@ import WebrtcStore from 'stores/webrtc_store.jsx';
import Client from 'client/web_client.jsx';
import WebSocketClient from 'client/web_websocket_client.jsx';
-import WebrtcSession from 'client/webrtc_session.jsx';
+import Janus from 'janus';
import SearchBox from '../search_bar.jsx';
import WebrtcHeader from './components/webrtc_header.jsx';
@@ -44,6 +44,8 @@ export default class WebrtcController extends React.Component {
this.close = this.close.bind(this);
this.clearError = this.clearError.bind(this);
+ this.getLocalMedia = this.getLocalMedia.bind(this);
+ this.stopMediaStream = this.stopMediaStream.bind(this);
this.previewVideo = this.previewVideo.bind(this);
this.stopRinging = this.stopRinging.bind(this);
@@ -160,6 +162,30 @@ export default class WebrtcController extends React.Component {
}, Constants.WEBRTC_CLEAR_ERROR_DELAY);
}
+ getLocalMedia(constraints, element, callback) {
+ const media = constraints || {audio: true, video: true};
+ navigator.mediaDevices.getUserMedia(media).
+ then((stream) => {
+ if (element) {
+ element.srcObject = stream;
+ }
+
+ if (callback && typeof callback === 'function') {
+ callback(null, stream);
+ }
+ }).
+ catch((error) => {
+ callback(error);
+ });
+ }
+
+ stopMediaStream(stream) {
+ const tracks = stream.getTracks();
+ tracks.forEach((track) => {
+ track.stop();
+ });
+ }
+
previewVideo() {
if (this.mounted) {
if (this.localMedia) {
@@ -169,7 +195,7 @@ export default class WebrtcController extends React.Component {
});
this.localMedia.enabled = true;
} else {
- WebrtcSession.getLocalMedia(
+ this.getLocalMedia(
{
audio: true,
video: {
@@ -399,12 +425,11 @@ export default class WebrtcController extends React.Component {
if (this.session) {
this.session.destroy();
- this.session.disconnect();
this.session = null;
}
if (this.localMedia) {
- WebrtcSession.stopMediaStream(this.localMedia);
+ this.stopMediaStream(this.localMedia);
this.localMedia = null;
}
@@ -648,8 +673,8 @@ export default class WebrtcController extends React.Component {
});
}
- this.session = new WebrtcSession({
- debug: global.mm_config.EnableDeveloper === 'true',
+ Janus.init({debug: global.mm_config.EnableDeveloper === 'true'});
+ this.session = new Janus({
server: info.gateway_url,
iceServers,
token: info.token,