use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.
the class BufferOccupancyCalculatorImpl method drawVeDone.
@Override
public double drawVeDone(List<VideoEvent> veDone, double beginByte) {
double buffer = beginByte;
if (veDone.size() == 0) {
// drain buffer
seriesDataSets.put(key, chunkPlayStartTime + "," + buffer);
key++;
buffer = bufferDrain(buffer);
} else {
Collections.sort(veDone, new VideoEventComparator(SortSelection.END_TS));
boolean drained = false;
for (VideoEvent chunk : veDone) {
seriesDataSets.put(key, chunk.getEndTS() + "," + buffer);
key++;
if (MathUtils.equals(chunk.getEndTS(), chunkPlayStartTime)) {
// drain
buffer = buffer + (chunk.getTotalBytes());
completedDownloads.add(chunk);
chunkDownload.remove(chunk);
buffer = bufferDrain(buffer);
drained = true;
/*if (buffer < 0) {
// stall
return -1;
}*/
} else {
buffer = buffer + (chunk.getTotalBytes());
seriesDataSets.put(key, chunk.getEndTS() + "," + buffer);
key++;
completedDownloads.add(chunk);
chunkDownload.remove(chunk);
}
}
if (drained == false) {
buffer = bufferDrain(buffer);
}
}
return buffer;
}
use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.
the class VideoChunkPlotterImpl method updateChunkPlayStartTimes.
public void updateChunkPlayStartTimes() {
this.chunkPlayStartTimesList.clear();
this.segmentStartTimeMap.clear();
boolean filterAgain = false;
List<VideoEvent> chunksBySegmentID = streamingVideoData.getStreamingVideoCompiled().getChunksBySegmentID();
Map<Double, VideoEvent> playStartTimeBySegment = new TreeMap<>();
for (int index = 0; index < chunksBySegmentID.size(); index++) {
double playtime = (chunksBySegmentID.get(index)).getPlayTime();
if (chunksBySegmentID.get(index).getEndTS() > playtime) {
boolean shuffled = alterFilteredSegmentList(chunksBySegmentID.get(index), playtime);
if (shuffled) {
filterAgain = true;
}
}
playStartTimeBySegment.put(playtime, chunksBySegmentID.get(index));
}
streamingVideoData.getStreamingVideoCompiled().getFilteredSegments().forEach(x -> {
chunkPlayStartTimesList.add((Double) x.getPlayTime());
segmentStartTimeMap.put(((Double) (x.getSegmentID())).longValue(), (Double) x.getPlayTime());
});
// VID-TODO looks inefficient, lots of re-iterating through chunksBySegmentID
if (filterAgain) {
List<VideoEvent> filteredSegments = streamingVideoData.getStreamingVideoCompiled().getFilteredSegments();
Collections.sort(filteredSegments, new VideoEventComparator(SortSelection.END_TS));
for (VideoEvent ve : filteredSegments) {
if (!chunksBySegmentID.contains(ve)) {
for (VideoEvent segment : chunksBySegmentID) {
if (segment.getSegmentID() == ve.getSegmentID()) {
// segment should be replaced by ve
chunksBySegmentID.add(chunksBySegmentID.indexOf(segment), ve);
chunksBySegmentID.remove(segment);
break;
}
}
}
}
}
}
use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.
the class VideoChunkPlotterImpl method getChunkCollectionDataSet.
private void getChunkCollectionDataSet() {
int count = 0;
List<VideoEvent> allSegments2 = streamingVideoData.getStreamingVideoCompiled().getAllSegments();
if (allSegments2 == null) {
return;
}
for (VideoEvent ve : allSegments2) {
BufferedImage img = ve.getThumbnail();
if (count == 0) {
// first chunk
firstChunkTimestamp = ve.getDLTimeStamp();
count++;
}
int checkCount = 0;
while (img.getHeight() > 20 && checkCount++ < 3) {
// background processing inserted a thumbnail, too soon for the image sizing to have completed, a very rare occurance
// wait 500 ms, sufficient time for processing to complete
// this prevents a "thumbnail" of 2k pixels wide filling up the display
Util.sleep(500);
img = ve.getThumbnail();
}
imgSeries.add(img);
seriesDataSets.put(key, ve.getDLTimeStamp());
key++;
}
}
use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.
the class VideoChunkPlotterImpl method alterFilteredSegmentList.
public boolean alterFilteredSegmentList(VideoEvent ve, double segmentPlayTime) {
List<VideoEvent> deleteChunks = streamingVideoData.getStreamingVideoCompiled().getDeleteChunkList();
if (!deleteChunks.isEmpty()) {
// descending order sorting by download end time.
Collections.sort(deleteChunks, new VideoEventComparator(SortSelection.END_TS_DESCENDING));
boolean swapedTheMinimum = false;
int minIndex = -1;
for (VideoEvent removeChunk : deleteChunks) {
if (removeChunk.getSegmentID() == ve.getSegmentID() && removeChunk.getEndTS() <= segmentPlayTime) {
// This is the correct quality level of this segment played
// swap
int index = streamingVideoData.getStreamingVideoCompiled().getFilteredSegments().indexOf(ve);
streamingVideoData.getStreamingVideoCompiled().getFilteredSegments().remove(ve);
streamingVideoData.getStreamingVideoCompiled().getFilteredSegments().add(index, removeChunk);
deleteChunks.add(ve);
deleteChunks.remove(removeChunk);
return true;
} else if (ve.getEndTS() > removeChunk.getEndTS() && removeChunk.getSegmentID() == ve.getSegmentID()) {
// swap the closest
minIndex = deleteChunks.indexOf(removeChunk);
swapedTheMinimum = true;
}
}
if (swapedTheMinimum && minIndex != -1) {
int index = streamingVideoData.getStreamingVideoCompiled().getFilteredSegments().indexOf(ve);
streamingVideoData.getStreamingVideoCompiled().getFilteredSegments().remove(ve);
streamingVideoData.getStreamingVideoCompiled().getFilteredSegments().add(index, deleteChunks.get(minIndex));
deleteChunks.add(ve);
deleteChunks.remove(deleteChunks.get(minIndex));
return true;
}
}
return false;
}
use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.
the class VideoSegmentAnalyzer method locateStartupDelay.
/**
* <pre>
* Loads, and or creates estimated, startup data for a stream Populates
* VideoStreamStartup from first segment and manifest data. Populates
* VideoStream so that graphs can be displayed. Attaches to VideoStream to aid
* SegmentTablePanel
*
* @param result
* @param videoStream
* @return existing or estimated VideoStreamStartup
*/
public VideoStreamStartup locateStartupDelay(AbstractTraceResult result, VideoStream videoStream) {
if (result instanceof TraceDirectoryResult) {
if ((videoStreamStartupData = ((TraceDirectoryResult) result).getVideoStartupData()) != null) {
if ((videoStreamStartup = findStartupFromName(videoStreamStartupData, videoStream)) != null) {
if (videoStreamStartup.getValidationStartup().equals(ValidationStartup.NA)) {
videoStreamStartup.setValidationStartup(ValidationStartup.USER);
}
}
} else {
videoStreamStartupData = new VideoStreamStartupData();
}
if (videoStreamStartup == null) {
VideoEvent firstEvent = null;
videoStreamStartup = new VideoStreamStartup(videoStream.getManifest().getVideoName());
videoStreamStartup.setValidationStartup(ValidationStartup.ESTIMATED);
videoStreamStartupData.getStreams().add(videoStreamStartup);
if (!CollectionUtils.isEmpty(videoStream.getVideoActiveMap())) {
firstEvent = videoStream.getFirstActiveSegment();
} else {
firstEvent = videoStream.getFirstSegment();
if (firstEvent == null) {
// invalid stream, no first segment that is a normal segment
return null;
}
if (videoStream.getManifest().getRequestTime() == 0.0) {
// CSI there is no requestTime so make an estimate
videoStream.getManifest().setRequestTime(firstEvent.getRequest().getTimeStamp() - videoPrefs.getStallRecovery());
}
}
if (firstEvent.getPlayRequestedTime() == 0) {
firstEvent.setPlayRequestedTime(videoStream.getManifest().getRequestTime());
}
firstEvent.setStartupOffset(firstEvent.getDLLastTimestamp() + videoPrefs.getStallRecovery());
videoStreamStartup.setFirstSegID(firstEvent.getSegmentID());
videoStreamStartup.setManifestReqTime(firstEvent.getManifest().getRequestTime());
videoStreamStartup.setStartupTime(firstEvent.getStartupOffset());
if (videoStreamStartup.getUserEvent() == null) {
UserEvent userEvent = new UserEvent();
double pressTime = videoStream.getManifest().getRequestTime();
userEvent.setPressTime(pressTime);
userEvent.setReleaseTime(pressTime);
userEvent.setEventType(UserEventType.EVENT_UNKNOWN);
videoStreamStartup.setUserEvent(userEvent);
}
}
videoStream.getManifest().setDelay(videoStreamStartup.getStartupTime() - videoStreamStartup.getManifestReqTime());
videoStream.setVideoPlayBackTime(videoStreamStartup.getStartupTime());
videoStream.setVideoStreamStartup(videoStreamStartup);
((TraceDirectoryResult) result).setVideoStartupData(videoStreamStartupData);
}
return videoStreamStartup;
}
Aggregations