Search in sources :

Example 36 with VideoEvent

use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.

the class VideoSegmentAnalyzer method process.

public void process(AbstractTraceResult result, StreamingVideoData streamingVideoData) {
    if (result instanceof TraceDirectoryResult) {
        videoStreamStartupData = ((TraceDirectoryResult) result).getVideoStartupData();
        this.videoPrefs = videoUsagePrefsManager.getVideoUsagePreference();
        if (!CollectionUtils.isEmpty(streamingVideoData.getVideoStreamMap())) {
            NavigableMap<Double, VideoStream> reverseVideoStreamMap = streamingVideoData.getVideoStreamMap().descendingMap();
            for (VideoStream videoStream : reverseVideoStreamMap.values()) {
                if (!CollectionUtils.isEmpty(videoStream.getVideoEventMap())) {
                    if ((videoStreamStartup = locateStartupDelay(result, videoStream)) == null) {
                        // StartupDelay could not be set, usually an invalid Stream
                        continue;
                    }
                    double startupDelay;
                    VideoEvent chosenEvent;
                    if (videoStreamStartup != null && videoStream.getManifest().getVideoName().equals(videoStreamStartup.getManifestName())) {
                        startupDelay = videoStreamStartup.getStartupTime();
                        chosenEvent = videoStream.getVideoEventBySegment(videoStreamStartup.getFirstSegID());
                        if (videoStreamStartup.getUserEvent() != null) {
                            videoStream.setPlayRequestedTime(videoStreamStartup.getUserEvent().getPressTime());
                        }
                    } else {
                        continue;
                    }
                    duplicateHandling = videoPrefs.getDuplicateHandling();
                    LOG.debug(String.format("Stream RQ:%10.3f", videoStream.getManifest().getRequestTime()));
                    applyStartupDelayToStream(startupDelay, chosenEvent, videoStream, streamingVideoData);
                    videoStream.setDuration(videoStream.getVideoEventMap().entrySet().stream().filter(f -> f.getValue().isSelected() && f.getValue().isNormalSegment()).mapToDouble(x -> x.getValue().getDuration()).sum());
                } else {
                    videoStream.setDuration(0);
                    videoStream.setSelected(false);
                    videoStream.setValid(false);
                }
            }
        }
    }
}
Also used : VideoStreamStartup(com.att.aro.core.peripheral.pojo.VideoStreamStartup) StringUtils(org.apache.commons.lang.StringUtils) UserEvent(com.att.aro.core.peripheral.pojo.UserEvent) ValidationStartup(com.att.aro.core.peripheral.pojo.VideoStreamStartup.ValidationStartup) AbstractTraceResult(com.att.aro.core.packetanalysis.pojo.AbstractTraceResult) Autowired(org.springframework.beans.factory.annotation.Autowired) DUPLICATE_HANDLING(com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs.DUPLICATE_HANDLING) ArrayList(java.util.ArrayList) Logger(org.apache.log4j.Logger) XYPair(com.att.aro.core.videoanalysis.XYPair) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) Nonnull(javax.annotation.Nonnull) VideoStall(com.att.aro.core.packetanalysis.pojo.VideoStall) VideoStreamStartupData(com.att.aro.core.peripheral.pojo.VideoStreamStartupData) VideoUsagePrefs(com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs) NonNull(lombok.NonNull) NavigableMap(java.util.NavigableMap) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) List(java.util.List) StreamingVideoData(com.att.aro.core.videoanalysis.pojo.StreamingVideoData) UserEventType(com.att.aro.core.peripheral.pojo.UserEvent.UserEventType) TreeMap(java.util.TreeMap) CollectionUtils(org.springframework.util.CollectionUtils) LogManager(org.apache.log4j.LogManager) IVideoUsagePrefsManager(com.att.aro.core.videoanalysis.IVideoUsagePrefsManager) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) Collections(java.util.Collections) SortedMap(java.util.SortedMap) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

Example 37 with VideoEvent

use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.

the class DashParser method toString.

