Search in sources :

Example 26 with VideoStream

use of com.att.aro.core.videoanalysis.pojo.VideoStream in project VideoOptimzer by attdevsupport.

the class PlotHelperAbstract method filterSegmentByVideoPref.

public List<VideoEvent> filterSegmentByVideoPref(StreamingVideoData videoData) {
    this.streamingVideoData = videoData;
    Map<VideoEvent, VideoStream> veManifestList = new HashMap<>();
    chunkDownload = new ArrayList<>();
    List<VideoEvent> allSegments = new ArrayList<>();
    streamingVideoData.getStreamingVideoCompiled().getDeleteChunkList().clear();
    DUPLICATE_HANDLING segmentFilterChoice = videoPrefManager.getVideoUsagePreference().getDuplicateHandling();
    for (VideoStream videoStream : streamingVideoData.getVideoStreamMap().values()) {
        // don't count if no videos with manifest, or only one video
        if (videoStream != null && videoStream.isSelected() && !videoStream.getVideoEventMap().isEmpty()) {
            for (VideoEvent videoEvent : videoStream.getVideoEventMap().values()) {
                if (!(videoEvent.getSegmentID() == 0 && videoStream.getManifest().getVideoFormat().equals(VideoFormat.MPEG4)) && (!chunkDownload.contains(videoEvent))) {
                    switch(segmentFilterChoice) {
                        case FIRST:
                            filterByFirst(chunkDownload, videoEvent);
                            break;
                        case LAST:
                            filterByLast(chunkDownload, videoEvent);
                            break;
                        case HIGHEST:
                            filterByHighest(chunkDownload, videoEvent);
                            break;
                        default:
                    }
                    veManifestList.put(videoEvent, videoStream);
                    chunkDownload.add(videoEvent);
                    allSegments.add(videoEvent);
                }
            }
        }
    }
    if (segmentFilterChoice == DUPLICATE_HANDLING.FIRST || segmentFilterChoice == DUPLICATE_HANDLING.LAST) {
        for (VideoEvent ve : streamingVideoData.getStreamingVideoCompiled().getDeleteChunkList()) {
            veManifestList.keySet().remove(ve);
            chunkDownload.remove(ve);
        }
    }
    streamingVideoData.getStreamingVideoCompiled().setAllSegments(allSegments);
    return chunkDownload;
}
Also used : HashMap(java.util.HashMap) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) ArrayList(java.util.ArrayList) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) DUPLICATE_HANDLING(com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs.DUPLICATE_HANDLING)

Example 27 with VideoStream

use of com.att.aro.core.videoanalysis.pojo.VideoStream in project VideoOptimzer by attdevsupport.

the class PlotHelperAbstract method filterVideoSegment.

public List<VideoEvent> filterVideoSegment(StreamingVideoData videoData) {
    this.streamingVideoData = videoData;
    Map<VideoEvent, VideoStream> veManifestList = new HashMap<>();
    chunkDownload = new ArrayList<>();
    List<VideoEvent> duplicateChunks = new ArrayList<>();
    List<VideoEvent> allSegments = new ArrayList<>();
    if (videoData != null && !CollectionUtils.isEmpty(videoData.getVideoStreamMap())) {
        for (VideoStream videoStream : videoData.getVideoStreamMap().values()) {
            // don't count if no videos with manifest, or only one video
            if (videoStream.isSelected() && !videoStream.getVideoEventMap().isEmpty()) {
                TreeMap<String, VideoEvent> segmentEventList = (TreeMap<String, VideoEvent>) videoStream.getVideoSegmentEventList();
                Entry<String, VideoEvent> segmentValue = segmentEventList.higherEntry("00000000:z");
                double firstSeg = segmentValue != null ? segmentValue.getValue().getSegmentID() : 0;
                VideoEvent first = null;
                for (VideoEvent videoEvent : videoStream.getVideoEventMap().values()) {
                    if (videoEvent.getSegmentID() == firstSeg) {
                        first = videoEvent;
                    }
                    if (videoEvent.isNormalSegment() && (!chunkDownload.contains(videoEvent))) {
                        for (VideoEvent video : chunkDownload) {
                            if ((videoEvent.getSegmentID() != firstSeg) && video.getSegmentID() == videoEvent.getSegmentID()) {
                                duplicateChunks.add(video);
                            }
                            if (videoEvent.getSegmentID() == firstSeg) {
                                if (!videoEvent.equals(first)) {
                                    duplicateChunks.add(videoEvent);
                                }
                            }
                        }
                        veManifestList.put(videoEvent, videoStream);
                        chunkDownload.add(videoEvent);
                        allSegments.add(videoEvent);
                    }
                }
            }
        }
    }
    for (VideoEvent ve : duplicateChunks) {
        veManifestList.keySet().remove(ve);
        chunkDownload.remove(ve);
    }
    return chunkDownload;
}
Also used : HashMap(java.util.HashMap) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) ArrayList(java.util.ArrayList) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) TreeMap(java.util.TreeMap)

