Merge pull request #435 from mconf/improving-client-checks
Client check - improvements to the webrtc related tests
This commit is contained in:
commit
298a0e4525
2
bbb-client-check/.gitignore
vendored
2
bbb-client-check/.gitignore
vendored
@ -7,3 +7,5 @@ org.eclipse.ltk.core.refactoring.prefs
|
||||
FlexPrettyPrintCommand.prefs
|
||||
index.template.html
|
||||
conf/config.xml
|
||||
resources/lib/bbb_webrtc_bridge_sip.js
|
||||
resources/lib/sip.js
|
||||
|
@ -103,6 +103,11 @@
|
||||
</target>
|
||||
<target name="Resolve-Dependency"
|
||||
description="Generate HTML wrapper">
|
||||
<copy todir="resources/lib/" >
|
||||
<fileset file="../bigbluebutton-client/resources/prod/lib/bbb_webrtc_bridge_sip.js" />
|
||||
<fileset file="../bigbluebutton-client/resources/prod/lib/sip.js" />
|
||||
</copy>
|
||||
|
||||
<get src="${TEST_IMAGE_URL}" dest="${html.output}/test_image.jpg" skipexisting="true" />
|
||||
<copy file="html-template/index.html"
|
||||
tofile="${html.output}/index.html"/>
|
||||
|
@ -35,7 +35,8 @@
|
||||
<!-- END Browser History required section -->
|
||||
|
||||
<script type="text/javascript" src="resources/lib/api-bridge.js"></script>
|
||||
<script type="text/javascript" src="resources/lib/sip-0.6.2.js"></script>
|
||||
<script type="text/javascript" src="resources/lib/sip.js"></script>
|
||||
<script type="text/javascript" src="resources/lib/bbb_webrtc_bridge_sip.js"></script>
|
||||
<script type="text/javascript" src="resources/lib/deployJava.js"></script>
|
||||
<script type="text/javascript" src="swfobject.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
@ -34,8 +34,10 @@
|
||||
<script type="text/javascript" src="history/history.js"></script>
|
||||
<!-- END Browser History required section -->
|
||||
|
||||
<script type="text/javascript" src="resources/lib/sip-0.6.2.js"></script>
|
||||
<script type="text/javascript" src="resources/lib/api-bridge.js"></script>
|
||||
<script type="text/javascript" src="resources/lib/api-bridge.js"></script>
|
||||
<script type="text/javascript" src="resources/lib/sip.js"></script>
|
||||
<script type="text/javascript" src="resources/lib/bbb_webrtc_bridge_sip.js"></script>
|
||||
<script type="text/javascript" src="resources/lib/deployJava.js"></script>
|
||||
<script type="text/javascript" src="swfobject.js"></script>
|
||||
<script type="text/javascript">
|
||||
// For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection.
|
||||
@ -62,6 +64,7 @@
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="deployJavaPluginContainer" style="visibility:hidden; height:0px; "></div>
|
||||
<!-- SWFObject's dynamic embed method replaces this alternative HTML content with Flash content when enough
|
||||
JavaScript and Flash plug-in support is available. The div is initially hidden so that it doesn't show
|
||||
when JavaScript is disabled.
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
var BBBClientCheck = {};
|
||||
var BBB = {};
|
||||
var userAgent;
|
||||
var userMicMedia;
|
||||
var currentSession;
|
||||
@ -184,152 +185,121 @@
|
||||
}
|
||||
|
||||
BBBClientCheck.isWebRTCSupported = function() {
|
||||
var isWebRTCSupportedInfo = SIP.WebRTC.isSupported();
|
||||
var isWebRTCSupportedInfo = isWebRTCAvailable();
|
||||
var swfObj = getSwfObj();
|
||||
|
||||
swfObj.isWebRTCSupported(isWebRTCSupportedInfo);
|
||||
}
|
||||
|
||||
BBBClientCheck.webRTCEchoAndSocketTest = function() {
|
||||
var audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
var silentStream = audioContext.createMediaStreamDestination().stream;
|
||||
|
||||
userMicMedia = silentStream;
|
||||
|
||||
startWebRTCAudioTest();
|
||||
}
|
||||
|
||||
function startWebRTCAudioTest() {
|
||||
console.log("Starting WebRTC audio test...");
|
||||
function sendWebRTCEchoTestAnswer(success, errorcode=undefined) {
|
||||
var swfObj = getSwfObj();
|
||||
|
||||
var callback = function(message) {
|
||||
switch(message.status) {
|
||||
case 'websocketFailed':
|
||||
console.log("websocketFailed");
|
||||
swfObj.webRTCSocketTest(false, message.cause);
|
||||
break;
|
||||
case 'websocketSuccess':
|
||||
console.log("websocketSuccess");
|
||||
swfObj.webRTCSocketTest(true, 'Connected');
|
||||
break;
|
||||
case 'failed':
|
||||
swfObj.webRTCEchoTest(false, message.cause);
|
||||
console.log("call failed");
|
||||
break;
|
||||
case 'ended':
|
||||
console.log("call ended");
|
||||
break;
|
||||
case 'started':
|
||||
console.log("call started");
|
||||
swfObj.webRTCEchoTest(true, 'Connected');
|
||||
break;
|
||||
case 'mediasuccess':
|
||||
console.log("call mediasuccess");
|
||||
break;
|
||||
case 'mediafail':
|
||||
console.log("call mediafail");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var callerIdName = "12345" + "-bbbID-" + "bbbTestUser";
|
||||
webrtc_call(callerIdName, "9196", callback);
|
||||
}
|
||||
|
||||
function createUA(username, server, callback) {
|
||||
|
||||
/* VERY IMPORTANT
|
||||
* - You must escape the username because spaces will cause the connection to fail
|
||||
* - We are connecting to the websocket through an nginx redirect instead of directly to 5066
|
||||
*/
|
||||
var configuration = {
|
||||
uri: 'sip:' + encodeURIComponent(username) + '@' + server,
|
||||
wsServers: 'ws://' + server + '/ws',
|
||||
displayName: username,
|
||||
register: false,
|
||||
traceSip: false,
|
||||
userAgentString: "BigBlueButton",
|
||||
stunServers: "stun:stun.freeswitch.org"
|
||||
};
|
||||
|
||||
console.log("Creating SIP.UA");
|
||||
|
||||
userAgent = new SIP.UA(configuration);
|
||||
|
||||
userAgent.on('disconnected', function() {
|
||||
if (userAgent !== undefined) {
|
||||
userAgent.stop();
|
||||
userAgent = null;
|
||||
callback({status: 'websocketFailed', cause: 'Could not make a WebSocket Connection'});
|
||||
}
|
||||
});
|
||||
|
||||
userAgent.on('connected', function() {
|
||||
callback({status: 'websocketSuccess'});
|
||||
});
|
||||
|
||||
userAgent.start();
|
||||
}
|
||||
|
||||
function make_call(username, voiceBridge, server, callback) {
|
||||
|
||||
var audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
var silentStream = audioContext.createMediaStreamDestination().stream;
|
||||
|
||||
console.log("Setting options.. ");
|
||||
var options = {
|
||||
media: {
|
||||
stream: silentStream,
|
||||
render: {
|
||||
remote: {
|
||||
audio: document.getElementById('remote-media')
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
console.log("Calling to " + voiceBridge + "....");
|
||||
currentSession = userAgent.invite('sip:' + voiceBridge + '@' + server, options);
|
||||
|
||||
console.log("Call connecting...");
|
||||
|
||||
currentSession.on('failed', function(response, cause) {
|
||||
console.log('call failed with the case ' + casuse);
|
||||
callback({status: 'failed', cause: cause});
|
||||
});
|
||||
|
||||
currentSession.on('bye', function(request) {
|
||||
console.log('call ended ' + currentSession.endTime);
|
||||
callback({status: 'ended'})
|
||||
});
|
||||
|
||||
currentSession.on('accepted', function(data) {
|
||||
console.log('BigBlueClient Test Call started');
|
||||
callback({status: 'started'});
|
||||
swfObj.webRTCEchoTest(success, errorcode);
|
||||
|
||||
webrtc_hangup(function() {
|
||||
console.log("[BBBClientCheck] Handling webRTC hangup callback");
|
||||
var userAgentTemp = userAgent;
|
||||
userAgent = null;
|
||||
userAgentTemp.stop();
|
||||
});
|
||||
}
|
||||
|
||||
function webrtc_call(username, voiceBridge, callback) {
|
||||
console.log("webrtc_call started...");
|
||||
|
||||
if (!SIP.WebRTC.isSupported()) {
|
||||
callback({status: "failed", cause: "Browser version not supported" });
|
||||
|
||||
BBB.getMyUserInfo = function(callback) {
|
||||
var obj = {
|
||||
myUserID: "12345",
|
||||
myUsername: "bbbTestUser",
|
||||
myAvatarURL: "undefined",
|
||||
myRole: "undefined",
|
||||
amIPresenter: "undefined",
|
||||
dialNumber: "undefined",
|
||||
voiceBridge: "undefined",
|
||||
customdata: "undefined"
|
||||
}
|
||||
|
||||
var server = window.document.location.host;
|
||||
console.log("webrtc_call server: " + server);
|
||||
|
||||
if(userAgent == undefined) {
|
||||
createUA(username, server, callback);
|
||||
}
|
||||
else {
|
||||
callback({status: 'websocketSuccess'});
|
||||
}
|
||||
|
||||
make_call(username, voiceBridge, server, callback);
|
||||
|
||||
callback(obj);
|
||||
}
|
||||
|
||||
function getUserMicMedia(getUserMediaSuccess, getUserMicMediaFail) {
|
||||
if (userMicMedia == undefined) {
|
||||
SIP.WebRTC.getUserMedia({audio:true, video:false}, getUserMediaSuccess, getUserMicMediaFail);
|
||||
} else {
|
||||
getUserMicMediaSuccess(userMicMedia);
|
||||
}
|
||||
|
||||
// webrtc test callbacks
|
||||
BBB.webRTCEchoTestFailed = function(errorcode) {
|
||||
console.log("[BBBClientCheck] Handling webRTCEchoTestFailed");
|
||||
sendWebRTCEchoTestAnswer(false, errorcode);
|
||||
}
|
||||
|
||||
BBB.webRTCEchoTestEnded = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCEchoTestEnded");
|
||||
}
|
||||
|
||||
BBB.webRTCEchoTestStarted = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCEchoTestStarted");
|
||||
sendWebRTCEchoTestAnswer(true, 'Connected');
|
||||
}
|
||||
|
||||
BBB.webRTCEchoTestConnecting = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCEchoTestConnecting");
|
||||
}
|
||||
|
||||
BBB.webRTCEchoTestWaitingForICE = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCEchoTestWaitingForICE");
|
||||
}
|
||||
|
||||
BBB.webRTCEchoTestWebsocketSucceeded = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCEchoTestWebsocketSucceeded");
|
||||
var swfObj = getSwfObj();
|
||||
swfObj.webRTCSocketTest(true, 'Connected');
|
||||
}
|
||||
|
||||
BBB.webRTCEchoTestWebsocketFailed = function(errorcode) {
|
||||
console.log("[BBBClientCheck] Handling webRTCEchoTestWebsocketFailed");
|
||||
var swfObj = getSwfObj();
|
||||
swfObj.webRTCSocketTest(false, errorcode);
|
||||
}
|
||||
|
||||
// webrtc callbacks
|
||||
BBB.webRTCConferenceCallFailed = function(errorcode) {
|
||||
console.log("[BBBClientCheck] Handling webRTCConferenceCallFailed");
|
||||
}
|
||||
|
||||
BBB.webRTCConferenceCallEnded = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCConferenceCallEnded");
|
||||
}
|
||||
|
||||
BBB.webRTCConferenceCallStarted = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCConferenceCallStarted");
|
||||
}
|
||||
|
||||
BBB.webRTCConferenceCallConnecting = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCConferenceCallConnecting");
|
||||
}
|
||||
|
||||
BBB.webRTCConferenceCallWaitingForICE = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCConferenceCallWaitingForICE");
|
||||
}
|
||||
|
||||
BBB.webRTCConferenceCallWebsocketSucceeded = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCConferenceCallWebsocketSucceeded");
|
||||
}
|
||||
|
||||
BBB.webRTCConferenceCallWebsocketFailed = function(errorcode) {
|
||||
console.log("[BBBClientCheck] Handling webRTCConferenceCallWebsocketFailed");
|
||||
}
|
||||
|
||||
BBB.webRTCMediaRequest = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCMediaRequest");
|
||||
}
|
||||
|
||||
BBB.webRTCMediaSuccess = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCMediaSuccess");
|
||||
}
|
||||
|
||||
BBB.webRTCMediaFail = function() {
|
||||
console.log("[BBBClientCheck] Handling webRTCMediaFail");
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -462,6 +462,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
BBB.webRTCConferenceCallWebsocketSucceeded = function() {
|
||||
}
|
||||
|
||||
BBB.webRTCConferenceCallWebsocketFailed = function(errorcode) {
|
||||
var swfObj = getSwfObj();
|
||||
if (swfObj) {
|
||||
swfObj.webRTCConferenceCallFailed(errorcode);
|
||||
}
|
||||
}
|
||||
|
||||
BBB.webRTCEchoTestStarted = function() {
|
||||
var swfObj = getSwfObj();
|
||||
if (swfObj) {
|
||||
@ -498,6 +508,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
BBB.webRTCEchoTestWebsocketSucceeded = function() {
|
||||
}
|
||||
|
||||
BBB.webRTCEchoTestWebsocketFailed = function(reason) {
|
||||
var swfObj = getSwfObj();
|
||||
if (swfObj) {
|
||||
swfObj.webRTCEchoTestFailed(reason);
|
||||
}
|
||||
}
|
||||
|
||||
BBB.webRTCMediaRequest = function() {
|
||||
var swfObj = getSwfObj();
|
||||
if (swfObj) {
|
||||
|
@ -50,6 +50,12 @@ function joinWebRTCVoiceConference() {
|
||||
case 'mediafail':
|
||||
BBB.webRTCMediaFail();
|
||||
break;
|
||||
case 'websocketSucceded':
|
||||
BBB.webRTCConferenceCallWebsocketSucceeded();
|
||||
break;
|
||||
case 'websocketFailed':
|
||||
BBB.webRTCConferenceCallWebsocketFailed(message.errorcode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,6 +96,12 @@ function startWebRTCAudioTest(){
|
||||
case 'mediafail':
|
||||
BBB.webRTCMediaFail();
|
||||
break;
|
||||
case 'websocketSucceded':
|
||||
BBB.webRTCEchoTestWebsocketSucceeded();
|
||||
break;
|
||||
case 'websocketFailed':
|
||||
BBB.webRTCEchoTestWebsocketFailed(message.errorcode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,6 +186,7 @@ function createUA(username, server, callback) {
|
||||
userAgent = new SIP.UA(configuration);
|
||||
userAgent.on('connected', function() {
|
||||
uaConnected = true;
|
||||
callback({'status':'websocketSucceded'});
|
||||
});
|
||||
userAgent.on('disconnected', function() {
|
||||
if (userAgent) {
|
||||
@ -181,9 +194,9 @@ function createUA(username, server, callback) {
|
||||
userAgent = null;
|
||||
|
||||
if (uaConnected) {
|
||||
callback({'status':'failed', 'errorcode': 1001}); // WebSocket disconnected
|
||||
callback({'status':'websocketFailed', 'errorcode': 1001}); // WebSocket disconnected
|
||||
} else {
|
||||
callback({'status':'failed', 'errorcode': 1002}); // Could not make a WebSocket connection
|
||||
callback({'status':'websocketFailed', 'errorcode': 1002}); // Could not make a WebSocket connection
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user