Search in sources :

Example 1 with RepresentationESL

use of com.att.aro.core.videoanalysis.parsers.encodedsegment.RepresentationESL in project VideoOptimzer by attdevsupport.

the class ManifestBuilderDASH method processEncodedSegment.

public void processEncodedSegment(Manifest newManifest, XmlManifestHelper manifestView, String key) {
    // DASH-VOD EncodedSegmentList
    switchManifestCollection(newManifest, key, manifest.getRequestTime());
    newManifest.setVideoType(VideoType.DASH_ENCODEDSEGMENTLIST);
    MPDEncodedSegment mpdEncodedSegment = (MPDEncodedSegment) manifestView.getManifest();
    DashEncodedSegmentParser dashEncodedSegmentParser = new DashEncodedSegmentParser(mpdEncodedSegment, newManifest, manifestCollection, childManifest);
    List<AdaptationSetESL> adaptationSetList = dashEncodedSegmentParser.getAdaptationSet();
    String[] encodedSegmentDurationList = null;
    Double segmentTimeScale = null;
    /* 
		 * Sort Adaptations by minBandwidth, for the purpose of assigning track numbers.
		 * Video tracks will start with track 0
		 * Audio tracks will start with track 0, also
		 */
    SortedMap<Double, AdaptationSetESL> sortedAdaptationSet;
    Map<String, SortedMap<Double, AdaptationSetESL>> sortedAdaptationSets = new HashMap<>();
    Map<String, Integer> trackMap = new HashMap<>();
    Integer track;
    Double bandWidth;
    for (AdaptationSetESL adaptation : adaptationSetList) {
        List<RepresentationESL> representation = adaptation.getRepresentation();
        if (sortedAdaptationSets.containsKey(adaptation.getContentType())) {
            sortedAdaptationSet = sortedAdaptationSets.get(adaptation.getContentType());
        } else {
            sortedAdaptationSet = new TreeMap<>();
            sortedAdaptationSets.put(adaptation.getContentType(), sortedAdaptationSet);
            trackMap.put(createKey(adaptation), 0);
        }
        if ((bandWidth = adaptation.getMinBandwidth()) == null || bandWidth == 0) {
            bandWidth = Double.MAX_VALUE;
            for (RepresentationESL repSet : representation) {
                if (repSet.getBandwidth() == null) {
                    bandWidth = 1.0;
                    break;
                }
                if (repSet.getBandwidth() < bandWidth) {
                    bandWidth = repSet.getBandwidth();
                }
            }
        }
        sortedAdaptationSet.put(bandWidth, adaptation);
    }
    for (SortedMap<Double, AdaptationSetESL> sortedMap : sortedAdaptationSets.values()) {
        for (AdaptationSetESL adaptation : sortedMap.values()) {
            ContentType contentType = manifest.matchContentType(adaptation.getContentType());
            if (adaptation.getEncodedSegmentDurations() != null && adaptation.getEncodedSegmentDurations().getEncodedSegmentDurationList() != null) {
                segmentTimeScale = StringParse.stringToDouble(adaptation.getEncodedSegmentDurations().getTimescale(), 1);
                encodedSegmentDurationList = adaptation.getEncodedSegmentDurations().getEncodedSegmentDurationList().split(";");
            }
            track = trackMap.get(createKey(adaptation));
            SortedMap<Double, RepresentationESL> sortedRepresentationESL = sortRepresentationByBandwidth(adaptation.getRepresentation());
            for (RepresentationESL representation : sortedRepresentationESL.values()) {
                if (representation.getEncodedSegment() != null) {
                    track++;
                    manifest.setTimeScale(StringParse.stringToDouble(representation.getEncodedSegment().getTimescale(), 1));
                    LOG.debug(String.format("representation.getBandwidth() %d:%s", track, representation.getBandwidth()));
                    generateChildManifestFromEncodedSegmentList(newManifest, contentType, track, representation, encodedSegmentDurationList, segmentTimeScale);
                    if (representation.getRepresentationACC() != null) {
                        // audio
                        childManifest.setChannels(representation.getRepresentationACC().getValue());
                    }
                    addToSegmentManifestCollectionMap(childManifest.getUriName());
                }
            }
            trackMap.put(createKey(adaptation), track);
        }
    }
}
Also used : ContentType(com.att.aro.core.videoanalysis.pojo.Manifest.ContentType) HashMap(java.util.HashMap) DashEncodedSegmentParser(com.att.aro.core.videoanalysis.parsers.DashEncodedSegmentParser) MPDEncodedSegment(com.att.aro.core.videoanalysis.parsers.encodedsegment.MPDEncodedSegment) RepresentationESL(com.att.aro.core.videoanalysis.parsers.encodedsegment.RepresentationESL) SortedMap(java.util.SortedMap) AdaptationSetESL(com.att.aro.core.videoanalysis.parsers.encodedsegment.AdaptationSetESL)

Example 2 with RepresentationESL

use of com.att.aro.core.videoanalysis.parsers.encodedsegment.RepresentationESL in project VideoOptimzer by attdevsupport.

the class DashEncodedSegmentParser method getBandwith.

public double getBandwith(String baseURL) {
    double bitrate = 0;
    String contentType = StringParse.findLabeledDataFromString("_", "_", baseURL);
    if (mpdOut != null) {
        List<RepresentationESL> videoRepresentationAmz = findAdaptationSet(mpdOut, contentType);
        if (videoRepresentationAmz != null) {
            for (RepresentationESL representationAmz : videoRepresentationAmz) {
                if (representationAmz.getBaseURL().endsWith(baseURL)) {
                    return Double.valueOf(representationAmz.getBandwidth());
                }
            }
        }
    }
    return bitrate;
}
Also used : RepresentationESL(com.att.aro.core.videoanalysis.parsers.encodedsegment.RepresentationESL)

Example 3 with RepresentationESL

use of com.att.aro.core.videoanalysis.parsers.encodedsegment.RepresentationESL in project VideoOptimzer by attdevsupport.

the class ManifestBuilderDASH method sortRepresentationByBandwidth.

/**
 *<pre>
 * Do not assume that bandwidth will always be in order
 * 	Make sure it is in sorted order by Bandwidth so that qualityID can be assigned
 * 	example: 100000, 150000, 200000, 300000, 500000, 800000, 1200000, 1800000
 */
public SortedMap<Double, RepresentationESL> sortRepresentationByBandwidth(List<RepresentationESL> representationList) {
    SortedMap<Double, RepresentationESL> sortedRepresentationAmz = new TreeMap<>();
    for (RepresentationESL representation : representationList) {
        Double bandwidth = representation.getBandwidth().doubleValue();
        sortedRepresentationAmz.put(bandwidth, representation);
    }
    return sortedRepresentationAmz;
}
Also used : RepresentationESL(com.att.aro.core.videoanalysis.parsers.encodedsegment.RepresentationESL) TreeMap(java.util.TreeMap)

Aggregations

RepresentationESL (com.att.aro.core.videoanalysis.parsers.encodedsegment.RepresentationESL)3 DashEncodedSegmentParser (com.att.aro.core.videoanalysis.parsers.DashEncodedSegmentParser)1 AdaptationSetESL (com.att.aro.core.videoanalysis.parsers.encodedsegment.AdaptationSetESL)1 MPDEncodedSegment (com.att.aro.core.videoanalysis.parsers.encodedsegment.MPDEncodedSegment)1 ContentType (com.att.aro.core.videoanalysis.pojo.Manifest.ContentType)1 HashMap (java.util.HashMap)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1