Search in sources :

Example 1 with ImageCompressionEntry

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");
    }
}
Also used : ImageMdataEntry(com.att.aro.core.bestpractice.pojo.ImageMdataEntry) TransmissionPrivateDataEntry(com.att.aro.core.bestpractice.pojo.TransmissionPrivateDataEntry) MultipleConnectionsEntry(com.att.aro.core.bestpractice.pojo.MultipleConnectionsEntry) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) DisplayNoneInCSSEntry(com.att.aro.core.bestpractice.pojo.DisplayNoneInCSSEntry) DiagnosticsTab(com.att.aro.ui.view.diagnostictab.DiagnosticsTab) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry) UnnecessaryConnectionEntry(com.att.aro.core.bestpractice.pojo.UnnecessaryConnectionEntry) ForwardSecrecyEntry(com.att.aro.core.bestpractice.pojo.ForwardSecrecyEntry) HttpEntry(com.att.aro.core.bestpractice.pojo.HttpEntry) ImageCompressionEntry(com.att.aro.core.bestpractice.pojo.ImageCompressionEntry) UnsecureSSLVersionEntry(com.att.aro.core.bestpractice.pojo.UnsecureSSLVersionEntry) WaterfallTab(com.att.aro.ui.view.waterfalltab.WaterfallTab) SpriteImageEntry(com.att.aro.core.bestpractice.pojo.SpriteImageEntry) Session(com.att.aro.core.packetanalysis.pojo.Session) VideoStall(com.att.aro.core.packetanalysis.pojo.VideoStall)

Example 2 with ImageCompressionEntry

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;
}
Also used : ImageCompressionEntry(com.att.aro.core.bestpractice.pojo.ImageCompressionEntry) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) File(java.io.File) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 3 with ImageCompressionEntry

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;
}
Also used : ImageCompressionEntry(com.att.aro.core.bestpractice.pojo.ImageCompressionEntry) File(java.io.File) ImageCompressionResult(com.att.aro.core.bestpractice.pojo.ImageCompressionResult)

Aggregations

ImageCompressionEntry (com.att.aro.core.bestpractice.pojo.ImageCompressionEntry)3 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)2 Session (com.att.aro.core.packetanalysis.pojo.Session)2 File (java.io.File)2 DisplayNoneInCSSEntry (com.att.aro.core.bestpractice.pojo.DisplayNoneInCSSEntry)1 ForwardSecrecyEntry (com.att.aro.core.bestpractice.pojo.ForwardSecrecyEntry)1 HttpEntry (com.att.aro.core.bestpractice.pojo.HttpEntry)1 ImageCompressionResult (com.att.aro.core.bestpractice.pojo.ImageCompressionResult)1 ImageMdataEntry (com.att.aro.core.bestpractice.pojo.ImageMdataEntry)1 MultipleConnectionsEntry (com.att.aro.core.bestpractice.pojo.MultipleConnectionsEntry)1 SpriteImageEntry (com.att.aro.core.bestpractice.pojo.SpriteImageEntry)1 TransmissionPrivateDataEntry (com.att.aro.core.bestpractice.pojo.TransmissionPrivateDataEntry)1 UnnecessaryConnectionEntry (com.att.aro.core.bestpractice.pojo.UnnecessaryConnectionEntry)1 UnsecureSSLVersionEntry (com.att.aro.core.bestpractice.pojo.UnsecureSSLVersionEntry)1 CacheEntry (com.att.aro.core.packetanalysis.pojo.CacheEntry)1 VideoStall (com.att.aro.core.packetanalysis.pojo.VideoStall)1 DiagnosticsTab (com.att.aro.ui.view.diagnostictab.DiagnosticsTab)1 WaterfallTab (com.att.aro.ui.view.waterfalltab.WaterfallTab)1 ArrayList (java.util.ArrayList)1