use of com.att.aro.core.videoanalysis.pojo.Manifest in project VideoOptimzer by attdevsupport.
the class ManifestBuilder method create.
/**
* <pre>
* Create a Manifest object from byte[] data.
* if manifest is a master, a new ManifestCollection will be created to hold the masterManifest
* if manifest is a "child" it will be attached to it's master
*
* @param request - object
* @param data - byte[]
* @param videoPath
* @return manifest, that was just created, master or child
*/
public Manifest create(HttpRequestResponseInfo request, byte[] data, String videoPath) {
crc32 = new CRC32();
manifest = new Manifest();
manifest.setRequest(request);
manifest.setVideoName(StringUtils.substringBefore(request.getObjNameWithoutParams(), ";"));
manifest.setUri(request.getObjUri());
manifest.setUriStr(request.getObjUri().toString());
manifest.setSession(request.getAssocReqResp().getSession());
manifest.setVideoPath(videoPath);
manifest.setContent(data);
crc32.update(data);
manifest.setChecksumCRC32(crc32.getValue());
manifest.setRequestTime(request.getTimeStamp());
manifest.setEndTime(request.getAssocReqResp().getLastDataPacket().getTimeStamp());
parseManifestData(manifest, data);
return manifest;
}
use of com.att.aro.core.videoanalysis.pojo.Manifest in project VideoOptimzer by attdevsupport.
the class ManifestBuilder method findManifest.
/**
* @param request
* @return ManifestCollection, null if not found
*/
public ManifestCollection findManifest(HttpRequestResponseInfo request) {
LOG.debug(String.format("locating manifest for|<%s>|", request.getObjUri().toString()));
if (CollectionUtils.isEmpty(manifestCollectionMap)) {
return null;
}
// initial
manifestCollectionToBeReturned = null;
identifiedManifestRequestTime = 0;
byteRangeKey = "";
double manifestReqTime = 0;
double lastManifestReqTime = 0;
for (Map<Double, ManifestCollection> innerMap : manifestCollectionMap.values()) {
for (ManifestCollection manifestCollection : innerMap.values()) {
if (manifestCollection.getManifest().getRequestTime() < request.getTimeStamp()) {
manifestReqTime = manifestCollection.getManifest().getRequestTime();
if (lastManifestReqTime == 0 || lastManifestReqTime < manifestReqTime) {
for (UrlMatchDef urlMatchDef : manifestCollection.getManifest().getMasterManifest().getSegUrlMatchDef()) {
key = buildUriNameKey(urlMatchDef, request);
// VID-TODO find #EXT-X-MAP:URI="5b3733a4-e7db-4700-975b-4e842c158274/3cec-BUMPER/02/1200K/map.mp4"
key += "|" + formatTimeKey(manifestCollection.getManifest().getRequestTime());
if (!StringUtils.isEmpty(key)) {
if (locatePatKey(segmentManifestCollectionMap, key, request, urlMatchDef) != null) {
manifestCollectionToBeReturned = manifestCollection;
lastManifestReqTime = manifestReqTime;
return manifestCollectionToBeReturned;
}
}
}
}
}
}
}
for (UrlMatchDef urlMatchDef : masterManifest.getSegUrlMatchDef()) {
key = buildUriNameKey(urlMatchDef, request);
if (StringUtils.isEmpty(key) && segmentManifestCollectionMap.selectKey("#EXT-X-BYTERANGE:") != null) {
String[] range = stringParse.parse(request.getAllHeaders(), "Range: bytes=(\\d+)-(\\d+)");
if (range != null) {
// #EXT-X-BYTERANGE:207928@0 //
String segName = String.format("#EXT-X-BYTERANGE:%.0f@%s", StringParse.stringToDouble(range[1], 0D) + 1, range[0]);
key = segmentManifestCollectionMap.selectKey(segName);
if (key.startsWith(segName)) {
key = keyMatch(request, segName, urlMatchDef);
byteRangeKey = segName;
} else {
LOG.error(String.format("Bad key match <%s> %s<>", segName, key));
key = "";
}
}
}
String key1 = StringUtils.substringBefore(key, "|");
try {
List<Entry<String, String>> tempList = segmentManifestCollectionMap.entrySet().parallelStream().filter(segmentManifestCollectionMapEntry -> segmentManifestCollectionMapEntry.getKey().contains(key)).collect(Collectors.toList());
if (tempList.size() > 1) {
tempList.stream().forEach(x -> {
manifestCollectionMap.entrySet().stream().filter(y -> y.getKey().contains(x.getValue())).forEach(y -> {
y.getValue().entrySet().stream().forEach(z -> {
if (request.getTimeStamp() > z.getKey() && z.getKey() > identifiedManifestRequestTime) {
identifiedManifestRequestTime = z.getKey();
manifestCollectionToBeReturned = z.getValue();
}
});
});
});
} else if (tempList.size() == 1 && !manifestCollectionMap.isEmpty()) {
String key = tempList.get(0).getValue();
manifestCollectionMap.entrySet().stream().filter(f -> f.getKey().endsWith(key)).forEach(outerMap -> {
outerMap.getValue().entrySet().stream().filter(f -> f.getKey() <= request.getTimeStamp() && f.getValue().getSegmentChildManifestTrie().containsKey(key1)).forEach(innerMap -> {
manifestCollectionToBeReturned = innerMap.getValue();
});
});
if (manifestCollectionToBeReturned == null) {
manifestCollectionMap.entrySet().stream().filter(f -> f.getKey().endsWith(key)).forEach(outerMap -> {
outerMap.getValue().entrySet().stream().filter(f -> f.getKey() <= request.getTimeStamp()).forEach(innerMap -> {
manifestCollectionToBeReturned = innerMap.getValue();
});
});
}
}
} catch (Exception e) {
LOG.error("Failed to locate manifestCollection: ", e);
}
if (manifestCollectionToBeReturned != null) {
break;
}
}
return manifestCollectionToBeReturned;
}
use of com.att.aro.core.videoanalysis.pojo.Manifest in project VideoOptimzer by attdevsupport.
the class VideoStreamConstructor method locateChildManifestAndSegmentInfo.
/**
* Locate ChildManifest using keys based on multiple storage strategies, depending on Manifest & Manifest usage
*
* @param request
* @param timeStamp
* @param manifestCollection
* @return
*/
public ChildManifest locateChildManifestAndSegmentInfo(HttpRequestResponseInfo request, byte[] content, Double timeStamp, ManifestCollection manifestCollection) {
childManifest = null;
segmentInfo = null;
for (UrlMatchDef urlMatchDef : manifestCollection.getManifest().getSegUrlMatchDef()) {
String key0 = manifestBuilder.locateKey(urlMatchDef, request);
String key = genKey(key0, request, urlMatchDef);
Double timeKey = timeStamp;
if ((childManifest = manifestCollection.getTimestampChildManifestMap().get(timeKey)) != null) {
LOG.debug("childManifest :" + childManifest.dumpManifest(600));
if ((segmentInfo = childManifest.getSegmentInfoTrie().get(key)) != null) {
return childManifest;
}
}
timeKey = request.getTimeStamp();
do {
if ((timeKey = manifestCollection.getTimestampChildManifestMap().lowerKey(timeKey)) != null) {
childManifest = manifestCollection.getTimestampChildManifestMap().get(timeKey);
}
} while (timeKey != null && (segmentInfo = childManifest.getSegmentInfoTrie().get(key)) == null);
if ((childManifest = manifestCollection.getSegmentChildManifestTrie().get(key0)) != null || (childManifest = manifestCollection.getChildManifest(key0)) != null) {
boolean encoded = childManifest.getSegmentInfoTrie().size() != 0 && VideoType.DASH_ENCODEDSEGMENTLIST.equals(childManifest.getManifest().getVideoType()) ? true : false;
String brKey = buildByteRangeKey(request, encoded);
if (brKey != null) {
// As part of standard dash implementation, we assume that the segment information exists in sidx box in the fragmented mp4 received in the response of the request.
if (content != null) {
populateSegmentInformation(request, content, childManifest);
}
if ((segmentInfo = childManifest.getSegmentInfoTrie().get(brKey.toLowerCase())) == null) {
segmentInfo = childManifest.getSegmentInfoTrie().get(brKey.toUpperCase());
}
}
if (segmentInfo == null) {
if ((segmentInfo = childManifest.getSegmentInfoTrie().get(key)) == null) {
if (!encoded && brKey != null) {
Map.Entry<String, SegmentInfo> entry = childManifest.getSegmentInfoTrie().select(brKey);
if (entry.getKey().split("-")[1].equals(brKey.split("-")[1])) {
segmentInfo = entry.getValue();
}
} else {
segmentInfo = childManifest.getSegmentInfoTrie().get(key);
}
}
}
LOG.debug("childManifest: " + childManifest.getUriName() + ", URL match def: " + urlMatchDef);
if (segmentInfo != null) {
break;
}
} else if (timeStamp != null) {
childManifest = manifestCollection.getTimestampChildManifestMap().get(timeStamp);
if (childManifest == null || !childManifest.getSegmentInfoTrie().keySet().parallelStream().filter(segmentUriName -> {
return request.getObjUri().toString().contains(segmentUriName);
}).findFirst().isPresent()) {
childManifest = manifestCollection.getUriNameChildMap().entrySet().stream().filter(x -> {
return x.getValue().getSegmentInfoTrie().keySet().parallelStream().filter(segmentUriName -> {
return request.getObjUri().toString().contains(segmentUriName);
}).findFirst().isPresent();
}).findFirst().map(x -> x.getValue()).orElseGet(() -> null);
}
if (childManifest == null) {
LOG.debug("ChildManifest wasn't found for segment request: " + request.getObjUri() + ", URL match def: " + urlMatchDef);
nullSegmentInfo();
continue;
}
segmentInfo = null;
if ((segmentInfo = childManifest.getSegmentInfoTrie().get(key)) == null) {
childManifest.getSegmentInfoTrie().entrySet().stream().filter(segmentInfoEntry -> segmentInfoEntry.getKey().contains(key)).findFirst().map(segmentInfoEntry -> segmentInfo = segmentInfoEntry.getValue()).orElseGet(() -> nullSegmentInfo());
}
if (segmentInfo != null) {
break;
}
}
}
return childManifest;
}
use of com.att.aro.core.videoanalysis.pojo.Manifest in project VideoOptimzer by attdevsupport.
the class VideoStartUpDelayImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
BPResultType bpResultType = BPResultType.SELF_TEST;
result = new VideoStartUpDelayResult();
init(result);
warningValue = videoPref.getVideoUsagePreference().getStartUpDelayWarnVal();
if ((streamingVideoData = tracedata.getStreamingVideoData()) != null && (videoStreamCollection = streamingVideoData.getVideoStreamMap()) != null && MapUtils.isNotEmpty(videoStreamCollection)) {
selectedManifestCount = streamingVideoData.getSelectedManifestCount();
hasSelectedManifest = (selectedManifestCount > 0);
invalidCount = streamingVideoData.getInvalidManifestCount();
// default startup delay
startupDelay = videoPref.getVideoUsagePreference().getStartupDelay();
startupDelaySet = false;
bpResultType = BPResultType.CONFIG_REQUIRED;
result.setResultExcelText(BPResultType.CONFIG_REQUIRED.getDescription());
if (selectedManifestCount == 0) {
if (invalidCount == videoStreamCollection.size()) {
result.setResultText(invalidManifestsFound);
} else if (invalidCount > 0) {
result.setResultText(noManifestsSelectedMixed);
} else {
if (videoStreamCollection.size() > 0 && MapUtils.isEmpty(streamingVideoData.getStreamingVideoCompiled().getChunkPlayTimeList())) {
result.setResultText(startUpDelayNotSet);
} else {
result.setResultText(noManifestsSelected);
}
}
} else if (MapUtils.isEmpty(streamingVideoData.getStreamingVideoCompiled().getChunkPlayTimeList())) {
result.setResultText(startUpDelayNotSet);
} else if (selectedManifestCount > 1) {
result.setResultText(multipleManifestsSelected);
} else if (hasSelectedManifest) {
startupDelaySet = true;
for (VideoStream videoStream : videoStreamCollection.values()) {
if (videoStream.isSelected() && MapUtils.isNotEmpty(videoStream.getVideoEventMap()) && videoStream.getManifest().getStartupVideoEvent() != null) {
Manifest manifest = videoStream.getManifest();
manifestRequestTime = manifest.getRequestTime();
// - tracedata.getTraceresult().getPcapTimeOffset();
manifestDeliveredTime = manifest.getEndTime() - manifestRequestTime;
startupDelay = manifest.getStartupDelay() - manifestRequestTime;
playDelay = manifest.getStartupDelay() - manifestRequestTime;
LOG.info(String.format("startup segment = %s", manifest.getStartupVideoEvent()));
LOG.info(String.format("segment startupDelay = %.03f", startupDelay));
LOG.info(String.format("videoStream request to segment_plays = %.03f", manifest.getStartupVideoEvent().getPlayTime() - manifestRequestTime));
LOG.info(String.format("segment_plays = %.03f", manifest.getStartupVideoEvent().getPlayTime()));
List<VideoStartup> compApps = new ArrayList<>();
compApps.add(new VideoStartup("RefApp 1", 0.914, 3.423));
compApps.add(new VideoStartup("RefApp 2", 3.27, 8.400));
compApps.add(new VideoStartup("RefApp 3", 2.409, 3.969));
VideoStartup testedApp = new VideoStartup("Tested", manifestDeliveredTime, playDelay);
compApps.add(testedApp);
result.setResults(compApps);
bpResultType = Util.checkPassFailorWarning(startupDelay, warningValue);
if (bpResultType.equals(BPResultType.PASS)) {
result.setResultText(MessageFormat.format(textResultPass, startupDelay, startupDelay == 1 ? "" : "s"));
result.setResultExcelText(BPResultType.PASS.getDescription());
} else {
result.setResultText(MessageFormat.format(textResults, String.format("%.03f", startupDelay), startupDelay == 1 ? "" : "s", String.format("%.04f", warningValue), warningValue == 1 ? "" : "s"));
result.setResultExcelText(MessageFormat.format(textExcelResults, bpResultType.getDescription(), String.format("%.03f", startupDelay)));
}
break;
}
}
} else {
bpResultType = BPResultType.CONFIG_REQUIRED;
result.setResultText(novalidManifestsFound);
result.setResultExcelText(BPResultType.CONFIG_REQUIRED.getDescription());
}
result.setStartUpDelay(startupDelay);
} else {
// No Data
result.setResultText(noData);
bpResultType = BPResultType.NO_DATA;
result.setResultExcelText(BPResultType.NO_DATA.getDescription());
}
result.setResultType(bpResultType);
return result;
}
use of com.att.aro.core.videoanalysis.pojo.Manifest in project VideoOptimzer by attdevsupport.
the class VideoTrafficInferencer method createManifest.
private Manifest createManifest(String manifestName, ManifestType manifestType, ContentType contentType) {
Manifest manifestMaster = new Manifest();
manifestMaster.setVideoName(manifestName);
manifestMaster.setManifestType(manifestType);
manifestMaster.setContentType(contentType);
return manifestMaster;
}
Aggregations