@Override
public String toString() {
    StringBuilder strblr = new StringBuilder("\n\tAROManifest :");
    strblr.append(videoType);
    strblr.append(", Name :");
    strblr.append(getVideoName());
    strblr.append(", Encryption :");
    strblr.append(getEncryption());
    strblr.append(", URIs :");
    strblr.append(uri != null ? uri.getRawPath() : "null");
    if (!segmentList.isEmpty()) {
        strblr.append("\n\t, segmentList  :");
        strblr.append(segmentList.size());
        strblr.append(segmentList);
        strblr.append("\n\t, durationList  :");
        strblr.append(durationList.size());
        strblr.append(durationList);
    }
    strblr.append("\n\t, segmentCount :");
    strblr.append(getSegmentCount());
    strblr.append(", duration :");
    strblr.append(getDuration());
    strblr.append("\n\t, bitrates :");
    strblr.append(bitrateMap);
    strblr.append(", \n\tvideoEvents [\n\t ");
    if (!videoEventList.isEmpty()) {
        for (VideoEvent videoEvent : videoEventList.values()) {
            strblr.append(videoEvent);
            strblr.append("\n\t ");
        }
    }
    strblr.append("]");
    strblr.append(", \n\tsegmentEvents [\n\t ");
    if (!segmentEventList.isEmpty()) {
        for (VideoEvent videoEvent : segmentEventList.values()) {
            strblr.append(videoEvent);
            strblr.append("\n\t ");
        }
    }
    strblr.append("]");
    return strblr.toString();
}
Also used : VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

Example 38 with VideoEvent

use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.

the class BufferOccupancyCalculatorImpl method initialize.

private void initialize(StreamingVideoData streamingVideoData) {
    filteredSegments = streamingVideoData.getStreamingVideoCompiled().getFilteredSegments();
    for (VideoStream videoStream : streamingVideoData.getVideoStreamMap().values()) {
        if (videoStream.isSelected()) {
            for (VideoEvent ve : videoStream.getVideoEventMap().values()) {
                if (ve.getSegmentID() != 0) {
                    chunkDownload.add(ve);
                }
            }
        }
    }
    chunkPlay.clear();
    for (VideoEvent vEvent : chunkDownload) {
        chunkPlay.add(vEvent);
    }
    Collections.sort(chunkPlay, new VideoEventComparator(SortSelection.SEGMENT_ID));
    Collections.sort(filteredSegments, new VideoEventComparator(SortSelection.SEGMENT_ID));
    runInit(streamingVideoData, filteredSegments);
}
Also used : VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

Example 39 with VideoEvent

use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.

the class VideoTrafficInferencer method inferVideoData.

