use of com.att.aro.core.bestpractice.pojo.ImageCompressionEntry in project VideoOptimzer by attdevsupport.
the class ARODiagnosticsOverviewRouteImpl method updateDiagnosticsTab.
@Override
public void updateDiagnosticsTab(Object routeInfo) {
int oldPanelIndex = jtabbedPane.getSelectedIndex();
jtabbedPane.setSelectedIndex(DIAGNOSTIC_INDEX);
DiagnosticsTab diagnosticsTab = (DiagnosticsTab) jtabbedPane.getSelectedComponent();
if (routeInfo == null) {
jtabbedPane.setSelectedIndex(oldPanelIndex);
LOG.error("Diagnostics Tab needs a type for updating");
return;
}
LOG.debug("Type used to route to Diagnostics Tab: " + routeInfo.getClass().getSimpleName());
if (routeInfo instanceof CacheEntry) {
diagnosticsTab.setHighlightedTCP(((CacheEntry) routeInfo).getHttpRequestResponse());
} else if (routeInfo instanceof Session) {
diagnosticsTab.setHighlightedTCP(((Session) routeInfo));
} else if (routeInfo instanceof HttpRequestResponseInfo) {
diagnosticsTab.setHighlightedTCP((HttpRequestResponseInfo) routeInfo);
} else if (routeInfo instanceof HttpEntry) {
diagnosticsTab.setHighlightedTCP(((HttpEntry) routeInfo).getHttpRequestResponse());
} else if (routeInfo instanceof DisplayNoneInCSSEntry) {
diagnosticsTab.setHighlightedTCP(((DisplayNoneInCSSEntry) routeInfo).getHttpRequestResponse());
} else if (routeInfo instanceof ImageMdataEntry) {
diagnosticsTab.setHighlightedTCP(((ImageMdataEntry) routeInfo).getHttpRequestResponse());
} else if (routeInfo instanceof ImageCompressionEntry) {
diagnosticsTab.setHighlightedTCP(((ImageCompressionEntry) routeInfo).getHttpRequestResponse());
} else if (routeInfo instanceof MultipleConnectionsEntry) {
if (((MultipleConnectionsEntry) routeInfo).isMultiple()) {
jtabbedPane.setSelectedIndex(WATERFALL_INDEX);
WaterfallTab waterfallTab = (WaterfallTab) jtabbedPane.getSelectedComponent();
waterfallTab.updateGraph(((MultipleConnectionsEntry) routeInfo).getHttpReqRespInfo());
} else {
if (((MultipleConnectionsEntry) routeInfo).getHttpReqRespInfo().getSession() != null) {
diagnosticsTab.setHighlightedSessionTCP(((MultipleConnectionsEntry) routeInfo).getHttpReqRespInfo());
} else {
diagnosticsTab.setHighlightedTCP(((MultipleConnectionsEntry) routeInfo).getHttpReqRespInfo());
}
}
} else if (routeInfo instanceof SpriteImageEntry) {
diagnosticsTab.setHighlightedTCP(((SpriteImageEntry) routeInfo).getHttpRequestResponse());
} else if (routeInfo instanceof UnnecessaryConnectionEntry) {
UnnecessaryConnectionEntry unConnectionEntry = (UnnecessaryConnectionEntry) routeInfo;
diagnosticsTab.setHighlightedTCP(unConnectionEntry.getLowTime());
} else if (routeInfo instanceof TransmissionPrivateDataEntry || routeInfo instanceof UnsecureSSLVersionEntry || routeInfo instanceof ForwardSecrecyEntry) {
diagnosticsTab.setHighlightedTCP(routeInfo);
} else if (routeInfo instanceof VideoStall) {
double timestamp = ((VideoStall) routeInfo).getSegmentTryingToPlay().getStartTS();
diagnosticsTab.getGraphPanel().setGraphView(timestamp, true);
diagnosticsTab.getVideoPlayer().setMediaTime(timestamp);
} else {
jtabbedPane.setSelectedIndex(oldPanelIndex);
LOG.error("Diagnostics Tab cannot handle a type of " + routeInfo.getClass().getSimpleName() + " for updating");
}
}
use of com.att.aro.core.bestpractice.pojo.ImageCompressionEntry in project VideoOptimzer by attdevsupport.
the class ImageCompressionImpl method getEntryList.
private List<ImageCompressionEntry> getEntryList() {
String originalImage = "";
String midCompressedImagePath = "";
String logCompressedImagepath = "";
long lowQualityImgSize = 0L;
long midQualityImgSize = 0L;
long orgImageSize = 0L;
String imgExtn = "";
List<ImageCompressionEntry> entryList = new ArrayList<ImageCompressionEntry>();
for (Session session : packetResult.getSessionlist()) {
for (HttpRequestResponseInfo reqResp : session.getRequestResponseInfo()) {
if (reqResp.getDirection() == HttpDirection.RESPONSE && reqResp.getContentType() != null && reqResp.getContentType().contains("image/")) {
originalImage = ImageHelper.extractFullNameFromRRInfo(reqResp);
if ((!originalImage.isEmpty() && !(originalImage.contains(".jpeg") || originalImage.contains(".jpg"))) && reqResp.getContentType().contains("jpeg")) {
originalImage = Util.parseImageName(originalImage, reqResp);
}
int pos = originalImage.lastIndexOf(".");
if (pos != -1) {
imgExtn = originalImage.substring(pos + 1, originalImage.length());
if (Util.isJPG(new File(imageFolderPath + originalImage), imgExtn)) {
midCompressedImagePath = imageCompressionFolderPath + originalImage.substring(0, originalImage.lastIndexOf(".")) + Quality.MID.getFileDesc() + originalImage.substring(originalImage.lastIndexOf("."), originalImage.length());
logCompressedImagepath = imageCompressionFolderPath + originalImage.substring(0, originalImage.lastIndexOf(".")) + Quality.LOW.getFileDesc() + originalImage.substring(originalImage.lastIndexOf("."), originalImage.length());
orgImageSize = new File(imageFolderPath + originalImage).length();
midQualityImgSize = new File(midCompressedImagePath).length();
lowQualityImgSize = new File(logCompressedImagepath).length();
if (midQualityImgSize > 0 && ((orgImageSize - midQualityImgSize) * 100 / orgImageSize >= 15) && lowQualityImgSize < orgImageSize) {
orginalImagesSize = orginalImagesSize + orgImageSize;
midQualImgsSize = midQualImgsSize + midQualityImgSize;
entryList.add(new ImageCompressionEntry(reqResp, session.getDomainName(), imageFolderPath + originalImage, Util.doubleFileSize(orgImageSize), Util.doubleFileSize(midQualityImgSize), Util.doubleFileSize(lowQualityImgSize)));
}
}
}
}
}
}
return entryList;
}
use of com.att.aro.core.bestpractice.pojo.ImageCompressionEntry in project VideoOptimzer by attdevsupport.
the class ImageCompressionImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
ImageCompressionResult result = new ImageCompressionResult();
packetResult = tracedata;
String tracePath = packetResult.getTraceresult().getTraceDirectory() + System.getProperty("file.separator");
imageFolderPath = tracePath + "Image" + System.getProperty("file.separator");
imageCompressionFolderPath = imageFolderPath + "Compressed" + System.getProperty("file.separator");
orginalImagesSize = 0L;
midQualImgsSize = 0L;
if (Util.isFilesforAnalysisAvailable(new File(imageFolderPath))) {
boolean isImagesCompressed = isImagesCompressed();
if (!isImagesCompressed) {
compressImages();
}
List<ImageCompressionEntry> entrylist = getEntryList();
result.setResults(entrylist);
String text = "";
String totalSavings = "";
if (entrylist.isEmpty()) {
result.setResultType(BPResultType.PASS);
text = MessageFormat.format(textResultPass, entrylist.size());
result.setResultText(text);
result.setResultExcelText(BPResultType.PASS.getDescription());
} else {
result.setResultType(BPResultType.FAIL);
long savings = orginalImagesSize - midQualImgsSize;
if (savings > 1024) {
totalSavings = Long.toString(savings / 1024) + " KB";
} else {
totalSavings = Long.toString(savings) + " B";
}
text = MessageFormat.format(textResults, totalSavings);
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), totalSavings));
}
} else {
result.setResultText(noData);
result.setResultExcelText(BPResultType.NO_DATA.getDescription());
result.setResultType(BPResultType.NO_DATA);
}
result.setAboutText(aboutText);
result.setDetailTitle(detailTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setOverviewTitle(overviewTitle);
return result;
}
Aggregations