Search in sources :

Example 6 with VideoEvent

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

the class VideoSegmentAnalyzer method propagatePlaytime.

/**
 * not quite there yet
 *
 * for each segment: playtime = SegmentStartTime + startupOffset + stallOffset
 *
 * if playtime is before segment has arrived need to increment stallOffset to
 * bring playtime up to arrival time plus all overhead of recovery from stall
 *
 * @param startupTime
 * @param chosenVideoEvent
 * @param videoStream
 */
public void propagatePlaytime(double startupTime, VideoEvent chosenVideoEvent, VideoStream videoStream) {
    double startupOffset;
    startupOffset = chosenVideoEvent != null ? startupTime - chosenVideoEvent.getSegmentStartTime() : 0;
    stallOffset = 0;
    totalStallOffset = 0;
    VideoEvent priorEvent = null;
    double priorDuration = 0;
    clearStalls(videoStream);
    videoStream.clearBufferOccupancyData();
    videoStream.applyStartupOffset(startupOffset);
    // key definition: segmentStartTime, endTS(in milliseconds)
    TreeMap<String, VideoEvent> audioStreamMap = videoStream.getAudioEventMap();
    applyDuplicateHandlingRules(audioStreamMap);
    applyDuplicateHandlingRules(videoStream.getVideoEventMap());
    boolean isAudio = !CollectionUtils.isEmpty(audioStreamMap);
    ArrayList<VideoEvent> videoStreamFiltered = sortBySegThenStartTS(videoStream);
    for (VideoEvent videoEvent : videoStreamFiltered) {
        if (videoEvent.isNormalSegment()) {
            if (priorEvent != null && videoEvent.isSelected()) {
                double playtime = videoEvent.getSegmentStartTime() + startupOffset + totalStallOffset;
                priorDuration = (priorEvent.getSegmentID() != videoEvent.getSegmentID()) ? priorEvent.getDuration() : priorDuration;
                if (videoEvent.getDLLastTimestamp() > playtime) {
                    // generate a video segment caused stall
                    double newStallOffset = 0;
                    newStallOffset = calcSegmentStallOffset(startupOffset, videoEvent, totalStallOffset);
                    totalStallOffset += newStallOffset;
                    videoEvent.setStallTime(newStallOffset);
                    stallOffset = newStallOffset;
                    playtime += videoEvent.getStallTime();
                    LOG.debug(String.format("VideoStall %.0f: %8.6f", videoEvent.getSegmentID(), videoEvent.getStallTime()));
                }
                VideoEvent audioStall;
                if (isAudio && (audioStall = syncWithAudio(startupOffset, videoStream, audioStreamMap, videoEvent)) != null && audioStall.getStallTime() > 0) {
                    LOG.debug(String.format("audioStall %.0f: %8.6f", audioStall.getSegmentID(), audioStall.getStallTime()));
                }
                videoEvent.setPlayTime(playtime);
                if (videoEvent.getStallTime() != 0) {
                    videoStream.addStall(videoEvent);
                }
            }
            priorEvent = videoEvent;
        }
    }
    populateActive(videoStream);
    generateByteBufferData(videoStream);
    generatePlaytimeData(videoStream);
    LOG.debug(videoStream.getByteToolTipDetailMap().keySet());
}
Also used : VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

Example 7 with VideoEvent

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

the class VideoSegmentAnalyzer method applyDuplicateHandlingRules.

