From 0371a37f85fe8c1d0d93dbf363aaf2feec0ecf89 Mon Sep 17 00:00:00 2001 From: "houssainy@google.com" Date: Fri, 17 Oct 2014 16:43:50 +0000 Subject: [PATCH] Moving creating TURN configration to the host machine instead of the bots - rtcBot R=andresp@webrtc.org Review URL: https://webrtc-codereview.appspot.com/24939004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7468 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/tools/rtcbot/bot/browser/bot.js | 29 ------------------- webrtc/tools/rtcbot/test.js | 21 ++++++++++++++ .../rtcbot/test/webrtc_video_streaming.js | 6 ++-- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/webrtc/tools/rtcbot/bot/browser/bot.js b/webrtc/tools/rtcbot/bot/browser/bot.js index f278d893b..99ff84d61 100644 --- a/webrtc/tools/rtcbot/bot/browser/bot.js +++ b/webrtc/tools/rtcbot/bot/browser/bot.js @@ -113,38 +113,9 @@ function getStreamFromIdentifier_(id) { return null; }; -// Ask computeengineondemand to give us TURN server credentials and URIs. -function asyncCreateTurnConfig(onSuccess, onError) { - var CEOD_URL = ('https://computeengineondemand.appspot.com/turn?' + - 'username=1234&key=5678'); - var xhr = new XMLHttpRequest(); - function onResult() { - if (xhr.readyState != 4) - return; - - if (xhr.status != 200) { - onError('TURN request failed'); - return; - } - - var response = JSON.parse(xhr.responseText); - var iceServer = { - 'username': response.username, - 'credential': response.password, - 'urls': response.uris - }; - onSuccess({ 'iceServers': [ iceServer ] }); - } - - xhr.onreadystatechange = onResult; - xhr.open('GET', CEOD_URL, true); - xhr.send(); -}; - connectToServer({ ping: ping, getUserMedia: getUserMedia, createPeerConnection: createPeerConnection, showStream: showStream, - asyncCreateTurnConfig: asyncCreateTurnConfig, }); diff --git a/webrtc/tools/rtcbot/test.js b/webrtc/tools/rtcbot/test.js index abf0e173d..33ef960b2 100644 --- a/webrtc/tools/rtcbot/test.js +++ b/webrtc/tools/rtcbot/test.js @@ -9,6 +9,7 @@ // Provides a Test class that exposes api to the tests. // Read test.prototype to see what methods are exposed. var fs = require('fs'); +var request = require('request'); var BotManager = require('./botmanager.js'); function Test() { @@ -71,6 +72,26 @@ Test.prototype = { createStatisticsReport: function (outputFileName) { return new StatisticsReport(outputFileName); }, + + // Ask computeengineondemand to give us TURN server credentials and URIs. + createTurnConfig: function (onSuccess, onError) { + request('https://computeengineondemand.appspot.com/turn?username=1234&key=5678', + function (error, response, body) { + if (error || response.statusCode != 200) { + onError('TURN request failed'); + return; + } + + var response = JSON.parse(body); + var iceServer = { + 'username': response.username, + 'credential': response.password, + 'urls': response.uris + }; + onSuccess({ 'iceServers': [ iceServer ] }); + } + ); + }, } StatisticsReport = function (outputFileName) { diff --git a/webrtc/tools/rtcbot/test/webrtc_video_streaming.js b/webrtc/tools/rtcbot/test/webrtc_video_streaming.js index db08a7837..60df68ec5 100644 --- a/webrtc/tools/rtcbot/test/webrtc_video_streaming.js +++ b/webrtc/tools/rtcbot/test/webrtc_video_streaming.js @@ -20,9 +20,11 @@ function testOneWayVideo(test, bot1, bot2) { onPeerConnectionCreated); function createPeerConnection(done) { - this.asyncCreateTurnConfig(function(config) { + test.createTurnConfig(onTrunConfig.bind(this), test.fail); + + function onTurnConfig(config) { this.createPeerConnection(config, done, test.fail); - }.bind(this), test.fail); + }; } function onPeerConnectionCreated(pc1, pc2) {