Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
niyatim23 committed Dec 21, 2023
1 parent cf0ce35 commit 2a4b3ba
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
12 changes: 6 additions & 6 deletions examples/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function getFormValues() {
secretAccessKey: $('#secretAccessKey').val(),
sessionToken: $('#sessionToken').val() || null,
enableDQPmetrics: $('#enableDQPmetrics').is(':checked'),
enableDatachannelBenchmarking: $('#enableDatachannelBenchmarking').is(':checked'),
enableProfileTimeline: $('#enableProfileTimeline').is(':checked'),
sendHostCandidates: $('#send-host').is(':checked'),
acceptHostCandidates: $('#accept-host').is(':checked'),
sendRelayCandidates: $('#send-relay').is(':checked'),
Expand Down Expand Up @@ -138,8 +138,8 @@ function onStop() {
$('#webrtc-live-stats').addClass('d-none');
}

if (getFormValues().enableDatachannelBenchmarking) {
$('#datachannel-benchmarking').addClass('d-none');
if (getFormValues().enableProfileTimeline) {
$('#timeline-profiling').addClass('d-none');
}

$('#form').removeClass('d-none');
Expand Down Expand Up @@ -221,8 +221,8 @@ $('#viewer-button').click(async () => {
$('#webrtc-live-stats').removeClass('d-none');
}

if (formValues.enableDatachannelBenchmarking) {
$('#datachannel-benchmarking').removeClass('d-none');
if (formValues.enableProfileTimeline) {
$('#timeline-profiling').removeClass('d-none');
}

$(remoteMessage).empty();
Expand Down Expand Up @@ -435,7 +435,7 @@ const fields = [
{ field: 'forceTURN', type: 'radio', name: 'natTraversal' },
{ field: 'natTraversalDisabled', type: 'radio', name: 'natTraversal' },
{ field: 'enableDQPmetrics', type: 'checkbox' },
{ field: 'enableDatachannelBenchmarking', type: 'checkbox' },
{ field: 'enableProfileTimeline', type: 'checkbox' },
{ field: 'send-host', type: 'checkbox' },
{ field: 'accept-host', type: 'checkbox' },
{ field: 'send-relay', type: 'checkbox' },
Expand Down
10 changes: 5 additions & 5 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ <h4>Amazon KVS WebRTC DQP</h4>
</div>
</div>

<h4>Amazon KVS WebRTC Datachannel Benchmarking</h4>
<h4>Amazon KVS WebRTC Profiling Timeline chart</h4>
<div class="form-group">
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="enableDatachannelBenchmarking" value="enableDatachannelBenchmarking">
<label for="enableDatachannelBenchmarking" class="form-check-label">Enable KVS WebRTC Datachannel Benchmarking <small>(Master + Viewer)</small></label>
<input class="form-check-input" type="checkbox" id="enableProfileTimeline" value="enableProfileTimeline">
<label for="enableProfileTimeline" class="form-check-label">Enable C SDK master and JS viewer profile timeline<small>(Master + Viewer)</small></label>
<span data-delay="{ &quot;hide&quot;: 1500 }" data-position="auto" tabindex="0" class="text-info ml-1" data-toggle="tooltip" data-html="true" title="
<p>Enables the test and metrics for the Amazon KVS WebRTC by sending the master-side metrics to the viewer via datachannel and display a timeline chart.</p>
<a href=&quot;https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-js/tree/develop?tab=readme-ov-file#metrics&quot;>Additional information</a>
Expand Down Expand Up @@ -371,10 +371,10 @@ <h3 id="live-stats-header">Live Stats (from Master)</h3>
<div id="webrtc-live-stats"></div>
</div>
</div>
<div id="datachannel-benchmarking" class="d-none" style="padding-top:20px;">
<div id="timeline-profiling" class="d-none" style="padding-top:20px;">
<div class="row">
<div class="col">
<h4 id="datachannel-benchmarking-header"></h4>
<h4 id="timeline-profiling-header"></h4>
<div id="timeline-chart" style="width:100%;height:0px">
</div>
</div>
Expand Down
48 changes: 24 additions & 24 deletions examples/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const viewer = {};

//globals for DQP metrics and test
const DQPtestLength = 120; //test time in seconds
const DatachannelBenchmarkingTestLength = 20;
const profilingTestLength = 20;
let viewerButtonPressed = Date.now();
let initialDate = 0;
let chart = {};
Expand All @@ -16,7 +16,7 @@ let vFDroppedPrev = 0;
let aBytesPrev = 0;
let connectionTime = 0;
let statStartTime = 0;
let benchmarkingStartTime = 0;
let profilingStartTime = 0;
let statStartDate = 0;
let rttSum = 0;
let vjitterSum = 0;
Expand Down Expand Up @@ -250,14 +250,14 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, rem
console.log('[VIEWER] Client id is:', formValues.clientId);
viewerButtonPressed = Date.now();

if (formValues.enableDatachannelBenchmarking) {
setTimeout(dataChannelBenchmarkingCalculations, DatachannelBenchmarkingTestLength * 1000);
if (formValues.enableProfileTimeline) {
setTimeout(profilingCalculations, profilingTestLength * 1000);
}

viewer.localView = localView;
viewer.remoteView = remoteView;

if (formValues.enableDatachannelBenchmarking) {
if (formValues.enableProfileTimeline) {
viewer.remoteView.addEventListener('loadeddata', () => {
metrics.viewer.ttff.endTime = Date.now();

Expand All @@ -273,7 +273,7 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, rem
});
}

if (formValues.enableDatachannelBenchmarking) {
if (formValues.enableProfileTimeline) {
metrics.viewer.ttff.startTime = viewerButtonPressed;
metrics.master.waitTime.endTime = viewerButtonPressed;

Expand Down Expand Up @@ -483,7 +483,7 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, rem
};
viewer.peerConnection = new RTCPeerConnection(configuration);

if (formValues.enableDatachannelBenchmarking) {
if (formValues.enableProfileTimeline) {
viewer.peerConnection.onicegatheringstatechange = (event) => {
if (viewer.peerConnection.iceGatheringState === 'gathering') {
metrics.viewer.iceGathering.startTime = Date.now();
Expand Down Expand Up @@ -519,7 +519,7 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, rem
const dataChannelObj = viewer.peerConnection.createDataChannel('kvsDataChannel');
viewer.dataChannel = dataChannelObj;
dataChannelObj.onopen = () => {
if (formValues.enableDatachannelBenchmarking) {
if (formValues.enableProfileTimeline) {
dataChannelLatencyCalcMessage.firstMessageFromViewerTs = Date.now().toString();
dataChannelObj.send(JSON.stringify(dataChannelLatencyCalcMessage));
} else {
Expand All @@ -530,7 +530,7 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, rem
let onRemoteDataMessageViewer = (message) => {

remoteMessage.append(`${message.data}\n\n`);
if (formValues.enableDatachannelBenchmarking) {
if (formValues.enableProfileTimeline) {

// The datachannel first sends a message of the following format with firstMessageFromViewerTs attached,
// to which the master responds back with the same message attaching firstMessageFromMasterTs.
Expand Down Expand Up @@ -614,14 +614,14 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, rem
viewer.peerConnectionStatsInterval = setInterval(() => viewer.peerConnection.getStats().then(stats => calcStats(stats, formValues.clientId)), 1000);
}

if (formValues.enableDatachannelBenchmarking) {
benchmarkingStartTime = new Date().getTime();
let headerElement = document.getElementById("datachannel-benchmarking-header");
viewer.dataChannelBenchmarkingInterval = setInterval(() => {
let statRunTime = calcDiffTimestamp2Sec(new Date().getTime(), benchmarkingStartTime);
if (formValues.enableProfileTimeline) {
profilingStartTime = new Date().getTime();
let headerElement = document.getElementById("timeline-profiling-header");
viewer.profilingInterval = setInterval(() => {
let statRunTime = calcDiffTimestamp2Sec(new Date().getTime(), profilingStartTime);
statRunTime = Number.parseFloat(statRunTime).toFixed(0);
if (statRunTime <= DatachannelBenchmarkingTestLength) {
headerElement.textContent = "Datachannel benchmarking timeline chart available in " + (DatachannelBenchmarkingTestLength - statRunTime);
if (statRunTime <= profilingTestLength) {
headerElement.textContent = "Profiling timeline chart available in " + (profilingTestLength - statRunTime);
}
}, 1000);
}
Expand Down Expand Up @@ -797,13 +797,13 @@ function stopViewer() {
statStartTime = 0;
}

if (getFormValues().enableDatachannelBenchmarking) {
if (getFormValues().enableProfileTimeline) {
let container = document.getElementById('timeline-chart');
let headerElement = document.getElementById("datachannel-benchmarking-header");
let headerElement = document.getElementById("timeline-profiling-header");
container.innerHTML = "";
container.style.height = "0px";
if (viewer.dataChannelBenchmarkingInterval) {
clearInterval(viewer.dataChannelBenchmarkingInterval);
if (viewer.profilingInterval) {
clearInterval(viewer.profilingInterval);
}
headerElement.textContent = "";
}
Expand All @@ -829,12 +829,12 @@ function sendViewerMessage(message) {
}
}

function dataChannelBenchmarkingCalculations() {
let headerElement = document.getElementById("datachannel-benchmarking-header");
headerElement.textContent = "Datachannel benchmarking timeline chart";
function profilingCalculations() {
let headerElement = document.getElementById("timeline-profiling-header");
headerElement.textContent = "Profiling Timeline chart";
google.charts.load('current', {packages:['timeline']});
google.charts.setOnLoadCallback(drawChart);
clearInterval(viewer.dataChannelBenchmarkingInterval);
clearInterval(viewer.profilingInterval);
}

// Functions below support DQP test and metrics
Expand Down

0 comments on commit 2a4b3ba

Please sign in to comment.