use of com.att.aro.core.videoanalysis.parsers.encodedsegment.AdaptationSetESL 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);
}
}
}
Aggregations