Search in sources :

Example 41 with VideoEvent

use of com.att.aro.core.videoanalysis.pojo.VideoEvent 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 42 with VideoEvent

use of com.att.aro.core.videoanalysis.pojo.VideoEvent 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 43 with VideoEvent

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

the class PlotHelperAbstract method filterByHighest.

private void filterByHighest(List<VideoEvent> chunkDownloadList, VideoEvent videoEvent) {
    for (VideoEvent video : chunkDownloadList) {
        if (video.getSegmentID() == videoEvent.getSegmentID()) {
            try {
                Integer videoQuality = video.getQuality().isEmpty() || video.getQuality() == null || video.getQuality().matches(".*[A-Za-z].*") ? 0 : Integer.parseInt(video.getQuality());
                Integer videoEventQuality = videoEvent.getQuality().isEmpty() || videoEvent.getQuality() == null || videoEvent.getQuality().matches(".*[A-Za-z].*") ? 0 : Integer.parseInt(videoEvent.getQuality());
                if (videoQuality.compareTo(videoEventQuality) < 0) {
                    streamingVideoData.getStreamingVideoCompiled().getDeleteChunkList().add(video);
                } else {
                    streamingVideoData.getStreamingVideoCompiled().getDeleteChunkList().add(videoEvent);
                }
            } catch (NumberFormatException e) {
                StackTraceElement[] stack = e.getStackTrace();
                LOGGER.error("NumberFormatException : " + e + " @ " + ((stack != null && stack.length > 0) ? stack[0] : ""));
            } catch (Exception e) {
                StackTraceElement[] stack = e.getStackTrace();
                LOGGER.error("Exception : " + e + " @ " + ((stack != null && stack.length > 0) ? stack[0] : ""));
            }
        }
    }
}
Also used : VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

Example 44 with VideoEvent

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

the class BufferInSecondsPlot method isDataItemStallPoint.

public VideoEvent isDataItemStallPoint(double xDataValue, double yDataValue) {
    VideoEvent segmentToPlay = null;
    List<VideoStall> videoStallResults = bufferInSecondsCalculatorImpl.getVideoStallResult();
    if (seriesDataSets == null || seriesDataSets.isEmpty()) {
        LOG.error("ERROR: Checking data item/segment for a stall point: dataset is null or empty.");
        return segmentToPlay;
    }
    String[] dataSetArray = seriesDataSets.get(seriesDataSets.size() - 1).split(",");
    if (dataSetArray.length > 1 && dataSetArray[1] != null) {
        if (videoStallResults != null && (!videoStallResults.isEmpty())) {
            VideoStall stallPoint = videoStallResults.get(videoStallResults.size() - 1);
            double lastDataSet_YValue = Double.parseDouble(dataSetArray[1]);
            if ((stallPoint.getStallEndTimestamp() == 0 || stallPoint.getStallEndTimestamp() == stallPoint.getStallEndTimestamp()) && stallPoint.getStallEndTimestamp() == xDataValue && lastDataSet_YValue == yDataValue) {
                segmentToPlay = stallPoint.getSegmentTryingToPlay();
            }
        }
    } else {
        LOG.error("ERROR: Checking data item/segment for a stall point: dataset y-value is null");
    }
    return segmentToPlay;
}
Also used : VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) VideoStall(com.att.aro.core.packetanalysis.pojo.VideoStall)

Example 45 with VideoEvent

use of com.att.aro.core.videoanalysis.pojo.VideoEvent 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

VideoEvent (com.att.aro.core.videoanalysis.pojo.VideoEvent)48 VideoStream (com.att.aro.core.videoanalysis.pojo.VideoStream)19 ArrayList (java.util.ArrayList)12 TreeMap (java.util.TreeMap)7 BPResultType (com.att.aro.core.bestpractice.pojo.BPResultType)5 VideoStall (com.att.aro.core.packetanalysis.pojo.VideoStall)5 StreamingVideoData (com.att.aro.core.videoanalysis.pojo.StreamingVideoData)5 HashMap (java.util.HashMap)4 List (java.util.List)4 XYDataset (org.jfree.data.xy.XYDataset)4 AbstractTraceResult (com.att.aro.core.packetanalysis.pojo.AbstractTraceResult)3 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)3 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)3 VideoStreamStartup (com.att.aro.core.peripheral.pojo.VideoStreamStartup)3 VideoStreamStartupData (com.att.aro.core.peripheral.pojo.VideoStreamStartupData)3 DUPLICATE_HANDLING (com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs.DUPLICATE_HANDLING)3 Collections (java.util.Collections)3 StringUtils (org.apache.commons.lang.StringUtils)3 LogManager (org.apache.log4j.LogManager)3 Logger (org.apache.log4j.Logger)3