public StreamingVideoData inferVideoData(AbstractTraceResult result, List<Session> sessionlist, String manifestFilePath) {
    videoRequestMap = new HashSet<>();
    nonSegmentRequestMap = new HashMap<>();
    possibleAudioRequestMap = new TreeMap<>();
    streamingVideoData = new StreamingVideoData(result.getTraceDirectory());
    boolean flag = false;
    File manifestFile;
    if (result.getTraceDirectory().equals(manifestFilePath)) {
        CSIManifestAndState csiState = csiDataHelper.readData(manifestFilePath + System.getProperty("file.separator") + "CSI");
        if (csiState.getAnalysisState().equals("Fail")) {
            return streamingVideoData;
        }
        manifestFile = csiDataHelper.generateManifestPath(manifestFilePath, csiState.getManifestFileName());
    } else {
        flag = true;
        manifestFile = new File(manifestFilePath);
    }
    byte[] fileContent;
    VideoManifest videoManifest = new VideoManifest();
    List<Track> tracks = new ArrayList<>();
    String fileExtName = FilenameUtils.getExtension(manifestFile.getPath());
    requestMap = generateRequestMap(sessionlist);
    if (manifestFile.exists() && fileExtName != null) {
        switch(fileExtName) {
            case "json":
                ObjectMapper mapper = new ObjectMapper();
                mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
                try {
                    videoManifest = mapper.readValue(manifestFile, VideoManifest.class);
                } catch (IOException ioe) {
                    LOGGER.error("Exception while parsing Manifest JSON for CSI", ioe);
                }
                break;
            case "mpd":
                try {
                    fileContent = Files.readAllBytes(manifestFile.toPath());
                    ManifestBuilderDASH manifestBuilderDASH = new ManifestBuilderDASH();
                    manifestBuilderDASH.create(requestMap.values().iterator().next(), fileContent, "blank");
                    for (ChildManifest cManifest : manifestBuilderDASH.getManifestCollection().getSegmentChildManifestListInOrder()) {
                        Track sTrack = new Track();
                        List<Integer> segmentSizes = new ArrayList<Integer>();
                        List<Double> segmentDurations = new ArrayList<Double>();
                        sTrack.setMediaType(cManifest.isVideo() ? MediaType.VIDEO : MediaType.AUDIO);
                        sTrack.setMediaBandwidth((float) cManifest.getBandwidth());
                        cManifest.getSegmentInfoTrie().values().forEach((segment) -> segmentSizes.add(segment.getSize()));
                        cManifest.getSegmentInfoTrie().values().forEach((segment) -> segmentDurations.add(segment.getDuration()));
                        sTrack.setSegmentSizes(segmentSizes);
                        sTrack.setSegmentDurations(segmentDurations);
                        tracks.add(sTrack);
                    }
                } catch (IOException ioe) {
                    LOGGER.error("Exception while parsing MPD for CSI", ioe);
                }
                videoManifest.setTracks(tracks);
            case "m3u8":
                try {
                    videoManifest = hlsManifestParseImpl.getManifest(videoManifest, manifestFile);
                } catch (Exception e) {
                    LOGGER.error(e.getMessage());
                }
                break;
            default:
                break;
        }
    }
    List<Segment> candidateList = prepareCandidates(requestMap, videoManifest);
    Map<Integer, List<Segment>> edgeDistanceMap = calculateDistancesAndPopulateAdjacencyList(candidateList, requestMap);
    TreeMap<Integer, List<Integer>> lastNodes = findShortestPath(candidateList, edgeDistanceMap);
    if (!lastNodes.isEmpty()) {
        VideoStream videoStream = new VideoStream();
        videoStream.setManifest(createManifest(FilenameUtils.getBaseName(manifestFile.getPath()), ManifestType.MASTER, ContentType.MUXED));
        streamingVideoData.addVideoStream(firstRequestTimeStamp, videoStream);
        List<Segment> solution = getLikelySequences(candidateList, edgeDistanceMap, lastNodes);
        Manifest manifest;
        if (!solution.isEmpty()) {
            for (Segment segment : solution) {
                manifest = createManifest(FilenameUtils.getBaseName(manifestFile.getPath()), ManifestType.CHILD, ContentType.VIDEO);
                ChildManifest childManifest = new ChildManifest();
                childManifest.setManifest(manifest);
                VideoEvent videoEvent = new VideoEvent(getDefaultThumbnail(), manifest, segment, requestMap.get(segment.getRequestKey()));
                videoRequestMap.add(requestMap.get(segment.getRequestKey()));
                videoEvent.setChildManifest(childManifest);
                videoStream.addVideoEvent(videoEvent);
            }
            int segmentIndex = 0;
            Track audioTrack;
            if ((audioTrack = videoManifest.getTracks().stream().filter(track -> (track.getMediaType()).equals(MediaType.AUDIO)).findFirst().get()) != null) {
                for (HttpRequestResponseInfo rrInfo : possibleAudioRequestMap.values()) {
                    if (!videoRequestMap.contains(rrInfo) && rrInfo.getTime() > videoStream.getFirstSegment().getDLTime()) {
                        Segment audioSegment = new Segment(videoManifest, videoManifest.getAudioTrack(), ++segmentIndex, audioTrack.getSegmentSizes().get(segmentIndex - 1), rrInfo.getKey(), rrInfo.getRequestCounterCSI(), -1);
                        manifest = createManifest(FilenameUtils.getBaseName(manifestFile.getPath()), ManifestType.CHILD, ContentType.AUDIO);
                        ChildManifest childManifest = new ChildManifest();
                        childManifest.setManifest(manifest);
                        VideoEvent videoEvent = new VideoEvent(getDefaultThumbnail(), manifest, audioSegment, rrInfo);
                        videoEvent.setChildManifest(childManifest);
                        videoStream.addVideoEvent(videoEvent);
                    }
                }
            }
        }
    }
    if (flag) {
        saveCSIManifestAndState(manifestFile.toString());
    }
    videoSegmentAnalyzer.process(result, streamingVideoData);
    return streamingVideoData;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) IFileManager(com.att.aro.core.fileio.IFileManager) AbstractTraceResult(com.att.aro.core.packetanalysis.pojo.AbstractTraceResult) Track(com.att.aro.core.video.pojo.Track) HLSManifestParserForCSI(com.att.aro.core.videoanalysis.csi.parsers.HLSManifestParserForCSI) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) ManifestBuilderDASH(com.att.aro.core.videoanalysis.impl.ManifestBuilderDASH) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) MediaType(com.att.aro.core.videoanalysis.pojo.MediaType) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Logger(org.apache.log4j.Logger) VideoSegmentAnalyzer(com.att.aro.core.videoanalysis.impl.VideoSegmentAnalyzer) CSIManifestAndState(com.att.aro.core.videoanalysis.csi.pojo.CSIManifestAndState) Manifest(com.att.aro.core.videoanalysis.pojo.Manifest) Map(java.util.Map) Path(java.nio.file.Path) Segment(com.att.aro.core.video.pojo.Segment) HttpDirection(com.att.aro.core.packetanalysis.pojo.HttpDirection) Files(java.nio.file.Files) Util(com.att.aro.core.util.Util) VideoManifest(com.att.aro.core.video.pojo.VideoManifest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) Session(com.att.aro.core.packetanalysis.pojo.Session) IOException(java.io.IOException) File(java.io.File) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) List(java.util.List) Component(org.springframework.stereotype.Component) StreamingVideoData(com.att.aro.core.videoanalysis.pojo.StreamingVideoData) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) ContentType(com.att.aro.core.videoanalysis.pojo.Manifest.ContentType) PreferenceHandlerImpl(com.att.aro.core.preferences.impl.PreferenceHandlerImpl) ChildManifest(com.att.aro.core.videoanalysis.pojo.ChildManifest) LogManager(org.apache.log4j.LogManager) Comparator(java.util.Comparator) Collections(java.util.Collections) ManifestType(com.att.aro.core.videoanalysis.pojo.Manifest.ManifestType) FilenameUtils(org.apache.commons.io.FilenameUtils) ArrayList(java.util.ArrayList) StreamingVideoData(com.att.aro.core.videoanalysis.pojo.StreamingVideoData) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent) Segment(com.att.aro.core.video.pojo.Segment) ChildManifest(com.att.aro.core.videoanalysis.pojo.ChildManifest) ArrayList(java.util.ArrayList) List(java.util.List) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) CSIManifestAndState(com.att.aro.core.videoanalysis.csi.pojo.CSIManifestAndState) VideoStream(com.att.aro.core.videoanalysis.pojo.VideoStream) VideoManifest(com.att.aro.core.video.pojo.VideoManifest) IOException(java.io.IOException) Manifest(com.att.aro.core.videoanalysis.pojo.Manifest) VideoManifest(com.att.aro.core.video.pojo.VideoManifest) ChildManifest(com.att.aro.core.videoanalysis.pojo.ChildManifest) IOException(java.io.IOException) ManifestBuilderDASH(com.att.aro.core.videoanalysis.impl.ManifestBuilderDASH) File(java.io.File) Track(com.att.aro.core.video.pojo.Track)