Example 28 with VideoStream

use of com.att.aro.core.videoanalysis.pojo.VideoStream in project VideoOptimzer by attdevsupport.

the class MetaDataHelper method updateMetaData.

private boolean updateMetaData(PacketAnalyzerResult packetAnalyzerResult) {
    TraceDirectoryResult result = (TraceDirectoryResult) packetAnalyzerResult.getTraceresult();
    boolean isMetaDataUpdated = false;
    if (metaData.getVideoStreams().isEmpty() || metaData.getVideoStreams().get(0).getVideoResolutionMap().isEmpty()) {
        ArrayList<MetaStream> videoStreams = new ArrayList<>();
        for (VideoStream videoStream : packetAnalyzerResult.getStreamingVideoData().getVideoStreams()) {
            MetaStream metaStream = new MetaStream();
            metaStream.setVideoDuration(videoStream.getDuration());
            metaStream.setType(videoStream.getManifest().getVideoFormat().toString());
            metaStream.setVideo(videoStream.getManifest().getVideoName());
            metaStream.setVideoOrientation(result.getCollectOptions().getOrientation());
            metaStream.setVideoDownloadtime(videoStream.getVideoActiveMap().entrySet().stream().mapToDouble(e -> e.getValue().getDLTime()).sum());
            metaStream.setAudioDownloadtime(videoStream.getAudioActiveMap().entrySet().stream().mapToDouble(e -> e.getValue().getDLTime()).sum());
            metaStream.setVideoSegmentTotal(videoStream.getVideoActiveMap().size());
            metaStream.setAudioSegmentTotal(videoStream.getAudioActiveMap().size());
            setVideoStreamTotals(metaStream, videoStream);
            videoStream.setMetaStream(metaStream);
            videoStreams.add(metaStream);
        }
        metaData.setVideoStreams(videoStreams);
        isMetaDataUpdated = true;
    }
    if (metaData.getCollectorName().isEmpty()) {
        metaData.setCollectorName(result.getCollectorName());
        isMetaDataUpdated = true;
    }
    if (metaData.getCollectorVersion().isEmpty()) {
        metaData.setCollectorVersion(result.getCollectorVersion());
        isMetaDataUpdated = true;
    }
    if (metaData.getTraceName().isEmpty()) {
        String name = result.getTraceDirectory();
        int pos = name.lastIndexOf(Util.FILE_SEPARATOR);
        if (pos > 0) {
            name = name.substring(pos + 1);
        }
        metaData.setTraceName(name);
        isMetaDataUpdated = true;
    }
    if (metaData.getDeviceScreenSize() == null) {
        metaData.setDeviceScreenSize(new Dimension(result.getDeviceScreenSizeX(), result.getDeviceScreenSizeY()));
        isMetaDataUpdated = true;
    }
    if (metaData.getPhoneMake().isEmpty()) {
        metaData.setPhoneMake(result.getDeviceMake());
        isMetaDataUpdated = true;
    }
    if (metaData.getPhoneModel().isEmpty()) {
        metaData.setPhoneModel(result.getDeviceModel());
        isMetaDataUpdated = true;
    }
    if (metaData.getOs().isEmpty()) {
        metaData.setOs(result.getOsType());
        isMetaDataUpdated = true;
    }
    if (metaData.getOsVersion().isEmpty()) {
        metaData.setOsVersion(result.getOsVersion());
        isMetaDataUpdated = true;
    }
    if (metaData.getStartUTC().isEmpty()) {
        ZonedDateTime startUTC = null;
        if (result != null && result.getTraceDateTime() != null) {
            startUTC = ZonedDateTime.ofInstant(result.getTraceDateTime().toInstant(), ZoneId.systemDefault());
            isMetaDataUpdated = true;
        }
        metaData.setStartUTC(startUTC != null ? startUTC.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME) : "");
    }
    if (metaData.getUtc() == null || metaData.getUtc() == 0L) {
        metaData.setUtc(result.getTraceDateTime().toInstant().getEpochSecond());
        isMetaDataUpdated = true;
    }
    if (metaData.getTraceDuration() == null) {
        metaData.setTraceDuration(result.getTraceDuration());
        isMetaDataUpdated = true;
    }
    if (metaData.getTraceSource().isEmpty()) {
        metaData.setTraceSource("Manual");
        isMetaDataUpdated = true;
    }
    if ((metaData.getTargetAppVer().isEmpty() || UNKNOWN.equals(metaData.getTargetAppVer())) && (!metaData.getTargetedApp().isEmpty() && !UNKNOWN.equals(metaData.getTargetedApp()))) {
        String appVersion = findAppVersion(result);
        if (!UNKNOWN.equals(appVersion)) {
            isMetaDataUpdated = true;
            metaData.setTargetAppVer(appVersion);
        }
    }
    return isMetaDataUpdated;
}
Also used : MetaStream(com.att.aro.core.tracemetadata.pojo.MetaStream) ZonedDateTime(java.time.ZonedDateTime) ArrayList(java.util.ArrayList) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) Dimension(java.awt.Dimension)

