apprtc: rationalize whitespace
- Remove ^M DOS line endings - Remove trailing whitespace - Remove leading 2-space indents from files that have carried this indent since their contents was removed from within enclosing contexts that required it. - Add a newline to avoid 82-column line. R=vikasmarwaha@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2112004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4619 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -46,7 +46,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
Sorry, this room is full. <a href="{{room_link}}">Click here</a> to try again.
|
Sorry, this room is full.
|
||||||
|
<a href="{{room_link}}">Click here</a> to try again.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<img id="logo" alt="WebRTC" src="images/webrtc_black_20p.png">
|
<img id="logo" alt="WebRTC" src="images/webrtc_black_20p.png">
|
||||||
|
@@ -1,27 +1,27 @@
|
|||||||
var localVideo;
|
var localVideo;
|
||||||
var miniVideo;
|
var miniVideo;
|
||||||
var remoteVideo;
|
var remoteVideo;
|
||||||
var localStream;
|
var localStream;
|
||||||
var remoteStream;
|
var remoteStream;
|
||||||
var channel;
|
var channel;
|
||||||
var pc;
|
var pc;
|
||||||
var socket;
|
var socket;
|
||||||
var xmlhttp;
|
var xmlhttp;
|
||||||
var started = false;
|
var started = false;
|
||||||
var turnDone = false;
|
var turnDone = false;
|
||||||
var channelReady = false;
|
var channelReady = false;
|
||||||
var signalingReady = false;
|
var signalingReady = false;
|
||||||
var msgQueue = [];
|
var msgQueue = [];
|
||||||
// Set up audio and video regardless of what devices are present.
|
// Set up audio and video regardless of what devices are present.
|
||||||
var sdpConstraints = {'mandatory': {
|
var sdpConstraints = {'mandatory': {
|
||||||
'OfferToReceiveAudio': true,
|
'OfferToReceiveAudio': true,
|
||||||
'OfferToReceiveVideo': true }};
|
'OfferToReceiveVideo': true }};
|
||||||
var isVideoMuted = false;
|
var isVideoMuted = false;
|
||||||
var isAudioMuted = false;
|
var isAudioMuted = false;
|
||||||
// Types of gathered ICE Candidates.
|
// Types of gathered ICE Candidates.
|
||||||
var gatheredIceCandidateTypes = { Local: {}, Remote: {} };
|
var gatheredIceCandidateTypes = { Local: {}, Remote: {} };
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
console.log('Initializing; room=' + roomKey + '.');
|
console.log('Initializing; room=' + roomKey + '.');
|
||||||
card = document.getElementById('card');
|
card = document.getElementById('card');
|
||||||
localVideo = document.getElementById('localVideo');
|
localVideo = document.getElementById('localVideo');
|
||||||
@@ -38,9 +38,9 @@
|
|||||||
doGetUserMedia();
|
doGetUserMedia();
|
||||||
// Caller is always ready to create peerConnection.
|
// Caller is always ready to create peerConnection.
|
||||||
signalingReady = initiator;
|
signalingReady = initiator;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openChannel() {
|
function openChannel() {
|
||||||
console.log('Opening channel.');
|
console.log('Opening channel.');
|
||||||
var channel = new goog.appengine.Channel(channelToken);
|
var channel = new goog.appengine.Channel(channelToken);
|
||||||
var handler = {
|
var handler = {
|
||||||
@@ -50,9 +50,9 @@
|
|||||||
'onclose': onChannelClosed
|
'onclose': onChannelClosed
|
||||||
};
|
};
|
||||||
socket = channel.open(handler);
|
socket = channel.open(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
function maybeRequestTurn() {
|
function maybeRequestTurn() {
|
||||||
// Skipping TURN Http request for Firefox version <=22.
|
// Skipping TURN Http request for Firefox version <=22.
|
||||||
// Firefox does not support TURN for version <=22.
|
// Firefox does not support TURN for version <=22.
|
||||||
if (webrtcDetectedBrowser === 'firefox' && webrtcDetectedVersion <=22) {
|
if (webrtcDetectedBrowser === 'firefox' && webrtcDetectedVersion <=22) {
|
||||||
@@ -80,9 +80,9 @@
|
|||||||
xmlhttp.onreadystatechange = onTurnResult;
|
xmlhttp.onreadystatechange = onTurnResult;
|
||||||
xmlhttp.open('GET', turnUrl, true);
|
xmlhttp.open('GET', turnUrl, true);
|
||||||
xmlhttp.send();
|
xmlhttp.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTurnResult() {
|
function onTurnResult() {
|
||||||
if (xmlhttp.readyState !== 4)
|
if (xmlhttp.readyState !== 4)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -103,18 +103,18 @@
|
|||||||
// If TURN request failed, continue the call with default STUN.
|
// If TURN request failed, continue the call with default STUN.
|
||||||
turnDone = true;
|
turnDone = true;
|
||||||
maybeStart();
|
maybeStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetStatus() {
|
function resetStatus() {
|
||||||
if (!initiator) {
|
if (!initiator) {
|
||||||
setStatus('Waiting for someone to join: \
|
setStatus('Waiting for someone to join: \
|
||||||
<a href=' + roomLink + '>' + roomLink + '</a>');
|
<a href=' + roomLink + '>' + roomLink + '</a>');
|
||||||
} else {
|
} else {
|
||||||
setStatus('Initializing...');
|
setStatus('Initializing...');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function doGetUserMedia() {
|
function doGetUserMedia() {
|
||||||
// Call into getUserMedia via the polyfill (adapter.js).
|
// Call into getUserMedia via the polyfill (adapter.js).
|
||||||
try {
|
try {
|
||||||
getUserMedia(mediaConstraints, onUserMediaSuccess,
|
getUserMedia(mediaConstraints, onUserMediaSuccess,
|
||||||
@@ -125,9 +125,9 @@
|
|||||||
alert('getUserMedia() failed. Is this a WebRTC capable browser?');
|
alert('getUserMedia() failed. Is this a WebRTC capable browser?');
|
||||||
console.log('getUserMedia failed with exception: ' + e.message);
|
console.log('getUserMedia failed with exception: ' + e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPeerConnection() {
|
function createPeerConnection() {
|
||||||
try {
|
try {
|
||||||
// Create an RTCPeerConnection via the polyfill (adapter.js).
|
// Create an RTCPeerConnection via the polyfill (adapter.js).
|
||||||
pc = new RTCPeerConnection(pcConfig, pcConstraints);
|
pc = new RTCPeerConnection(pcConfig, pcConstraints);
|
||||||
@@ -143,9 +143,9 @@
|
|||||||
}
|
}
|
||||||
pc.onaddstream = onRemoteStreamAdded;
|
pc.onaddstream = onRemoteStreamAdded;
|
||||||
pc.onremovestream = onRemoteStreamRemoved;
|
pc.onremovestream = onRemoteStreamRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
function maybeStart() {
|
function maybeStart() {
|
||||||
if (!started && signalingReady &&
|
if (!started && signalingReady &&
|
||||||
localStream && channelReady && turnDone) {
|
localStream && channelReady && turnDone) {
|
||||||
setStatus('Connecting...');
|
setStatus('Connecting...');
|
||||||
@@ -160,48 +160,48 @@
|
|||||||
else
|
else
|
||||||
calleeStart();
|
calleeStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus(state) {
|
function setStatus(state) {
|
||||||
document.getElementById('footer').innerHTML = state;
|
document.getElementById('footer').innerHTML = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
function doCall() {
|
function doCall() {
|
||||||
var constraints = mergeConstraints(offerConstraints, sdpConstraints);
|
var constraints = mergeConstraints(offerConstraints, sdpConstraints);
|
||||||
console.log('Sending offer to peer, with constraints: \n' +
|
console.log('Sending offer to peer, with constraints: \n' +
|
||||||
' \'' + JSON.stringify(constraints) + '\'.')
|
' \'' + JSON.stringify(constraints) + '\'.')
|
||||||
pc.createOffer(setLocalAndSendMessage, null, constraints);
|
pc.createOffer(setLocalAndSendMessage, null, constraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
function calleeStart() {
|
function calleeStart() {
|
||||||
// Callee starts to process cached offer and other messages.
|
// Callee starts to process cached offer and other messages.
|
||||||
while (msgQueue.length > 0) {
|
while (msgQueue.length > 0) {
|
||||||
processSignalingMessage(msgQueue.shift());
|
processSignalingMessage(msgQueue.shift());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function doAnswer() {
|
function doAnswer() {
|
||||||
console.log('Sending answer to peer.');
|
console.log('Sending answer to peer.');
|
||||||
pc.createAnswer(setLocalAndSendMessage, null, sdpConstraints);
|
pc.createAnswer(setLocalAndSendMessage, null, sdpConstraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mergeConstraints(cons1, cons2) {
|
function mergeConstraints(cons1, cons2) {
|
||||||
var merged = cons1;
|
var merged = cons1;
|
||||||
for (var name in cons2.mandatory) {
|
for (var name in cons2.mandatory) {
|
||||||
merged.mandatory[name] = cons2.mandatory[name];
|
merged.mandatory[name] = cons2.mandatory[name];
|
||||||
}
|
}
|
||||||
merged.optional.concat(cons2.optional);
|
merged.optional.concat(cons2.optional);
|
||||||
return merged;
|
return merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLocalAndSendMessage(sessionDescription) {
|
function setLocalAndSendMessage(sessionDescription) {
|
||||||
// Set Opus as the preferred codec in SDP if Opus is present.
|
// Set Opus as the preferred codec in SDP if Opus is present.
|
||||||
sessionDescription.sdp = preferOpus(sessionDescription.sdp);
|
sessionDescription.sdp = preferOpus(sessionDescription.sdp);
|
||||||
pc.setLocalDescription(sessionDescription);
|
pc.setLocalDescription(sessionDescription);
|
||||||
sendMessage(sessionDescription);
|
sendMessage(sessionDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMessage(message) {
|
function sendMessage(message) {
|
||||||
var msgString = JSON.stringify(message);
|
var msgString = JSON.stringify(message);
|
||||||
console.log('C->S: ' + msgString);
|
console.log('C->S: ' + msgString);
|
||||||
// NOTE: AppRTCClient.java searches & parses this line; update there when
|
// NOTE: AppRTCClient.java searches & parses this line; update there when
|
||||||
@@ -210,9 +210,9 @@
|
|||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('POST', path, true);
|
xhr.open('POST', path, true);
|
||||||
xhr.send(msgString);
|
xhr.send(msgString);
|
||||||
}
|
}
|
||||||
|
|
||||||
function processSignalingMessage(message) {
|
function processSignalingMessage(message) {
|
||||||
if (!started) {
|
if (!started) {
|
||||||
console.log('peerConnection has not been created yet!');
|
console.log('peerConnection has not been created yet!');
|
||||||
return;
|
return;
|
||||||
@@ -237,14 +237,14 @@
|
|||||||
} else if (message.type === 'bye') {
|
} else if (message.type === 'bye') {
|
||||||
onRemoteHangup();
|
onRemoteHangup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChannelOpened() {
|
function onChannelOpened() {
|
||||||
console.log('Channel opened.');
|
console.log('Channel opened.');
|
||||||
channelReady = true;
|
channelReady = true;
|
||||||
maybeStart();
|
maybeStart();
|
||||||
}
|
}
|
||||||
function onChannelMessage(message) {
|
function onChannelMessage(message) {
|
||||||
console.log('S->C: ' + message.data);
|
console.log('S->C: ' + message.data);
|
||||||
var msg = JSON.parse(message.data);
|
var msg = JSON.parse(message.data);
|
||||||
// Since the turn response is async and also GAE might disorder the
|
// Since the turn response is async and also GAE might disorder the
|
||||||
@@ -264,15 +264,15 @@
|
|||||||
} else {
|
} else {
|
||||||
processSignalingMessage(msg);
|
processSignalingMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onChannelError() {
|
function onChannelError() {
|
||||||
console.log('Channel error.');
|
console.log('Channel error.');
|
||||||
}
|
}
|
||||||
function onChannelClosed() {
|
function onChannelClosed() {
|
||||||
console.log('Channel closed.');
|
console.log('Channel closed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUserMediaSuccess(stream) {
|
function onUserMediaSuccess(stream) {
|
||||||
console.log('User has granted access to local media.');
|
console.log('User has granted access to local media.');
|
||||||
// Call the polyfill wrapper to attach the media stream to this element.
|
// Call the polyfill wrapper to attach the media stream to this element.
|
||||||
attachMediaStream(localVideo, stream);
|
attachMediaStream(localVideo, stream);
|
||||||
@@ -280,16 +280,16 @@
|
|||||||
localStream = stream;
|
localStream = stream;
|
||||||
// Caller creates PeerConnection.
|
// Caller creates PeerConnection.
|
||||||
maybeStart();
|
maybeStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUserMediaError(error) {
|
function onUserMediaError(error) {
|
||||||
console.log('Failed to get access to local media. Error code was ' +
|
console.log('Failed to get access to local media. Error code was ' +
|
||||||
error.code);
|
error.code);
|
||||||
alert('Failed to get access to local media. Error code was ' +
|
alert('Failed to get access to local media. Error code was ' +
|
||||||
error.code + '.');
|
error.code + '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function iceCandidateType(candidateSDP) {
|
function iceCandidateType(candidateSDP) {
|
||||||
if (candidateSDP.indexOf("typ relay ") >= 0)
|
if (candidateSDP.indexOf("typ relay ") >= 0)
|
||||||
return "TURN";
|
return "TURN";
|
||||||
if (candidateSDP.indexOf("typ srflx ") >= 0)
|
if (candidateSDP.indexOf("typ srflx ") >= 0)
|
||||||
@@ -297,9 +297,9 @@
|
|||||||
if (candidateSDP.indexOf("typ host ") >= 0)
|
if (candidateSDP.indexOf("typ host ") >= 0)
|
||||||
return "HOST";
|
return "HOST";
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
function onIceCandidate(event) {
|
function onIceCandidate(event) {
|
||||||
if (event.candidate) {
|
if (event.candidate) {
|
||||||
sendMessage({type: 'candidate',
|
sendMessage({type: 'candidate',
|
||||||
label: event.candidate.sdpMLineIndex,
|
label: event.candidate.sdpMLineIndex,
|
||||||
@@ -309,37 +309,37 @@
|
|||||||
} else {
|
} else {
|
||||||
console.log('End of candidates.');
|
console.log('End of candidates.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRemoteStreamAdded(event) {
|
function onRemoteStreamAdded(event) {
|
||||||
console.log('Remote stream added.');
|
console.log('Remote stream added.');
|
||||||
reattachMediaStream(miniVideo, localVideo);
|
reattachMediaStream(miniVideo, localVideo);
|
||||||
attachMediaStream(remoteVideo, event.stream);
|
attachMediaStream(remoteVideo, event.stream);
|
||||||
remoteStream = event.stream;
|
remoteStream = event.stream;
|
||||||
waitForRemoteVideo();
|
waitForRemoteVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRemoteStreamRemoved(event) {
|
function onRemoteStreamRemoved(event) {
|
||||||
console.log('Remote stream removed.');
|
console.log('Remote stream removed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function onHangup() {
|
function onHangup() {
|
||||||
console.log('Hanging up.');
|
console.log('Hanging up.');
|
||||||
transitionToDone();
|
transitionToDone();
|
||||||
localStream.stop();
|
localStream.stop();
|
||||||
stop();
|
stop();
|
||||||
// will trigger BYE from server
|
// will trigger BYE from server
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRemoteHangup() {
|
function onRemoteHangup() {
|
||||||
console.log('Session terminated.');
|
console.log('Session terminated.');
|
||||||
initiator = 0;
|
initiator = 0;
|
||||||
transitionToWaiting();
|
transitionToWaiting();
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
function stop() {
|
function stop() {
|
||||||
started = false;
|
started = false;
|
||||||
signalingReady = false;
|
signalingReady = false;
|
||||||
isAudioMuted = false;
|
isAudioMuted = false;
|
||||||
@@ -347,9 +347,9 @@
|
|||||||
pc.close();
|
pc.close();
|
||||||
pc = null;
|
pc = null;
|
||||||
msgQueue.length = 0;
|
msgQueue.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForRemoteVideo() {
|
function waitForRemoteVideo() {
|
||||||
// Call the getVideoTracks method via adapter.js.
|
// Call the getVideoTracks method via adapter.js.
|
||||||
videoTracks = remoteStream.getVideoTracks();
|
videoTracks = remoteStream.getVideoTracks();
|
||||||
if (videoTracks.length === 0 || remoteVideo.currentTime > 0) {
|
if (videoTracks.length === 0 || remoteVideo.currentTime > 0) {
|
||||||
@@ -357,9 +357,9 @@
|
|||||||
} else {
|
} else {
|
||||||
setTimeout(waitForRemoteVideo, 100);
|
setTimeout(waitForRemoteVideo, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function transitionToActive() {
|
function transitionToActive() {
|
||||||
remoteVideo.style.opacity = 1;
|
remoteVideo.style.opacity = 1;
|
||||||
card.style.webkitTransform = 'rotateY(180deg)';
|
card.style.webkitTransform = 'rotateY(180deg)';
|
||||||
setTimeout(function() { localVideo.src = ''; }, 500);
|
setTimeout(function() { localVideo.src = ''; }, 500);
|
||||||
@@ -368,9 +368,9 @@
|
|||||||
window.onresize();
|
window.onresize();
|
||||||
setStatus('<input type=\'button\' id=\'hangup\' value=\'Hang up\' \
|
setStatus('<input type=\'button\' id=\'hangup\' value=\'Hang up\' \
|
||||||
onclick=\'onHangup()\' />');
|
onclick=\'onHangup()\' />');
|
||||||
}
|
}
|
||||||
|
|
||||||
function transitionToWaiting() {
|
function transitionToWaiting() {
|
||||||
card.style.webkitTransform = 'rotateY(0deg)';
|
card.style.webkitTransform = 'rotateY(0deg)';
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
localVideo.src = miniVideo.src;
|
localVideo.src = miniVideo.src;
|
||||||
@@ -379,32 +379,32 @@
|
|||||||
miniVideo.style.opacity = 0;
|
miniVideo.style.opacity = 0;
|
||||||
remoteVideo.style.opacity = 0;
|
remoteVideo.style.opacity = 0;
|
||||||
resetStatus();
|
resetStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function transitionToDone() {
|
function transitionToDone() {
|
||||||
localVideo.style.opacity = 0;
|
localVideo.style.opacity = 0;
|
||||||
remoteVideo.style.opacity = 0;
|
remoteVideo.style.opacity = 0;
|
||||||
miniVideo.style.opacity = 0;
|
miniVideo.style.opacity = 0;
|
||||||
setStatus('You have left the call. <a href=' + roomLink + '>\
|
setStatus('You have left the call. <a href=' + roomLink + '>\
|
||||||
Click here</a> to rejoin.');
|
Click here</a> to rejoin.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function enterFullScreen() {
|
function enterFullScreen() {
|
||||||
container.webkitRequestFullScreen();
|
container.webkitRequestFullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
function noteIceCandidate(location, type) {
|
function noteIceCandidate(location, type) {
|
||||||
if (gatheredIceCandidateTypes[location][type])
|
if (gatheredIceCandidateTypes[location][type])
|
||||||
return;
|
return;
|
||||||
gatheredIceCandidateTypes[location][type] = 1;
|
gatheredIceCandidateTypes[location][type] = 1;
|
||||||
updateInfoDiv();
|
updateInfoDiv();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInfoDiv() {
|
function getInfoDiv() {
|
||||||
return document.getElementById("infoDiv");
|
return document.getElementById("infoDiv");
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInfoDiv() {
|
function updateInfoDiv() {
|
||||||
var contents = "<pre>Gathered ICE Candidates\n";
|
var contents = "<pre>Gathered ICE Candidates\n";
|
||||||
for (var endpoint in gatheredIceCandidateTypes) {
|
for (var endpoint in gatheredIceCandidateTypes) {
|
||||||
contents += endpoint + ":\n";
|
contents += endpoint + ":\n";
|
||||||
@@ -413,18 +413,18 @@
|
|||||||
}
|
}
|
||||||
var div = getInfoDiv();
|
var div = getInfoDiv();
|
||||||
div.innerHTML = contents + "</pre>";
|
div.innerHTML = contents + "</pre>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleInfoDivDisplay() {
|
function toggleInfoDivDisplay() {
|
||||||
var div = getInfoDiv();
|
var div = getInfoDiv();
|
||||||
if (div.style.display == "block") {
|
if (div.style.display == "block") {
|
||||||
div.style.display = "none";
|
div.style.display = "none";
|
||||||
} else {
|
} else {
|
||||||
div.style.display = "block";
|
div.style.display = "block";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleVideoMute() {
|
function toggleVideoMute() {
|
||||||
// Call the getVideoTracks method via adapter.js.
|
// Call the getVideoTracks method via adapter.js.
|
||||||
videoTracks = localStream.getVideoTracks();
|
videoTracks = localStream.getVideoTracks();
|
||||||
|
|
||||||
@@ -446,9 +446,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
isVideoMuted = !isVideoMuted;
|
isVideoMuted = !isVideoMuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleAudioMute() {
|
function toggleAudioMute() {
|
||||||
// Call the getAudioTracks method via adapter.js.
|
// Call the getAudioTracks method via adapter.js.
|
||||||
audioTracks = localStream.getAudioTracks();
|
audioTracks = localStream.getAudioTracks();
|
||||||
|
|
||||||
@@ -470,15 +470,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
isAudioMuted = !isAudioMuted;
|
isAudioMuted = !isAudioMuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mac: hotkey is Command.
|
// Mac: hotkey is Command.
|
||||||
// Non-Mac: hotkey is Control.
|
// Non-Mac: hotkey is Control.
|
||||||
// <hotkey>-D: toggle audio mute.
|
// <hotkey>-D: toggle audio mute.
|
||||||
// <hotkey>-E: toggle video mute.
|
// <hotkey>-E: toggle video mute.
|
||||||
// <hotkey>-I: toggle Info box.
|
// <hotkey>-I: toggle Info box.
|
||||||
// Return false to screen out original Chrome shortcuts.
|
// Return false to screen out original Chrome shortcuts.
|
||||||
document.onkeydown = function(event) {
|
document.onkeydown = function(event) {
|
||||||
var hotkey = event.ctrlKey;
|
var hotkey = event.ctrlKey;
|
||||||
if (navigator.appVersion.indexOf('Mac') != -1)
|
if (navigator.appVersion.indexOf('Mac') != -1)
|
||||||
hotkey = event.metaKey;
|
hotkey = event.metaKey;
|
||||||
@@ -497,10 +497,10 @@
|
|||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Opus as the default audio codec if it's present.
|
// Set Opus as the default audio codec if it's present.
|
||||||
function preferOpus(sdp) {
|
function preferOpus(sdp) {
|
||||||
var sdpLines = sdp.split('\r\n');
|
var sdpLines = sdp.split('\r\n');
|
||||||
|
|
||||||
// Search for m line.
|
// Search for m line.
|
||||||
@@ -529,10 +529,10 @@
|
|||||||
|
|
||||||
sdp = sdpLines.join('\r\n');
|
sdp = sdpLines.join('\r\n');
|
||||||
return sdp;
|
return sdp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Opus in stereo if stereo is enabled.
|
// Set Opus in stereo if stereo is enabled.
|
||||||
function addStereo(sdp) {
|
function addStereo(sdp) {
|
||||||
var sdpLines = sdp.split('\r\n');
|
var sdpLines = sdp.split('\r\n');
|
||||||
|
|
||||||
// Find opus payload.
|
// Find opus payload.
|
||||||
@@ -562,15 +562,15 @@
|
|||||||
|
|
||||||
sdp = sdpLines.join('\r\n');
|
sdp = sdpLines.join('\r\n');
|
||||||
return sdp;
|
return sdp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractSdp(sdpLine, pattern) {
|
function extractSdp(sdpLine, pattern) {
|
||||||
var result = sdpLine.match(pattern);
|
var result = sdpLine.match(pattern);
|
||||||
return (result && result.length == 2)? result[1]: null;
|
return (result && result.length == 2)? result[1]: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the selected codec to the first in m line.
|
// Set the selected codec to the first in m line.
|
||||||
function setDefaultCodec(mLine, payload) {
|
function setDefaultCodec(mLine, payload) {
|
||||||
var elements = mLine.split(' ');
|
var elements = mLine.split(' ');
|
||||||
var newLine = new Array();
|
var newLine = new Array();
|
||||||
var index = 0;
|
var index = 0;
|
||||||
@@ -581,10 +581,10 @@
|
|||||||
newLine[index++] = elements[i];
|
newLine[index++] = elements[i];
|
||||||
}
|
}
|
||||||
return newLine.join(' ');
|
return newLine.join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip CN from sdp before CN constraints is ready.
|
// Strip CN from sdp before CN constraints is ready.
|
||||||
function removeCN(sdpLines, mLineIndex) {
|
function removeCN(sdpLines, mLineIndex) {
|
||||||
var mLineElements = sdpLines[mLineIndex].split(' ');
|
var mLineElements = sdpLines[mLineIndex].split(' ');
|
||||||
// Scan from end for the convenience of removing an item.
|
// Scan from end for the convenience of removing an item.
|
||||||
for (var i = sdpLines.length-1; i >= 0; i--) {
|
for (var i = sdpLines.length-1; i >= 0; i--) {
|
||||||
@@ -602,16 +602,16 @@
|
|||||||
|
|
||||||
sdpLines[mLineIndex] = mLineElements.join(' ');
|
sdpLines[mLineIndex] = mLineElements.join(' ');
|
||||||
return sdpLines;
|
return sdpLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send BYE on refreshing(or leaving) a demo page
|
// Send BYE on refreshing(or leaving) a demo page
|
||||||
// to ensure the room is cleaned for next session.
|
// to ensure the room is cleaned for next session.
|
||||||
window.onbeforeunload = function() {
|
window.onbeforeunload = function() {
|
||||||
sendMessage({type: 'bye'});
|
sendMessage({type: 'bye'});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the video diplaying in the center of window.
|
// Set the video diplaying in the center of window.
|
||||||
window.onresize = function(){
|
window.onresize = function(){
|
||||||
var aspectRatio;
|
var aspectRatio;
|
||||||
if (remoteVideo.style.opacity === '1') {
|
if (remoteVideo.style.opacity === '1') {
|
||||||
aspectRatio = remoteVideo.videoWidth/remoteVideo.videoHeight;
|
aspectRatio = remoteVideo.videoWidth/remoteVideo.videoHeight;
|
||||||
@@ -632,4 +632,4 @@
|
|||||||
containerDiv.style.height = videoHeight + 'px';
|
containerDiv.style.height = videoHeight + 'px';
|
||||||
containerDiv.style.left = (innerWidth - videoWidth) / 2 + 'px';
|
containerDiv.style.left = (innerWidth - videoWidth) / 2 + 'px';
|
||||||
containerDiv.style.top = (innerHeight - videoHeight) / 2 + 'px';
|
containerDiv.style.top = (innerHeight - videoHeight) / 2 + 'px';
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user