Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/gh-pages' into fix/update-eslint…
Browse files Browse the repository at this point in the history
…-to-google-standard

# Conflicts:
#	index.html
#	package.json
#	src/content/datachannel/filetransfer/js/main.js
#	src/js/common.js
  • Loading branch information
ErikHellman committed Aug 8, 2018
2 parents ef98fd6 + 2570c46 commit 20640cd
Show file tree
Hide file tree
Showing 114 changed files with 788 additions and 5,142 deletions.
16 changes: 8 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ module.exports = function(grunt) {
grunt.initConfig({
// make node configurations available
pkg: grunt.file.readJSON('package.json'),
csslint: {
options: {
csslintrc: '.csslintrc'
},
src: ['src/content/**/*.css', '!**/third_party/*.css' ]
},
// csslint: {
// options: {
// csslintrc: '.csslintrc'
// },
// src: ['src/content/**/*.css', '!**/third_party/*.css' ]
// },
eslint: {
options: {
configFile: '.eslintrc.js',
Expand Down Expand Up @@ -55,13 +55,13 @@ module.exports = function(grunt) {

// enable plugins
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-csslint');
// grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-githooks');
grunt.loadNpmTasks('grunt-htmlhint');

// set default tasks to run when grunt is called without parameters
grunt.registerTask('default', ['csslint', 'htmlhint', 'eslint']);
grunt.registerTask('default', ['htmlhint', 'eslint']);
// also possible to call JavaScript directly in registerTask()
// or to call external tasks with grunt.loadTasks()
};
244 changes: 123 additions & 121 deletions index.html

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"devDependencies": {
"eslint-config-google": "^0.9.1",
"express": "^4.14.1",
"faucet": "0.0.1",
"geckodriver": "^1.10.0",
"grunt": "^0.4.5",
"grunt-cli": ">=0.1.9",
"grunt-contrib-compress": "^0.13.0",
"grunt-contrib-csslint": ">=0.3.1",
"grunt-eslint": "^21.0.0",
"grunt-githooks": "^0.3.1",
"grunt-htmlhint": ">=0.9.12",
Expand Down
35 changes: 8 additions & 27 deletions src/content/capture/canvas-pc/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,17 @@

canvas {
background-color: #ccc;
height: 231px;
margin: 0 20px 0 0;
--width: calc(45%);
width: var(--width);
height: calc(var(--width) * 0.75);
margin: 1em;
vertical-align: top;
width: calc(50% - 12px);
}

video {
height: 231px;
margin: 0 0 20px 0;
--width: calc(45%);
width: var(--width);
height: calc(var(--width) * 0.75);
margin: 1em;
object-fit: cover;
width: calc(50% - 12px);
}

@media screen and (max-width: 400px) {
canvas {
margin: 0 10px 0 0;
width: calc(50% - 7px);
}
video {
margin: 0 0 20px 0;
width: calc(50% - 7px);
}
}

@media screen and (max-width: 700px) {
canvas {
border: 1px solid #ccc;
width: calc(50% - 14px);
}
video {
object-fit: inherit;
}
}
14 changes: 7 additions & 7 deletions src/content/capture/canvas-pc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ <h1>
</div>

<!-- Teapot code -->
<script src="js/third_party/webgl-utils.js"></script>
<script src="js/third_party/webgl-debug.js"></script>
<script src="js/third_party/matrix4x4.js"></script>
<script src="js/third_party/cameracontroller.js"></script>
<script src="js/third_party/teapot-streams.js"></script>
<script src="js/third_party/demo.js"></script>
<script src="../../../js/third_party/webgl_teapot/webgl-utils.js"></script>
<script src="../../../js/third_party/webgl_teapot/webgl-debug.js"></script>
<script src="../../../js/third_party/webgl_teapot/matrix4x4.js"></script>
<script src="../../../js/third_party/webgl_teapot/cameracontroller.js"></script>
<script src="../../../js/third_party/webgl_teapot/teapot-streams.js"></script>
<script src="../../../js/third_party/webgl_teapot/demo.js"></script>

<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<script src="../../../js/common.js"></script>

<script src="js/main.js" async></script>

<script src="../../../js/lib/ga.js"></script>
Expand Down
54 changes: 27 additions & 27 deletions src/content/capture/canvas-pc/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ const offerOptions = {
let startTime;

video.addEventListener('loadedmetadata', function() {
trace(`Remote video videoWidth: ${this.videoWidth}px, videoHeight: ${this.videoHeight}px`);
console.log(`Remote video videoWidth: ${this.videoWidth}px, videoHeight: ${this.videoHeight}px`);
});

video.onresize = () => {
trace(`Remote video size changed to ${video.videoWidth}x${video.videoHeight}`);
console.log(`Remote video size changed to ${video.videoWidth}x${video.videoHeight}`);
// We'll use the first onsize callback as an indication that video has started
// playing out.
if (startTime) {
const elapsedTime = window.performance.now() - startTime;
trace(`Setup time: ${elapsedTime.toFixed(3)}ms`);
console.log(`Setup time: ${elapsedTime.toFixed(3)}ms`);
startTime = null;
}
};
Expand All @@ -41,27 +41,27 @@ video.onresize = () => {
main();

const stream = canvas.captureStream();
trace('Got stream from canvas');
console.log('Got stream from canvas');

call();

function call() {
trace('Starting call');
console.log('Starting call');
startTime = window.performance.now();
const videoTracks = stream.getVideoTracks();
const audioTracks = stream.getAudioTracks();
if (videoTracks.length > 0) {
trace(`Using video device: ${videoTracks[0].label}`);
console.log(`Using video device: ${videoTracks[0].label}`);
}
if (audioTracks.length > 0) {
trace(`Using audio device: ${audioTracks[0].label}`);
console.log(`Using audio device: ${audioTracks[0].label}`);
}
const servers = null;
pc1 = new RTCPeerConnection(servers);
trace('Created local peer connection object pc1');
console.log('Created local peer connection object pc1');
pc1.onicecandidate = e => onIceCandidate(pc1, e);
pc2 = new RTCPeerConnection(servers);
trace('Created remote peer connection object pc2');
console.log('Created remote peer connection object pc2');
pc2.onicecandidate = e => onIceCandidate(pc2, e);
pc1.oniceconnectionstatechange = e => onIceStateChange(pc1, e);
pc2.oniceconnectionstatechange = e => onIceStateChange(pc2, e);
Expand All @@ -75,53 +75,53 @@ function call() {
);
}
);
trace('Added local stream to pc1');
console.log('Added local stream to pc1');

trace('pc1 createOffer start');
console.log('pc1 createOffer start');
pc1.createOffer(onCreateOfferSuccess, onCreateSessionDescriptionError, offerOptions);
}

function onCreateSessionDescriptionError(error) {
trace(`Failed to create session description: ${error.toString()}`);
console.log(`Failed to create session description: ${error.toString()}`);
}

function onCreateOfferSuccess(desc) {
trace(`Offer from pc1\n${desc.sdp}`);
trace('pc1 setLocalDescription start');
console.log(`Offer from pc1\n${desc.sdp}`);
console.log('pc1 setLocalDescription start');
pc1.setLocalDescription(desc, () => onSetLocalSuccess(pc1), onSetSessionDescriptionError);
trace('pc2 setRemoteDescription start');
console.log('pc2 setRemoteDescription start');
pc2.setRemoteDescription(desc, () => onSetRemoteSuccess(pc2), onSetSessionDescriptionError);
trace('pc2 createAnswer start');
console.log('pc2 createAnswer start');
// Since the 'remote' side has no media stream we need
// to pass in the right constraints in order for it to
// accept the incoming offer of audio and video.
pc2.createAnswer(onCreateAnswerSuccess, onCreateSessionDescriptionError);
}

function onSetLocalSuccess(pc) {
trace(`${getName(pc)} setLocalDescription complete`);
console.log(`${getName(pc)} setLocalDescription complete`);
}

function onSetRemoteSuccess(pc) {
trace(`${getName(pc)} setRemoteDescription complete`);
console.log(`${getName(pc)} setRemoteDescription complete`);
}

function onSetSessionDescriptionError(error) {
trace(`Failed to set session description: ${error.toString()}`);
console.log(`Failed to set session description: ${error.toString()}`);
}

function gotRemoteStream(e) {
if (video.srcObject !== e.streams[0]) {
video.srcObject = e.streams[0];
trace('pc2 received remote stream');
console.log('pc2 received remote stream');
}
}

function onCreateAnswerSuccess(desc) {
trace(`Answer from pc2:\n${desc.sdp}`);
trace('pc2 setLocalDescription start');
console.log(`Answer from pc2:\n${desc.sdp}`);
console.log('pc2 setLocalDescription start');
pc2.setLocalDescription(desc, () => onSetLocalSuccess(pc2), onSetSessionDescriptionError);
trace('pc1 setRemoteDescription start');
console.log('pc1 setRemoteDescription start');
pc1.setRemoteDescription(desc, () => onSetRemoteSuccess(pc1), onSetSessionDescriptionError);
}

Expand All @@ -131,20 +131,20 @@ function onIceCandidate(pc, event) {
() => onAddIceCandidateSuccess(pc),
err => onAddIceCandidateError(pc, err)
);
trace(`${getName(pc)} ICE candidate: ${event.candidate ? event.candidate.candidate : '(null)'}`);
console.log(`${getName(pc)} ICE candidate: ${event.candidate ? event.candidate.candidate : '(null)'}`);
}

function onAddIceCandidateSuccess(pc) {
trace(`${getName(pc)} addIceCandidate success`);
console.log(`${getName(pc)} addIceCandidate success`);
}

function onAddIceCandidateError(pc, error) {
trace(`${getName(pc)} failed to add ICE Candidate: ${error.toString()}`);
console.log(`${getName(pc)} failed to add ICE Candidate: ${error.toString()}`);
}

function onIceStateChange(pc, event) {
if (pc) {
trace(`${getName(pc)} ICE state: ${pc.iceConnectionState}`);
console.log(`${getName(pc)} ICE state: ${pc.iceConnectionState}`);
console.log('ICE state change event: ', event);
}
}
Expand Down
Loading

0 comments on commit 20640cd

Please sign in to comment.