Skip to content

Commit

Permalink
fix: added prettier config and ran across project
Browse files Browse the repository at this point in the history
  • Loading branch information
dnovicki committed May 9, 2019
1 parent 33f18a0 commit a0cd642
Show file tree
Hide file tree
Showing 10 changed files with 806 additions and 567 deletions.
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore list:
/*
# Except list:
!/src/**/*.js
!/*.js
!/demo
!/test
6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
trailingComma: 'none',
tabWidth: 4,
semi: true,
singleQuote: true
};
14 changes: 5 additions & 9 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = function (grunt) {
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
Expand All @@ -14,24 +14,20 @@ module.exports = function (grunt) {
},
browserify: {
connectRtcGlobalObjectDebug: {
src: [
'./src/js/connect-rtc.js'
],
src: ['./src/js/connect-rtc.js'],
dest: './out/connect-rtc-debug.js',
options: {
browserifyOptions: {
debug: true
},
transform: [["babelify", { "presets": ["env"] }]],
transform: [['babelify', { presets: ['env'] }]]
}
},
connectRtcGlobalObject: {
src: [
'./src/js/connect-rtc.js'
],
src: ['./src/js/connect-rtc.js'],
dest: './out/connect-rtc.js',
options: {
transform: [["babelify", { "presets": ["env"] }]],
transform: [['babelify', { presets: ['env'] }]]
}
}
},
Expand Down
173 changes: 108 additions & 65 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,69 +1,112 @@
<html>
<head>
<title>connect-rtc-js demo</title>
</head>

<head>
<title>connect-rtc-js demo</title>
</head>

<body>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script type="application/javascript" src="/out/connect-rtc-debug.js"></script>
<script type="application/javascript" src="./index.js"></script>

<h1>Amazon Connect RTC Demo</h1>
<p>See <a href="https://github.com/aws/amazon-connect-streams/blob/9acf8d23ee836382c29a21d691943e5001b1c907/src/softphone.js#L77">amazon-connect-streams</a> for how to get the softphone media info</p>
<p>Note: stringify the object returned by <b>contact.getAgentConnection().getSoftphoneMediaInfo()</b> before pasting it
here
</p>
<audio id='remoteAudio' autoplay></audio>
<input id='softphoneMediaInfo' type='text' style="width:80em;">
<br>
<label><input type="checkbox" id="echoCancellationOption" checked="true">Enable echo cancellation</label>
<br>
<div>
<input id="enable-video" name="enable-video" type="checkbox"/>
<label for="enable-video">Enable Video</label>
</div>
<div>
<label>Set Audio Codec</label>
<select id="forced-audio-codec">
<option value="NONE">None</option>
<option value="OPUS">OPUS</option>
</select>
</div>
<div>
<label>Set Video Codec</label>
<select id="forced-video-codec">
<option value="NONE">None</option>
<option value="VP8">VP8</option>
<option value="VP9">VP9</option>
<option value="H264">H.264</option>
</select>
</div>
<div>
<button id='makeCall'>Call</button>
<button id='disconnectCall' disabled="true">Hangup</button>
</div>
<div>
<input id="pause-local-audio" name="pause-local-audio" type="checkbox"/>
<label for="pause-local-audio">Pause Local Audio (remote peer won't hear you)</label>
</div>
<div>
<input id="pause-remote-audio" name="pause-remote-audio" type="checkbox"/>
<label for="pause-remote-audio">Pause Remote Audio (you won't hear the remote peer)</label>
</div>
<div>
<input id="pause-local-video" name="pause-local-video" type="checkbox"/>
<label for="pause-local-video">Pause Local Video (remote peer won't see you)</label>
</div>
<div>
<input id="pause-remote-video" name="pause-remote-video" type="checkbox"/>
<label for="pause-remote-video">Pause Remote Video (you won't see the remote peer)</label>
</div>
<div id='video-display' style="display: none">
<p> Video Stream connected with the other side</p>
<video id="remoteVideo" autoplay="" style="display: inline"></video>
</div>
</body>
<body>
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"
></script>
<script
type="application/javascript"
src="/out/connect-rtc-debug.js"
></script>
<script type="application/javascript" src="./index.js"></script>

<h1>Amazon Connect RTC Demo</h1>
<p>
See
<a
href="https://github.com/aws/amazon-connect-streams/blob/9acf8d23ee836382c29a21d691943e5001b1c907/src/softphone.js#L77"
>amazon-connect-streams</a
>
for how to get the softphone media info
</p>
<p>
Note: stringify the object returned by
<b>contact.getAgentConnection().getSoftphoneMediaInfo()</b> before
pasting it here
</p>
<audio id="remoteAudio" autoplay></audio>
<input id="softphoneMediaInfo" type="text" style="width:80em;" />
<br />
<label
><input
type="checkbox"
id="echoCancellationOption"
checked="true"
/>Enable echo cancellation</label
>
<br />
<div>
<input id="enable-video" name="enable-video" type="checkbox" />
<label for="enable-video">Enable Video</label>
</div>
<div>
<label>Set Audio Codec</label>
<select id="forced-audio-codec">
<option value="NONE">None</option>
<option value="OPUS">OPUS</option>
</select>
</div>
<div>
<label>Set Video Codec</label>
<select id="forced-video-codec">
<option value="NONE">None</option>
<option value="VP8">VP8</option>
<option value="VP9">VP9</option>
<option value="H264">H.264</option>
</select>
</div>
<div>
<button id="makeCall">Call</button>
<button id="disconnectCall" disabled="true">Hangup</button>
</div>
<div>
<input
id="pause-local-audio"
name="pause-local-audio"
type="checkbox"
/>
<label for="pause-local-audio"
>Pause Local Audio (remote peer won't hear you)</label
>
</div>
<div>
<input
id="pause-remote-audio"
name="pause-remote-audio"
type="checkbox"
/>
<label for="pause-remote-audio"
>Pause Remote Audio (you won't hear the remote peer)</label
>
</div>
<div>
<input
id="pause-local-video"
name="pause-local-video"
type="checkbox"
/>
<label for="pause-local-video"
>Pause Local Video (remote peer won't see you)</label
>
</div>
<div>
<input
id="pause-remote-video"
name="pause-remote-video"
type="checkbox"
/>
<label for="pause-remote-video"
>Pause Remote Video (you won't see the remote peer)</label
>
</div>
<div id="video-display" style="display: none">
<p>Video Stream connected with the other side</p>
<video id="remoteVideo" autoplay="" style="display: inline"></video>
</div>
</body>
</html>
81 changes: 50 additions & 31 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
$(document).ready(function () {
$(document).ready(function() {
var audioElement = $('#remoteAudio')[0];
var videoElement = $('#remoteVideo')[0];

if (window.location.hash) {
$('#softphoneMediaInfo').val(decodeURIComponent(window.location.hash.substr(1)));
$('#softphoneMediaInfo').val(
decodeURIComponent(window.location.hash.substr(1))
);
}

$('#makeCall').click(function () {
$('#makeCall').click(function() {
var mediaInfo = JSON.parse($('#softphoneMediaInfo').val());
var rtcConfig = mediaInfo.webcallConfig || JSON.parse(mediaInfo.callConfigJson);//mediaInfo.webcallConfig is used internally by Amazon Connect team only
var session = new connect.RTCSession(rtcConfig.signalingEndpoint,
var rtcConfig =
mediaInfo.webcallConfig || JSON.parse(mediaInfo.callConfigJson); //mediaInfo.webcallConfig is used internally by Amazon Connect team only
var session = new connect.RTCSession(
rtcConfig.signalingEndpoint,
rtcConfig.iceServers,
mediaInfo.callContextToken,
console);
console
);

session.echoCancellation = $('#echoCancellationOption').is(':checked');

Expand All @@ -27,27 +32,41 @@ $(document).ready(function () {
}

if ($('#enable-video')[0].checked) {
$('#video-display')[0].style.display = 'block';
session.remoteVideoElement = videoElement;
// enable video with 240p requested.
session.enableVideo = true;
session.maxVideoWidth = 426;
session.maxVideoHeight = 240;
$('#video-display')[0].style.display = 'block';
session.remoteVideoElement = videoElement;
// enable video with 240p requested.
session.enableVideo = true;
session.maxVideoWidth = 426;
session.maxVideoHeight = 240;
} else {
$('#video-display')[0].style.display = 'none';
session.remoteVideoElement = null;
$('#video-display')[0].style.display = 'none';
session.remoteVideoElement = null;
}

var statsCollector;
session.onSessionConnected = () => {
statsCollector = setInterval(() => {
var collectTime = new Date();
Promise.all([session.getUserAudioStats(), session.getRemoteAudioStats()]).then((streamStats) => {
console.log(collectTime + " Audio statistics : " + JSON.stringify(streamStats));
Promise.all([
session.getUserAudioStats(),
session.getRemoteAudioStats()
]).then(streamStats => {
console.log(
collectTime +
' Audio statistics : ' +
JSON.stringify(streamStats)
);
});
if ($('#enable-video')[0].checked) {
Promise.all([session.getUserVideoStats(), session.getRemoteVideoStats()]).then((streamStats) => {
console.log(collectTime + " Video statistics : " + JSON.stringify(streamStats));
Promise.all([
session.getUserVideoStats(),
session.getRemoteVideoStats()
]).then(streamStats => {
console.log(
collectTime +
' Video statistics : ' +
JSON.stringify(streamStats)
);
});
}
}, 2000);
Expand All @@ -68,7 +87,7 @@ $(document).ready(function () {
$('#enable-video').prop('disabled', true);
$('#disconnectCall').prop('disabled', false);

$('#disconnectCall').click(function () {
$('#disconnectCall').click(function() {
if (session) {
try {
session.hangup();
Expand All @@ -83,39 +102,39 @@ $(document).ready(function () {
}
});

$('#pause-local-video').click(function(){
if(session) {
if($('#pause-local-video').is(':checked'))
$('#pause-local-video').click(function() {
if (session) {
if ($('#pause-local-video').is(':checked'))
session.pauseLocalVideo();
else {
session.resumeLocalVideo();
}
}
});

$('#pause-remote-video').click(function(){
if(session) {
if($('#pause-remote-video').is(':checked'))
$('#pause-remote-video').click(function() {
if (session) {
if ($('#pause-remote-video').is(':checked'))
session.pauseRemoteVideo();
else {
session.resumeRemoteVideo();
}
}
});

$('#pause-local-audio').click(function(){
if(session) {
if($('#pause-local-audio').is(':checked'))
$('#pause-local-audio').click(function() {
if (session) {
if ($('#pause-local-audio').is(':checked'))
session.pauseLocalAudio();
else {
session.resumeLocalAudio();
}
}
});

$('#pause-remote-audio').click(function(){
if(session) {
if($('#pause-remote-audio').is(':checked'))
$('#pause-remote-audio').click(function() {
if (session) {
if ($('#pause-remote-audio').is(':checked'))
session.pauseRemoteAudio();
else {
session.resumeRemoteAudio();
Expand Down
Loading

0 comments on commit a0cd642

Please sign in to comment.