Example 29 with VideoStream

use of com.att.aro.core.videoanalysis.pojo.VideoStream in project VideoOptimzer by attdevsupport.

the class BufferInSecondsPlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData aroTraceData) {
    seriesPlayTimeBufferCollection.removeAllSeries();
    if (aroTraceData != null && aroTraceData.getAnalyzerResult().getStreamingVideoData() != null) {
        bufferInSecondsCalculatorImpl.setStreamingVideoData(aroTraceData.getAnalyzerResult().getStreamingVideoData());
        for (VideoStream videoStream : aroTraceData.getAnalyzerResult().getStreamingVideoData().getVideoStreams()) {
            if (videoStream.isSelected()) {
                this.videoStream = videoStream;
                LOG.debug("VideoStream :" + videoStream.getManifest().getVideoName());
                seriesPlayTimeBuffer = new XYSeries("Play Time Buffer");
                double yPlotValue = 0.00;
                for (XYPair xy : videoStream.getPlayTimeList()) {
                    yPlotValue = xy.getYVal();
                    bufferTimeList.add(yPlotValue);
                    seriesPlayTimeBuffer.add(xy.getXVal(), yPlotValue);
                    LOG.debug(String.format("%.3f\t%.0f", xy.getXVal(), yPlotValue));
                }
                Collections.sort(bufferTimeList);
                seriesPlayTimeBufferCollection.addSeries(seriesPlayTimeBuffer);
                LOG.debug(videoStream.getByteToolTipDetailMap());
            }
        }
        BufferTimeBPResult bufferTimeResult = bufferInSecondsCalculatorImpl.updateBufferTimeResult(bufferTimeList);
        aroTraceData.getAnalyzerResult().setBufferTimeResult(bufferTimeResult);
        plot.setRenderer(createRenderer());
    }
    plot.setDataset(seriesPlayTimeBufferCollection);
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) BufferTimeBPResult(com.att.aro.core.packetanalysis.pojo.BufferTimeBPResult) XYPair(com.att.aro.core.videoanalysis.XYPair)

Example 30 with VideoStream

use of com.att.aro.core.videoanalysis.pojo.VideoStream in project VideoOptimzer by attdevsupport.

the class SliderDialogBox method createSliderDialog.