Example 40 with VideoEvent

use of com.att.aro.core.videoanalysis.pojo.VideoEvent in project VideoOptimzer by attdevsupport.

the class BufferInSecondsCalculatorImpl method getSegmentEndTimeMap.

public Map<Double, Long> getSegmentEndTimeMap() {
    Map<Long, Double> segmentStartTimeMap = getSegmentStartTimeMap();
    Map<Double, Long> segmentEndTimeMap = new HashMap<>();
    if (segmentStartTimeMap != null) {
        for (VideoEvent ve : streamingVideoData.getStreamingVideoCompiled().getFilteredSegments()) {
            if (ve != null) {
                Double startTime = segmentStartTimeMap.get(new Double(ve.getSegmentID()).longValue());
                double segmentPlayEndTime = (startTime != null ? startTime : 0.0) + ve.getDuration();
                segmentEndTimeMap.put(segmentPlayEndTime, new Double(ve.getSegmentID()).longValue());
            }
        }
    }
    return segmentEndTimeMap;
}
Also used : HashMap(java.util.HashMap) VideoEvent(com.att.aro.core.videoanalysis.pojo.VideoEvent)

Aggregations

VideoEvent (com.att.aro.core.videoanalysis.pojo.VideoEvent)48 VideoStream (com.att.aro.core.videoanalysis.pojo.VideoStream)19 ArrayList (java.util.ArrayList)12 TreeMap (java.util.TreeMap)7 BPResultType (com.att.aro.core.bestpractice.pojo.BPResultType)5 VideoStall (com.att.aro.core.packetanalysis.pojo.VideoStall)5 StreamingVideoData (com.att.aro.core.videoanalysis.pojo.StreamingVideoData)5 HashMap (java.util.HashMap)4 List (java.util.List)4 XYDataset (org.jfree.data.xy.XYDataset)4 AbstractTraceResult (com.att.aro.core.packetanalysis.pojo.AbstractTraceResult)3 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)3 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)3 VideoStreamStartup (com.att.aro.core.peripheral.pojo.VideoStreamStartup)3 VideoStreamStartupData (com.att.aro.core.peripheral.pojo.VideoStreamStartupData)3 DUPLICATE_HANDLING (com.att.aro.core.videoanalysis.pojo.VideoUsagePrefs.DUPLICATE_HANDLING)3 Collections (java.util.Collections)3 StringUtils (org.apache.commons.lang.StringUtils)3 LogManager (org.apache.log4j.LogManager)3 Logger (org.apache.log4j.Logger)3