use of com.att.aro.core.peripheral.pojo.UserEvent in project VideoOptimzer by attdevsupport.
the class UserEventReaderImpl method readUserInputFile.
private List<UserEvent> readUserInputFile(Map<UserEventType, Double> lastEvent, String filepath, double startTime, double eventTime0) {
List<UserEvent> userEventsList = new ArrayList<UserEvent>();
String[] lines = null;
try {
lines = filereader.readAllLine(filepath);
} catch (IOException e) {
LOGGER.error("failed to read user event file: " + filepath);
}
if (lines != null && lines.length > 0) {
for (String lineBuf : lines) {
// Ignore empty line
if (lineBuf.trim().isEmpty()) {
continue;
}
// Parse entry
String[] strFields = lineBuf.split(" ");
// Get timestamp
double dTimeStamp = Double.parseDouble(strFields[0]);
if (dTimeStamp > 1.0e9) {
dTimeStamp = Util.normalizeTime(dTimeStamp, startTime);
} else {
// Old data collector method (backward compatible)
dTimeStamp -= eventTime0;
}
// Get event type
UserEvent.UserEventType actionType = UserEvent.UserEventType.EVENT_UNKNOWN;
String processedEvent;
if (strFields.length == 3 && TraceDataConst.UserEvent.SCREEN.equals(strFields[1])) {
processedEvent = strFields[2];
actionType = UserEventType.SCREEN_TOUCH;
} else if (strFields.length == 4 && TraceDataConst.UserEvent.KEY.equals(strFields[1])) {
processedEvent = strFields[3];
if (TraceDataConst.UserEvent.KEY_KEY.equals(strFields[2])) {
actionType = UserEventType.KEY_KEY;
} else if (TraceDataConst.UserEvent.KEY_POWER.equals(strFields[2])) {
actionType = UserEventType.KEY_POWER;
} else if (TraceDataConst.UserEvent.KEY_VOLUP.equals(strFields[2])) {
actionType = UserEventType.KEY_VOLUP;
} else if (TraceDataConst.UserEvent.KEY_VOLDOWN.equals(strFields[2])) {
actionType = UserEventType.KEY_VOLDOWN;
} else if (TraceDataConst.UserEvent.KEY_BALL.equals(strFields[2])) {
actionType = UserEventType.KEY_BALL;
} else if (TraceDataConst.UserEvent.KEY_HOME.equals(strFields[2])) {
actionType = UserEventType.KEY_HOME;
} else if (TraceDataConst.UserEvent.KEY_MENU.equals(strFields[2])) {
actionType = UserEventType.KEY_MENU;
} else if (TraceDataConst.UserEvent.KEY_BACK.equals(strFields[2])) {
actionType = UserEventType.KEY_BACK;
} else if (TraceDataConst.UserEvent.KEY_SEARCH.equals(strFields[2])) {
actionType = UserEventType.KEY_SEARCH;
} else if (TraceDataConst.UserEvent.KEY_GREEN.equals(strFields[2])) {
actionType = UserEventType.KEY_GREEN;
} else if (TraceDataConst.UserEvent.KEY_RED.equals(strFields[2])) {
actionType = UserEventType.KEY_RED;
}
} else {
LOGGER.warn("Invalid user event type in trace: " + lineBuf);
continue;
}
// Get press or release
boolean bPress = false;
if (TraceDataConst.UserEvent.PRESS.equalsIgnoreCase(processedEvent)) {
bPress = true;
} else if (TraceDataConst.UserEvent.RELEASE.equalsIgnoreCase(processedEvent)) {
bPress = false;
} else {
LOGGER.warn("211 - Key event does not have press/release indication: " + lineBuf);
continue;
}
if (bPress) {
lastEvent.put(actionType, dTimeStamp);
} else {
Double lastTime = lastEvent.remove(actionType);
if (lastTime != null) {
userEventsList.add(new UserEvent(actionType, lastTime, dTimeStamp));
} else {
LOGGER.warn("Found key release event with no associated press event: " + lineBuf);
continue;
}
}
}
}
return userEventsList;
}
use of com.att.aro.core.peripheral.pojo.UserEvent in project VideoOptimzer by attdevsupport.
the class SegmentTablePanel method launchStartUpDelayDialog.
public void launchStartUpDelayDialog() {
GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendViews("StartupDelayDialog");
IVideoPlayer player = aroView.getVideoPlayer();
double maxDuration = player.getDuration();
List<UserEvent> userEventList = analyzerResult.getAnalyzerResult().getTraceresult().getUserEvents();
if (maxDuration >= 0) {
selectVideoStreamWithRefresh(videoStream);
try {
dialog = new StartupDelayDialog(aroView.getGraphPanel(), maxDuration, videoStream, userEventList, this, viewIndex);
dialog.pack();
dialog.setSize(dialog.getPreferredSize());
dialog.validate();
dialog.setModalityType(ModalityType.APPLICATION_MODAL);
dialog.setVisible(true);
} catch (Exception e) {
LOG.error("Exception in StartupDelayDialog:", e);
new MessageDialogFactory().showErrorDialog(null, ResourceBundleHelper.getMessageString("startupdelay.error.message"));
}
}
}
use of com.att.aro.core.peripheral.pojo.UserEvent in project VideoOptimzer by attdevsupport.
the class StartupDelayDialog method loadStartupDelay.
public double loadStartupDelay() {
Double tempStartupTime = ((TraceDirectoryResult) traceData.getAnalyzerResult().getTraceresult()).getVideoStartTime();
if ((videoStreamStartupData = ((TraceDirectoryResult) traceData.getAnalyzerResult().getTraceresult()).getVideoStartupData()) != null) {
if ((videoStreamStartup = videoSegmentAnalyzer.findStartupFromName(videoStreamStartupData, videoStream)) != null) {
tempStartupTime = videoStreamStartup.getStartupTime();
}
} else {
videoStreamStartupData = new VideoStreamStartupData();
}
if (videoStreamStartup == null) {
videoStreamStartup = new VideoStreamStartup(videoStream.getManifest().getVideoName());
videoStreamStartupData.getStreams().add(videoStreamStartup);
}
if (!allUserEventList.isEmpty() && videoStreamStartup.getUserEvent() == null) {
UserEvent ue = findPriorUserEvent(manifestRequestTime);
if (ue != null) {
videoStreamStartup.setUserEvent(ue);
}
int lastIndex = 0;
for (int idx = 0; idx < allUserEventList.size(); idx++) {
if (allUserEventList.get(idx).getPressTime() > manifestRequestTime) {
break;
}
lastIndex = idx;
}
videoStreamStartup.setUserEvent(allUserEventList.get(lastIndex));
}
((TraceDirectoryResult) traceData.getAnalyzerResult().getTraceresult()).setVideoStartupData(videoStreamStartupData);
if (tempStartupTime == 0) {
// as in based on Manifest request timeStamp
return getStartTime();
}
return tempStartupTime;
}
use of com.att.aro.core.peripheral.pojo.UserEvent in project VideoOptimzer by attdevsupport.
the class UserEventPlot method populate.
@Override
public void populate(XYPlot plot, AROTraceData analysis) {
if (analysis != null) {
userInputData.removeAllSeries();
// create the dataset...
Map<UserEvent.UserEventType, XYIntervalSeries> seriesMap = new EnumMap<UserEvent.UserEventType, XYIntervalSeries>(UserEvent.UserEventType.class);
for (UserEvent.UserEventType eventType : UserEvent.UserEventType.values()) {
XYIntervalSeries series = new XYIntervalSeries(eventType);
seriesMap.put(eventType, series);
userInputData.addSeries(series);
}
for (UserEvent event : analysis.getAnalyzerResult().getTraceresult().getUserEvents()) {
seriesMap.get(event.getEventType()).add(event.getPressTime(), event.getPressTime(), event.getReleaseTime(), 0.5, 0, 1);
}
// Assign ToolTip to renderer
XYItemRenderer renderer = plot.getRenderer();
renderer.setSeriesPaint(userInputData.indexOf(UserEventType.SCREEN_LANDSCAPE), Color.BLUE);
renderer.setSeriesPaint(userInputData.indexOf(UserEventType.SCREEN_PORTRAIT), Color.RED);
renderer.setSeriesPaint(userInputData.indexOf(UserEventType.SCREEN_TOUCH), Color.GREEN);
renderer.setSeriesPaint(userInputData.indexOf(UserEventType.KEY_VOLUP), Color.DARK_GRAY);
renderer.setSeriesPaint(userInputData.indexOf(UserEventType.KEY_VOLDOWN), Color.MAGENTA);
renderer.setSeriesPaint(userInputData.indexOf(UserEventType.KEY_POWER), Color.YELLOW);
renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
UserEvent.UserEventType eventType = (UserEvent.UserEventType) userInputData.getSeries(series).getKey();
return ResourceBundleHelper.getEnumString(eventType);
}
});
}
plot.setDataset(userInputData);
}
use of com.att.aro.core.peripheral.pojo.UserEvent in project VideoOptimzer by attdevsupport.
the class BurstCollectionAnalysisImpl method analyzeBursts.
/**
* Assigns burst category to each burst in a collection of bursts.
* The collection of bursts have been populated prior to this API call.
*/
private int analyzeBursts(List<Burst> burstCollection, List<UserEvent> userEvents, List<CpuActivity> cpuEvents, Profile profile) {
int userEventsSize = userEvents.size();
int cpuEventsSize = cpuEvents.size();
int userEventPointer = 0;
int cpuPointer = 0;
int longBurstCount = 0;
// Analyze each burst
Burst burst = null;
Burst lastBurst;
for (Iterator<Burst> iterator = burstCollection.iterator(); iterator.hasNext(); ) {
lastBurst = burst;
burst = iterator.next();
List<PacketInfo> burstPacketCollection = new ArrayList<PacketInfo>(burst.getPackets().size());
int burstPayloadLen = 0;
Set<TcpInfo> burstPacketTcpInfo = new HashSet<TcpInfo>();
for (PacketInfo pInfo : burst.getPackets()) {
burstPayloadLen += pInfo.getPayloadLen();
burstPacketCollection.add(pInfo);
TcpInfo tcp = pInfo.getTcpInfo();
if (tcp != null) {
burstPacketTcpInfo.add(tcp);
}
}
PacketInfo pkt0 = null;
TcpInfo info0 = null;
double time0 = 0;
if (!burstPacketCollection.isEmpty()) {
pkt0 = burstPacketCollection.get(0);
info0 = pkt0.getTcpInfo();
time0 = pkt0.getTimeStamp();
}
/*
* Mark the burst as Long Burst based on the
* burst duration and size of the payload.
*/
if (burst.getEndTime() - burst.getBeginTime() > profile.getLargeBurstDuration() && burstPayloadLen > profile.getLargeBurstSize()) {
burst.setBurstInfo(BurstCategory.LONG);
++longBurstCount;
continue;
}
/*
* For bursts with no payload assign burst type based on
* the the type of TCP packets.
*/
if (burstPayloadLen == 0) {
if (burstPacketTcpInfo.contains(TcpInfo.TCP_CLOSE) || burstPacketTcpInfo.contains(TcpInfo.TCP_ESTABLISH) || burstPacketTcpInfo.contains(TcpInfo.TCP_RESET) || burstPacketTcpInfo.contains(TcpInfo.TCP_KEEP_ALIVE) || burstPacketTcpInfo.contains(TcpInfo.TCP_KEEP_ALIVE_ACK) || burstPacketTcpInfo.contains(TcpInfo.TCP_ZERO_WINDOW) || burstPacketTcpInfo.contains(TcpInfo.TCP_WINDOW_UPDATE)) {
burst.setBurstInfo(BurstCategory.TCP_PROTOCOL);
continue;
}
if (info0 == TcpInfo.TCP_ACK_RECOVER || info0 == TcpInfo.TCP_ACK_DUP) {
burst.setBurstInfo(BurstCategory.TCP_LOSS_OR_DUP);
continue;
}
}
if (pkt0 == null) {
continue;
}
// Step 4: Server delay
if (pkt0.getDir() == PacketDirection.DOWNLINK && (info0 == TcpInfo.TCP_DATA || info0 == TcpInfo.TCP_ACK)) {
burst.setBurstInfo(BurstCategory.SERVER_NET_DELAY);
continue;
}
// Step 5: Loss recover
if (info0 == TcpInfo.TCP_ACK_DUP || info0 == TcpInfo.TCP_DATA_DUP) {
burst.setBurstInfo(BurstCategory.TCP_LOSS_OR_DUP);
continue;
}
if (info0 == TcpInfo.TCP_DATA_RECOVER || info0 == TcpInfo.TCP_ACK_RECOVER) {
burst.setBurstInfo(BurstCategory.TCP_LOSS_OR_DUP);
continue;
}
// Step 6: User triggered
final double USER_EVENT_SMALL_TOLERATE = profile.getUserInputTh();
if (burstPayloadLen > 0) {
UserEvent uevent = null;
while ((userEventPointer < userEventsSize) && ((uevent = userEvents.get(userEventPointer)).getReleaseTime() < (time0 - USER_EVENT_TOLERATE))) {
++userEventPointer;
}
BurstCategory userInputBurst = null;
if (uevent != null) {
if (uevent.getEventType() == UserEventType.SCREEN_LANDSCAPE || uevent.getEventType() == UserEventType.SCREEN_PORTRAIT) {
userInputBurst = BurstCategory.SCREEN_ROTATION;
} else {
userInputBurst = BurstCategory.USER_INPUT;
}
}
int userEventCount = userEventPointer;
double minGap = Double.MAX_VALUE;
while (userEventCount < userEventsSize) {
UserEvent uEvent = userEvents.get(userEventCount);
if (withinTolerate(uEvent.getPressTime(), time0)) {
double gap = time0 - uEvent.getPressTime();
if (gap < minGap) {
minGap = gap;
}
}
if (withinTolerate(uEvent.getReleaseTime(), time0)) {
double gap = time0 - uEvent.getReleaseTime();
if (gap < minGap) {
minGap = gap;
}
}
if (uEvent.getPressTime() > time0) {
break;
}
userEventCount++;
}
if (minGap < USER_EVENT_SMALL_TOLERATE) {
burst.setBurstInfo(userInputBurst);
continue;
} else if (minGap < USER_EVENT_TOLERATE && (lastBurst == null || lastBurst.getEndTime() < burst.getBeginTime() - minGap)) {
double cpuBegin = time0 - minGap;
double cpuEnd = time0;
// Check CPU usage
while (cpuPointer < cpuEventsSize) {
double eventTimeStamp = cpuEvents.get(cpuPointer).getTimeStamp();
if (eventTimeStamp < burst.getBeginTime() - USER_EVENT_TOLERATE) {
++cpuPointer;
} else {
break;
}
}
int cpuActivityKey = cpuPointer;
double totalCpuUsage = 0.0f;
int cEventsCount = 0;
while (cpuActivityKey < cpuEventsSize) {
CpuActivity cpuAct = cpuEvents.get(cpuActivityKey);
double caTimeStamp = cpuAct.getTimeStamp();
if (caTimeStamp > cpuBegin && caTimeStamp < cpuEnd) {
totalCpuUsage += cpuAct.getTotalCpuUsage();
cEventsCount++;
}
if (caTimeStamp >= cpuEnd) {
break;
}
cpuActivityKey++;
}
if (cEventsCount > 0 && (totalCpuUsage / cEventsCount) > AVG_CPU_USAGE_THRESHOLD) {
burst.setBurstInfo(BurstCategory.CPU);
continue;
} else {
burst.setBurstInfo(userInputBurst);
continue;
}
}
}
// Step 7: Client delay
if (burstPayloadLen == 0) {
burst.setBurstInfo(BurstCategory.UNKNOWN);
continue;
} else {
burst.setBurstInfo(BurstCategory.CLIENT_APP);
continue;
}
}
return longBurstCount;
}
Aggregations