Search in sources :

Example 36 with HttpRequestResponseInfo

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) + "%");
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

Example 37 with HttpRequestResponseInfo

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;
}
Also used : UrlMatchDef(com.att.aro.core.videoanalysis.pojo.UrlMatchDef) StringUtils(org.apache.commons.lang.StringUtils) VideoFormat(com.att.aro.core.videoanalysis.pojo.VideoFormat) SortedSet(java.util.SortedSet) IFileManager(com.att.aro.core.fileio.IFileManager) Autowired(org.springframework.beans.factory.annotation.Autowired) Random(java.util.Random) FFmpegRunner(com.att.aro.core.videoanalysis.videoframe.FFmpegRunner) Logger(org.apache.log4j.Logger) ManifestBuilderHLS(com.att.aro.core.videoanalysis.impl.ManifestBuilderHLS) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) IStringParse(com.att.aro.core.util.IStringParse) VideoType(com.att.aro.core.videoanalysis.pojo.VideoEvent.VideoType) Path(java.nio.file.Path) HttpDirection(com.att.aro.core.packetanalysis.pojo.HttpDirection) NonNull(lombok.NonNull) Box(org.mp4parser.Box) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) IsoFile(org.mp4parser.IsoFile) IHttpRequestResponseHelper(com.att.aro.core.packetanalysis.IHttpRequestResponseHelper) ChildManifest(com.att.aro.core.videoanalysis.pojo.ChildManifest) Pattern(java.util.regex.Pattern) ManifestType(com.att.aro.core.videoanalysis.pojo.Manifest.ManifestType) SortedMap(java.util.SortedMap) Getter(lombok.Getter) HashMap(java.util.HashMap) ManifestBuilderDASH(com.att.aro.core.videoanalysis.impl.ManifestBuilderDASH) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) LinkedHashMap(java.util.LinkedHashMap) Value(org.springframework.beans.factory.annotation.Value) ManifestCollection(com.att.aro.core.videoanalysis.pojo.ManifestCollection) Manifest(com.att.aro.core.videoanalysis.pojo.Manifest) StringParse(com.att.aro.core.util.StringParse) Files(java.nio.file.Files) Util(com.att.aro.core.util.Util) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) File(java.io.File) ManifestBuilder(com.att.aro.core.videoanalysis.impl.ManifestBuilder) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) StreamingVideoData(com.att.aro.core.videoanalysis.pojo.StreamingVideoData) IExternalProcessRunner(com.att.aro.core.commandline.IExternalProcessRunner) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) UrlMatchDef(com.att.aro.core.videoanalysis.pojo.UrlMatchDef) CRC32(java.util.zip.CRC32) SegmentInfo(com.att.aro.core.videoanalysis.impl.SegmentInfo) LogManager(org.apache.log4j.LogManager) SegmentIndexBox(org.mp4parser.boxes.iso14496.part12.SegmentIndexBox) SegmentInfo(com.att.aro.core.videoanalysis.impl.SegmentInfo) Map(java.util.Map) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap)

Example 38 with HttpRequestResponseInfo

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;
        }
    }
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)

Example 39 with HttpRequestResponseInfo

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);
    }
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)

Example 40 with HttpRequestResponseInfo

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;
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) TreeMap(java.util.TreeMap) Session(com.att.aro.core.packetanalysis.pojo.Session)

Aggregations

HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)108 Session (com.att.aro.core.packetanalysis.pojo.Session)74 ArrayList (java.util.ArrayList)62 BaseTest (com.att.aro.core.BaseTest)40 Test (org.junit.Test)40 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)29 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)14 IOException (java.io.IOException)10 HashMap (java.util.HashMap)10 TreeMap (java.util.TreeMap)10 File (java.io.File)9 IHttpRequestResponseHelper (com.att.aro.core.packetanalysis.IHttpRequestResponseHelper)5 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)5 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)5 URISyntaxException (java.net.URISyntaxException)5 List (java.util.List)5 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)4 RequestResponseTimeline (com.att.aro.core.packetanalysis.pojo.RequestResponseTimeline)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 InetAddress (java.net.InetAddress)4