private void applyDuplicateHandlingRules(SortedMap<String, VideoEvent> eventStreamMap) {
    VideoEvent priorEvent = null;
    ArrayList<VideoEvent> videoStreamSorted = new ArrayList<VideoEvent>(eventStreamMap.values());
    Collections.sort(videoStreamSorted, new VideoEventComparator(SortSelection.END_TS));
    Collections.sort(videoStreamSorted, new VideoEventComparator(SortSelection.SEGMENT_ID));
    for (VideoEvent event : videoStreamSorted) {
        if (event.isNormalSegment()) {
            // set to 'selected' so applyRules can judge
            event.setSelected(true);
            applyRules(event, priorEvent);
            if (event.isSelected()) {
                priorEvent = event;
            }
        } else {
            LOG.debug("reject:" + event);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

Example 8 with VideoEvent

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

the class SegmentTablePanel method getStreamTable.

private JPanel getStreamTable(String title, SortedMap<String, VideoEvent> eventList, JScrollPane tableScrollPane) {
    // Do not resize columns or setPreferredWidth in this method
    DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
    rightRenderer.setHorizontalAlignment(SwingConstants.RIGHT);
    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment(SwingConstants.CENTER);
    Collection<VideoEvent> videoEventList = eventList.values();
    rowCount = videoEventList.size();
    TableModel tableModel = new SegmentTableModel(videoEventList, videoStream.getPlayRequestedTime() != null ? videoStream.getPlayRequestedTime() : 0.0);
    JTable jTable;
    jTable = new JTable(tableModel);
    jTable.setName(title);
    streamTables.put(title, jTable);
    jTable.setGridColor(Color.LIGHT_GRAY);
    for (int idx = 0; idx < jTable.getColumnCount() - 2; idx++) {
        jTable.getColumnModel().getColumn(idx).setCellRenderer(rightRenderer);
    }
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.TRACK)).setCellRenderer(centerRenderer);
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.TCP_STATE)).setCellRenderer(centerRenderer);
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.CHANNELS)).setCellRenderer(centerRenderer);
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.DOWNLOAD_DELAY)).setCellRenderer(centerRenderer);
    jTable.getColumnModel().getColumn(((SegmentTableModel) tableModel).findColumn(SegmentTableModel.PLAYBACK_DELAY)).setCellRenderer(centerRenderer);
    JTableHeader header = jTable.getTableHeader();
    header.setDefaultRenderer(new MultiLineTableHeaderRenderer());
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createTitledBorder(title));
    if (rowCount > tableHeight) {
        tableScrollPane.setPreferredSize(new Dimension(0, MAX_HEIGHT));
    } else {
        int rowHeight = jTable.getRowHeight();
        tblHeight = 100 + (eventList.size() * (rowHeight + 3));
        tableScrollPane.setPreferredSize(new Dimension(0, tblHeight));
        tableScrollPane.setSize(new Dimension(0, tblHeight));
        panel.setPreferredSize(new Dimension(0, tblHeight));
        panel.setMinimumSize(new Dimension(0, tblHeight));
        panel.setSize(new Dimension(0, tblHeight));
    }
    tableScrollPane.setViewportView(jTable);
    panel.setLayout(new BorderLayout());
    panel.add(header, BorderLayout.NORTH);
    panel.add(tableScrollPane, BorderLayout.CENTER);
    // Sorter for jTable
    TableRowSorter<TableModel> rowSorter = new TableRowSorter<TableModel>(jTable.getModel());
    jTable.setRowSorter(rowSorter);
    refreshSegmentPanel();
    int colCount = rowSorter.getModel().getColumnCount();
    for (int column = 0; column < colCount; column++) {
        rowSorter.setComparator(column, new TableSortComparator(column, "-"));
    }
    jTable.addMouseListener(streamTableClickHandler(tableModel, jTable, jTable.getColumnModel().getColumnIndex("SessionLink")));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) JTableHeader(javax.swing.table.JTableHeader) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) Dimension(java.awt.Dimension) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) TableModel(javax.swing.table.TableModel) TableRowSorter(javax.swing.table.TableRowSorter)

Example 9 with VideoEvent

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

the class SegmentTablePanel method getCheckBoxStreamEnable.

