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;
}
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;
}
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] : ""));
}
}
}
}
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;
}
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();
}
Aggregations