@SuppressWarnings("serial")
public void createSliderDialog(double max, IVideoPlayer player, final VideoChunksPlot vcPlot, int indexKey) {
    setUndecorated(false);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setBounds(300, 200, 1000, 1000);
    setResizable(false);
    panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    add(panel);
    streamingVideoData = mainFrame.getController().getTheModel().getAnalyzerResult().getStreamingVideoData();
    jcb = new JComboBox<ComboManifest>();
    jcb.addItem(new ComboManifest());
    int manifestsSelectedCount = 0;
    int manifestIdxSelected = 0;
    int selectedIndex = 1;
    for (VideoStream videoStream : streamingVideoData.getVideoStreamMap().values()) {
        if (videoStream.isSelected()) {
            manifestsSelectedCount++;
            selectedIndex = manifestIdxSelected;
            manifestIdxSelected++;
            jcb.addItem(new ComboManifest(videoStream));
        }
    }
    jcb.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked") JComboBox<ComboManifest> comboBox = (JComboBox<ComboManifest>) e.getSource();
            ComboManifest comboManifest = (ComboManifest) comboBox.getSelectedItem();
            VideoStream videoStream = comboManifest.getVideoStream();
            if (null != videoStream) {
                allChunks.clear();
                allChunks = new ArrayList<VideoEvent>();
                if (videoStream.getManifest().getVideoFormat() == VideoFormat.MPEG4) {
                    for (VideoEvent videoEvent : videoStream.getVideoEventsBySegment()) {
                        if (videoEvent.getSegmentID() != 0) {
                            allChunks.add(videoEvent);
                        }
                    }
                } else {
                    allChunks = new ArrayList<VideoEvent>(videoStream.getVideoEventsBySegment());
                }
                listSegments.clear();
                populateList();
                tableModel.getDataVector().removeAllElements();
                tableModel.fireTableDataChanged();
                tableModel.setRowCount(listSegments.size());
                updateJTableData();
            }
        }
    });
    panel.add(jcb);
    JPanel labelPanel = new JPanel(new BorderLayout());
    labelPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    labelPanel.add(new JLabel(resourceBundle.getString("sliderdialog.segmentlist.label")));
    panel.add(labelPanel);
    JPanel comboPanel = new JPanel(new BorderLayout(5, 0));
    comboPanel.setBorder(BorderFactory.createEmptyBorder(1, 5, 1, 5));
    comboPanel.setSize(500, 100);
    GridBagConstraints constraint = new GridBagConstraints();
    listSegments.clear();
    populateList();
    // making the correct selection of JTable row based on user input -->
    // Then scroll JTable to selected row
    makeSelection(indexKey);
    // JTable model having two columns
    tableModel = new DefaultTableModel();
    tableModel.setRowCount(listSegments.size());
    tableModel.setColumnCount(SLIDERDIALOG_COLUMN_COUNT);
    // JTable Renderer listeners
    jTable = new JTable(tableModel) {

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            if (getValueAt(row, column) instanceof Boolean) {
                JTableItems itemObject = listSegments.get(row);
                boolean checkBoxStatus = (boolean) getValueAt(row, column);
                itemObject.setSelected(checkBoxStatus);
                return super.getDefaultRenderer(Boolean.class);
            } else {
                return super.getCellRenderer(row, column);
            }
        }

        @Override
        public TableCellEditor getCellEditor(int row, int column) {
            if (getValueAt(row, column) instanceof Boolean) {
                return super.getDefaultEditor(Boolean.class);
            } else {
                return super.getCellEditor(row, column);
            }
        }
    };
    updateJTableData();
    if (manifestsSelectedCount == 1) {
        jcb.setSelectedIndex(selectedIndex + 1);
    }
    // Listener for mouse click
    jTable.addMouseListener(getCheckboxListener());
    // Listener for list selection on jTable
    jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            int row = jTable.getSelectedRow();
            if (row >= 0 && row < listSegments.size()) {
                JTableItems itemObject = listSegments.get(row);
                resizedThumbnail = itemObject.getVideoEvent().getImageOriginal();
                ImageIcon img = new ImageIcon(resizedThumbnail);
                img = new ImageIcon(img.getImage().getScaledInstance(-1, 300, Image.SCALE_DEFAULT));
                imgLabel.setIcon(img);
                double timestamp = itemObject.getVideoEvent().getPlayTime() != 0 ? itemObject.getVideoEvent().getPlayTime() : itemObject.getVideoEvent().getEndTS();
                slider.setValue((int) Math.round(timestamp * 25));
                panel.setSize(panel.getPreferredSize());
                panel.revalidate();
                JDialog parentDialog = (JDialog) panel.getRootPane().getParent();
                parentDialog.setSize(parentDialog.getPreferredSize());
                parentDialog.revalidate();
            }
            selectSegment();
        }
    });
    JScrollPane listScrollPanel = new JScrollPane(jTable);
    listScrollPanel.setPreferredSize(new Dimension(500, 100));
    comboPanel.add(listScrollPanel);
    if (manifestIdxSelected > 1) {
        JLabel warningLabel = new JLabel(resourceBundle.getString("sliderdialog.manifest.warning"));
        comboPanel.add(warningLabel, BorderLayout.EAST);
    }
    panel.add(comboPanel);
    JPanel imgLabelPanel = new JPanel(new BorderLayout());
    imgLabelPanel.setBorder(BorderFactory.createEmptyBorder(1, 3, 1, 1));
    imgLabelPanel.add(imgLabel);
    imgLabelPanel.setSize(imgLabelPanel.getPreferredSize());
    panel.add(imgLabelPanel);
    JPanel sliderBoxPanel = new JPanel(new BorderLayout());
    sliderBoxPanel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 1));
    JPanel sliderPanel = new JPanel();
    sliderPanel.setLayout(new GridBagLayout());
    constraint = new GridBagConstraints();
    constraint.fill = GridBagConstraints.HORIZONTAL;
    constraint.gridx = 0;
    constraint.gridy = 0;
    constraint.weightx = 2;
    double initialValue = getPlayer().getVideoOffset();
    this.maxValue = setMaxMinValue(max + initialValue, true);
    this.minValue = setMaxMinValue(initialValue, false);
    this.player = player;
    // define slider
    slider = new JSlider(JSlider.HORIZONTAL, minValue, maxValue, minValue);
    slider.setPaintLabels(true);
    slider.setPaintTicks(true);
    slider.addChangeListener(getSliderListener());
    slider.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent e) {
        }

        @Override
        public void mouseDragged(MouseEvent e) {
            ComboManifest comboBoxItem = (ComboManifest) jcb.getSelectedItem();
            if (segmentChosen == null || (!segmentChosen.isSelected) && (comboBoxItem.getVideoStream() == null)) {
                showWarningMessage();
            }
        }
    });
    sliderPanel.add(slider, constraint);
    startTimeField = getStartTimeDisplay();
    constraint.fill = GridBagConstraints.HORIZONTAL;
    constraint.gridx = 1;
    constraint.gridy = 0;
    constraint.insets = new Insets(0, 0, 0, 1);
    constraint.weightx = 0.35;
    sliderPanel.add(startTimeField, constraint);
    minusTunerBtn = getTunerButton("-");
    constraint.fill = GridBagConstraints.HORIZONTAL;
    constraint.gridx = 2;
    constraint.gridy = 0;
    constraint.insets = new Insets(0, 0, 0, 1);
    constraint.weightx = 0.35;
    sliderPanel.add(minusTunerBtn, constraint);
    plusTunerBtn = getTunerButton("+");
    constraint.fill = GridBagConstraints.HORIZONTAL;
    constraint.gridx = 3;
    constraint.gridy = 0;
    constraint.insets = new Insets(0, 0, 0, 2);
    constraint.weightx = 0.35;
    sliderPanel.add(plusTunerBtn, constraint);
    sliderBoxPanel.add(sliderPanel);
    panel.add(sliderBoxPanel);
    JPanel btnPanel = new JPanel();
    btnPanel.setLayout(new BorderLayout());
    btnPanel.setBorder(BorderFactory.createEmptyBorder(0, 220, 1, 220));
    // build the 'Set' JButton
    okButton = new JButton("Set");
    okButton.addActionListener(getSetButtonListener(vcPlot));
    btnPanel.add(okButton);
    panel.add(btnPanel);
    panel.setSize(panel.getPreferredSize());
    panel.validate();
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) DefaultTableModel(javax.swing.table.DefaultTableModel) ArrayList(java.util.ArrayList) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) MouseMotionListener(java.awt.event.MouseMotionListener) BorderLayout(java.awt.BorderLayout) JSlider(javax.swing.JSlider) TableCellEditor(javax.swing.table.TableCellEditor) JScrollPane(javax.swing.JScrollPane) TableCellRenderer(javax.swing.table.TableCellRenderer) MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) JDialog(javax.swing.JDialog)

Aggregations

VideoStream (com.att.aro.core.videoanalysis.pojo.VideoStream)33 VideoEvent (com.att.aro.core.videoanalysis.pojo.VideoEvent)19 ArrayList (java.util.ArrayList)13 BPResultType (com.att.aro.core.bestpractice.pojo.BPResultType)6 StreamingVideoData (com.att.aro.core.videoanalysis.pojo.StreamingVideoData)6 XYPair (com.att.aro.core.videoanalysis.XYPair)5 List (java.util.List)5 TreeMap (java.util.TreeMap)5 AbstractTraceResult (com.att.aro.core.packetanalysis.pojo.AbstractTraceResult)3 Session (com.att.aro.core.packetanalysis.pojo.Session)3 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)3 VideoStall (com.att.aro.core.packetanalysis.pojo.VideoStall)3 DUPLICATE_HANDLING (com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs.DUPLICATE_HANDLING)3 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 StringUtils (org.apache.commons.lang.StringUtils)3 LogManager (org.apache.log4j.LogManager)3 Logger (org.apache.log4j.Logger)3 XYSeries (org.jfree.data.xy.XYSeries)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3