Skip to content

Commit 694bc22

Browse files
committed
test
1 parent baccde7 commit 694bc22

File tree

8 files changed

+101
-26
lines changed

8 files changed

+101
-26
lines changed

.jshintrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
"inject",
2323
"expect",
2424
"spyOn",
25-
25+
2626
"QB",
2727
"CONFIG",
2828
"QBApp",
29-
"QBUsers"
29+
"QBUsers",
30+
"Promise"
3031
]
31-
}
32+
}

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = function (grunt) {
5858
server: {
5959
options: {
6060
protocol: 'https',
61-
hostname: '192.168.1.133',
61+
hostname: 'localhost',
6262
port: 8080,
6363
open: true,
6464
keepalive: true

js/modules/webrtc/qbWebRTCClient.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* - onStopCallListener(session, userID, extension)
1212
* - onUpdateCallListener(session, userID, extension)
1313
*/
14+
'use strict';
1415

1516
var WebRTCSession = require('./qbWebRTCSession');
1617
var WebRTCSignalingProcessor = require('./qbWebRTCSignalingProcessor');
@@ -41,6 +42,63 @@ function WebRTCClient(service, connection) {
4142
this.sessions = {};
4243
}
4344

45+
/**
46+
* [function description]
47+
* @param {[string]} spec [specify what type of devices you wnat to get.
48+
* Possible values: audioinput, audiooutput, videoinput]
49+
* @return {[array]} [array of devices]
50+
*/
51+
WebRTCClient.prototype.getMediaDevices = function(spec) {
52+
var specDevices = [],
53+
errMsg = 'Selection of camera is unavailable.';
54+
55+
return new Promise(function(resolve, reject) {
56+
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
57+
reject(errMsg);
58+
Helpers.traceWarning(errMsg);
59+
} else {
60+
navigator.mediaDevices.enumerateDevices().then(function(devices) {
61+
if(spec) {
62+
devices.forEach(function(device, i) {
63+
if(device.kind === spec) {
64+
specDevices.push(device);
65+
}
66+
});
67+
68+
resolve(specDevices);
69+
} else {
70+
resolve(devices);
71+
}
72+
});
73+
}
74+
});
75+
};
76+
77+
// WebRTCClient.getOutputDevices = function(callback) {
78+
//
79+
// return new Promise(function() {
80+
//
81+
// devices.forEach(function(device, i) {
82+
// if(device.kind === 'videoinput') {
83+
// /** If user don't share device, device.label will be empty */
84+
// if(device.label === '') {
85+
// device.name = 'Camera #' + index;
86+
// ++index;
87+
// }
88+
// avaibleDevices.push(device);
89+
// }
90+
// });
91+
//
92+
// callback(avaibleDevices, null);
93+
// })
94+
// .catch(function(error) {
95+
// Helpers.traceError(error.name + ": " + error.message);
96+
//
97+
// callback(null, err);
98+
// });
99+
// });
100+
// };
101+
44102
/**
45103
* A map with all sessions the user had/have.
46104
* @type {Object.<string, Object>}

js/modules/webrtc/qbWebRTCHelpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ WebRTCHelpers.CallType = {
7676
AUDIO: 2
7777
};
7878

79-
module.exports = WebRTCHelpers;
79+
module.exports = WebRTCHelpers;

quickblox.min.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/webrtc/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ <h4 class="caller__name">
225225
</div>
226226

227227
<div class="caller__frames_fl">
228-
<select class="caller__frames_fl_select j-filter">
228+
<select class="qb-select j-filter">
229229
<option value="no">No Filter</option>
230230
<option value="_1977">1977</option>
231231
<option value="inkwell">inkwell</option>
@@ -236,6 +236,11 @@ <h4 class="caller__name">
236236
<option value="walden">walden</option>
237237
</select>
238238
</div>
239+
240+
<div class="caller__frames_source">
241+
<select class="qb-select j-source invisible">
242+
</select>
243+
</div>
239244
</div>
240245
</div>
241246
</script>

samples/webrtc/js/app.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
var ui = {
1313
'income_call': '#income_call',
14-
'filterSelect': '.j-filter'
14+
'filterSelect': '.j-filter',
15+
'sourceFilter': '.j-source'
1516
};
1617

1718
var call = {
@@ -110,6 +111,16 @@
110111
var framesTpl = _.template( $('#frames_tpl').html() );
111112
$('.j-board').append( framesTpl({'nameUser': app.caller.full_name}));
112113

114+
QB.webrtc.getMediaDevices('videoinput').then(function(devices) {
115+
if(devices.length > 1) {
116+
var $select = $('.j-source');
117+
118+
$select.removeClass('invisible');
119+
}
120+
}).catch(function(error) {
121+
console.warn('getMediaDevices', error);
122+
});
123+
113124
app.helpers.setFooterPosition();
114125
}
115126
});

samples/webrtc/styles.css

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ b {
3636
font-weight: 700;
3737
}
3838

39+
.qb-select {
40+
width: 100%;
41+
padding: 6px;
42+
43+
border: 1px solid #cdcdcd;
44+
border-radius: 3px;
45+
46+
outline: none;
47+
}
48+
3949
.qb-video {
4050
position: relative;
4151
padding: 0 0 75% 0; /* 4:3 */
@@ -538,16 +548,6 @@ b {
538548
margin: 30px 0 10px 0;
539549
}
540550

541-
.caller__frames_fl_select {
542-
width: 100%;
543-
padding: 6px;
544-
545-
border: 1px solid #cdcdcd;
546-
border-radius: 3px;
547-
548-
outline: none;
549-
}
550-
551551
/**
552552
* MAIN VIDEO
553553
*/

0 commit comments

Comments
 (0)