private Component getCheckBoxStreamEnable() {
    enableCheckBox = new JCheckBox();
    videoStreamCollection = analyzerResult.getAnalyzerResult().getStreamingVideoData().getVideoStreamMap().values();
    boolean selected = videoStream.getVideoEventMap() != null ? true : false;
    if (!selected || videoStream.getVideoEventMap().isEmpty() || ((VideoEvent) videoStream.getVideoEventMap().values().toArray()[0]).getSegmentID() < 0) {
        enableCheckBox.setEnabled(false);
    } else {
        boolean selectCheckBox = videoStreamCollection.size() == 1;
        videoStream.setSelected(selectCheckBox);
        enableCheckBox.setSelected(selectCheckBox);
        if (selectCheckBox) {
            refreshStream();
        }
        enableCheckBox.addActionListener(addActionListener());
    }
    return enableCheckBox;
}
Also used : JCheckBox(javax.swing.JCheckBox) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

Example 10 with VideoEvent

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

the class VideoProgressPlot method calculateProgress.

public void calculateProgress(SegmentOptions option) {
    videoDownloadSeries.clear();
    audioDownloadSeries.clear();
    videoPlaytimeSeries.clear();
    audioPlaytimeSeries.clear();
    if (videoStream != null) {
        optionSelected = option;
        double dlTimeStamp = 0.0;
        if (option == SegmentOptions.DEFAULT || option == SegmentOptions.VIDEO) {
            for (Entry<String, VideoEvent> videoEventEntry : videoStream.getVideoStartTimeMap().entrySet()) {
                VideoEvent videoEvent = videoEventEntry.getValue();
                if (videoEvent.isSelected() && videoEvent.isNormalSegment()) {
                    videoEvent.setOption(SegmentOptions.VIDEO.toString());
                    videoEventList.add(videoEvent);
                    eventList.add(videoEvent);
                    double videoDownloadProgress = getProgress(videoStream.getVideoStartTimeMap(), videoEvent, true);
                    progressList.add(videoDownloadProgress);
                    dlTimeStamp = videoEvent.getDLTimeStamp();
                    timestampList.add(dlTimeStamp);
                    videoDownloadSeries.add(dlTimeStamp, videoDownloadProgress);
                }
            }
        }
        if (option == SegmentOptions.DEFAULT || option == SegmentOptions.AUDIO) {
            for (Entry<String, VideoEvent> audioEventEntry : videoStream.getAudioStartTimeMap().entrySet()) {
                VideoEvent audioEvent = audioEventEntry.getValue();
                if (audioEvent.isSelected() && audioEvent.isNormalSegment()) {
                    audioEvent.setOption(SegmentOptions.AUDIO.toString());
                    audioEventList.add(audioEvent);
                    eventList.add(audioEvent);
                    double audioDownloadProgress = getProgress(videoStream.getAudioStartTimeMap(), audioEvent, false);
                    progressList.add(audioDownloadProgress);
                    dlTimeStamp = audioEvent.getDLTimeStamp();
                    timestampList.add(dlTimeStamp);
                    audioDownloadSeries.add(dlTimeStamp, audioDownloadProgress);
                }
            }
        }
        if (optionSelected != SegmentOptions.AUDIO && optionSelected != SegmentOptions.VIDEO) {
            if (!videoDownloadSeries.isEmpty() && !audioDownloadSeries.isEmpty()) {
                isMuxed = false;
            } else if (videoDownloadSeries.isEmpty() || audioDownloadSeries.isEmpty()) {
                isMuxed = true;
            }
        }
        Collections.sort(progressList);
        Collections.sort(timestampList);
        if (!CollectionUtils.isEmpty(progressList) && !CollectionUtils.isEmpty(timestampList)) {
            minYValue = progressList.stream().findFirst().get();
            maxYValue = progressList.stream().reduce((first, second) -> second).get();
            minXValue = timestampList.stream().findFirst().get();
            maxXValue = timestampList.stream().reduce((first, second) -> second).get();
        }
    }
}
Also used : VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

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