use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.
the class VideoStreamConstructor method processFailures.
public void processFailures() {
double sumDelivered = 0;
double sumExpected = 0;
for (HttpRequestResponseInfo request : failedSegmentRequests.values()) {
// Guarantee a request, not a response
request = (request.getDirection() == HttpDirection.RESPONSE) ? request.getAssocReqResp() : request;
HttpRequestResponseInfo response = request.getAssocReqResp();
sumDelivered += response.getContentLengthDuringFail();
sumExpected += response.getContentLength();
if ((childManifest = matchSegment(streamingVideoData, request, request.getTimeStamp(), null)) != null) {
VideoEvent videoEvent = new VideoEvent(null, manifestCollection.getManifest(), segmentInfo, childManifest, (int) response.getContentLengthDuringFail(), response, 0L);
videoEvent.setFailedRequest(true);
videoStream.addVideoEvent(videoEvent);
LOG.debug("Failed segment added to videStream: " + videoEvent);
} else {
// logging a failed segment that could not be matched with a VideoStream
LOG.warn(String.format("Unmatched - failed segment: %s delivered %.0f of %.0f", request.getObjNameWithoutParams(), sumDelivered, sumExpected));
}
}
LOG.info(String.format("Of the %d failed video downloads, total percentage received was: %.2f", failedSegmentRequests.size(), (sumDelivered / sumExpected) * 100) + "%");
}
use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo 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.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.
the class VideoTrafficCollectorImpl method processRequests.
public void processRequests(SortedMap<Double, HttpRequestResponseInfo> requestMap) {
for (HttpRequestResponseInfo req : requestMap.values()) {
LOG.debug(req.toString());
if (req.getAssocReqResp() == null) {
LOG.debug("NO Associated rrInfo (skipped):" + req.getTimeStamp() + ": " + req.getObjUri());
streamingVideoData.addFailedRequestMap(req);
continue;
}
String fname = videoStreamConstructor.extractFullNameFromRRInfo(req);
LOG.debug("oName :" + req.getObjNameWithoutParams() + "\theader :" + req.getAllHeaders() + "\tresponse :" + req.getAssocReqResp().getAllHeaders());
String extn = videoStreamConstructor.extractExtensionFromRequest(req);
if (extn == null) {
if (fname.contains("audio")) {
extn = "audio";
} else {
extn = fname;
}
}
// catch offset filename, usually before a byte range, example: 4951221a-709b-4cb9-8f52-7bd7abb4b5c9_v5.ts/range/340280-740719
if (fname.contains(".ts\\/")) {
extn = ".ts";
}
if (fname.contains(".aac\\/")) {
extn = ".aac";
}
switch(extn) {
// DASH - Amazon, Hulu, Netflix, Fullscreen
case // Dash Manifest
".mpd":
processManifestDASH(req);
break;
case // HLS Manifest, iOS, DTV
".m3u8":
processManifestHLS(req);
break;
// audio
case ".m4a":
// audio
case ".mp4a":
case ".aac":
case ".ac3":
case "audio":
case ".dash":
// MPEG
case ".mp2t":
case ".mp4":
case ".mp4v":
case ".m4v":
case ".m4i":
case ".m4s":
case // TransportStream
".ts":
segmentRequests.put(req.getFirstDataPacket().getPacketId(), req);
LOG.debug("\tsegment: " + trackManifestTimeStamp + ": " + req.getObjNameWithoutParams());
manifestReqMap.put(req.getObjNameWithoutParams(), trackManifestTimeStamp);
break;
case // SSM
".ism":
LOG.debug("skipping SmoothStreamingMedia :" + fname);
break;
case ".vtt":
LOG.debug("skipping closed caption :" + fname);
break;
default:
// items found here may need to be handled OR ignored as the above
LOG.debug("skipped :" + fname);
break;
}
}
}
use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.
the class VideoTrafficCollectorImpl method processSegments.
public void processSegments() {
Double trackManifestTimestamp = null;
LOG.debug("\n>>>>>>>>>> segmentRequests: " + segmentRequests);
for (HttpRequestResponseInfo request : segmentRequests.values()) {
LOG.debug("\n>>>>>>>>>> Segment: " + request.getObjNameWithoutParams());
trackManifestTimestamp = manifestReqMap.get(request.getObjNameWithoutParams());
videoStreamConstructor.extractVideo(streamingVideoData, request, trackManifestTimestamp);
}
}
use of com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo in project VideoOptimzer by attdevsupport.
the class VideoTrafficInferencer method generateRequestMap.
public Map<Double, HttpRequestResponseInfo> generateRequestMap(List<Session> sessionList) {
TreeMap<Double, HttpRequestResponseInfo> requestMap = new TreeMap<>();
int counter = 0;
for (Session session : sessionList) {
List<HttpRequestResponseInfo> rriList = session.getRequestResponseInfo();
for (HttpRequestResponseInfo rrInfo : rriList) {
if (rrInfo.getContentLength() > 0 && rrInfo.getDirection() == HttpDirection.RESPONSE) {
rrInfo.setKey(getReqInfoKey(rrInfo.getTimeStamp(), ++counter));
requestMap.put(rrInfo.getKey(), rrInfo);
}
}
}
counter = 0;
for (HttpRequestResponseInfo rrInfo : requestMap.values()) {
firstRequestTimeStamp = rrInfo.getTimeStamp();
rrInfo.setRequestCounterCSI(counter++);
}
return requestMap;
}
Aggregations