提交 eb3a27cc authored 作者: Seven Du's avatar Seven Du

use 4 spaces indent to match the default of jslint

this is the first step of making the code follow the default jslint behaviour,
I also manually changed some { } to make it reasonable in addition to replacing tabs
上级 ab24bde2
...@@ -64,8 +64,9 @@ ...@@ -64,8 +64,9 @@
var newLine = []; var newLine = [];
var index = 0; var index = 0;
for (var i = 0; i < elements.length; i++) { for (var i = 0; i < elements.length; i++) {
if (index === 3) // Format of media starts from the fourth. if (index === 3) { // Format of media starts from the fourth.
newLine[index++] = payload; // Put target payload to the first. newLine[index++] = payload; // Put target payload to the first.
}
if (elements[i] !== payload) newLine[index++] = elements[i]; if (elements[i] !== payload) newLine[index++] = elements[i];
} }
return newLine.join(' '); return newLine.join(' ');
...@@ -76,7 +77,7 @@ ...@@ -76,7 +77,7 @@
useVideo: null, useVideo: null,
useStereo: false, useStereo: false,
userData: null, userData: null,
iceServers: false, iceServers: false,
videoParams: {}, videoParams: {},
audioParams: {}, audioParams: {},
callbacks: { callbacks: {
...@@ -84,8 +85,7 @@ ...@@ -84,8 +85,7 @@
onICE: function() {}, onICE: function() {},
onOfferSDP: function() {} onOfferSDP: function() {}
} }
}, }, options);
options);
this.mediaData = { this.mediaData = {
SDP: null, SDP: null,
...@@ -163,9 +163,9 @@ ...@@ -163,9 +163,9 @@
function setCompat() { function setCompat() {
$.FSRTC.moz = !!navigator.mozGetUserMedia; $.FSRTC.moz = !!navigator.mozGetUserMedia;
//navigator.getUserMedia || (navigator.getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia); //navigator.getUserMedia || (navigator.getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia);
if (!navigator.getUserMedia) { if (!navigator.getUserMedia) {
navigator.getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia; navigator.getUserMedia = navigator.mozGetUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia;
} }
} }
function checkCompat() { function checkCompat() {
...@@ -307,7 +307,7 @@ ...@@ -307,7 +307,7 @@
return onChannelError(self, e); return onChannelError(self, e);
}, },
constraints: self.constraints, constraints: self.constraints,
iceServers: self.options.iceServers, iceServers: self.options.iceServers,
offerSDP: { offerSDP: {
type: "offer", type: "offer",
sdp: self.remoteSDP sdp: self.remoteSDP
...@@ -324,9 +324,9 @@ ...@@ -324,9 +324,9 @@
getUserMedia({ getUserMedia({
constraints: { constraints: {
audio: { audio: {
mandatory: this.options.audioParams, mandatory: this.options.audioParams,
optional: [] optional: []
}, },
video: this.options.useVideo ? { video: this.options.useVideo ? {
mandatory: this.options.videoParams, mandatory: this.options.videoParams,
optional: [] optional: []
...@@ -371,7 +371,7 @@ ...@@ -371,7 +371,7 @@
return onChannelError(self, e); return onChannelError(self, e);
}, },
constraints: self.constraints, constraints: self.constraints,
iceServers: self.options.iceServers, iceServers: self.options.iceServers,
}); });
onStreamSuccess(self); onStreamSuccess(self);
...@@ -384,9 +384,9 @@ ...@@ -384,9 +384,9 @@
getUserMedia({ getUserMedia({
constraints: { constraints: {
audio: { audio: {
mandatory: this.options.audioParams, mandatory: this.options.audioParams,
optional: [] optional: []
}, },
video: this.options.useVideo ? { video: this.options.useVideo ? {
mandatory: this.options.videoParams, mandatory: this.options.videoParams,
optional: [] optional: []
...@@ -398,11 +398,11 @@ ...@@ -398,11 +398,11 @@
}); });
/* /*
navigator.getUserMedia({ navigator.getUserMedia({
video: this.options.useVideo, video: this.options.useVideo,
audio: true audio: true
}, onSuccess, onError); }, onSuccess, onError);
*/ */
}; };
...@@ -428,34 +428,34 @@ ...@@ -428,34 +428,34 @@
credential: 'homeo' credential: 'homeo'
}; };
var iceServers = null; var iceServers = null;
if (options.iceServers) { if (options.iceServers) {
var tmp = options.iceServers;; var tmp = options.iceServers;;
if (typeof(tmp) === "boolean") { if (typeof(tmp) === "boolean") {
tmp = null; tmp = null;
} }
if (tmp && typeof(tmp) !== "array") { if (tmp && typeof(tmp) !== "array") {
console.warn("iceServers must be an array, reverting to default ice servers"); console.warn("iceServers must be an array, reverting to default ice servers");
tmp = null; tmp = null;
} }
iceServers = { iceServers = {
iceServers: tmp || [STUN] iceServers: tmp || [STUN]
}; };
if (!moz && !tmp) { if (!moz && !tmp) {
if (parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2]) >= 28) TURN = { if (parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2]) >= 28) TURN = {
url: 'turn:turn.bistri.com:80', url: 'turn:turn.bistri.com:80',
credential: 'homeo', credential: 'homeo',
username: 'homeo' username: 'homeo'
}; };
iceServers.iceServers = [STUN]; iceServers.iceServers = [STUN];
} }
} }
var optional = { var optional = {
optional: [] optional: []
...@@ -488,30 +488,30 @@ ...@@ -488,30 +488,30 @@
options.onICESDP(peer.localDescription); options.onICESDP(peer.localDescription);
//x = 1; //x = 1;
/* /*
x = 1; x = 1;
peer.createOffer(function(sessionDescription) { peer.createOffer(function(sessionDescription) {
sessionDescription.sdp = serializeSdp(sessionDescription.sdp); sessionDescription.sdp = serializeSdp(sessionDescription.sdp);
peer.setLocalDescription(sessionDescription); peer.setLocalDescription(sessionDescription);
if (options.onICESDP) { if (options.onICESDP) {
options.onICESDP(sessionDescription); options.onICESDP(sessionDescription);
} }
}, onSdpError, constraints); }, onSdpError, constraints);
*/ */
} }
} else { } else {
if (!x && options.onICESDP) { if (!x && options.onICESDP) {
options.onICESDP(peer.localDescription); options.onICESDP(peer.localDescription);
//x = 1; //x = 1;
/* /*
x = 1; x = 1;
peer.createAnswer(function(sessionDescription) { peer.createAnswer(function(sessionDescription) {
sessionDescription.sdp = serializeSdp(sessionDescription.sdp); sessionDescription.sdp = serializeSdp(sessionDescription.sdp);
peer.setLocalDescription(sessionDescription); peer.setLocalDescription(sessionDescription);
if (options.onICESDP) { if (options.onICESDP) {
options.onICESDP(sessionDescription); options.onICESDP(sessionDescription);
} }
}, onSdpError, constraints); }, onSdpError, constraints);
*/ */
} }
} }
} }
...@@ -730,8 +730,8 @@ ...@@ -730,8 +730,8 @@
channel: channel, channel: channel,
sendData: function(message) { sendData: function(message) {
if (channel) { if (channel) {
channel.send(message); channel.send(message);
} }
}, },
stop: function() { stop: function() {
...@@ -770,8 +770,8 @@ ...@@ -770,8 +770,8 @@
//video.play(); //video.play();
} }
if (options.onsuccess) { if (options.onsuccess) {
options.onsuccess(stream); options.onsuccess(stream);
} }
media = stream; media = stream;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论