Search in sources :

Example 1 with ImageMdataEntry

use of com.att.aro.core.bestpractice.pojo.ImageMdataEntry in project VideoOptimzer by attdevsupport.

the class ImageFormatImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    tracedataResult = tracedata;
    ImageFormatResult result = new ImageFormatResult();
    String tracePath = tracedata.getTraceresult().getTraceDirectory() + System.getProperty("file.separator");
    imageFolderPath = tracePath + "Image" + System.getProperty("file.separator");
    orginalImagesSize = 0L;
    convImgsSize = 0L;
    if (Util.isFilesforAnalysisAvailable(new File(imageFolderPath))) {
        if (isAndroid()) {
            convExtn = "webp";
        } else {
            convExtn = "jp2";
        }
        if (!isImagesConverted()) {
            try {
                formatImages();
            } catch (Exception imgException) {
                LOGGER.error("Image Format  exception : ", imgException);
            }
        }
        List<ImageMdataEntry> 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 - convImgsSize;
            long savingsKB = savings / 1024;
            int digits = (int) (Math.log10(savingsKB) + 1);
            if (digits > 3) {
                totalSavings = String.format("%.1f", ((double) savings / 1048576)) + "MB";
            } else {
                totalSavings = Long.toString(savingsKB) + "KB";
            }
            String percentageSaving = String.valueOf(Math.round(((double) savings / orginalImagesSize) * 100));
            text = MessageFormat.format(textResults, entrylist.size(), totalSavings, percentageSaving);
            result.setResultText(text);
            result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), entrylist.size(), totalSavings, percentageSaving));
        }
    } 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 : ImageMdataEntry(com.att.aro.core.bestpractice.pojo.ImageMdataEntry) ImageFormatResult(com.att.aro.core.bestpractice.pojo.ImageFormatResult) File(java.io.File) IOException(java.io.IOException)

Example 2 with ImageMdataEntry

use of com.att.aro.core.bestpractice.pojo.ImageMdataEntry in project VideoOptimzer by attdevsupport.

the class ImageMetaDataImpl method runTestForFiles.

private void runTestForFiles(List<String> imageList, List<ImageMdataEntry> entrylist, Session session, HttpRequestResponseInfo req, String imagePath, String extractedImageName, int pos, File[] listOfFiles) {
    String imgFullName = "";
    String imgExtn = "";
    String imgFile = "";
    // check folder exists
    for (int i = 0; i < listOfFiles.length; i++) {
        if (listOfFiles[i].isFile()) {
            imgFullName = listOfFiles[i].getName();
            if (extractedImageName.equalsIgnoreCase(imgFullName)) {
                imgExtn = imgFullName.substring(pos, imgFullName.length());
                imgFile = imagePath + imgFullName;
                if (Util.isJPG(new File(imgFile), imgExtn)) {
                    extractMetadata(imgFile);
                }
            // isMetaDataPresent = true;
            }
        // clear
        }
        if (isMetaDataPresent) {
            File getImage = new File(imgFile);
            JpegImageParser imgP = new JpegImageParser();
            byte[] mdata = null;
            long mSize = 0;
            try {
                mdata = imgP.getExifRawData(new ByteSourceFile(getImage));
                mSize = mdata.length;
            } catch (ImageReadException | IOException e) {
            }
            imageList.add(imgFile);
            long iSize = getImage.length();
            double savings = (mSize * 100) / iSize;
            if (savings >= 15.00) {
                entrylist.add(new ImageMdataEntry(req, session.getDomainName(), imgFile, Util.doubleFileSize(iSize), Util.doubleFileSize(mSize), String.valueOf(new DecimalFormat("##.##").format(savings)) + "%"));
            }
            isMetaDataPresent = false;
        }
    }
}
Also used : ImageMdataEntry(com.att.aro.core.bestpractice.pojo.ImageMdataEntry) DecimalFormat(java.text.DecimalFormat) IOException(java.io.IOException) JpegImageParser(org.apache.commons.imaging.formats.jpeg.JpegImageParser) ImageReadException(org.apache.commons.imaging.ImageReadException) File(java.io.File) ByteSourceFile(org.apache.commons.imaging.common.bytesource.ByteSourceFile) ByteSourceFile(org.apache.commons.imaging.common.bytesource.ByteSourceFile)

Example 3 with ImageMdataEntry

use of com.att.aro.core.bestpractice.pojo.ImageMdataEntry in project VideoOptimzer by attdevsupport.

the class ImageMetaDataImpl method runTest.

