Selecting bot_type changed to be specified in the test file
Selecting bot_type changed to be specified in the test file instead of
specify it in the running command.
Now we can write test for rtcBot that run one bot on chrome for android
and the other bot on chrome for desktop.
R=andresp@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/23069004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7458 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/tools/rtcbot/bot/browser/bot.js b/webrtc/tools/rtcbot/bot/browser/bot.js
index 808d88a..f278d89 100644
--- a/webrtc/tools/rtcbot/bot/browser/bot.js
+++ b/webrtc/tools/rtcbot/bot/browser/bot.js
@@ -25,10 +25,10 @@
}
}
-function createPeerConnection(doneCallback, failCallback) {
+function createPeerConnection(config, doneCallback, failCallback) {
console.log("Creating peer connection");
var obj = {};
- var pc = new webkitRTCPeerConnection(null);
+ var pc = new webkitRTCPeerConnection(config);
expose(obj, pc, "close");
expose(obj, pc, "createOffer");
@@ -113,9 +113,38 @@
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,
});