Skip to content

Commit

Permalink
Added peer connection configuration option to web API
Browse files Browse the repository at this point in the history
Allows for specifying TURN/STUN servers for web client RobotWebTools#24
  • Loading branch information
Mitchell Wills committed Jun 21, 2015
1 parent 116c2ca commit 46f7a14
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions webrtc_ros/web/webrtc_ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ window.WebrtcRos = (function() {
// Just need unique identifiers for streams
return "webrtc_ros_stream-"+Math.floor(Math.random()*1000000000).toString();
};
var WebrtcRosConnection = function(signalingServerPath) {
var WebrtcRosConnection = function(signalingServerPath, configuration) {
this.signalingServerPath = signalingServerPath || "ws://"+window.location.host+"/webrtc";
this.onConfigurationNeeded = undefined;
this.signalingChannel = null;
this.peerConnection = null;
this.peerConnectionOptions = {
this.peerConnectionMediaConstraints = {
optional: [
{DtlsSrtpKeyAgreement: true}
]
};
this.peerConnectionConfiguration = configuration;

this.lastConfigureActionPromise = Promise.resolve([]);

Expand All @@ -37,7 +38,7 @@ window.WebrtcRos = (function() {
this.signalingChannel.onclose = function() {
console.log("WebRTC signaling close");
};
this.peerConnection = new RTCPeerConnection(null, this.peerConnectionOptions);
this.peerConnection = new RTCPeerConnection(this.peerConnectionConfiguration, this.peerConnectionMediaConstraints);
this.peerConnection.onicecandidate = function(event) {
if (event.candidate) {
var candidate = {
Expand Down Expand Up @@ -221,8 +222,8 @@ window.WebrtcRos = (function() {
};

var WebrtcRos = {
createConnection: function(signalingServerPath) {
return new WebrtcRosConnection(signalingServerPath);
createConnection: function(signalingServerPath, configuration) {
return new WebrtcRosConnection(signalingServerPath, configuration);
}
};
return WebrtcRos;
Expand Down

0 comments on commit 46f7a14

Please sign in to comment.