@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
    ImageMdtaResult result = new ImageMdtaResult();
    List<String> imageList = new ArrayList<String>();
    List<ImageMdataEntry> entrylist = new ArrayList<ImageMdataEntry>();
    String imagePath = tracedata.getTraceresult().getTraceDirectory() + System.getProperty("file.separator") + "Image" + System.getProperty("file.separator");
    if (Util.isFilesforAnalysisAvailable(new File(imagePath))) {
        for (Session session : tracedata.getSessionlist()) {
            for (HttpRequestResponseInfo req : session.getRequestResponseInfo()) {
                if (req.getDirection() == HttpDirection.RESPONSE && req.getContentType() != null && req.getContentType().contains("image/")) {
                    String extractedImageName = ImageHelper.extractFullNameFromRRInfo(req);
                    int pos = extractedImageName.lastIndexOf('.') + 1;
                    // List<String> imageList = new ArrayList<String>();
                    File folder = new File(imagePath);
                    File[] listOfFiles = folder.listFiles();
                    if (listOfFiles != null) {
                        runTestForFiles(imageList, entrylist, session, req, imagePath, extractedImageName, pos, listOfFiles);
                    }
                }
            }
        }
        result.setResults(entrylist);
        String text = "";
        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);
            text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), entrylist.size());
            result.setResultText(text);
            result.setResultExcelText(MessageFormat.format(textExcelResults, BPResultType.FAIL.getDescription(), entrylist.size()));
        }
    } 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);
    result.setExportNumberOfMdataImages(String.valueOf(entrylist.size()));
    return result;
}
Also used : ImageMdataEntry(com.att.aro.core.bestpractice.pojo.ImageMdataEntry) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) File(java.io.File) ByteSourceFile(org.apache.commons.imaging.common.bytesource.ByteSourceFile) ImageMdtaResult(com.att.aro.core.bestpractice.pojo.ImageMdtaResult) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 4 with ImageMdataEntry

use of com.att.aro.core.bestpractice.pojo.ImageMdataEntry in project VideoOptimzer by attdevsupport.

the class ImageFormatImpl method getEntryList.

private List<ImageMdataEntry> getEntryList() {
    String originalImage = "";
    long convertedImgSize = 0L;
    long orgImageSize = 0L;
    String imgExtn = "";
    long orgImgSize;
    long convImageSize;
    String convImage = "";
    String convertedImagesFolderPath = "";
    List<ImageMdataEntry> imgEntryList = new ArrayList<ImageMdataEntry>();
    for (Session session : tracedataResult.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);
                }
                File orgImage = new File(imageFolderPath + originalImage);
                orgImageSize = orgImage.length();
                int pos = originalImage.lastIndexOf(".");
                imgExtn = originalImage.substring(pos + 1, originalImage.length());
                if (orgImageSize > 0 && Util.isJPG(orgImage, imgExtn)) {
                    convertedImagesFolderPath = imageFolderPath + "Format" + System.getProperty("file.separator");
                    convImage = convertedImagesFolderPath + originalImage.substring(0, originalImage.lastIndexOf(".") + 1) + convExtn;
                    convertedImgSize = new File(convImage).length();
                    long indSavings = (orgImageSize - convertedImgSize) * 100 / orgImageSize;
                    if (convertedImgSize > 0 && (indSavings >= 15)) {
                        orginalImagesSize = orginalImagesSize + orgImageSize;
                        convImgsSize = convImgsSize + convertedImgSize;
                        orgImgSize = orgImageSize / 1024;
                        convImageSize = convertedImgSize / 1024;
                        imgEntryList.add(new ImageMdataEntry(reqResp, session.getDomainName(), imageFolderPath + originalImage, orgImgSize, convImageSize, Long.toString(indSavings)));
                    }
                }
            }
        }
    }
    return imgEntryList;
}
Also used : ImageMdataEntry(com.att.aro.core.bestpractice.pojo.ImageMdataEntry) 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 5 with ImageMdataEntry

use of com.att.aro.core.bestpractice.pojo.ImageMdataEntry 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)

Aggregations

ImageMdataEntry (com.att.aro.core.bestpractice.pojo.ImageMdataEntry)6 File (java.io.File)5 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)3 Session (com.att.aro.core.packetanalysis.pojo.Session)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ByteSourceFile (org.apache.commons.imaging.common.bytesource.ByteSourceFile)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 ImageComparatorResult (com.att.aro.core.bestpractice.pojo.ImageComparatorResult)1 ImageCompressionEntry (com.att.aro.core.bestpractice.pojo.ImageCompressionEntry)1 ImageFormatResult (com.att.aro.core.bestpractice.pojo.ImageFormatResult)1 ImageMdtaResult (com.att.aro.core.bestpractice.pojo.ImageMdtaResult)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